Add shared settings to makegen

This commit is contained in:
Thraix
2018-11-18 00:32:31 +01:00
parent 73503f6f48
commit 21809e3724
14 changed files with 37 additions and 5 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+1 -1
View File
@@ -12,7 +12,7 @@
// Release , should be backwards compatible with any minor version
#define MAKEGEN_VERSION_RELEASE 0
// Minor changes, should be compatible with any other minor version with same major and release.
#define MAKEGEN_VERSION_MINOR 5
#define MAKEGEN_VERSION_MINOR 6
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
const static unsigned int FLAG_HELP = BIT(0);
Regular → Executable
+20 -1
View File
@@ -8,7 +8,7 @@
#define FLAG_STRING 2
#define FLAG_BOOL 3
ConfigFile::ConfigFile()
: outputdir("bin"), outputname("out.a"),executable(true)
: outputdir("bin"), outputname("out.a"),executable(true), shared(true)
{
}
@@ -74,6 +74,11 @@ ConfigFile ConfigFile::Load()
b = &conf.executable;
loadFlag = FLAG_BOOL;
}
else if(line == "#shared")
{
b = &conf.shared;
loadFlag = FLAG_BOOL;
}
else
{
LOG_ERROR("Invalid flag");
@@ -134,6 +139,18 @@ ConfigFile ConfigFile::Gen()
InputMultiple("Enter library:", conf.libs,false);
InputMultiple("Enter library directory:", conf.libdirs,true);
}
else
{
while(input == "")
{
LOG_INFO("Should it be compiled as a shared library (y/n):");
std::getline(std::cin, input);
if(input[0] != 'y' && input[0] != 'n')
input = "";
}
conf.shared = input[0] == 'y';
}
InputMultiple("Enter include directory:", conf.includedirs,true);
InputMultiple("Enter source directories:", conf.srcdirs,true);
InputMultiple("Enter preprocessor definitions:", conf.defines,false);
@@ -191,5 +208,7 @@ void ConfigFile::Save() const
file << outputname << std::endl;
file << "#executable" << std::endl;
file << (executable ? "true" : "false") << std::endl;
file << "#shared" << std::endl;
file << (shared ? "true" : "false") << std::endl;
file.close();
}
Regular → Executable
+1
View File
@@ -15,6 +15,7 @@ class ConfigFile
std::string outputname;
std::string projectname;
bool executable;
bool shared;
public:
ConfigFile();
void Save() const;
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+13 -1
View File
@@ -45,7 +45,12 @@ void Makefile::Save(const ConfigFile& conf)
outputFile << "# https://github.com/Thraix/MakeGen" << std::endl;
outputFile << "CC=@g++" << std::endl;
if(!conf.executable)
outputFile << "CO=@ar rs" << std::endl;
{
if(conf.shared)
outputFile << "CO=@g++ -shared -o" << std::endl;
else
outputFile << "CO=@g++ -o" << std::endl;
}
else
outputFile << "CO=@g++ -o" << std::endl;
@@ -65,7 +70,14 @@ void Makefile::Save(const ConfigFile& conf)
outputFile << "$(OBJPATH)/" << it->first.substr(slash, extensionPos - slash) << ".o ";
}
outputFile << std::endl;
if(conf.executable || !conf.shared)
{
outputFile << "CFLAGS=$(INCLUDES) -std=c++17 -c -w -g3 ";
}
else
{
outputFile << "CFLAGS=$(INCLUDES) -fPIC -std=c++17 -c -w -g3 ";
}
for(auto it = conf.defines.begin();it!=conf.defines.end();++it)
{
outputFile << "-D" << *it << " ";
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File