Add compile progress to Makefile

This commit is contained in:
Thraix
2018-06-10 16:30:46 +02:00
parent 9e87c15367
commit f77d3e8a3d
5 changed files with 46 additions and 34 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
# This Makefile was generated using MakeGen v1.0.3 made by Tim Håkansson # This Makefile was generated using MakeGen v1.0.4 made by Tim Håkansson
# and is licensed under MIT. Full source of the project can be found at # and is licensed under MIT. Full source of the project can be found at
# https://github.com/Thraix/MakeGen # https://github.com/Thraix/MakeGen
CC=@g++ CC=@g++
@@ -23,14 +23,14 @@ install: all
$(info Installing MakeGen to /usr/bin/) $(info Installing MakeGen to /usr/bin/)
@cp $(OUTPUT) /usr/bin/makegen @cp $(OUTPUT) /usr/bin/makegen
$(OBJPATH)/ConfigFile.o : src/ConfigFile.cpp src/Common.h src/ConfigFile.h $(OBJPATH)/ConfigFile.o : src/ConfigFile.cpp src/Common.h src/ConfigFile.h
$(info ---- $<) $(info -[25%]- $<)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/IncludeDeps.o : src/IncludeDeps.cpp src/IncludeDeps.h $(OBJPATH)/IncludeDeps.o : src/IncludeDeps.cpp src/IncludeDeps.h
$(info ---- $<) $(info -[50%]- $<)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/Makefile.o : src/Makefile.cpp src/Common.h src/IncludeDeps.h src/Makefile.h src/ConfigFile.h $(OBJPATH)/Makefile.o : src/Makefile.cpp src/Common.h src/IncludeDeps.h src/Makefile.h src/ConfigFile.h
$(info ---- $<) $(info -[75%]- $<)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigFile.h src/IncludeDeps.h src/Makefile.h $(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigFile.h src/IncludeDeps.h src/Makefile.h
$(info ---- $<) $(info -[100%]- $<)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
+4 -4
View File
@@ -7,10 +7,10 @@
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x) #define STR(x) STRINGIFY(x)
#define VERSION_MAJOR 1 #define MAKEGEN_VERSION_MAJOR 1
#define VERSION_UPDATE 0 #define MAKEGEN_VERSION_RELEASE 0
#define VERSION_MINOR 3 #define MAKEGEN_VERSION_MINOR 4
#define VERSION ("v" STR(VERSION_MAJOR) "." STR(VERSION_UPDATE) "." STR(VERSION_MINOR)) #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_HELP = BIT(0);
const static unsigned int FLAG_GEN= BIT(1); const static unsigned int FLAG_GEN= BIT(1);
+15 -11
View File
@@ -119,8 +119,21 @@ void ConfigFile::InputMultiple(const std::string& inputText, std::vector<std::st
ConfigFile ConfigFile::Gen() ConfigFile ConfigFile::Gen()
{ {
ConfigFile conf; ConfigFile conf;
InputMultiple("Enter library:", conf.libs,false); std::string input = "";
InputMultiple("Enter library directory:", conf.libdirs,true); 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 include directory:", conf.includedirs,true);
InputMultiple("Enter source directories:", conf.srcdirs,true); InputMultiple("Enter source directories:", conf.srcdirs,true);
InputMultiple("Enter preprocessor definitions:", conf.defines,false); InputMultiple("Enter preprocessor definitions:", conf.defines,false);
@@ -139,15 +152,6 @@ ConfigFile ConfigFile::Gen()
LOG_INFO("Enter a name for the output file:"); LOG_INFO("Enter a name for the output file:");
std::getline(std::cin, conf.outputname); 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; return conf;
} }
+21 -13
View File
@@ -40,7 +40,7 @@ void Makefile::Save(const ConfigFile& conf)
PreSave(conf,hFiles,cppFiles); PreSave(conf,hFiles,cppFiles);
std::ofstream outputFile("Makefile"); 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 << "# 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 << "# https://github.com/Thraix/MakeGen" << std::endl;
outputFile << "CC=@g++" << std::endl; outputFile << "CC=@g++" << std::endl;
@@ -71,18 +71,21 @@ void Makefile::Save(const ConfigFile& conf)
outputFile << "-D" << *it << " "; outputFile << "-D" << *it << " ";
} }
outputFile << std::endl; outputFile << std::endl;
outputFile << "LIBDIR="; if(conf.executable)
for(auto it = conf.libdirs.begin();it!=conf.libdirs.end();++it)
{ {
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 << "OUTPUT=$(BIN)" << conf.outputname << std::endl;
outputFile << "all: $(OUTPUT)" << std::endl; outputFile << "all: $(OUTPUT)" << std::endl;
//outputFile << "\t$(info ------------------------)" << 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 << "\trm -rf $(OBJPATH)/*.o" << std::endl;
outputFile << "$(OUTPUT): $(OBJECTS)" << std::endl; outputFile << "$(OUTPUT): $(OBJECTS)" << std::endl;
outputFile << "\t$(info Generating output file)" << 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 << "install: all" << std::endl;
outputFile << "\t$(info Installing " << conf.projectname <<" to /usr/bin/)" << std::endl; outputFile << "\t$(info Installing " << conf.projectname <<" to /usr/bin/)" << std::endl;
outputFile << "\t@cp $(OUTPUT) /usr/bin/" << conf.outputname << std::endl; outputFile << "\t@cp $(OUTPUT) /usr/bin/" << conf.outputname << std::endl;
std::map<std::string, IncludeDeps*> dependencies; std::map<std::string, IncludeDeps*> dependencies;
size_t i = 0;
for(auto it = cppFiles.begin(); it!=cppFiles.end();++it) for(auto it = cppFiles.begin(); it!=cppFiles.end();++it)
{ {
i++;
auto itD = dependencies.find(it->first+it->second); auto itD = dependencies.find(it->first+it->second);
if(itD == dependencies.end()) if(itD == dependencies.end())
{ {
@@ -109,7 +117,7 @@ void Makefile::Save(const ConfigFile& conf)
size_t slash = it->first.find_last_of("/")+1; size_t slash = it->first.find_last_of("/")+1;
std::string oFile = it->first.substr(slash, extensionPos - slash)+".o "; std::string oFile = it->first.substr(slash, extensionPos - slash)+".o ";
outputFile << "$(OBJPATH)/" << oFile << ": " << *deps << std::endl; 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; outputFile << "\t$(CC) $(CFLAGS) -o $@ $<" << std::endl;
//std::cout << *deps << std::endl; //std::cout << *deps << std::endl;
} }
+1 -1
View File
@@ -61,7 +61,7 @@ int main(int argc, char** argv)
} }
if(flags & FLAG_VERSION) if(flags & FLAG_VERSION)
{ {
LOG_INFO("MakeGen ",VERSION); LOG_INFO("MakeGen ",MAKEGEN_VERSION);
return 0; return 0;
} }
if(flags & FLAG_GEN) if(flags & FLAG_GEN)