X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilder.cpp;h=c0574e924d51512ba5af04ff11e14517e78bebf0;hb=2992094d86385f06bf9c86bb1d35ad8fe857f257;hp=94bbce04d3a552480994b2d4597fdeb5e154f3b1;hpb=c51884994862b02613c2c0ae75b1f8d39e0f1ee5;p=builder.git diff --git a/source/builder.cpp b/source/builder.cpp index 94bbce0..c0574e9 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -37,6 +37,7 @@ Builder::Builder(int argc, char **argv): package_manager(*this), main_pkg(0), native_arch(*this, string()), + build_type(0), vfs(*this), analyzer(0), build(false), @@ -62,6 +63,7 @@ Builder::Builder(int argc, char **argv): unsigned verbose = 1; bool silent = false; list log_channels; + string build_type_name; GetOpt getopt; getopt.add_option('a', "analyze", analyze_mode, GetOpt::REQUIRED_ARG).set_help("Perform analysis. MODE can be deps, alldeps or rebuild.", "MODE"); @@ -73,6 +75,7 @@ Builder::Builder(int argc, char **argv): getopt.add_option('l', "log", log_channels, GetOpt::REQUIRED_ARG).set_help("Set log channels to be displayed.", "LIST"); getopt.add_option('n', "dry-run", dry_run, GetOpt::NO_ARG).set_help("Don't actually do anything, only show what would be done."); getopt.add_option('s', "silent", silent, GetOpt::NO_ARG).set_help("Don't print any messages other than errors."); + getopt.add_option('t', "build-type", build_type_name, GetOpt::REQUIRED_ARG).set_help("Set build type.", "TYPE"); getopt.add_option('v', "verbose", verbose, GetOpt::NO_ARG).set_help("Print more information about what's going on."); getopt.add_option('x', "no-externals", no_externals, GetOpt::NO_ARG).set_help("Do not load external source packages."); getopt.add_option('A', "conf-all", conf_all, GetOpt::NO_ARG).set_help("Apply configuration to all packages."); @@ -99,6 +102,7 @@ Builder::Builder(int argc, char **argv): } if(verbose>=2) { + logger.enable_channel("environment"); logger.enable_channel("packages"); logger.enable_channel("commands"); } @@ -165,23 +169,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()) { @@ -193,6 +187,14 @@ Builder::Builder(int argc, char **argv): else prefix = FS::getcwd()/prfx; + if(!build_type_name.empty()) + { + BuildTypeMap::iterator i = build_types.find(build_type_name); + if(i==build_types.end()) + throw usage_error("Unknown build type"); + build_type = &i->second; + } + warnings.push_back("all"); warnings.push_back("extra"); warnings.push_back("shadow"); @@ -274,6 +276,8 @@ int Builder::main() logger.log("environment", format("Building on %s, for %s%s", native_arch.get_name(), current_arch->get_name(), (current_arch->is_native() ? " (native)" : ""))); logger.log("environment", format("Prefix is %s", prefix)); + if(build_type) + logger.log("environment", format("Build type is %s", build_type->get_name())); const PackageManager::PackageMap &packages = package_manager.get_packages(); list package_details; @@ -341,20 +345,6 @@ Target *Builder::get_target(const string &n) const return 0; } -void Builder::apply_profile_template(Config &config, const string &pt) const -{ - vector parts = split(pt, '-'); - - for(vector::iterator i=parts.begin(); i!=parts.end(); ++i) - { - ProfileTemplateMap::const_iterator j = profile_tmpl.find(*i); - if(j==profile_tmpl.end()) - continue; - - config.update(j->second); - } -} - void Builder::problem(const string &p, const string &d) { problems.push_back(Problem(p, d)); @@ -402,13 +392,13 @@ int Builder::create_targets() Target *world = new VirtualTarget(*this, "world"); Target *def_tgt = new VirtualTarget(*this, "default"); - world->add_depend(def_tgt); + world->add_depend(*def_tgt); Target *install = new VirtualTarget(*this, "install"); - world->add_depend(install); + world->add_depend(*install); Target *tarballs = new VirtualTarget(*this, "tarballs"); - world->add_depend(tarballs); + world->add_depend(*tarballs); const PackageManager::PackageMap &packages = package_manager.get_packages(); for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i) @@ -430,7 +420,7 @@ int Builder::create_targets() return -1; } - cmdline->add_depend(tgt); + cmdline->add_depend(*tgt); } cmdline->prepare(); @@ -454,9 +444,11 @@ int Builder::create_targets() i->second->force_rebuild(); } - for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i) - if(SourcePackage *spkg = dynamic_cast(i->second)) - spkg->get_deps_cache().save(); + if(!dry_run) + { + for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i) + i->second->save_caches(); + } return 0; } @@ -609,29 +601,37 @@ 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("build_type", &Loader::build_type); add("profile", &Loader::profile); add("package", &Loader::package); } +void Builder::Loader::architecture(const string &n) +{ + if(obj.current_arch->match_name(n)) + load_sub(*obj.current_arch); +} + void Builder::Loader::binpkg(const string &n) { BinaryPackage *pkg = new BinaryPackage(obj, n); load_sub(*pkg); } -void Builder::Loader::cross_prefix(const string &a, const string &p) +void Builder::Loader::build_type(const string &n) { - obj.cross_prefixes[a] = p; + BuildType btype(n); + load_sub(btype); + BuildTypeMap::iterator i = obj.build_types.insert(BuildTypeMap::value_type(n, btype)).first; + if(!obj.build_type) + obj.build_type = &i->second; } -void Builder::Loader::profile(const string &n) +void Builder::Loader::profile(const string &) { - StringMap prf; - ProfileLoader ldr(prf); - load_sub_with(ldr); - obj.profile_tmpl.insert(ProfileTemplateMap::value_type(n, prf)); + IO::print("Profiles are deprecated\n"); } void Builder::Loader::package(const string &n) @@ -641,16 +641,6 @@ void Builder::Loader::package(const string &n) obj.main_pkg = pkg; load_sub(*pkg); -} - - -Builder::ProfileLoader::ProfileLoader(StringMap &p): - profile(p) -{ - add("option", &ProfileLoader::option); -} - -void Builder::ProfileLoader::option(const string &o, const string &v) -{ - profile.insert(StringMap::value_type(o, v)); + if(obj.build_type) + pkg->set_build_type(*obj.build_type); }