Add compile progress to Makefile
This commit is contained in:
+4
-4
@@ -7,10 +7,10 @@
|
||||
#define STRINGIFY(x) #x
|
||||
#define STR(x) STRINGIFY(x)
|
||||
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_UPDATE 0
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION ("v" STR(VERSION_MAJOR) "." STR(VERSION_UPDATE) "." STR(VERSION_MINOR))
|
||||
#define MAKEGEN_VERSION_MAJOR 1
|
||||
#define MAKEGEN_VERSION_RELEASE 0
|
||||
#define MAKEGEN_VERSION_MINOR 4
|
||||
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
|
||||
|
||||
const static unsigned int FLAG_HELP = BIT(0);
|
||||
const static unsigned int FLAG_GEN= BIT(1);
|
||||
|
||||
+15
-11
@@ -119,8 +119,21 @@ void ConfigFile::InputMultiple(const std::string& inputText, std::vector<std::st
|
||||
ConfigFile ConfigFile::Gen()
|
||||
{
|
||||
ConfigFile conf;
|
||||
InputMultiple("Enter library:", conf.libs,false);
|
||||
InputMultiple("Enter library directory:", conf.libdirs,true);
|
||||
std::string input = "";
|
||||
while(input == "")
|
||||
{
|
||||
LOG_INFO("Should it be compiled as an executable (y/n):");
|
||||
std::getline(std::cin, input);
|
||||
if(input[0] != 'y' && input[0] != 'n')
|
||||
input = "";
|
||||
}
|
||||
conf.executable = input[0] == 'y';
|
||||
// If it isn't an executable there is not need to have libraries
|
||||
if(conf.executable)
|
||||
{
|
||||
InputMultiple("Enter library:", conf.libs,false);
|
||||
InputMultiple("Enter library directory:", conf.libdirs,true);
|
||||
}
|
||||
InputMultiple("Enter include directory:", conf.includedirs,true);
|
||||
InputMultiple("Enter source directories:", conf.srcdirs,true);
|
||||
InputMultiple("Enter preprocessor definitions:", conf.defines,false);
|
||||
@@ -139,15 +152,6 @@ ConfigFile ConfigFile::Gen()
|
||||
LOG_INFO("Enter a name for the output file:");
|
||||
std::getline(std::cin, conf.outputname);
|
||||
}
|
||||
std::string input = "";
|
||||
while(input == "")
|
||||
{
|
||||
LOG_INFO("Should it be compiled as an executable (y/n):");
|
||||
std::getline(std::cin, input);
|
||||
if(input[0] != 'y' && input[0] != 'n')
|
||||
input = "";
|
||||
}
|
||||
conf.executable = input[0] == 'y';
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
||||
+21
-13
@@ -40,7 +40,7 @@ void Makefile::Save(const ConfigFile& conf)
|
||||
PreSave(conf,hFiles,cppFiles);
|
||||
|
||||
std::ofstream outputFile("Makefile");
|
||||
outputFile << "# This Makefile was generated using MakeGen "<< VERSION<< " made by Tim Håkansson" << std::endl;
|
||||
outputFile << "# This Makefile was generated using MakeGen "<< MAKEGEN_VERSION<< " made by Tim Håkansson" << std::endl;
|
||||
outputFile << "# and is licensed under MIT. Full source of the project can be found at" << std::endl;
|
||||
outputFile << "# https://github.com/Thraix/MakeGen" << std::endl;
|
||||
outputFile << "CC=@g++" << std::endl;
|
||||
@@ -71,18 +71,21 @@ void Makefile::Save(const ConfigFile& conf)
|
||||
outputFile << "-D" << *it << " ";
|
||||
}
|
||||
outputFile << std::endl;
|
||||
outputFile << "LIBDIR=";
|
||||
for(auto it = conf.libdirs.begin();it!=conf.libdirs.end();++it)
|
||||
if(conf.executable)
|
||||
{
|
||||
outputFile << "-L./" << *it << " ";
|
||||
outputFile << "LIBDIR=";
|
||||
for(auto it = conf.libdirs.begin();it!=conf.libdirs.end();++it)
|
||||
{
|
||||
outputFile << "-L./" << *it << " ";
|
||||
}
|
||||
outputFile << std::endl;
|
||||
outputFile << "LIBS=$(LIBDIR) ";
|
||||
for(auto it = conf.libs.begin();it!=conf.libs.end();++it)
|
||||
{
|
||||
outputFile << "-l" << *it << " ";
|
||||
}
|
||||
outputFile << std::endl;
|
||||
}
|
||||
outputFile << std::endl;
|
||||
outputFile << "LIBS=$(LIBDIR) ";
|
||||
for(auto it = conf.libs.begin();it!=conf.libs.end();++it)
|
||||
{
|
||||
outputFile << "-l" << *it << " ";
|
||||
}
|
||||
outputFile << std::endl;
|
||||
outputFile << "OUTPUT=$(BIN)" << conf.outputname << std::endl;
|
||||
outputFile << "all: $(OUTPUT)" << std::endl;
|
||||
//outputFile << "\t$(info ------------------------)" << std::endl;
|
||||
@@ -94,13 +97,18 @@ void Makefile::Save(const ConfigFile& conf)
|
||||
outputFile << "\trm -rf $(OBJPATH)/*.o" << std::endl;
|
||||
outputFile << "$(OUTPUT): $(OBJECTS)" << std::endl;
|
||||
outputFile << "\t$(info Generating output file)" << std::endl;
|
||||
outputFile << "\t$(CO) $(OUTPUT) $(OBJECTS) $(LIBS)" << std::endl;
|
||||
if(conf.executable)
|
||||
outputFile << "\t$(CO) $(OUTPUT) $(OBJECTS) $(LIBS)" << std::endl;
|
||||
else
|
||||
outputFile << "\t$(CO) $(OUTPUT) $(OBJECTS)" << std::endl;
|
||||
outputFile << "install: all" << std::endl;
|
||||
outputFile << "\t$(info Installing " << conf.projectname <<" to /usr/bin/)" << std::endl;
|
||||
outputFile << "\t@cp $(OUTPUT) /usr/bin/" << conf.outputname << std::endl;
|
||||
std::map<std::string, IncludeDeps*> dependencies;
|
||||
size_t i = 0;
|
||||
for(auto it = cppFiles.begin(); it!=cppFiles.end();++it)
|
||||
{
|
||||
i++;
|
||||
auto itD = dependencies.find(it->first+it->second);
|
||||
if(itD == dependencies.end())
|
||||
{
|
||||
@@ -109,7 +117,7 @@ void Makefile::Save(const ConfigFile& conf)
|
||||
size_t slash = it->first.find_last_of("/")+1;
|
||||
std::string oFile = it->first.substr(slash, extensionPos - slash)+".o ";
|
||||
outputFile << "$(OBJPATH)/" << oFile << ": " << *deps << std::endl;
|
||||
outputFile << "\t$(info ---- $<)" << std::endl;
|
||||
outputFile << "\t$(info -[" << (int)(i / (float)cppFiles.size() * 100) << "%]- $<)" << std::endl;
|
||||
outputFile << "\t$(CC) $(CFLAGS) -o $@ $<" << std::endl;
|
||||
//std::cout << *deps << std::endl;
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
if(flags & FLAG_VERSION)
|
||||
{
|
||||
LOG_INFO("MakeGen ",VERSION);
|
||||
LOG_INFO("MakeGen ",MAKEGEN_VERSION);
|
||||
return 0;
|
||||
}
|
||||
if(flags & FLAG_GEN)
|
||||
|
||||
Reference in New Issue
Block a user