From: Mikko Rasa Date: Thu, 3 Dec 2009 09:03:56 +0000 (+0000) Subject: Style update: add spaces around assignment operators X-Git-Url: http://git.tdb.fi/?p=builder.git;a=commitdiff_plain;h=04c316da6d5d90e43cba262f54d90ca231f703bf Style update: add spaces around assignment operators --- diff --git a/source/action.h b/source/action.h index 4ae787a..3892ac7 100644 --- a/source/action.h +++ b/source/action.h @@ -34,7 +34,7 @@ public: if the action has completed successfully, 1 if an error was encountered and -1 if it is still executing. */ - virtual int check()=0; + virtual int check() = 0; protected: /** diff --git a/source/analyzer.cpp b/source/analyzer.cpp index eae9de7..f8af44f 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -46,9 +46,9 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(mode!=REBUILD && mode!=ALLDEPS) { // Skip trivial targets - if(ObjectFile *obj=dynamic_cast(&tgt)) + if(ObjectFile *obj = dynamic_cast(&tgt)) return build_depend_table(obj->get_source(), depth); - else if(Install *inst=dynamic_cast(&tgt)) + else if(Install *inst = dynamic_cast(&tgt)) return build_depend_table(inst->get_source(), depth); } else if(mode==REBUILD && !tgt.get_rebuild()) @@ -60,12 +60,12 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) string fn; if(full_paths) - fn=tgt.get_name(); + fn = tgt.get_name(); else - fn=FS::basename(tgt.get_name()); + fn = FS::basename(tgt.get_name()); row.push_back(string(depth*2, ' ')+fn); - const Package *pkg=tgt.get_package(); + const Package *pkg = tgt.get_package(); if(pkg) row.push_back(pkg->get_name()); else @@ -85,7 +85,7 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(!max_depth || depthsize()) col_width.resize(i->size(), 0); for(unsigned j=0; jsize(); ++j) - col_width[j]=max(col_width[j], (*i)[j].size()); + col_width[j] = max(col_width[j], (*i)[j].size()); } for(Table::const_iterator i=table.begin(); i!=table.end(); ++i) @@ -112,8 +112,8 @@ void Analyzer::print_table() const for(unsigned j=0; jsize(); ++j) { if(j>0) - line+=" "; - line+=lexical_cast((*i)[j], Fmt("%-s").width(col_width[j])); + line += " "; + line += lexical_cast((*i)[j], Fmt("%-s").width(col_width[j])); } IO::print("%s\n", line); } diff --git a/source/analyzer.h b/source/analyzer.h index 7dd4c13..b9afffa 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -41,9 +41,9 @@ private: public: Analyzer(Builder &); - void set_mode(Mode m) { mode=m; } - void set_max_depth(unsigned m) { max_depth=m; } - void set_full_paths(bool f) { full_paths=f; } + void set_mode(Mode m) { mode = m; } + void set_max_depth(unsigned m) { max_depth = m; } + void set_full_paths(bool f) { full_paths = f; } /** Performs the analysis and prints out the resulting dependency tree. diff --git a/source/architecture.cpp b/source/architecture.cpp index c2e9162..65a7577 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -19,12 +19,12 @@ Architecture::Architecture(Builder &b, const string &n, bool a): void Architecture::set_tool(const string &t, const string &p) { - tools[t]=p; + tools[t] = p; } std::string Architecture::get_tool(const string &t) const { - StringMap::const_iterator i=tools.find(t); + StringMap::const_iterator i = tools.find(t); if(i!=tools.end()) { if(i->second[0]=='-') @@ -35,7 +35,7 @@ std::string Architecture::get_tool(const string &t) const if(!native) { - const Architecture &native_arch=builder.get_native_arch(); + const Architecture &native_arch = builder.get_native_arch(); return prefix+"-"+native_arch.get_tool(t); } else @@ -52,5 +52,5 @@ Architecture::Loader::Loader(Architecture &a): void Architecture::Loader::tool(const string &t, const string &p) { - arch.tools[t]=p; + arch.tools[t] = p; } diff --git a/source/architecture.h b/source/architecture.h index 3a4d7ec..aa5f865 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -37,7 +37,7 @@ private: StringMap tools; public: - Architecture(Builder &b, const std::string &n, bool a=false); + Architecture(Builder &b, const std::string &n, bool a = false); void set_tool(const std::string &t, const std::string &p); std::string get_tool(const std::string &t) const; const std::string &get_name() const { return name; } diff --git a/source/archive.cpp b/source/archive.cpp index 64a88af..a56891b 100644 --- a/source/archive.cpp +++ b/source/archive.cpp @@ -21,21 +21,21 @@ using namespace Msp; Archive::Archive(Builder &b, const StaticLibrary &lib): ExternalAction(b) { - const Component &comp=lib.get_component(); + const Component &comp = lib.get_component(); - work_dir=comp.get_package().get_source(); + work_dir = comp.get_package().get_source(); - std::string tool="AR"; + std::string tool = "AR"; argv.push_back(builder.get_current_arch().get_tool(tool)); argv.push_back("rc"); argv.push_back(relative(lib.get_path(), work_dir).str()); - const TargetList &deps=lib.get_depends(); + const TargetList &deps = lib.get_depends(); for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) - if(ObjectFile *obj=dynamic_cast(*i)) + if(ObjectFile *obj = dynamic_cast(*i)) argv.push_back(relative(obj->get_path(), work_dir).str()); - FS::Path lpath=lib.get_path(); + FS::Path lpath = lib.get_path(); if(!builder.get_dry_run()) { FS::mkpath(FS::dirname(lpath), 0755); diff --git a/source/binary.cpp b/source/binary.cpp index 591e934..08da59a 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -24,38 +24,38 @@ Binary::Binary(Builder &b, const Component &c, const list &objs): FileTarget(b, &c.get_package(), generate_target_path(c)), comp(c) { - buildable=true; + buildable = true; for(list::const_iterator i=objs.begin(); i!=objs.end(); ++i) add_depend(*i); } void Binary::find_depends() { - LibMode libmode=comp.get_package().get_library_mode(); + LibMode libmode = comp.get_package().get_library_mode(); if(dynamic_cast(this)) - libmode=DYNAMIC; + libmode = DYNAMIC; list queue; list dep_libs; queue.push_back(&comp); while(!queue.empty()) { - const Component *c=queue.front(); + const Component *c = queue.front(); queue.erase(queue.begin()); - const StringList &libpath=c->get_build_info().libpath; + const StringList &libpath = c->get_build_info().libpath; - const list &libs=c->get_build_info().libs; + const list &libs = c->get_build_info().libs; for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i) { - Target *lib=builder.get_library(*i, libpath, libmode); + Target *lib = builder.get_library(*i, libpath, libmode); if(lib) { dep_libs.push_back(lib); - if(Install *inst=dynamic_cast(lib)) - lib=&inst->get_source(); - if(StaticLibrary *stlib=dynamic_cast(lib)) + if(Install *inst = dynamic_cast(lib)) + lib = &inst->get_source(); + if(StaticLibrary *stlib = dynamic_cast(lib)) queue.push_back(&stlib->get_component()); } else @@ -67,14 +67,14 @@ void Binary::find_depends() This ensures that static library ordering is correct. */ for(list::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i) { - bool last=true; + bool last = true; for(list::iterator j=i; (last && j!=dep_libs.end()); ++j) - last=(j==i || *j!=*i); + last = (j==i || *j!=*i); if(last) add_depend(*i); } - deps_ready=true; + deps_ready = true; } Action *Binary::create_action() @@ -84,24 +84,24 @@ Action *Binary::create_action() FS::Path Binary::generate_target_path(const Component &c) { - const SourcePackage &pkg=c.get_package(); + const SourcePackage &pkg = c.get_package(); string prefix, suffix; - const string &arch=pkg.get_builder().get_current_arch().get_name(); + const string &arch = pkg.get_builder().get_current_arch().get_name(); if(c.get_type()==Component::LIBRARY) { - prefix="lib"; + prefix = "lib"; if(arch=="win32") - suffix=".dll"; + suffix = ".dll"; else - suffix=".so"; + suffix = ".so"; } else if(c.get_type()==Component::MODULE) - suffix=".m"; + suffix = ".m"; else if(c.get_type()==Component::PROGRAM) { if(arch=="win32") - suffix=".exe"; + suffix = ".exe"; } return pkg.get_out_dir()/(prefix+c.get_name()+suffix); diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index cc15888..8c9ba5c 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -17,34 +17,34 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n): Package(b, n), need_path(false) { - use_pkgconfig=false; + use_pkgconfig = false; } void BinaryPackage::set_path(const FS::Path &p) { - path=builder.get_cwd()/p; + path = builder.get_cwd()/p; } void BinaryPackage::create_build_info() { for(StringList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) if((*i)[0]=='@') - *i=(path/i->substr(1)).str(); + *i = (path/i->substr(1)).str(); for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) if((*i)[0]=='@') - *i=(path/i->substr(1)).str(); + *i = (path/i->substr(1)).str(); } BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &name) { - string info=builder.run_pkgconfig(name, "flags"); + string info = builder.run_pkgconfig(name, "flags"); - BinaryPackage *pkg=new BinaryPackage(builder, name); - pkg->use_pkgconfig=true; - BuildInfo &binfo=pkg->export_binfo; + BinaryPackage *pkg = new BinaryPackage(builder, name); + pkg->use_pkgconfig = true; + BuildInfo &binfo = pkg->export_binfo; - vector flags=split(info); + vector flags = split(info); for(vector::const_iterator i=flags.begin(); i!=flags.end(); ++i) { if(!i->compare(0, 2, "-I")) diff --git a/source/builder.cpp b/source/builder.cpp index ce82ba3..76522ad 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -46,7 +46,7 @@ namespace { void update_hash(string &hash, const string &value) { for(unsigned i=0; i ...]"; - helpmsg=getopt.generate_help(); + usagemsg = getopt.generate_usage(argv[0])+" [ ...]"; + helpmsg = getopt.generate_help(); getopt(argc, argv); if(!analyze_mode.empty()) { - analyzer=new Analyzer(*this); + analyzer = new Analyzer(*this); if(analyze_mode=="deps") analyzer->set_mode(Analyzer::DEPS); @@ -119,12 +119,12 @@ Builder::Builder(int argc, char **argv): analyzer->set_full_paths(full_paths); } else if(!clean && !create_makefile) - build=true; + build = true; - const vector &args=getopt.get_args(); + const vector &args = getopt.get_args(); for(vector::const_iterator i=args.begin(); i!=args.end(); ++i) { - string::size_type equal=i->find('='); + string::size_type equal = i->find('='); if(equal!=string::npos) cmdline_options.insert(StringMap::value_type(i->substr(0, equal), i->substr(equal+1))); else @@ -137,14 +137,14 @@ Builder::Builder(int argc, char **argv): if(!work_dir.empty()) FS::chdir(work_dir); - cwd=FS::getcwd(); + cwd = FS::getcwd(); utsname un; - string sysname="native"; + string sysname = "native"; if(uname(&un)==0) - sysname=tolower(un.sysname); + sysname = tolower(un.sysname); - native_arch=&archs.insert(ArchMap::value_type(sysname, Architecture(*this, sysname, true))).first->second; + native_arch = &archs.insert(ArchMap::value_type(sysname, Architecture(*this, sysname, true))).first->second; native_arch->set_tool("CC", "gcc"); native_arch->set_tool("CXX", "g++"); native_arch->set_tool("LD", "gcc"); @@ -155,19 +155,19 @@ Builder::Builder(int argc, char **argv): load_build_file((FS::get_user_data_dir("builder")/"rc").str()); if(arch.empty()) - current_arch=native_arch; + current_arch = native_arch; else - current_arch=&get_architecture(arch); + current_arch = &get_architecture(arch); if(prfx.empty()) { if(current_arch->is_native()) - prefix=(FS::get_home_dir()/"local").str(); + prefix = (FS::get_home_dir()/"local").str(); else - prefix=(FS::get_home_dir()/"local"/current_arch->get_name()).str(); + prefix = (FS::get_home_dir()/"local"/current_arch->get_name()).str(); } else - prefix=FS::getcwd()/prfx; + prefix = FS::getcwd()/prfx; warnings.push_back("all"); warnings.push_back("extra"); @@ -176,7 +176,7 @@ Builder::Builder(int argc, char **argv): warnings.push_back("error"); for(StringList::iterator i=cmdline_warn.begin(); i!=cmdline_warn.end(); ++i) { - vector warns=split(*i, ','); + vector warns = split(*i, ','); warnings.insert(warnings.end(), warns.begin(), warns.end()); } @@ -197,13 +197,13 @@ int Builder::main() { if(prefix.str()!="/usr") { - FS::Path pcdir=prefix/"lib"/"pkgconfig"; - if(const char *pcp=getenv("PKG_CONFIG_PATH")) + FS::Path pcdir = prefix/"lib"/"pkgconfig"; + if(const char *pcp = getenv("PKG_CONFIG_PATH")) { - vector path=split(pcp, ':'); - bool found=false; + vector path = split(pcp, ':'); + bool found = false; for(vector::const_iterator i=path.begin(); (!found && i!=path.end()); ++i) - found=(*i==pcdir.str()); + found = (*i==pcdir.str()); if(!found) { path.push_back(pcdir.str()); @@ -241,7 +241,7 @@ int Builder::main() if(!conf_only && create_targets()) return 1; - PackageList all_reqs=main_pkg->collect_requires(); + PackageList all_reqs = main_pkg->collect_requires(); if(conf_only) return 0; @@ -257,8 +257,8 @@ int Builder::main() IO::print(" %s", (*i)->get_name()); if(dynamic_cast(*i)) IO::print("*"); - unsigned count=0; - unsigned to_be_built=0; + unsigned count = 0; + unsigned to_be_built = 0; for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j) if(j->second->get_package()==*i) { @@ -291,9 +291,9 @@ int Builder::main() } if(clean) - exit_code=do_clean(); + exit_code = do_clean(); else if(build) - exit_code=do_build(); + exit_code = do_build(); return exit_code; } @@ -317,7 +317,7 @@ string Builder::run_pkgconfig(const string &pkg, const string &what) IO::print("Running %s\n", join(argv.begin(), argv.end())); int status; - string res=run_command(argv, &status); + string res = run_command(argv, &status); if(status) throw Exception(format("pkg-config for package %s failed", pkg)); @@ -326,25 +326,25 @@ string Builder::run_pkgconfig(const string &pkg, const string &what) Package *Builder::get_package(const string &name) { - PackageMap::iterator i=packages.find(format("%s/%s", name, current_arch->get_name())); + PackageMap::iterator i = packages.find(format("%s/%s", name, current_arch->get_name())); if(i==packages.end()) - i=packages.find(name); + i = packages.find(name); if(i!=packages.end()) return i->second; - FS::Path path=get_package_location(name); + FS::Path path = get_package_location(name); if(!path.empty() && !load_build_file(path/"Build")) { - i=packages.find(name); + i = packages.find(name); if(i!=packages.end()) return i->second; } - Package *pkg=0; + Package *pkg = 0; try { // Package source not found - create a binary package - pkg=BinaryPackage::from_pkgconfig(*this, name); + pkg = BinaryPackage::from_pkgconfig(*this, name); } catch(...) { @@ -359,7 +359,7 @@ Package *Builder::get_package(const string &name) Target *Builder::get_target(const string &n) const { // XXX Used for getting targets by path. get_target(const FS::Path &)? - TargetMap::const_iterator i=targets.find(n); + TargetMap::const_iterator i = targets.find(n); if(i!=targets.end()) return i->second; return 0; @@ -373,8 +373,8 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l for(list::const_iterator i=path.begin(); i!=path.end(); ++i) update_hash(hash, *i); - string id=hash+include; - TargetMap::iterator i=includes.find(id); + string id = hash+include; + TargetMap::iterator i = includes.find(id); if(i!=includes.end()) return i->second; @@ -384,12 +384,12 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l StringList argv; argv.push_back(current_arch->get_tool("CXX")); argv.push_back("--version"); - if(RegMatch m=Regex("[0-9]\\.[0-9.]+").match(run_command(argv))) + if(RegMatch m = Regex("[0-9]\\.[0-9.]+").match(run_command(argv))) { - cxx_ver=m[0].str; + cxx_ver = m[0].str; while(!cxx_ver.empty() && !FS::is_dir(FS::Path("/usr/include/c++")/cxx_ver)) { - string::size_type dot=cxx_ver.rfind('.'); + string::size_type dot = cxx_ver.rfind('.'); if(dot==string::npos) break; cxx_ver.erase(dot); @@ -398,10 +398,10 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l IO::print("C++ version is %s\n", cxx_ver); } else - cxx_ver="-"; + cxx_ver = "-"; } - string fn=include.substr(1); + string fn = include.substr(1); if(verbose>=5) IO::print("Looking for include %s from %s with path %s\n", fn, from, join(path.begin(), path.end())); @@ -413,13 +413,13 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l if(cxx_ver!="-") syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver).str()); - Target *tgt=0; + Target *tgt = 0; if(include[0]=='\"') - tgt=get_header(FS::Path(from)/fn); + tgt = get_header(FS::Path(from)/fn); for(list::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j) - tgt=get_header(cwd/ *j/fn); + tgt = get_header(cwd/ *j/fn); for(list::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j) - tgt=get_header(FS::Path(*j)/fn); + tgt = get_header(FS::Path(*j)/fn); includes.insert(TargetMap::value_type(id, tgt)); @@ -432,8 +432,8 @@ Target *Builder::get_library(const string &lib, const list &path, LibMod for(list::const_iterator i=path.begin(); i!=path.end(); ++i) update_hash(hash, *i); - string id=hash+string(1, mode)+lib; - TargetMap::iterator i=libraries.find(id); + string id = hash+string(1, mode)+lib; + TargetMap::iterator i = libraries.find(id); if(i!=libraries.end()) return i->second; @@ -449,11 +449,11 @@ Target *Builder::get_library(const string &lib, const list &path, LibMod if(verbose>=5) IO::print("Looking for library %s with path %s\n", lib, join(path.begin(), path.end())); - Target *tgt=0; + Target *tgt = 0; for(StringList::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j) - tgt=get_library(lib, cwd/ *j, mode); + tgt = get_library(lib, cwd/ *j, mode); for(StringList::iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j) - tgt=get_library(lib, *j, mode); + tgt = get_library(lib, *j, mode); libraries.insert(TargetMap::value_type(id, tgt)); @@ -462,7 +462,7 @@ Target *Builder::get_library(const string &lib, const list &path, LibMod const Architecture &Builder::get_architecture(const string &arch) const { - ArchMap::const_iterator i=archs.find(arch); + ArchMap::const_iterator i = archs.find(arch); if(i==archs.end()) throw KeyError("Unknown architecture", arch); @@ -471,11 +471,11 @@ const Architecture &Builder::get_architecture(const string &arch) const void Builder::apply_profile_template(Config &config, const string &pt) const { - vector parts=split(pt, '-'); + vector parts = split(pt, '-'); for(vector::iterator i=parts.begin(); i!=parts.end(); ++i) { - ProfileTemplateMap::const_iterator j=profile_tmpl.find(*i); + ProfileTemplateMap::const_iterator j = profile_tmpl.find(*i); if(j==profile_tmpl.end()) continue; @@ -518,7 +518,7 @@ FS::Path Builder::get_package_location(const string &name) try { // Try to get source directory with pkgconfig - string srcdir=strip(run_pkgconfig(name, "source")); + string srcdir = strip(run_pkgconfig(name, "source")); if(!srcdir.empty()) return srcdir; } @@ -529,10 +529,10 @@ FS::Path Builder::get_package_location(const string &name) { for(list::const_iterator i=pkg_path.begin(); i!=pkg_path.end(); ++i) { - list files=list_files(*i); + list files = list_files(*i); for(list::const_iterator j=files.begin(); j!=files.end(); ++j) { - FS::Path full=*i / *j; + FS::Path full = *i / *j; if(FS::exists(full/"Build")) pkg_dirs.push_back(full); } @@ -541,11 +541,11 @@ FS::Path Builder::get_package_location(const string &name) IO::print("%d packages found in path\n", pkg_dirs.size()); } - bool msp=!name.compare(0, 3, "msp"); + bool msp = !name.compare(0, 3, "msp"); for(list::const_iterator i=pkg_dirs.begin(); i!=pkg_dirs.end(); ++i) { - string base=basename(*i); - unsigned dash=base.rfind('-'); + string base = basename(*i); + unsigned dash = base.rfind('-'); if(!base.compare(0, dash, name)) return *i; @@ -579,31 +579,31 @@ int Builder::load_build_file(const FS::Path &fn) int Builder::create_targets() { - Target *world=new VirtualTarget(*this, "world"); + Target *world = new VirtualTarget(*this, "world"); - Target *def_tgt=new VirtualTarget(*this, "default"); + Target *def_tgt = new VirtualTarget(*this, "default"); world->add_depend(def_tgt); - Target *install=new VirtualTarget(*this, "install"); + Target *install = new VirtualTarget(*this, "install"); world->add_depend(install); - Target *tarballs=new VirtualTarget(*this, "tarballs"); + Target *tarballs = new VirtualTarget(*this, "tarballs"); world->add_depend(tarballs); - PackageList all_reqs=main_pkg->collect_requires(); + PackageList all_reqs = main_pkg->collect_requires(); for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i) { - SourcePackage *spkg=dynamic_cast(*i); + SourcePackage *spkg = dynamic_cast(*i); if(!spkg) continue; - const ComponentList &components=spkg->get_components(); + const ComponentList &components = spkg->get_components(); for(ComponentList::const_iterator j=components.begin(); j!=components.end(); ++j) j->create_targets(); if(spkg->get_install_flags()&(SourcePackage::LIB|SourcePackage::INCLUDE)) { - PkgConfig *pc=new PkgConfig(*this, *spkg); + PkgConfig *pc = new PkgConfig(*this, *spkg); install->add_depend(new Install(*this, *spkg, *pc)); } } @@ -611,7 +611,7 @@ int Builder::create_targets() // Find dependencies until no new targets are created while(!new_tgts.empty()) { - Target *tgt=new_tgts.front(); + Target *tgt = new_tgts.front(); new_tgts.erase(new_tgts.begin()); tgt->find_depends(); if(!tgt->get_depends_ready()) @@ -621,7 +621,7 @@ int Builder::create_targets() // Apply what-ifs for(StringList::iterator i=what_if.begin(); i!=what_if.end(); ++i) { - Target *tgt=get_target((cwd/ *i).str()); + Target *tgt = get_target((cwd/ *i).str()); if(!tgt) { IO::print(IO::cerr, "Unknown what-if target %s\n", *i); @@ -631,27 +631,27 @@ int Builder::create_targets() } // Make the cmdline target depend on all targets mentioned on the command line - Target *cmdline=new VirtualTarget(*this, "cmdline"); - bool build_world=false; + Target *cmdline = new VirtualTarget(*this, "cmdline"); + bool build_world = false; for(list::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i) { - Target *tgt=get_target(*i); + Target *tgt = get_target(*i); if(!tgt) - tgt=get_target((cwd/ *i).str()); + tgt = get_target((cwd/ *i).str()); if(!tgt) { IO::print("I don't know anything about %s\n", *i); return -1; } if(tgt==world) - build_world=true; + build_world = true; cmdline->add_depend(tgt); } cmdline->prepare(); for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i) - if(SourcePackage *spkg=dynamic_cast(i->second)) + if(SourcePackage *spkg = dynamic_cast(i->second)) spkg->get_deps_cache().save(); return 0; @@ -659,12 +659,12 @@ int Builder::create_targets() Target *Builder::get_header(const FS::Path &fn) { - Target *tgt=get_target(fn.str()); + Target *tgt = get_target(fn.str()); if(tgt) return tgt; if(FS::is_reg(fn)) { - tgt=new SystemHeader(*this, fn.str()); + tgt = new SystemHeader(*this, fn.str()); return tgt; } return 0; @@ -694,14 +694,14 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo for(StringList::iterator i=candidates.begin(); i!=candidates.end(); ++i) { - string full=(path/ *i).str(); - Target *tgt=get_target(full); + string full = (path/ *i).str(); + Target *tgt = get_target(full); if(tgt) { - Target *real_tgt=tgt; - if(Install *inst=dynamic_cast(tgt)) - real_tgt=&inst->get_source(); + Target *real_tgt = tgt; + if(Install *inst = dynamic_cast(tgt)) + real_tgt = &inst->get_source(); /* Ignore dynamic libraries from local packages unless library mode is DYNAMIC */ @@ -712,7 +712,7 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo } else if(FS::is_reg(full)) { - tgt=new SystemLibrary(*this, full); + tgt = new SystemLibrary(*this, full); return tgt; } } @@ -722,9 +722,9 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo int Builder::do_build() { - Target *cmdline=get_target("cmdline"); + Target *cmdline = get_target("cmdline"); - unsigned total=0; + unsigned total = 0; for(map::const_iterator i=targets.begin(); i!=targets.end(); ++i) if(i->second->is_buildable() && i->second->get_rebuild()) ++total; @@ -739,19 +739,19 @@ int Builder::do_build() vector actions; - unsigned count=0; + unsigned count = 0; - bool fail=false; - bool finish=false; + bool fail = false; + bool finish = false; while(!finish) { if(actions.size()get_buildable_target(); + Target *tgt = cmdline->get_buildable_target(); if(tgt) { - Action *action=tgt->build(); + Action *action = tgt->build(); if(action) actions.push_back(action); @@ -759,14 +759,14 @@ int Builder::do_build() IO::print("%d of %d target%s built\033[1G", count, total, (total!=1 ? "s" : "")); } else if(actions.empty()) - finish=true; + finish = true; } else Time::sleep(10*Time::msec); for(unsigned i=0; icheck(); + int status = actions[i]->check(); if(status>=0) { ++count; @@ -774,9 +774,9 @@ int Builder::do_build() delete actions[i]; actions.erase(actions.begin()+i); if(status>0) - fail=true; + fail = true; if(actions.empty() && fail) - finish=true; + finish = true; } else ++i; @@ -803,22 +803,22 @@ int Builder::do_clean() while(!queue.empty()) { - Target *tgt=queue.front(); + Target *tgt = queue.front(); queue.erase(queue.begin()); if(tgt->is_buildable() && (tgt->get_package()==main_pkg || clean>=2)) clean_tgts.insert(tgt); - const TargetList &deps=tgt->get_depends(); + const TargetList &deps = tgt->get_depends(); for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) if(!clean_tgts.count(*i)) queue.push_back(*i); } for(set::iterator i=clean_tgts.begin(); i!=clean_tgts.end(); ++i) - if(FileTarget *ft=dynamic_cast(*i)) + if(FileTarget *ft = dynamic_cast(*i)) { - Action *action=new Unlink(*this, *ft); + Action *action = new Unlink(*this, *ft); while(action->check()<0) ; delete action; } @@ -828,11 +828,11 @@ int Builder::do_clean() void Builder::package_help() { - const Config &config=main_pkg->get_config(); - const Config::OptionMap &options=config.get_options(); + const Config &config = main_pkg->get_config(); + const Config::OptionMap &options = config.get_options(); IO::print("Required packages:\n "); - const PackageList &requires=main_pkg->get_requires(); + const PackageList &requires = main_pkg->get_requires(); for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) { if(i!=requires.begin()) @@ -842,7 +842,7 @@ void Builder::package_help() IO::print("\n\nPackage configuration:\n"); for(Config::OptionMap::const_iterator i=options.begin(); i!=options.end(); ++i) { - const Config::Option &opt=i->second; + const Config::Option &opt = i->second; IO::print(" %s: %s (%s)", opt.name, opt.descr, opt.value); if(opt.value!=opt.defv) IO::print(" [%s]", opt.defv); @@ -874,7 +874,7 @@ void Builder::Loader::architecture(const string &n) void Builder::Loader::binpkg(const string &n) { - BinaryPackage *pkg=new BinaryPackage(bld, n); + BinaryPackage *pkg = new BinaryPackage(bld, n); load_sub(*pkg); bld.packages.insert(PackageMap::value_type(n, pkg)); } @@ -889,9 +889,9 @@ void Builder::Loader::profile(const string &n) void Builder::Loader::package(const string &n) { - SourcePackage *pkg=new SourcePackage(bld, n, src); + SourcePackage *pkg = new SourcePackage(bld, n, src); if(!bld.main_pkg) - bld.main_pkg=pkg; + bld.main_pkg = pkg; load_sub(*pkg); bld.packages.insert(PackageMap::value_type(n, pkg)); diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 9ad0a55..8259625 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -21,7 +21,7 @@ void unique(StringList &l) for(StringList::iterator j=i; j!=l.end();) { if(j!=i && *j==*i) - j=l.erase(j); + j = l.erase(j); else ++j; } @@ -52,23 +52,23 @@ void BuildInfo::unique() for(StringList::iterator i=warnings.begin(); i!=warnings.end(); ++i) { - bool flag=i->compare(0, 3, "no-"); + bool flag = i->compare(0, 3, "no-"); - string warn=(flag ? *i : i->substr(3)); - string no_warn="no-"+warn; + string warn = (flag ? *i : i->substr(3)); + string no_warn = "no-"+warn; for(StringList::iterator j=i; j!=warnings.end();) { if(j!=i && (*j==warn || *j==no_warn)) { - flag=(*j==warn); - j=warnings.erase(j); + flag = (*j==warn); + j = warnings.erase(j); } else ++j; } - *i=(flag ? warn : no_warn); + *i = (flag ? warn : no_warn); } } diff --git a/source/compile.cpp b/source/compile.cpp index 4a0e85e..f6a4dd6 100644 --- a/source/compile.cpp +++ b/source/compile.cpp @@ -21,23 +21,23 @@ using namespace Msp; Compile::Compile(Builder &b, const ObjectFile &obj): ExternalAction(b) { - const Component &comp=obj.get_component(); + const Component &comp = obj.get_component(); - work_dir=comp.get_package().get_source(); + work_dir = comp.get_package().get_source(); - FS::Path spath=obj.get_source().get_path(); + FS::Path spath = obj.get_source().get_path(); - string ext=FS::extpart(spath.str()); - const char *tool=0; + string ext = FS::extpart(spath.str()); + const char *tool = 0; if(ext==".cpp" || ext==".cc") - tool="CXX"; + tool = "CXX"; else - tool="CC"; + tool = "CC"; argv.push_back(builder.get_current_arch().get_tool(tool)); argv.push_back("-c"); - const BuildInfo &binfo=comp.get_build_info(); + const BuildInfo &binfo = comp.get_build_info(); for(list::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i) argv.push_back("-W"+*i); for(list::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i) @@ -47,7 +47,7 @@ Compile::Compile(Builder &b, const ObjectFile &obj): for(list::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) argv.push_back("-D"+*i); - FS::Path opath=obj.get_path(); + FS::Path opath = obj.get_path(); argv.push_back("-o"); argv.push_back(relative(opath, work_dir).str()); argv.push_back(relative(spath, work_dir).str()); diff --git a/source/component.cpp b/source/component.cpp index 5e32de5..5c1d9f6 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -46,24 +46,24 @@ void Component::create_build_info() build_info.add((*i)->get_exported_binfo()); for(StringList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i) - *i=(pkg.get_source() / *i).str(); + *i = (pkg.get_source() / *i).str(); for(StringList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i) - *i=(pkg.get_source() / *i).str(); + *i = (pkg.get_source() / *i).str(); if(pkg.get_library_mode()!=DYNAMIC) { // XXX This may pull in some unnecessary libpaths too. More thought required. - PackageList reqs=pkg.collect_requires(); + PackageList reqs = pkg.collect_requires(); for(PackageList::iterator i=reqs.begin(); i!=reqs.end(); ++i) { - const BuildInfo &ebi=(*i)->get_exported_binfo(); + const BuildInfo &ebi = (*i)->get_exported_binfo(); build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end()); } } if(type==PROGRAM) { - string strip=pkg.get_config().get_option("strip").value; + string strip = pkg.get_config().get_option("strip").value; if(lexical_cast(strip)) build_info.ldflags.push_back("-s"); } @@ -79,7 +79,7 @@ void Component::create_build_info() } else if(module_host) { - const PathList &host_src=module_host->get_sources(); + const PathList &host_src = module_host->get_sources(); for(PathList::const_iterator i=host_src.begin(); i!=host_src.end(); ++i) build_info.incpath.push_back(i->str()); } @@ -89,24 +89,24 @@ void Component::create_build_info() void Component::create_targets() const { - Builder &builder=pkg.get_builder(); - Target *world=builder.get_target("world"); - Target *def_tgt=builder.get_target("default"); + Builder &builder = pkg.get_builder(); + Target *world = builder.get_target("world"); + Target *def_tgt = builder.get_target("default"); - PathList files=collect_source_files(); + PathList files = collect_source_files(); list inst_list; string inst_loc; if(type==TARBALL) { - string tarname=name; + string tarname = name; if(name=="@src") - tarname=pkg.get_name()+"-"+pkg.get_version(); - TarBall *result=new TarBall(builder, pkg, tarname); + tarname = pkg.get_name()+"-"+pkg.get_version(); + TarBall *result = new TarBall(builder, pkg, tarname); if(name=="@src") { - const TargetMap &targets=builder.get_targets(); + const TargetMap &targets = builder.get_targets(); for(TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) if(i->second->get_package()==&pkg && !i->second->is_buildable()) result->add_depend(i->second); @@ -116,39 +116,39 @@ void Component::create_targets() const for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) { FileTarget *ft; - if(Target *tgt=builder.get_target(i->str())) - ft=dynamic_cast(tgt); + if(Target *tgt = builder.get_target(i->str())) + ft = dynamic_cast(tgt); else - ft=new File(builder, *i); + ft = new File(builder, *i); result->add_depend(ft); } - Target *tarbls_tgt=builder.get_target("tarballs"); + Target *tarbls_tgt = builder.get_target("tarballs"); tarbls_tgt->add_depend(result); return; } else if(type==INSTALL) { - inst_loc=name; + inst_loc = name; for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) { FileTarget *ft; - if(Target *tgt=builder.get_target(i->str())) - ft=dynamic_cast(tgt); + if(Target *tgt = builder.get_target(i->str())) + ft = dynamic_cast(tgt); else - ft=new File(builder, pkg, *i); + ft = new File(builder, pkg, *i); inst_list.push_back(ft); } } else if(type==DATAFILE) { File *source; - if(Target *tgt=builder.get_target(files.front().str())) - source=dynamic_cast(tgt); + if(Target *tgt = builder.get_target(files.front().str())) + source = dynamic_cast(tgt); else - source=new File(builder, pkg, files.front()); - ::DataFile *result=new ::DataFile(builder, *this, *source); + source = new File(builder, pkg, files.front()); + ::DataFile *result = new ::DataFile(builder, *this, *source); if(&pkg==builder.get_main_package() && deflt) def_tgt->add_depend(result); @@ -161,12 +161,12 @@ void Component::create_targets() const { for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) { - string ext=FS::extpart(FS::basename(*i)); + string ext = FS::extpart(FS::basename(*i)); if(ext==".h") { - FileTarget *hdr=dynamic_cast(builder.get_target(i->str())); + FileTarget *hdr = dynamic_cast(builder.get_target(i->str())); if(!hdr) - hdr=new Header(builder, *this, i->str()); + hdr = new Header(builder, *this, i->str()); // Install headers if requested if(type==HEADERS && install) @@ -180,11 +180,11 @@ void Component::create_targets() const list objs; for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) { - string ext=FS::extpart(FS::basename(*i)); + string ext = FS::extpart(FS::basename(*i)); if((ext==".cpp" || ext==".cc" || ext==".c")) { - SourceFile *src=new SourceFile(builder, *this, i->str()); - ObjectFile *obj=new ObjectFile(builder, *this, *src); + SourceFile *src = new SourceFile(builder, *this, i->str()); + ObjectFile *obj = new ObjectFile(builder, *this, *src); objs.push_back(obj); } } @@ -209,7 +209,7 @@ void Component::create_targets() const } } - Target *inst_tgt=builder.get_target("install"); + Target *inst_tgt = builder.get_target("install"); for(list::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i) inst_tgt->add_depend(new Install(builder, pkg, **i, inst_loc)); } @@ -221,7 +221,7 @@ PathList Component::collect_source_files() const { if(FS::is_dir(*i)) { - list sfiles=list_files(*i); + list sfiles = list_files(*i); for(list::iterator j=sfiles.begin(); j!=sfiles.end(); ++j) files.push_back(*i / *j); } @@ -251,8 +251,8 @@ void Component::Loader::finish() if(!inst_hdr.empty()) { Component hdrcomp(comp.pkg, HEADERS, inst_hdr); - hdrcomp.sources=comp.sources; - hdrcomp.install=true; + hdrcomp.sources = comp.sources; + hdrcomp.install = true; const_cast(comp.pkg.get_components()).push_back(hdrcomp); } } @@ -264,7 +264,7 @@ void Component::Loader::source(const string &s) void Component::Loader::require(const string &n) { - Package *req=comp.pkg.get_builder().get_package(n); + Package *req = comp.pkg.get_builder().get_package(n); if(req) comp.requires.push_back(req); } @@ -273,18 +273,18 @@ void Component::Loader::modular() { if(comp.type!=PROGRAM) throw Exception("Only programs can be modular"); - comp.modular=true; + comp.modular = true; } void Component::Loader::host(const string &n) { - const ComponentList &comps=comp.pkg.get_components(); + const ComponentList &comps = comp.pkg.get_components(); for(ComponentList::const_iterator i=comps.begin(); i!=comps.end(); ++i) if(i->get_name()==n) { if(i->get_type()!=PROGRAM || !i->is_modular()) throw Exception("Module host must be a modular program"); - comp.module_host=&*i; + comp.module_host = &*i; return; } @@ -296,11 +296,11 @@ void Component::Loader::install_headers(const string &p) IO::print("%s: Note: install_headers is deprecated\n", get_source()); if(comp.type==HEADERS) { - comp.name=p; - comp.install=true; + comp.name = p; + comp.install = true; } else - inst_hdr=p; + inst_hdr = p; } void Component::Loader::build_info() diff --git a/source/condition.cpp b/source/condition.cpp index 4c9ac0b..314d9c9 100644 --- a/source/condition.cpp +++ b/source/condition.cpp @@ -16,14 +16,14 @@ using namespace Msp; Condition::Condition(SourcePackage &p, const string &expr): pkg(p) { - vector parts=split(expr); + vector parts = split(expr); for(vector::iterator i=parts.begin(); i!=parts.end(); ++i) { if(*i=="and") continue; - string::size_type token=i->find_first_of("=!"); + string::size_type token = i->find_first_of("=!"); if(token==string::npos) expression.insert(StringMap::value_type(*i, "!0")); else if(token==0 && (*i)[0]=='!') @@ -35,24 +35,24 @@ Condition::Condition(SourcePackage &p, const string &expr): bool Condition::eval() { - const Config &conf=pkg.get_config(); + const Config &conf = pkg.get_config(); - bool result=true; + bool result = true; for(StringMap::iterator i=expression.begin(); i!=expression.end(); ++i) { - bool neg=(i->second[0]=='!'); - unsigned start=1; + bool neg = (i->second[0]=='!'); + unsigned start = 1; if(i->second[1]=='=') ++start; string value; if(conf.is_option(i->first)) - value=conf.get_option(i->first).value; + value = conf.get_option(i->first).value; else if(i->first=="arch") - value=pkg.get_builder().get_current_arch().get_name(); + value = pkg.get_builder().get_current_arch().get_name(); if((value==i->second.substr(start))==neg) - result=false; + result = false; } return result; diff --git a/source/config.cpp b/source/config.cpp index 99bfeea..4ec969a 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -32,7 +32,7 @@ void Config::add_option(const string &n, const string &v, const string &d) const Config::Option &Config::get_option(const string &name) const { - OptionMap::const_iterator i=options.find(name); + OptionMap::const_iterator i = options.find(name); if(i==options.end()) throw KeyError("Unknown option", name); @@ -56,9 +56,9 @@ void Config::select_last_profile() catch(const IO::FileNotFound &) { } - freeze_mtime=true; + freeze_mtime = true; package.get_builder().apply_profile_template(*this, get_option("profile").value); - freeze_mtime=false; + freeze_mtime = false; load(); } @@ -73,24 +73,24 @@ void Config::select_profile(const string &profile) IO::print(out, "%s\n", profile); } - freeze_mtime=true; + freeze_mtime = true; package.get_builder().apply_profile_template(*this, profile); - freeze_mtime=false; + freeze_mtime = false; load(); } bool Config::update(const StringMap &opts) { - bool changed=false; + bool changed = false; for(StringMap::const_iterator i=opts.begin(); i!=opts.end(); ++i) { if(set_option(i->first, i->second) && i->first!="profile") - changed=true; + changed = true; } if(changed && !freeze_mtime) - mtime=Time::now(); + mtime = Time::now(); return changed; } @@ -99,41 +99,41 @@ void Config::finish() { for(unsigned n=0; n<20; ++n) { - bool changed=false; + bool changed = false; for(OptionMap::iterator i=options.begin(); i!=options.end(); ++i) { - Option &opt=i->second; - string::size_type dollar=0; - while((dollar=opt.value.find('$', dollar))!=string::npos) + Option &opt = i->second; + string::size_type dollar = 0; + while((dollar = opt.value.find('$', dollar))!=string::npos) { string::size_type end; string var; if(opt.value[dollar+1]=='{') { - end=opt.value.find('}', dollar+2); + end = opt.value.find('}', dollar+2); if(end==string::npos) throw Exception("Unterminated variable reference"); - var=opt.value.substr(dollar+2, end-dollar-2); + var = opt.value.substr(dollar+2, end-dollar-2); ++end; } else { for(end=dollar+1; (isalnum(opt.value[end]) && opt.value[end]!='_'); ++end) ; - var=opt.value.substr(dollar+1, end-dollar-1); + var = opt.value.substr(dollar+1, end-dollar-1); } string value; if(is_option(var)) - value=get_option(var).value; + value = get_option(var).value; else if(var=="arch") - value=package.get_builder().get_current_arch().get_name(); - else if(const char *ptr=getenv(var.c_str())) - value=ptr; + value = package.get_builder().get_current_arch().get_name(); + else if(const char *ptr = getenv(var.c_str())) + value = ptr; opt.value.replace(dollar, end-dollar, value); - dollar+=value.size(); - changed=true; + dollar += value.size(); + changed = true; } } @@ -144,11 +144,11 @@ void Config::finish() void Config::save() const { - FS::Path fn=package.get_source()/".options"; + FS::Path fn = package.get_source()/".options"; - OptionMap::const_iterator i=options.find("profile"); + OptionMap::const_iterator i = options.find("profile"); if(i!=options.end()) - fn=package.get_source()/(".options."+i->second.value); + fn = package.get_source()/(".options."+i->second.value); IO::BufferedFile out(fn.str(), IO::M_WRITE); @@ -158,14 +158,14 @@ void Config::save() const bool Config::set_option(const string &opt, const string &val) { - bool result=false; + bool result = false; - OptionMap::iterator i=options.find(opt); + OptionMap::iterator i = options.find(opt); if(i!=options.end()) { if(i->second.value!=val) - result=true; - i->second.value=val; + result = true; + i->second.value = val; } return result; @@ -173,13 +173,13 @@ bool Config::set_option(const string &opt, const string &val) void Config::load() { - FS::Path fn=package.get_source()/(".options."+get_option("profile").value); + FS::Path fn = package.get_source()/(".options."+get_option("profile").value); try { IO::BufferedFile in(fn.str()); - mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); + mtime = Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); DataFile::Parser parser(in, fn.str()); Loader loader(*this); diff --git a/source/copy.cpp b/source/copy.cpp index 6c24cdc..581221a 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -28,7 +28,7 @@ Copy::Copy(Builder &b, const Package &pkg, const FS::Path &s, const FS::Path &d) IO::print("%s -> %s\n", s, d); if(!builder.get_dry_run()) - worker=new Worker(*this); + worker = new Worker(*this); } @@ -52,7 +52,7 @@ void Copy::Worker::main() catch(const Exception &e) { IO::print(IO::cerr, "%s\n", e.what()); - done=error=true; + done = error = true; return; } } @@ -66,20 +66,20 @@ void Copy::Worker::main() char buf[16384]; while(!in.eof()) { - unsigned len=in.read(buf, sizeof(buf)); + unsigned len = in.read(buf, sizeof(buf)); out.write(buf, len); } } catch(const Exception &e) { IO::print(IO::cerr, "%s\n", e.what()); - done=error=true; + done = error = true; return; } // Preserve file permissions - struct stat st=FS::stat(copy.src); + struct stat st = FS::stat(copy.src); chmod(copy.dest.str().c_str(), st.st_mode&0777); - done=true; + done = true; } diff --git a/source/datacompile.cpp b/source/datacompile.cpp index 9e9a287..5fa5a53 100644 --- a/source/datacompile.cpp +++ b/source/datacompile.cpp @@ -19,19 +19,19 @@ using namespace Msp; DataCompile::DataCompile(Builder &b, ::DataFile &dfile): ExternalAction(b) { - const Component &comp=dfile.get_component(); + const Component &comp = dfile.get_component(); - work_dir=comp.get_package().get_source(); + work_dir = comp.get_package().get_source(); argv.push_back("mspdatatool"); argv.push_back("-c"); argv.push_back("-b"); - FS::Path opath=dfile.get_path(); + FS::Path opath = dfile.get_path(); argv.push_back("-o"); argv.push_back(relative(opath, work_dir).str()); - FS::Path spath=dfile.get_source().get_path(); + FS::Path spath = dfile.get_source().get_path(); argv.push_back(relative(spath, work_dir).str()); if(!builder.get_dry_run()) diff --git a/source/datafile.cpp b/source/datafile.cpp index 66e610c..12acfe6 100644 --- a/source/datafile.cpp +++ b/source/datafile.cpp @@ -16,7 +16,7 @@ DataFile::DataFile(Builder &b, const Component &c, File &s): component(c), source(s) { - buildable=true; + buildable = true; add_depend(&source); } diff --git a/source/dependencycache.cpp b/source/dependencycache.cpp index 08d8af7..ffc6fd6 100644 --- a/source/dependencycache.cpp +++ b/source/dependencycache.cpp @@ -24,13 +24,13 @@ DependencyCache::DependencyCache(SourcePackage &p): void DependencyCache::set_deps(const string &tgt, const StringList &d) { - deps[tgt]=d; - changed=true; + deps[tgt] = d; + changed = true; } const StringList &DependencyCache::get_deps(const string &tgt) const { - DepsMap::const_iterator i=deps.find(tgt); + DepsMap::const_iterator i = deps.find(tgt); if(i==deps.end()) throw KeyError("Unknown dependencies", tgt); @@ -55,7 +55,7 @@ void DependencyCache::save() const void DependencyCache::load() { - string fn=(package.get_source()/".deps").str(); + string fn = (package.get_source()/".deps").str(); try { @@ -64,11 +64,11 @@ void DependencyCache::load() string line; while(in.getline(line)) { - vector parts=split(line, '|'); - deps[parts[0]]=StringList(parts.begin()+1, parts.end()); + vector parts = split(line, '|'); + deps[parts[0]] = StringList(parts.begin()+1, parts.end()); } - mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); + mtime = Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); } catch(const IO::FileNotFound &) { } diff --git a/source/externalaction.cpp b/source/externalaction.cpp index 7e0a23d..6989f69 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -23,18 +23,18 @@ void ExternalAction::launch() IO::print("%s\n", join(argv.begin(), argv.end())); if(builder.get_dry_run()) - pid=-1; + pid = -1; else { - pid=fork(); + pid = fork(); if(pid==0) { char *argv_[argv.size()+1]; - unsigned j=0; + unsigned j = 0; for(StringList::iterator i=argv.begin(); i!=argv.end(); ++i) - argv_[j++]=strdup(i->c_str()); - argv_[j]=0; + argv_[j++] = strdup(i->c_str()); + argv_[j] = 0; if(!work_dir.empty()) FS::chdir(work_dir); @@ -43,7 +43,7 @@ void ExternalAction::launch() exit(1); } else if(pid<0) - pid=0; + pid = 0; } } @@ -63,10 +63,10 @@ int ExternalAction::check() { signal_done.emit(); if(WIFEXITED(status)) - exit_code=WEXITSTATUS(status); + exit_code = WEXITSTATUS(status); else - exit_code=254; - pid=0; + exit_code = 254; + pid = 0; return exit_code; } else diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 08b0f31..37cc65c 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -21,7 +21,7 @@ FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a): struct stat st; if(!FS::stat(path, st)) { - mtime=Time::TimeStamp::from_unixtime(st.st_mtime); - size=st.st_size; + mtime = Time::TimeStamp::from_unixtime(st.st_mtime); + size = st.st_size; } } diff --git a/source/install.cpp b/source/install.cpp index 27bb9a3..893f021 100644 --- a/source/install.cpp +++ b/source/install.cpp @@ -24,7 +24,7 @@ Install::Install(Builder &b, const SourcePackage &p, FileTarget &s, const std::s FileTarget(b, &p, generate_target_path(s, loc)), source(s) { - buildable=true; + buildable = true; add_depend(&source); } @@ -48,34 +48,34 @@ FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string if(!tgt.get_package()) throw InvalidParameterValue("Can't install package-less targets"); - FS::Path base=tgt.get_package()->get_builder().get_prefix(); - string tgtname=FS::basename(tgt.get_path()); + FS::Path base = tgt.get_package()->get_builder().get_prefix(); + string tgtname = FS::basename(tgt.get_path()); string mid; if(!loc.empty()) - mid=loc; - else if(const Header *hdr=dynamic_cast(&tgt)) + mid = loc; + else if(const Header *hdr = dynamic_cast(&tgt)) { if(hdr->get_component()->get_type()!=Component::HEADERS) throw Exception("Header install from non-header component?"); - mid="include/"+hdr->get_component()->get_name(); + mid = "include/"+hdr->get_component()->get_name(); } else if(dynamic_cast(&tgt)) - mid="bin"; - else if(const SharedLibrary *shlib=dynamic_cast(&tgt)) + mid = "bin"; + else if(const SharedLibrary *shlib = dynamic_cast(&tgt)) { - const Component &comp=shlib->get_component(); + const Component &comp = shlib->get_component(); if(comp.get_type()==Component::LIBRARY) - mid="lib"; + mid = "lib"; else if(comp.get_type()==Component::MODULE) - mid="lib/"+tgt.get_package()->get_name(); + mid = "lib/"+tgt.get_package()->get_name(); } else if(dynamic_cast(&tgt)) - mid="lib"; + mid = "lib"; else if(dynamic_cast(&tgt)) - mid="lib/pkgconfig"; + mid = "lib/pkgconfig"; else if(dynamic_cast(&tgt)) - mid="share/"+tgt.get_package()->get_name(); + mid = "share/"+tgt.get_package()->get_name(); if(mid.empty()) throw InvalidParameterValue("Don't know where to install "+tgtname); diff --git a/source/link.cpp b/source/link.cpp index 69a1d40..b6537d9 100644 --- a/source/link.cpp +++ b/source/link.cpp @@ -24,12 +24,12 @@ using namespace Msp; Link::Link(Builder &b, const Binary &bin): ExternalAction(b) { - const Component &comp=bin.get_component(); + const Component &comp = bin.get_component(); - work_dir=comp.get_package().get_source(); + work_dir = comp.get_package().get_source(); //XXX Determine whether to use g++ or gcc - string tool="LXX"; + string tool = "LXX"; argv.push_back(builder.get_current_arch().get_tool(tool)); if(comp.get_type()==Component::LIBRARY || comp.get_type()==Component::MODULE) @@ -37,7 +37,7 @@ Link::Link(Builder &b, const Binary &bin): else if(comp.get_package().get_library_mode()==ALL_STATIC) argv.push_back("-static"); - const BuildInfo &binfo=comp.get_build_info(); + const BuildInfo &binfo = comp.get_build_info(); for(list::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i) argv.push_back(*i); for(list::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) @@ -45,22 +45,22 @@ Link::Link(Builder &b, const Binary &bin): argv.push_back("-o"); argv.push_back(relative(bin.get_path(), work_dir).str()); - const TargetList &deps=bin.get_depends(); + const TargetList &deps = bin.get_depends(); for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) { - Target *tgt=*i; - if(Install *inst=dynamic_cast(tgt)) - tgt=&inst->get_source(); + Target *tgt = *i; + if(Install *inst = dynamic_cast(tgt)) + tgt = &inst->get_source(); - if(ObjectFile *obj=dynamic_cast(tgt)) + if(ObjectFile *obj = dynamic_cast(tgt)) argv.push_back(relative(obj->get_path(), work_dir).str()); - else if(StaticLibrary *stlib=dynamic_cast(tgt)) + else if(StaticLibrary *stlib = dynamic_cast(tgt)) argv.push_back(stlib->get_path().str()); - else if(Library *lib=dynamic_cast(tgt)) + else if(Library *lib = dynamic_cast(tgt)) argv.push_back("-l"+lib->get_libname()); } - FS::Path binpath=bin.get_path(); + FS::Path binpath = bin.get_path(); if(!builder.get_dry_run()) FS::mkpath(FS::dirname(binpath), 0755); diff --git a/source/misc.cpp b/source/misc.cpp index 2409e05..aadc056 100644 --- a/source/misc.cpp +++ b/source/misc.cpp @@ -22,20 +22,20 @@ string run_command(const StringList &argv, int *status) string result; - pid_t pid=fork(); + pid_t pid = fork(); if(pid==0) { char *argv_[argv.size()+1]; - unsigned j=0; + unsigned j = 0; for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i) - argv_[j++]=strdup(i->c_str()); - argv_[j]=0; + argv_[j++] = strdup(i->c_str()); + argv_[j] = 0; close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]); - int devnull=open("/dev/null", O_WRONLY); + int devnull = open("/dev/null", O_WRONLY); dup2(devnull, 2); close(devnull); @@ -50,7 +50,7 @@ string run_command(const StringList &argv, int *status) while(1) { char buf[1024]; - int len=read(pfd[0], buf, sizeof(buf)); + int len = read(pfd[0], buf, sizeof(buf)); if(len<=0) { int s; @@ -59,9 +59,9 @@ string run_command(const StringList &argv, int *status) if(status) { if(WIFEXITED(s)) - *status=WEXITSTATUS(s); + *status = WEXITSTATUS(s); else - *status=-1; + *status = -1; } break; } diff --git a/source/objectfile.cpp b/source/objectfile.cpp index ba20f7d..766188b 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -23,7 +23,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): comp(c), source(s) { - buildable=true; + buildable = true; add_depend(&source); } @@ -31,42 +31,42 @@ void ObjectFile::find_depends() { for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();) { - Target *tgt=*i; + Target *tgt = *i; if(tgt->get_depends_ready()) { - i=new_deps.erase(i); + i = new_deps.erase(i); find_depends(tgt); } else ++i; } - deps_ready=new_deps.empty(); + deps_ready = new_deps.empty(); } void ObjectFile::find_depends(Target *tgt) { - SourceFile *src=dynamic_cast(tgt); - FileTarget *file=src; + SourceFile *src = dynamic_cast(tgt); + FileTarget *file = src; if(!src) { - if(Install *inst=dynamic_cast(tgt)) + if(Install *inst = dynamic_cast(tgt)) { - file=inst; - src=dynamic_cast(&inst->get_source()); + file = inst; + src = dynamic_cast(&inst->get_source()); } } if(!src) return; - FS::Path spath=FS::dirname(file->get_path()); - const StringList &incpath=comp.get_build_info().incpath; + FS::Path spath = FS::dirname(file->get_path()); + const StringList &incpath = comp.get_build_info().incpath; - const list &includes=src->get_includes(); + const list &includes = src->get_includes(); for(list::const_iterator i=includes.begin(); i!=includes.end(); ++i) { - Target *hdr2=builder.get_header(*i, spath, incpath); + Target *hdr2 = builder.get_header(*i, spath, incpath); if(hdr2 && find(depends.begin(), depends.end(), hdr2)==depends.end()) add_depend(hdr2); } @@ -85,6 +85,6 @@ Action *ObjectFile::create_action() FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src) { - const SourcePackage &pkg=comp.get_package(); + const SourcePackage &pkg = comp.get_package(); return pkg.get_temp_dir()/comp.get_name()/(FS::basepart(src)+".o"); } diff --git a/source/package.cpp b/source/package.cpp index 6e60b76..f137429 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -28,7 +28,7 @@ PackageList Package::collect_requires() result.push_back(this); for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) { - PackageList r=(*i)->collect_requires(); + PackageList r = (*i)->collect_requires(); result.splice(result.end(), r); } @@ -56,7 +56,7 @@ void Package::configure(const StringMap &opts, unsigned flag) create_build_info(); - conf_done=true; + conf_done = true; } @@ -68,7 +68,7 @@ Package::Loader::Loader(Package &p): void Package::Loader::require(const string &n) { - Package *req=pkg.builder.get_package(n); + Package *req = pkg.builder.get_package(n); if(req) pkg.requires.push_back(req); } diff --git a/source/pkgconfig.cpp b/source/pkgconfig.cpp index 5daf455..4169f1e 100644 --- a/source/pkgconfig.cpp +++ b/source/pkgconfig.cpp @@ -12,7 +12,7 @@ Distributed under the LGPL PkgConfig::PkgConfig(Builder &b, const SourcePackage &p): FileTarget(b, &p, p.get_source()/(p.get_name()+".pc")) { - buildable=true; + buildable = true; } Action *PkgConfig::create_action() diff --git a/source/pkgconfigaction.cpp b/source/pkgconfigaction.cpp index 3e5d678..d0209fa 100644 --- a/source/pkgconfigaction.cpp +++ b/source/pkgconfigaction.cpp @@ -18,7 +18,7 @@ using namespace Msp; PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): Action(b) { - const SourcePackage &spkg=*static_cast(p.get_package()); + const SourcePackage &spkg = *static_cast(p.get_package()); announce(spkg.get_name(), "PC", basename(p.get_path())); @@ -32,13 +32,13 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): IO::print(out, "Version: %s\n", spkg.get_version()); IO::print(out, "Requires:"); - const PackageList &reqs=spkg.get_requires(); + const PackageList &reqs = spkg.get_requires(); for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i) if((*i)->get_use_pkgconfig()) IO::print(out, " %s", (*i)->get_name()); out.put('\n'); - const BuildInfo &binfo=spkg.get_exported_binfo(); + const BuildInfo &binfo = spkg.get_exported_binfo(); IO::print(out, "Libs:"); for(StringList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) IO::print(out, " -L%s", *i); diff --git a/source/sourcefile.cpp b/source/sourcefile.cpp index 7425a0f..3a1941a 100644 --- a/source/sourcefile.cpp +++ b/source/sourcefile.cpp @@ -31,20 +31,20 @@ void SourceFile::find_depends() { if(!comp) { - deps_ready=true; + deps_ready = true; return; } - const SourcePackage &spkg=comp->get_package(); - string relname=FS::relative(name, spkg.get_source()).str(); - DependencyCache &deps_cache=spkg.get_deps_cache(); - bool deps_found=false; + const SourcePackage &spkg = comp->get_package(); + string relname = FS::relative(name, spkg.get_source()).str(); + DependencyCache &deps_cache = spkg.get_deps_cache(); + bool deps_found = false; if(mtimeget_build_info().incpath; + const StringList &incpath = comp->get_build_info().incpath; - FS::Path dir=FS::dirname(path); + FS::Path dir = FS::dirname(path); for(list::iterator i=includes.begin(); i!=includes.end(); ++i) { - Target *hdr=builder.get_header(*i, dir, incpath); + Target *hdr = builder.get_header(*i, dir, incpath); if(hdr) add_depend(hdr); } - deps_ready=true; + deps_ready = true; } diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 889bf7b..838ab16 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -40,7 +40,7 @@ FS::Path SourcePackage::get_temp_dir() const FS::Path SourcePackage::get_out_dir() const { - const Architecture &arch=builder.get_current_arch(); + const Architecture &arch = builder.get_current_arch(); if(arch.is_native()) return source/config.get_option("outdir").value; else @@ -49,16 +49,16 @@ FS::Path SourcePackage::get_out_dir() const unsigned SourcePackage::get_install_flags() { - unsigned flags=0; + unsigned flags = 0; for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) if(i->get_install()) { if(i->get_type()==Component::PROGRAM) - flags|=BIN; + flags |= BIN; else if(i->get_type()==Component::LIBRARY || i->get_type()==Component::MODULE) - flags|=LIB; + flags |= LIB; else if(i->get_type()==Component::HEADERS) - flags|=INCLUDE; + flags |= INCLUDE; } return flags; @@ -66,7 +66,7 @@ unsigned SourcePackage::get_install_flags() LibMode SourcePackage::get_library_mode() const { - const string &mode=config.get_option("staticlibs").value; + const string &mode = config.get_option("staticlibs").value; if(mode=="all") return ALL_STATIC; else if(mode=="local") @@ -81,7 +81,7 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) { init_config(); - StringMap::const_iterator prof=opts.find("profile"); + StringMap::const_iterator prof = opts.find("profile"); if(prof!=opts.end() && flag) config.select_profile(prof->second); else @@ -100,23 +100,23 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) for(ConditionList::iterator i=conditions.begin(); i!=conditions.end(); ++i) if(i->eval()) { - const StringList &reqs=i->get_requires(); + const StringList &reqs = i->get_requires(); for(StringList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j) - if(Package *pkg=builder.get_package(*j)) + if(Package *pkg = builder.get_package(*j)) requires.push_back(pkg); } - base_reqs=requires; + base_reqs = requires; for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) { - const PackageList &reqs=i->get_requires(); + const PackageList &reqs = i->get_requires(); requires.insert(requires.end(), reqs.begin(), reqs.end()); } for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i) { - BinaryPackage *bpkg=dynamic_cast(*i); + BinaryPackage *bpkg = dynamic_cast(*i); if(bpkg && bpkg->get_need_path()) bpkg->set_path(config.get_option(bpkg->get_name()+"_path").value); } @@ -140,7 +140,7 @@ void SourcePackage::init_config() for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) { - BinaryPackage *bpkg=dynamic_cast(*i); + BinaryPackage *bpkg = dynamic_cast(*i); if(bpkg && bpkg->get_need_path()) config.add_option(bpkg->get_name()+"_path", "/usr", "Path for "+bpkg->get_name()); } @@ -150,7 +150,7 @@ void SourcePackage::create_build_info() { for(PackageList::iterator i=base_reqs.begin(); i!=base_reqs.end(); ++i) { - const BuildInfo &ebi=(*i)->get_exported_binfo(); + const BuildInfo &ebi = (*i)->get_exported_binfo(); build_info.add(ebi); export_binfo.cflags.insert(export_binfo.cflags.end(), ebi.cflags.begin(), ebi.cflags.end()); @@ -159,10 +159,10 @@ void SourcePackage::create_build_info() } // XXX Currently, a package-specific settings will override cmdline. This might or might not be desirable. - const StringList &warnings=builder.get_warnings(); + const StringList &warnings = builder.get_warnings(); build_info.warnings.insert(build_info.warnings.begin(), warnings.begin(), warnings.end()); - unsigned flags=get_install_flags(); + unsigned flags = get_install_flags(); build_info.incpath.push_back((builder.get_prefix()/"include").str()); build_info.libpath.push_back((builder.get_prefix()/"lib").str()); @@ -172,12 +172,12 @@ void SourcePackage::create_build_info() if(flags&LIB) export_binfo.libpath.push_back((builder.get_prefix()/"lib").str()); - string optimize=config.get_option("optimize").value; + string optimize = config.get_option("optimize").value; if(lexical_cast(optimize)) { build_info.cflags.push_back("-O"+optimize); build_info.ldflags.push_back("-O"+optimize); - string cpu=config.get_option("cpu").value; + string cpu = config.get_option("cpu").value; if(cpu!="none") build_info.cflags.push_back("-march="+cpu); } @@ -229,7 +229,7 @@ SourcePackage::Loader::Loader(Package &p): void SourcePackage::Loader::finish() { - SourcePackage &spkg=static_cast(pkg); + SourcePackage &spkg = static_cast(pkg); spkg.components.sort(component_sort); } @@ -244,7 +244,7 @@ void SourcePackage::Loader::feature(const string &n, const string &d) void SourcePackage::Loader::condition(const string &c) { - SourcePackage &spkg=static_cast(pkg); + SourcePackage &spkg = static_cast(pkg); Condition cond(spkg, c); load_sub(cond); spkg.conditions.push_back(cond); @@ -253,7 +253,7 @@ void SourcePackage::Loader::condition(const string &c) template void SourcePackage::Loader::component(const string &n) { - SourcePackage &spkg=static_cast(pkg); + SourcePackage &spkg = static_cast(pkg); Component comp(spkg, t, n); load_sub(comp); spkg.components.push_back(comp); @@ -266,7 +266,7 @@ void SourcePackage::Loader::build_info() void SourcePackage::Loader::tarball(const string &n) { - SourcePackage &spkg=static_cast(pkg); + SourcePackage &spkg = static_cast(pkg); if(n=="@src") { for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i) @@ -283,7 +283,7 @@ void SourcePackage::Loader::tarball(const string &n) void SourcePackage::Loader::tar_file(const string &f) { IO::print("%s: Note: tar_file is deprecated\n", get_source()); - SourcePackage &spkg=static_cast(pkg); + SourcePackage &spkg = static_cast(pkg); for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i) if(i->get_type()==Component::TARBALL && i->get_name()=="@src") const_cast(i->get_sources()).push_back(spkg.source/f); diff --git a/source/sourcepackage.h b/source/sourcepackage.h index 0745a1b..883bbf6 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -27,10 +27,10 @@ class SourcePackage: public Package public: enum InstallFlags { - INCLUDE=1, - BIN=2, - LIB=4, - DATA=8 + INCLUDE = 1, + BIN = 2, + LIB = 4, + DATA = 8 }; class Loader: public Package::Loader diff --git a/source/staticlibrary.cpp b/source/staticlibrary.cpp index b7e4eff..c599886 100644 --- a/source/staticlibrary.cpp +++ b/source/staticlibrary.cpp @@ -18,7 +18,7 @@ StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list::const_iterator i=objs.begin(); i!=objs.end(); ++i) add_depend(*i); } diff --git a/source/systemlibrary.cpp b/source/systemlibrary.cpp index 58eaea7..66a346f 100644 --- a/source/systemlibrary.cpp +++ b/source/systemlibrary.cpp @@ -19,7 +19,7 @@ SystemLibrary::SystemLibrary(Builder &b, const FS::Path &p): string SystemLibrary::extract_libname(const FS::Path &p) { - string result=FS::basepart(FS::basename(p)); + string result = FS::basepart(FS::basename(p)); if(!result.compare(0, 3, "lib")) result.erase(0, 3); return result; diff --git a/source/tar.cpp b/source/tar.cpp index 75018fb..bfb4f5f 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -22,13 +22,13 @@ Tar::Tar(Builder &b, const TarBall &t): InternalAction(b), tarball(t) { - string basename=FS::basename(tarball.get_path()); + string basename = FS::basename(tarball.get_path()); announce(tarball.get_package()->get_name(), "TAR ", basename); if(builder.get_verbose()>=2) IO::print("Create %s\n", basename); if(!builder.get_dry_run()) - worker=new Worker(*this); + worker = new Worker(*this); } @@ -40,63 +40,63 @@ Tar::Worker::Worker(Tar &t): void Tar::Worker::main() { - const FS::Path &pkg_src=tar.tarball.get_package()->get_source(); - FS::Path basedir=FS::basepart(FS::basename(tar.tarball.get_path())); + const FS::Path &pkg_src = tar.tarball.get_package()->get_source(); + FS::Path basedir = FS::basepart(FS::basename(tar.tarball.get_path())); IO::File out(tar.tarball.get_path().str(), IO::M_WRITE); - const TargetList &deps=tar.tarball.get_depends(); + const TargetList &deps = tar.tarball.get_depends(); for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) { - FileTarget *ft=dynamic_cast(*i); + FileTarget *ft = dynamic_cast(*i); if(!ft) continue; char buf[4096]; memset(buf, 0, 512); - string rel_path=(basedir/relative(ft->get_path(), pkg_src)).str(); + string rel_path = (basedir/relative(ft->get_path(), pkg_src)).str(); if(rel_path.size()>99) { IO::print("Can't store %s in tar archive - too long name\n", rel_path); - error=true; + error = true; break; } memcpy(buf, rel_path.data(), rel_path.size()); - struct stat st=FS::stat(ft->get_path()); + struct stat st = FS::stat(ft->get_path()); store_number(buf+100, st.st_mode, 7); store_number(buf+108, st.st_uid, 7); store_number(buf+116, st.st_gid, 7); store_number(buf+124, st.st_size, 11); store_number(buf+136, st.st_mtime, 11); - buf[156]='0'; + buf[156] = '0'; memset(buf+148, ' ', 8); - unsigned chk=0; + unsigned chk = 0; for(unsigned j=0; j<512; ++j) - chk+=static_cast(buf[j]); + chk += static_cast(buf[j]); store_number(buf+148, chk, 7); - buf[155]=0; + buf[155] = 0; out.write(buf, 512); IO::File in(ft->get_path().str()); for(int j=0; jget_buildable_target(); + Target *tgt = (*i)->get_buildable_target(); if(tgt) return tgt; else if((*i)->get_rebuild()) - self_ok=false; + self_ok = false; } if(self_ok) @@ -71,33 +71,33 @@ void Target::prepare() return; } - preparing=true; + preparing = true; for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) (*i)->prepare(); check_rebuild(); - preparing=false; - prepared=true; + preparing = false; + prepared = true; } Action *Target::build() { if(!buildable) { - rebuild=false; + rebuild = false; return 0; } - if(FileTarget *ft=dynamic_cast(this)) + if(FileTarget *ft = dynamic_cast(this)) if(!builder.get_dry_run() && FS::exists(ft->get_path())) FS::unlink(ft->get_path()); - Action *action=create_action(); + Action *action = create_action(); if(action) { action->signal_done.connect(sigc::mem_fun(this, &Target::build_done)); - building=true; + building = true; } return action; @@ -105,13 +105,13 @@ Action *Target::build() void Target::touch() { - mtime=Time::now(); + mtime = Time::now(); } void Target::mark_rebuild(const std::string &reason) { - rebuild=true; - rebuild_reason=reason; + rebuild = true; + rebuild_reason = reason; } void Target::check_rebuild() @@ -134,13 +134,13 @@ void Target::check_rebuild() } } - const SourcePackage *spkg=dynamic_cast(package); + const SourcePackage *spkg = dynamic_cast(package); if(!rebuild && spkg && spkg->get_config().get_mtime()>mtime) mark_rebuild("Package options changed"); } void Target::build_done() { - building=false; - rebuild=false; + building = false; + rebuild = false; } diff --git a/source/target.h b/source/target.h index 805b64a..80c6a17 100644 --- a/source/target.h +++ b/source/target.h @@ -49,7 +49,7 @@ protected: public: virtual ~Target() { } - virtual const char *get_type() const=0; + virtual const char *get_type() const = 0; const std::string &get_name() const { return name; } const Package *get_package() const { return package; } const Msp::Time::TimeStamp &get_mtime() const { return mtime; } @@ -72,7 +72,7 @@ public: Finds dependencies for the target. When all dependencies have been found, the function should set deps_ready to true. */ - virtual void find_depends() { deps_ready=true; } + virtual void find_depends() { deps_ready = true; } /** Prepares the target by recursively preparing dependencies, then checking diff --git a/source/unlink.cpp b/source/unlink.cpp index fbe6388..f1a5486 100644 --- a/source/unlink.cpp +++ b/source/unlink.cpp @@ -13,7 +13,7 @@ Distributed under the LGPL Unlink::Unlink(Builder &b, const FileTarget &t): Action(b) { - const SourcePackage &spkg=*static_cast(t.get_package()); + const SourcePackage &spkg = *static_cast(t.get_package()); announce(spkg.get_name(), "RM", relative(t.get_path(), spkg.get_source()).str());