42 lines
1 KiB
C++
42 lines
1 KiB
C++
#include "grbc/spec.h"
|
|
#include "grbc/state.h"
|
|
|
|
Package grbc_pkg(const std::string &package_name) {
|
|
for (auto &pkg : GState::get().packages) {
|
|
if (pkg.first == package_name) return pkg.second;
|
|
}
|
|
|
|
grbc_exception("Could not find package with name '" + package_name + "'");
|
|
|
|
return Package{};
|
|
}
|
|
|
|
Package grbc_bake_package_config(const PackageConfig &config) {
|
|
Package pkg{};
|
|
pkg.name = config.name;
|
|
|
|
// Generate list of compiler + linker arguments
|
|
|
|
for (auto &subpkg : config.libraries) {
|
|
pkg.compiler_flags += subpkg.compiler_flags + " ";
|
|
pkg.linker_flags += subpkg.linker_flags + " ";
|
|
}
|
|
|
|
for (auto &linker_flag : config.linker_flags) {
|
|
pkg.linker_flags += linker_flag + " ";
|
|
}
|
|
|
|
for (auto &compiler_flag : config.compile_flags) {
|
|
pkg.compiler_flags += compiler_flag + " ";
|
|
}
|
|
|
|
// Remove trailing whitespace
|
|
|
|
if (pkg.compiler_flags.back() == ' ')
|
|
pkg.compiler_flags.pop_back();
|
|
|
|
if (pkg.linker_flags.back() == ' ')
|
|
pkg.linker_flags.pop_back();
|
|
|
|
return pkg;
|
|
} |