Add version number to Makefile, Cleanup code

This commit is contained in:
Thraix
2018-06-10 12:15:41 +02:00
parent 464c483445
commit 5283801871
5 changed files with 30 additions and 26 deletions
+5 -5
View File
@@ -1,5 +1,5 @@
# This Makefile was generated using MakeGen made by Tim Håkansson and is
# licensed under MIT. Full source of the project can be found at
# This Makefile was generated using MakeGen v1.0.2 made by Tim Håkansson
# and is licensed under MIT. Full source of the project can be found at
# https://github.com/Thraix/MakeGen
CC=@g++
CO=@g++ -o
@@ -21,15 +21,15 @@ $(OUTPUT): $(OBJECTS)
install: all
$(info Installing MakeGen to /usr/bin/)
@cp $(OUTPUT) /usr/bin/makegen
$(OBJPATH)/ConfigFile.o : src/ConfigFile.cpp src/ConfigFile.h src/Logging.h
$(OBJPATH)/ConfigFile.o : src/ConfigFile.cpp src/Common.h src/ConfigFile.h
$(info ---- $<)
$(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/IncludeDeps.o : src/IncludeDeps.cpp src/IncludeDeps.h
$(info ---- $<)
$(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/Makefile.o : src/Makefile.cpp src/IncludeDeps.h src/Logging.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 ---- $<)
$(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/main.o : src/main.cpp src/ConfigFile.h src/IncludeDeps.h src/Logging.h src/Makefile.h
$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigFile.h src/IncludeDeps.h src/Makefile.h
$(info ---- $<)
$(CC) $(CFLAGS) -o $@ $<
+15
View File
@@ -2,6 +2,21 @@
#include <iostream>
#define BIT(x) (1<<x)
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
#define VERSION_MAJOR 1
#define VERSION_UPDATE 0
#define VERSION_MINOR 2
#define VERSION ("v" STR(VERSION_MAJOR) "." STR(VERSION_UPDATE) "." STR(VERSION_MINOR))
const static unsigned int FLAG_HELP = BIT(0);
const static unsigned int FLAG_GEN= BIT(1);
const static unsigned int FLAG_VERSION= BIT(2);
#define LOG_INFO(...) Log(__VA_ARGS__); std::cout << std::endl
#define LOG_WARNING(...) Log(__VA_ARGS__); std::cout << std::endl
#define LOG_ERROR(...) Log(__VA_ARGS__); std::cout << std::endl
+1 -1
View File
@@ -1,7 +1,7 @@
#include "ConfigFile.h"
#include <fstream>
#include "Logging.h"
#include "Common.h"
#define FLAG_NONE 0
#define FLAG_VECTOR 1
+3 -3
View File
@@ -4,8 +4,8 @@
#include <dirent.h>
#include <cstring>
#include <fstream>
#include "Logging.h"
#include "IncludeDeps.h"
#include "Common.h"
void Makefile::GetAllFiles(const std::string& folder, std::vector<std::string>& files)
{
@@ -40,8 +40,8 @@ void Makefile::Save(const ConfigFile& conf)
PreSave(conf,hFiles,cppFiles);
std::ofstream outputFile("Makefile");
outputFile << "# This Makefile was generated using MakeGen made by Tim Håkansson and is" << std::endl;
outputFile << "# licensed under MIT. Full source of the project can be found at" << std::endl;
outputFile << "# This Makefile was generated using 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;
if(!conf.executable)
+6 -17
View File
@@ -4,23 +4,10 @@
#include <vector>
#include <map>
#include <fstream>
#include "Common.h"
#include "IncludeDeps.h"
#include "ConfigFile.h"
#include "Makefile.h"
#include "Logging.h"
#define BIT(x) (1<<x)
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
#define VERSION_MAJOR 1
#define VERSION_UPDATE 0
#define VERSION_MINOR 2
#define VERSION ("v" STR(VERSION_MAJOR) "." STR(VERSION_UPDATE) "." STR(VERSION_MINOR))
const static unsigned int FLAG_HELP = BIT(0);
const static unsigned int FLAG_GEN= BIT(1);
const static unsigned int FLAG_VERSION= BIT(2);
int flags = 0;
void GenMakefile()
{
@@ -28,8 +15,9 @@ void GenMakefile()
Makefile::Save(conf);
}
void ReadFlags(int argc, char** argv)
unsigned int ReadFlags(int argc, char** argv)
{
unsigned int flags = 0;
for(int i = 1;i<argc;i++)
{
if(strlen(argv[i]) > 1)
@@ -52,11 +40,12 @@ void ReadFlags(int argc, char** argv)
}
}
}
return flags;
}
int main(int argc, char** argv)
{
ReadFlags(argc,argv);
unsigned int flags = ReadFlags(argc,argv);
if(flags & FLAG_HELP)
{
LOG_INFO("Usage: makegen [options]");
@@ -65,7 +54,7 @@ int main(int argc, char** argv)
LOG_INFO(" --conf\tGenerate a config file for the project");
LOG_INFO(" --version\tDisplays the version of this program");
LOG_INFO(" install\tGenerates a Makefile and runs make install");
LOG_INFO(" clean\tGenerates a Makefile and runs make clean");
LOG_INFO(" clean\t\tGenerates a Makefile and runs make clean");
LOG_INFO(" rebuild\tGenerates a Makefile and runs make rebuild");
LOG_INFO(" If no option is given it will generate a Makefile and run default make");
return 0;