diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Conf.cpp | 23 | ||||
-rw-r--r-- | src/GlobalLib.cpp | 23 | ||||
-rw-r--r-- | src/main.cpp | 25 |
3 files changed, 34 insertions, 37 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp index 743942a..5282bb5 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -339,6 +339,27 @@ namespace sibs case OPT_LEV_RELEASE: return "release"; } } + + bool SibsConfig::isDefined(const std::string &name) const + { + return defines.find(name) != defines.end(); + } + + bool SibsConfig::define(const std::string &name, const std::string &value) + { + if(isDefined(name)) + return false; + else + { + defines[name] = value; + return true; + } + } + + const std::unordered_map<std::string, std::string>& SibsConfig::getDefines() const + { + return defines; + } void SibsConfig::processObject(StringView name) { @@ -497,4 +518,4 @@ namespace sibs { finishedProcessing = true; } -}
\ No newline at end of file +} diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp index db85abd..fde7797 100644 --- a/src/GlobalLib.cpp +++ b/src/GlobalLib.cpp @@ -138,22 +138,7 @@ namespace sibs return Result<string>::Err(errMsg); } - backend::Ninja::LibraryType libraryType; - switch(sibsConfig.getPackageType()) - { - case PackageType::STATIC: - libraryType = backend::Ninja::LibraryType::STATIC; - break; - case PackageType::DYNAMIC: - case PackageType::LIBRARY: - libraryType = backend::Ninja::LibraryType::DYNAMIC; - break; - default: - assert(false); - return Result<string>::Err("Unexpected error"); - } - - backend::Ninja ninja(libraryType); + backend::Ninja ninja; FileWalkCallbackFunc collectSourceFiles = [&ninja, &sibsConfig, &collectSourceFiles](tinydir_file *file) { if(file->is_reg) @@ -201,7 +186,7 @@ namespace sibs buildPath += TINYDIR_STRING("release"); break; } - + string libPath = toUtf8(buildPath); switch (sibsConfig.getCompiler()) { @@ -209,7 +194,7 @@ namespace sibs { libPath += "/lib"; libPath += name; - if (libraryType == backend::Ninja::LibraryType::STATIC) + if (sibsConfig.getPackageType() == PackageType::STATIC) { libPath += ".a"; string libPathCmd = "'"; @@ -231,7 +216,7 @@ namespace sibs { libPath += "/"; libPath += name; - if (libraryType == backend::Ninja::LibraryType::STATIC) + if (sibsConfig.getPackageType() == PackageType::STATIC) { libPath += ".lib"; string libPathCmd = "\""; diff --git a/src/main.cpp b/src/main.cpp index f49ba59..855b1dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include <cstdio> #include <iostream> #include <unordered_set> +#include <chrono> #include "../include/FileUtil.hpp" #include "../include/Conf.hpp" #include "../include/Exec.hpp" @@ -8,6 +9,7 @@ using namespace std; using namespace sibs; +using namespace std::chrono; // TODO: Fail if multiple versions of the same dependency is used // as linking will fail because of multiple definitions of the same thing @@ -20,6 +22,8 @@ using namespace sibs; // TODO: Places that use PATH_MAX should be modified. A path CAN be longer than PATH_MAX... (does this include replacing tinydir.h?) +// TODO: Remove install.sh when sibs supports installation of packages (so it can install itself) + #if OS_FAMILY == OS_FAMILY_POSIX #define ferr std::cerr #else @@ -207,23 +211,7 @@ int buildProject(int argc, const _tinydir_char_t **argv) //string projectSrcPath = projectPath + "/src"; //validateDirectoryPath(projectSrcPath.c_str()); - PackageType packageType = sibsConfig.getPackageType(); - backend::Ninja::LibraryType libraryType; - switch(packageType) - { - case PackageType::EXECUTABLE: - libraryType = backend::Ninja::LibraryType::EXECUTABLE; - break; - case PackageType::STATIC: - libraryType = backend::Ninja::LibraryType::STATIC; - break; - case PackageType::DYNAMIC: - case PackageType::LIBRARY: - libraryType = backend::Ninja::LibraryType::DYNAMIC; - break; - } - - backend::Ninja ninja(libraryType); + backend::Ninja ninja; FileWalkCallbackFunc collectSourceFiles = [&ninja, &sibsConfig, &collectSourceFiles](tinydir_file *file) { if(file->is_reg) @@ -263,12 +251,15 @@ int buildProject(int argc, const _tinydir_char_t **argv) break; } + auto startTime = high_resolution_clock::now(); Result<bool> buildFileResult = ninja.build(sibsConfig, buildPath.c_str()); if(buildFileResult.isErr()) { ferr << "Failed to build ninja file: " << toFileString(buildFileResult.getErrMsg()) << endl; exit(7); } + auto elapsedTime = duration_cast<duration<double>>(high_resolution_clock::now() - startTime); + printf("Build finished in %fs\n", elapsedTime.count()); return 0; } |