From 4b4841394185cf225692f997724c75603ca8f8ef Mon Sep 17 00:00:00 2001 From: Thraix Date: Sun, 1 Mar 2020 20:44:13 +0100 Subject: [PATCH] Add support for adding linking flags --- makegen.xml | 7 ++++--- src/Common.h | 2 +- src/ConfigCLI.cpp | 13 ++++++++----- src/ConfigUtils.h | 9 +++++++-- src/Makefile.cpp | 5 +++++ 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/makegen.xml b/makegen.xml index c1f7e8d..430f561 100644 --- a/makegen.xml +++ b/makegen.xml @@ -7,7 +7,7 @@ executable MakeGen src/ - + _DEBUG false @@ -17,6 +17,7 @@ executable MakeGen src/ - - v1.3.0 + + Release + v1.3.1 diff --git a/src/Common.h b/src/Common.h index 5a91d5e..2a4b62b 100755 --- a/src/Common.h +++ b/src/Common.h @@ -12,7 +12,7 @@ // Release, should be backwards compatible with any minor version #define MAKEGEN_VERSION_RELEASE 3 // Minor changes, generally bug fixes -#define MAKEGEN_VERSION_MINOR 0 +#define MAKEGEN_VERSION_MINOR 1 #define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR)) diff --git a/src/ConfigCLI.cpp b/src/ConfigCLI.cpp index 2114971..1ffcd1c 100644 --- a/src/ConfigCLI.cpp +++ b/src/ConfigCLI.cpp @@ -17,11 +17,10 @@ Generating config files Modifying config settings add Add values to config settings which support multiple arguments - remove Remove values to config settings which support multiple + remove Remove values from config settings which support multiple arguments set Set value to config settings which support only one argument - Querying config settings get Get value of the config setting)"); } @@ -52,7 +51,8 @@ Valid settings are: librarydir Library directory includedir Include directory define Preprocessor define - cflag g++ compiler flags + cflag g++ compiler flag + lflag g++ linking flag dependency Project which current project depends on)"); } @@ -68,7 +68,8 @@ Valid settings are librarydir Library directory includedir Include directory define Preprocessor define - cflag g++ compiler flags + cflag g++ compiler flag + lflag g++ linking flag dependency Project which current project depends on)"); } @@ -105,7 +106,8 @@ Valid settings are: librarydir Library directory includedir Include directory define Preprocessor define - cflag g++ compiler flags + cflag g++ compiler flag + lflag g++ linking flag dependency Project which current project depends on outputdir Directory of the compiled output outputname Name of the output executable/library @@ -131,6 +133,7 @@ ConfigSetting ConfigCLI::CLIStringToSetting(const std::string& s) {"includedir", ConfigSetting::IncludeDir}, {"define", ConfigSetting::Define}, {"cflag", ConfigSetting::CFlag}, + {"lflag", ConfigSetting::LFlag}, {"dependency", ConfigSetting::Dependency}, {"genhfile", ConfigSetting::GenerateHFile}, }; diff --git a/src/ConfigUtils.h b/src/ConfigUtils.h index bfcf066..602bdd3 100644 --- a/src/ConfigUtils.h +++ b/src/ConfigUtils.h @@ -18,7 +18,7 @@ struct ConfigCache enum class ConfigSetting { // vectors - Library = 0, LibraryDir = 1, IncludeDir = 2, Define = 3, CFlag = 4, Dependency = 5, + Library = 0, LibraryDir = 1, IncludeDir = 2, Define = 3, Dependency = 4, CFlag = 5, LFlag = 6, // Strings SourceDir = 32, OutputDir = 33, OutputName = 34, OutputType = 35, ProjectName = 36, HFileName = 37, // Bools @@ -57,6 +57,8 @@ struct ConfigUtils return "define"; case ConfigSetting::CFlag: return "cflag"; + case ConfigSetting::LFlag: + return "lflag"; case ConfigSetting::GenerateHFile: return "generatehfile"; case ConfigSetting::Invalid: @@ -66,7 +68,6 @@ struct ConfigUtils static bool IsDirectory(ConfigSetting setting) { - // Library, LibraryDir, IncludeDir, Define, CFlag, Dependency, switch(setting) { case ConfigSetting::SourceDir: @@ -82,6 +83,7 @@ struct ConfigUtils case ConfigSetting::Library: case ConfigSetting::Define: case ConfigSetting::CFlag: + case ConfigSetting::LFlag: case ConfigSetting::GenerateHFile: return false; default: @@ -107,6 +109,7 @@ struct ConfigUtils case ConfigSetting::Library: case ConfigSetting::Define: case ConfigSetting::CFlag: + case ConfigSetting::LFlag: case ConfigSetting::GenerateHFile: case ConfigSetting::Invalid: return false; @@ -123,6 +126,7 @@ struct ConfigUtils case ConfigSetting::Library: case ConfigSetting::Define: case ConfigSetting::CFlag: + case ConfigSetting::LFlag: return true; case ConfigSetting::SourceDir: case ConfigSetting::OutputDir: @@ -153,6 +157,7 @@ struct ConfigUtils case ConfigSetting::Library: case ConfigSetting::Define: case ConfigSetting::CFlag: + case ConfigSetting::LFlag: case ConfigSetting::Invalid: return false; } diff --git a/src/Makefile.cpp b/src/Makefile.cpp index ecc13b9..6fb8ff0 100755 --- a/src/Makefile.cpp +++ b/src/Makefile.cpp @@ -77,7 +77,12 @@ void Makefile::Save(ConfigFile& conf, unsigned int flags) outputFile << "-L./" << *it << " "; } outputFile << std::endl; + std::vector& lflags = conf.GetSettingVectorString(ConfigSetting::LFlag); outputFile << "LDFLAGS="; + for(auto it = lflags.begin(); it != lflags.end(); ++it) + { + outputFile << *it << " "; + } for(auto it = libdirs.begin(); it != libdirs.end(); ++it) { outputFile << "-Wl,-rpath=" << *it << " ";