25 using namespace basis;
45 const char*
COPYRIGHT =
"2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh";
46 const char*
LICENSE =
"See https://cmake-basis.github.io/download.html#license or COPYING file.";
47 const char*
CONTACT =
"andreas.schuh.84@gmail.com";
58 static inline bool executing_in_build_tree()
74 return !(rel_path ==
"" || rel_path ==
"." ||
75 (rel_path.substr(0, 2) ==
".." && (rel_path.size() == 2 || rel_path[2] ==
'/')));
95 typedef std::map <std::string, std::string> MapType;
96 typedef MapType::const_iterator MapIterator;
108 ExecutableTargetInfo();
111 ~ExecutableTargetInfo() {}
122 static const ExecutableTargetInfo* instance();
128 std::string
targetuid(
const std::string& target)
const;
129 bool istarget(
const std::string& target)
const;
130 std::string
basename(
const std::string& target)
const;
131 std::string
dirname(
const std::string& target)
const;
142 ExecutableTargetInfo(
const ExecutableTargetInfo&);
149 void operator=(
const ExecutableTargetInfo&);
161 MapType _install_dirs;
193 static string install_prefix()
205 if (executing_in_build_tree()) {
206 return "/Users/as12312/Software/BASIS/Xcode/bin";
215 if (executing_in_build_tree()) {
216 return "/Users/as12312/Software/BASIS/Xcode/lib";
225 if (executing_in_build_tree()) {
226 return "/Users/as12312/Software/BASIS/Xcode/lib";
235 if (executing_in_build_tree()) {
236 return "/Users/as12312/Software/BASIS/Workspace/data";
253 void print_version(
const char* name,
const char* version,
const char* project,
const char* copyright,
const char* license)
256 version != NULL ? version : RELEASE,
257 project != NULL ? project : PROJECT,
258 copyright != NULL ? copyright : COPYRIGHT,
259 license != NULL ? license : LICENSE);
297 int execute(
const string& cmd,
bool quiet, ostream* out,
298 bool allow_fail,
int verbose,
bool simulate)
301 ExecutableTargetInfo::instance());
305 int execute(vector<string> args,
bool quiet, ostream* out,
306 bool allow_fail,
int verbose,
bool simulate)
309 ExecutableTargetInfo::instance());
317 const ExecutableTargetInfo* ExecutableTargetInfo::instance()
319 static ExecutableTargetInfo instance;
327 if (target.empty())
return "";
329 if (target[0] ==
'.')
return target;
331 string prefix = string(
"basis");
334 if (_exec_names.find(prefix +
"." + target) != _exec_names.end()) {
335 return prefix +
"." + target;
337 string::size_type pos = prefix.rfind(
'.');
338 if (pos == string::npos)
break;
339 prefix = prefix.substr(0, pos);
348 if (target.empty())
return false;
350 if (target[0] ==
'.') uid = target.substr(1);
352 return _exec_names.find(uid) != _exec_names.end();
358 if (target.empty())
return "";
360 if (target[0] ==
'.') uid = target.substr(1);
362 MapIterator it = _exec_names.find(uid);
363 if (it == _exec_names.end ())
return "";
370 if (target.empty())
return "";
372 if (target[0] ==
'.') uid = target.substr(1);
374 if (executing_in_build_tree()) {
375 MapIterator it = _build_dirs.find(uid);
376 if (it == _build_dirs.end())
return "";
378 const char *
match =
"/$<CONFIG>";
379 const size_t n = strlen(match);
380 if (it->second.length() >= n) {
381 const size_t pos = it->second.length() - n;
382 if (it->second.compare(pos, n, match, n) == 0) {
389 MapIterator it = _install_dirs.find(uid);
390 if (it == _install_dirs.end())
return "";
396 ExecutableTargetInfo::ExecutableTargetInfo()
402 _exec_names [
"basis.basisproject"] =
"basisproject";
403 _build_dirs [
"basis.basisproject"] =
"/Users/as12312/Software/BASIS/Xcode/bin/$<CONFIG>";
404 _install_dirs[
"basis.basisproject"] =
"/opt/basis/bin";
407 _exec_names [
"basis.testdriver"] =
"testdriver";
408 _build_dirs [
"basis.testdriver"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
409 _install_dirs[
"basis.testdriver"] =
"/opt/basis/lib";
412 _exec_names [
"basis.basistest"] =
"basistest";
413 _build_dirs [
"basis.basistest"] =
"/Users/as12312/Software/BASIS/Xcode/bin/$<CONFIG>";
414 _install_dirs[
"basis.basistest"] =
"/opt/basis/bin";
417 _exec_names [
"basis.basistest-master"] =
"basistest-master";
418 _build_dirs [
"basis.basistest-master"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
419 _install_dirs[
"basis.basistest-master"] =
"/opt/basis/lib";
422 _exec_names [
"basis.basistest-slave"] =
"basistest-slave";
423 _build_dirs [
"basis.basistest-slave"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
424 _install_dirs[
"basis.basistest-slave"] =
"/opt/basis/lib";
427 _exec_names [
"basis.basistest-cron"] =
"basistest-cron";
428 _build_dirs [
"basis.basistest-cron"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
429 _install_dirs[
"basis.basistest-cron"] =
"/opt/basis/lib";
432 _exec_names [
"basis.basistest-svn"] =
"basistest-svn";
433 _build_dirs [
"basis.basistest-svn"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
434 _install_dirs[
"basis.basistest-svn"] =
"/opt/basis/lib";
437 _exec_names [
"basis.doxyfilter"] =
"doxyfilter";
438 _build_dirs [
"basis.doxyfilter"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
439 _install_dirs[
"basis.doxyfilter"] =
"/opt/basis/lib";
442 _exec_names [
"basis.doxyfilter-perl"] =
"doxyfilter-perl";
443 _build_dirs [
"basis.doxyfilter-perl"] =
"/Users/as12312/Software/BASIS/Xcode/lib/$<CONFIG>";
444 _install_dirs[
"basis.doxyfilter-perl"] =
"/opt/basis/lib";
447 _exec_names [
"basis.dummy_command"] =
"dummy_command";
448 _build_dirs [
"basis.dummy_command"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
449 _install_dirs[
"basis.dummy_command"] =
"/opt/basis/bin";
452 _exec_names [
"basis.test_future_statements"] =
"test_future_statements";
453 _build_dirs [
"basis.test_future_statements"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
454 _install_dirs[
"basis.test_future_statements"] =
"/opt/basis/bin";
457 _exec_names [
"basis.test_matlabtools"] =
"test_matlabtools";
458 _build_dirs [
"basis.test_matlabtools"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
459 _install_dirs[
"basis.test_matlabtools"] =
"/opt/basis/bin";
462 _exec_names [
"basis.test_basisproject"] =
"test_basisproject";
463 _build_dirs [
"basis.test_basisproject"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
464 _install_dirs[
"basis.test_basisproject"] =
"/opt/basis/bin";
467 _exec_names [
"basis.test_os"] =
"test_os";
468 _build_dirs [
"basis.test_os"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
469 _install_dirs[
"basis.test_os"] =
"/opt/basis/bin";
472 _exec_names [
"basis.test_path"] =
"test_path";
473 _build_dirs [
"basis.test_path"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
474 _install_dirs[
"basis.test_path"] =
"/opt/basis/bin";
477 _exec_names [
"basis.test_subprocess"] =
"test_subprocess";
478 _build_dirs [
"basis.test_subprocess"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
479 _install_dirs[
"basis.test_subprocess"] =
"/opt/basis/bin";
482 _exec_names [
"basis.test_core"] =
"test_core";
483 _build_dirs [
"basis.test_core"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
484 _install_dirs[
"basis.test_core"] =
"/opt/basis/bin";
487 _exec_names [
"basis.test_shutilities"] =
"test_shutilities";
488 _build_dirs [
"basis.test_shutilities"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
489 _install_dirs[
"basis.test_shutilities"] =
"/opt/basis/bin";
492 _exec_names [
"basis.test_shtap"] =
"test_shtap";
493 _build_dirs [
"basis.test_shtap"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
494 _install_dirs[
"basis.test_shtap"] =
"/opt/basis/bin";
497 _exec_names [
"basis.parseargs"] =
"parseargs";
498 _build_dirs [
"basis.parseargs"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
499 _install_dirs[
"basis.parseargs"] =
"/opt/basis/bin";
502 _exec_names [
"basis.test_utilities"] =
"test_utilities";
503 _build_dirs [
"basis.test_utilities"] =
"/Users/as12312/Software/BASIS/Xcode/Testing/bin/$<CONFIG>";
504 _install_dirs[
"basis.test_utilities"] =
"/opt/basis/bin";
std::string bindir()
Get absolute path to directory containing runtime executables.
const unsigned int VERSION_MAJOR
The major version number.
string PROJECT
Project name.
std::string exedir(const std::string &name=std::string(), const IExecutableTargetInfo *targets=NULL)
Get directory of executable file.
function targetuid(out uid, in name)
Get UID of build target.
std::string libexecdir()
Get absolute path to directory containing auxiliary executables.
function realpath(in path)
Get canonical file path.
function istarget(in target)
Determine whether a given build target is known.
void print_contact(const char *contact)
Print contact information.
int execute(const std::string &cmd, bool quiet=false, std::ostream *out=NULL, bool allow_fail=false, int verbose=0, bool simulate=false, const IExecutableTargetInfo *targets=NULL)
Execute command as subprocess.
std::string join(const std::string &base, const std::string &path)
Join two paths, e.g., base path and relative path.
string COPYRIGHT
Default copyright of executables.
std::string basename(const std::string &path)
Get file name.
Provides information about executable build targets.
void print_version(const char *name, const char *version=NULL, const char *project=NULL, const char *copyright=NULL, const char *license=NULL)
Print version information including copyright and license notices.
BASIS utilities of BASIS project of BASIS package.
std::string relpath(const std::string &path, const std::string &base=std::string())
Make path relative.
string VERSION
Project version.
std::string exepath(const std::string &name=std::string(), const IExecutableTargetInfo *targets=NULL)
Get absolute path of executable file.
function exepath(out path, in target)
Get absolute path of executable file.
string RELEASE
Project release.
std::string targetuid(const std::string &name, const IExecutableTargetInfo *targets=NULL)
Get UID of build target.
std::string dirname(const std::string &path)
Get file directory.
std::string libdir()
Get absolute path to directory containing libraries.
function match(in value, in pattern)
This function implements a more portable way to do pattern matching.
function exedir(out dir, in name)
Get directory of executable file.
string LICENSE
Default license of executables.
MultiSwitchArg verbose("v", "verbose", "Increase verbosity of output messages.", false)
std::string datadir()
Get absolute path to directory containing auxiliary data.
std::string exename(const std::string &name=std::string(), const IExecutableTargetInfo *targets=NULL)
Get name of executable file.
const unsigned int VERSION_MINOR
The minor version number.
const unsigned int VERSION_PATCH
The patch number.
void print_version(const char *name, const char *version, const char *project=NULL, const char *copyright=NULL, const char *license=NULL)
Print version information including copyright and license notices.
void print_contact(const char *contact=NULL)
Print contact information.
function exename(out file, in name)
Get name of executable file.
bool istarget(const std::string &name, const IExecutableTargetInfo *targets=NULL)
Determine whether a given build target is known.
string CONTACT
Default contact to use for help output of executables.
function execute(in options, in cmd, in args)
Execute command as subprocess.