From: Mikko Rasa Date: Tue, 10 Jul 2012 20:52:57 +0000 (+0300) Subject: Better way to set cross_prefix in architectures X-Git-Url: http://git.tdb.fi/?p=builder.git;a=commitdiff_plain;h=88a344b29ab173cd6ecacd0b038ea96dcb7484fc Better way to set cross_prefix in architectures --- diff --git a/builderrc b/builderrc index 8fed1dc..cb2cd6b 100644 --- a/builderrc +++ b/builderrc @@ -76,8 +76,15 @@ binary_package "openal/windows" }; }; -cross_prefix "arm" "arm-linux-gnueabi"; -cross_prefix "windows" "i586-mingw32msvc"; +architecture "arm" +{ + prefix "arm-linux-gnueabi"; +}; + +architecture "windows" +{ + prefix "i586-mingw32msvc"; +}; profile "debug" { diff --git a/source/architecture.cpp b/source/architecture.cpp index 97ed2fe..efe9c73 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -120,11 +120,6 @@ Architecture::Architecture(Builder &b, const string &spec): } } -void Architecture::set_cross_prefix(const string &p) -{ - cross_prefix = p; -} - bool Architecture::match_name(const string &pattern) const { vector parts = split(pattern, "-"); diff --git a/source/architecture.h b/source/architecture.h index 00719cf..2d7ca5f 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -46,7 +46,6 @@ public: bool is_native() const { return native; } bool is_cross() const { return !cross_prefix.empty(); } - void set_cross_prefix(const std::string &); const std::string &get_cross_prefix() const { return cross_prefix; } const PatternList &get_shared_library_patterns() const { return sharedlib_patterns; } diff --git a/source/builder.cpp b/source/builder.cpp index 94bbce0..df6eda4 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -165,23 +165,13 @@ Builder::Builder(int argc, char **argv): package_manager.set_no_externals(no_externals); - load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str()); - load_build_file((FS::get_user_data_dir("builder")/"rc").str()); - if(arch.empty()) current_arch = &native_arch; else current_arch = new Architecture(*this, arch); - if(!current_arch->is_native()) - { - for(StringMap::const_iterator i=cross_prefixes.begin(); i!=cross_prefixes.end(); ++i) - if(current_arch->match_name(i->first)) - { - current_arch->set_cross_prefix(i->second); - break; - } - } + load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str()); + load_build_file((FS::get_user_data_dir("builder")/"rc").str()); if(prfx.empty()) { @@ -609,21 +599,22 @@ Builder::Loader::Loader(Builder &b, const FS::Path &s): DataFile::ObjectLoader(b), src(s) { + add("architecture", &Loader::architecture); add("binary_package", &Loader::binpkg); - add("cross_prefix", &Loader::cross_prefix); add("profile", &Loader::profile); add("package", &Loader::package); } -void Builder::Loader::binpkg(const string &n) +void Builder::Loader::architecture(const string &n) { - BinaryPackage *pkg = new BinaryPackage(obj, n); - load_sub(*pkg); + if(obj.current_arch->match_name(n)) + load_sub(*obj.current_arch); } -void Builder::Loader::cross_prefix(const string &a, const string &p) +void Builder::Loader::binpkg(const string &n) { - obj.cross_prefixes[a] = p; + BinaryPackage *pkg = new BinaryPackage(obj, n); + load_sub(*pkg); } void Builder::Loader::profile(const string &n) diff --git a/source/builder.h b/source/builder.h index e524864..90380a6 100644 --- a/source/builder.h +++ b/source/builder.h @@ -38,8 +38,8 @@ private: public: Loader(Builder &, const Msp::FS::Path &); private: + void architecture(const std::string &); void binpkg(const std::string &); - void cross_prefix(const std::string &, const std::string &); void profile(const std::string &); void package(const std::string &); }; @@ -73,7 +73,6 @@ private: Architecture native_arch; Architecture *current_arch; - StringMap cross_prefixes; ProfileTemplateMap profile_tmpl; Toolchain toolchain; VirtualFileSystem vfs;