#include <set>
-#include <cstdlib>
#include <msp/core/getopt.h>
#include <msp/datafile/parser.h>
#include <msp/fs/dir.h>
prefix = (FS::get_home_dir()/"local"/current_arch->get_name()).str();
}
else
- prefix = FS::getcwd()/prfx;
+ prefix = cwd/prfx;
if(!temp_str.empty())
tempdir = temp_str;
int Builder::main()
{
- if(prefix.str()!="/usr")
- {
- FS::Path pcdir = prefix/"lib"/"pkgconfig";
- if(const char *pcp = getenv("PKG_CONFIG_PATH"))
- {
- vector<string> path = split(pcp, ':');
- bool found = false;
- for(vector<string>::const_iterator i=path.begin(); (!found && i!=path.end()); ++i)
- found = (*i==pcdir.str());
- if(!found)
- {
- path.push_back(pcdir.str());
- setenv("PKG_CONFIG_PATH", join(path.begin(), path.end(), ":").c_str(), true);
- }
- }
- else
- setenv("PKG_CONFIG_PATH", pcdir.str().c_str(), true);
- }
-
if(load_build_file(cwd/build_file))
{
if(help)
return 0;
}
+ if(!prepare_build())
+ return 1;
+
if(conf_only)
return 0;
- if(create_targets())
- return 1;
-
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));
return 0;
}
-int Builder::create_targets()
+bool Builder::prepare_build()
{
Target *world = new VirtualTarget(*this, "world");
if(!tgt)
{
IO::print("I don't know anything about %s\n", *i);
- return -1;
+ return false;
}
cmdline->add_depend(*tgt);
if(!tgt)
{
IO::print(IO::cerr, "Unknown what-if target %s\n", *i);
- return -1;
+ return false;
}
tgt->touch();
}
i->second->save_caches();
}
- return 0;
+ return true;
}
int Builder::do_build()