From 0ffb0a1a0a13d07c4448f7752232d8854b790623 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 30 Apr 2017 23:21:12 +0300 Subject: Add hxx extension for headers and lib prefix for library dirs --- bbot/.gitignore | 3 +- bbot/agent | 44 -------- bbot/agent.cxx | 18 ++-- bbot/agent.hxx | 44 ++++++++ bbot/bootstrap-manifest | 50 ---------- bbot/bootstrap-manifest.cxx | 2 +- bbot/bootstrap-manifest.hxx | 50 ++++++++++ bbot/buildfile | 10 +- bbot/common.cli | 2 +- bbot/diagnostics | 166 ------------------------------- bbot/diagnostics.cxx | 4 +- bbot/diagnostics.hxx | 166 +++++++++++++++++++++++++++++++ bbot/machine | 82 --------------- bbot/machine-manifest | 118 ---------------------- bbot/machine-manifest.cxx | 2 +- bbot/machine-manifest.hxx | 118 ++++++++++++++++++++++ bbot/machine.cxx | 6 +- bbot/machine.hxx | 82 +++++++++++++++ bbot/tftp | 45 --------- bbot/tftp.cxx | 4 +- bbot/tftp.hxx | 45 +++++++++ bbot/types | 107 -------------------- bbot/types-parsers | 38 ------- bbot/types-parsers.cxx | 4 +- bbot/types-parsers.hxx | 38 +++++++ bbot/types.hxx | 107 ++++++++++++++++++++ bbot/utility | 164 ------------------------------ bbot/utility.cxx | 4 +- bbot/utility.hxx | 164 ++++++++++++++++++++++++++++++ bbot/utility.txx | 2 +- bbot/version-impl.in | 87 ---------------- bbot/version.hxx.in | 87 ++++++++++++++++ bbot/worker.cxx | 12 +-- build/root.build | 2 +- buildfile | 3 +- tests/.gitignore | 2 + unit-tests/.gitignore | 2 + unit-tests/bootstrap-manifest/driver.cxx | 8 +- 38 files changed, 948 insertions(+), 944 deletions(-) delete mode 100644 bbot/agent create mode 100644 bbot/agent.hxx delete mode 100644 bbot/bootstrap-manifest create mode 100644 bbot/bootstrap-manifest.hxx delete mode 100644 bbot/diagnostics create mode 100644 bbot/diagnostics.hxx delete mode 100644 bbot/machine delete mode 100644 bbot/machine-manifest create mode 100644 bbot/machine-manifest.hxx create mode 100644 bbot/machine.hxx delete mode 100644 bbot/tftp create mode 100644 bbot/tftp.hxx delete mode 100644 bbot/types delete mode 100644 bbot/types-parsers create mode 100644 bbot/types-parsers.hxx create mode 100644 bbot/types.hxx delete mode 100644 bbot/utility create mode 100644 bbot/utility.hxx delete mode 100644 bbot/version-impl.in create mode 100644 bbot/version.hxx.in create mode 100644 tests/.gitignore diff --git a/bbot/.gitignore b/bbot/.gitignore index 59e9ffd..e7ffd50 100644 --- a/bbot/.gitignore +++ b/bbot/.gitignore @@ -1,5 +1,4 @@ -*-options *-options.?xx bbot-agent bbot-worker -version-impl +version.hxx diff --git a/bbot/agent b/bbot/agent deleted file mode 100644 index 990ad2d..0000000 --- a/bbot/agent +++ /dev/null @@ -1,44 +0,0 @@ -// file : bbot/agent -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_AGENT -#define BBOT_AGENT - -#include // uid_t - -#include -#include - -#include - -namespace bbot -{ - extern agent_options ops; - - extern const string bs_prot; // Bootstrap protocol version. - - extern string tc_name; // Toolchain name. - extern uint16_t tc_num; // Toolchain number. - extern string tc_id; // Toolchain id. - - extern string hname; // Our host name. - extern uid_t uid; // Our effective user id. - extern string uname; // Our effective user name. - - // Random number generator (currently not MT-safe and limited to RAND_MAX). - // - size_t - genrand (); - - template - inline T - genrand () {return static_cast (genrand ());} - - // Return the IPv4 address of an interface. - // - string - iface_addr (const string&); -} - -#endif // BBOT_AGENT diff --git a/bbot/agent.cxx b/bbot/agent.cxx index 7e0021a..6b59092 100644 --- a/bbot/agent.cxx +++ b/bbot/agent.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include #include // getpwuid() #include // PATH_MAX @@ -22,16 +22,16 @@ #include #include // dir_iterator -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include using namespace std; using namespace butl; diff --git a/bbot/agent.hxx b/bbot/agent.hxx new file mode 100644 index 0000000..e5115ae --- /dev/null +++ b/bbot/agent.hxx @@ -0,0 +1,44 @@ +// file : bbot/agent.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_AGENT_HXX +#define BBOT_AGENT_HXX + +#include // uid_t + +#include +#include + +#include + +namespace bbot +{ + extern agent_options ops; + + extern const string bs_prot; // Bootstrap protocol version. + + extern string tc_name; // Toolchain name. + extern uint16_t tc_num; // Toolchain number. + extern string tc_id; // Toolchain id. + + extern string hname; // Our host name. + extern uid_t uid; // Our effective user id. + extern string uname; // Our effective user name. + + // Random number generator (currently not MT-safe and limited to RAND_MAX). + // + size_t + genrand (); + + template + inline T + genrand () {return static_cast (genrand ());} + + // Return the IPv4 address of an interface. + // + string + iface_addr (const string&); +} + +#endif // BBOT_AGENT_HXX diff --git a/bbot/bootstrap-manifest b/bbot/bootstrap-manifest deleted file mode 100644 index 94a2a24..0000000 --- a/bbot/bootstrap-manifest +++ /dev/null @@ -1,50 +0,0 @@ -// file : bbot/bootstrap-manifest -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_BOOTSTRAP_MANIFEST -#define BBOT_BOOTSTRAP_MANIFEST - -#include - -#include - -#include -#include - -namespace bbot -{ - // Bootstrap result manifest. Uploaded by the worker to the agent's TFTP - // server. - // - class bootstrap_manifest - { - public: - - // Map of packages to their (numeric) versions that were used inside the - // bootstrapped machine. Used to make sure bbot agent/worker use the same - // versions. For example: - // - // libbbot-version: 1010100 # 1.1.1 - // bbot-version: 1010200 # 1.1.2 - // - using versions_type = std::map; - versions_type versions; - - explicit - bootstrap_manifest (versions_type v) - : versions (move (v)) {} - - public: - bootstrap_manifest () = default; // VC export. - bootstrap_manifest (butl::manifest_parser&, bool ignore_unknown = false); - bootstrap_manifest (butl::manifest_parser&, - butl::manifest_name_value start, - bool ignore_unknown = false); - - void - serialize (butl::manifest_serializer&) const; - }; -} - -#endif // BBOT_BOOTSTRAP_MANIFEST diff --git a/bbot/bootstrap-manifest.cxx b/bbot/bootstrap-manifest.cxx index 6a0ff8d..0d6e6b5 100644 --- a/bbot/bootstrap-manifest.cxx +++ b/bbot/bootstrap-manifest.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include #include #include diff --git a/bbot/bootstrap-manifest.hxx b/bbot/bootstrap-manifest.hxx new file mode 100644 index 0000000..9d583ad --- /dev/null +++ b/bbot/bootstrap-manifest.hxx @@ -0,0 +1,50 @@ +// file : bbot/bootstrap-manifest.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_BOOTSTRAP_MANIFEST_HXX +#define BBOT_BOOTSTRAP_MANIFEST_HXX + +#include + +#include + +#include +#include + +namespace bbot +{ + // Bootstrap result manifest. Uploaded by the worker to the agent's TFTP + // server. + // + class bootstrap_manifest + { + public: + + // Map of packages to their (numeric) versions that were used inside the + // bootstrapped machine. Used to make sure bbot agent/worker use the same + // versions. For example: + // + // libbbot-version: 1010100 # 1.1.1 + // bbot-version: 1010200 # 1.1.2 + // + using versions_type = std::map; + versions_type versions; + + explicit + bootstrap_manifest (versions_type v) + : versions (move (v)) {} + + public: + bootstrap_manifest () = default; // VC export. + bootstrap_manifest (butl::manifest_parser&, bool ignore_unknown = false); + bootstrap_manifest (butl::manifest_parser&, + butl::manifest_name_value start, + bool ignore_unknown = false); + + void + serialize (butl::manifest_serializer&) const; + }; +} + +#endif // BBOT_BOOTSTRAP_MANIFEST_HXX diff --git a/bbot/buildfile b/bbot/buildfile index 962d379..ccfc837 100644 --- a/bbot/buildfile +++ b/bbot/buildfile @@ -35,7 +35,7 @@ if ($cxx.target.class == "linux") {hxx }{ types } \ {hxx cxx}{ types-parsers } \ {hxx txx cxx}{ utility } \ - {hxx }{ version-impl } \ + {hxx }{ version } \ $libs } @@ -49,11 +49,11 @@ exe{bbot-worker}: \ {hxx }{ types } \ {hxx cxx}{ types-parsers } \ {hxx txx cxx}{ utility } \ -{hxx }{ version-impl } \ +{hxx }{ version } \ $libs -hxx{version-impl}: in{version-impl} $src_root/file{manifest} -hxx{version-impl}: dist = true +hxx{version}: in{version} $src_root/file{manifest} +hxx{version}: dist = true # Generated options parser. # @@ -64,7 +64,7 @@ if $cli.configured cli.cxx{worker-options}: cli{worker} cli.options += -I $src_root --include-with-brackets --include-prefix bbot \ ---guard-prefix BBOT --cxx-prologue "#include " \ +--guard-prefix BBOT --cxx-prologue "#include " \ --cli-namespace bbot::cli --generate-specifier --generate-parse cli.cxx{common-options}: cli.options = $cli.options # No usage. diff --git a/bbot/common.cli b/bbot/common.cli index 6bbd48b..b58fa93 100644 --- a/bbot/common.cli +++ b/bbot/common.cli @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -include ; +include ; namespace bbot { diff --git a/bbot/diagnostics b/bbot/diagnostics deleted file mode 100644 index 60df57c..0000000 --- a/bbot/diagnostics +++ /dev/null @@ -1,166 +0,0 @@ -// file : bbot/diagnostics -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_DIAGNOSTICS -#define BBOT_DIAGNOSTICS - -#include - -#include // Note: not . - -namespace bbot -{ - using butl::diag_record; - - // Throw this exception to terminate the process. The handler should - // assume that the diagnostics has already been issued. - // - class failed: public std::exception {}; - - // Verbosity level. Update documentation for --verbose if changing. - // - // 0 - disabled - // 1 - high-level information messages - // 2 - essential underlying commands that are being executed - // 3 - all underlying commands that are being executed - // 4 - information that could be helpful to the user - // 5 - information that could be helpful to the developer - // 6 - even more detailed information - // - // While uint8 is more than enough, use uint16 for the ease of printing. - // - extern uint16_t verb; - - template inline void l1 (const F& f) {if (verb >= 1) f ();} - template inline void l2 (const F& f) {if (verb >= 2) f ();} - template inline void l3 (const F& f) {if (verb >= 3) f ();} - template inline void l4 (const F& f) {if (verb >= 4) f ();} - template inline void l5 (const F& f) {if (verb >= 5) f ();} - template inline void l6 (const F& f) {if (verb >= 6) f ();} - - // Diagnostic facility, base infrastructure. - // - using butl::diag_stream; - using butl::diag_epilogue; - - // Diagnostic facility, project specifics. - // - struct simple_prologue_base - { - explicit - simple_prologue_base (const char* type, const char* name) - : type_ (type), name_ (name) {} - - void - operator() (const diag_record& r) const; - - private: - const char* type_; - const char* name_; - }; - - struct basic_mark_base - { - using simple_prologue = butl::diag_prologue; - - explicit - basic_mark_base (const char* type, - const char* indent = "\n ", - const char* name = nullptr, - const void* data = nullptr, - diag_epilogue* epilogue = nullptr) - : type_ (type), name_ (name), data_ (data), - indent_ (indent), epilogue_ (epilogue) {} - - simple_prologue - operator() () const - { - return simple_prologue (indent_, epilogue_, type_, name_); - } - - public: - const char* type_; - const char* name_; - const void* data_; - - const char* indent_; - diag_epilogue* const epilogue_; - }; - using basic_mark = butl::diag_mark; - - extern basic_mark error; - extern basic_mark warn; - extern basic_mark info; - extern basic_mark text; - - // trace - // - extern const char* trace_type; - extern const char* trace_indent; - - struct trace_mark_base: basic_mark_base - { - explicit - trace_mark_base (const char* name, const void* data = nullptr); - }; - using trace_mark = butl::diag_mark; - - // using tracer = trace_mark; - class tracer: public trace_mark - { - public: using trace_mark::trace_mark; - }; - - // fail - // - struct fail_mark_base: basic_mark_base - { - explicit - fail_mark_base (const char* type, - const char* indent = "\n ", - const void* data = nullptr) - : basic_mark_base (type, - indent, - nullptr, - data, - [](const diag_record& r) - { - r.flush (); - throw failed (); - }) {} - }; - - using fail_mark = butl::diag_mark; - - struct fail_end_base - { - [[noreturn]] void - operator() (const diag_record& r) const - { - // If we just throw then the record's destructor will see an active - // exception and will not flush the record. - // - r.flush (); - throw failed (); - } - }; - using fail_end = butl::diag_noreturn_end; - - extern fail_mark fail; - extern const fail_end endf; - - // Map to systemd severity prefixes (see sd-daemon(3) for details). Note - // that here we assume we will never have location (like file name which - // would end up being before the prefix). - // - // If with_critical is true, then distinguish between fail (critical error, - // daemon terminates) and error (non-fatal error, daemon continues to run). - // Note that this means we should be careful not to use fail to report - // normal errors and vice-versa. - // - void - systemd_diagnostics (bool with_critical); -} - -#endif // BBOT_DIAGNOSTICS diff --git a/bbot/diagnostics.cxx b/bbot/diagnostics.cxx index c6008c6..f3a2bb9 100644 --- a/bbot/diagnostics.cxx +++ b/bbot/diagnostics.cxx @@ -2,9 +2,9 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/bbot/diagnostics.hxx b/bbot/diagnostics.hxx new file mode 100644 index 0000000..07052a0 --- /dev/null +++ b/bbot/diagnostics.hxx @@ -0,0 +1,166 @@ +// file : bbot/diagnostics.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_DIAGNOSTICS_HXX +#define BBOT_DIAGNOSTICS_HXX + +#include + +#include // Note: not . + +namespace bbot +{ + using butl::diag_record; + + // Throw this exception to terminate the process. The handler should + // assume that the diagnostics has already been issued. + // + class failed: public std::exception {}; + + // Verbosity level. Update documentation for --verbose if changing. + // + // 0 - disabled + // 1 - high-level information messages + // 2 - essential underlying commands that are being executed + // 3 - all underlying commands that are being executed + // 4 - information that could be helpful to the user + // 5 - information that could be helpful to the developer + // 6 - even more detailed information + // + // While uint8 is more than enough, use uint16 for the ease of printing. + // + extern uint16_t verb; + + template inline void l1 (const F& f) {if (verb >= 1) f ();} + template inline void l2 (const F& f) {if (verb >= 2) f ();} + template inline void l3 (const F& f) {if (verb >= 3) f ();} + template inline void l4 (const F& f) {if (verb >= 4) f ();} + template inline void l5 (const F& f) {if (verb >= 5) f ();} + template inline void l6 (const F& f) {if (verb >= 6) f ();} + + // Diagnostic facility, base infrastructure. + // + using butl::diag_stream; + using butl::diag_epilogue; + + // Diagnostic facility, project specifics. + // + struct simple_prologue_base + { + explicit + simple_prologue_base (const char* type, const char* name) + : type_ (type), name_ (name) {} + + void + operator() (const diag_record& r) const; + + private: + const char* type_; + const char* name_; + }; + + struct basic_mark_base + { + using simple_prologue = butl::diag_prologue; + + explicit + basic_mark_base (const char* type, + const char* indent = "\n ", + const char* name = nullptr, + const void* data = nullptr, + diag_epilogue* epilogue = nullptr) + : type_ (type), name_ (name), data_ (data), + indent_ (indent), epilogue_ (epilogue) {} + + simple_prologue + operator() () const + { + return simple_prologue (indent_, epilogue_, type_, name_); + } + + public: + const char* type_; + const char* name_; + const void* data_; + + const char* indent_; + diag_epilogue* const epilogue_; + }; + using basic_mark = butl::diag_mark; + + extern basic_mark error; + extern basic_mark warn; + extern basic_mark info; + extern basic_mark text; + + // trace + // + extern const char* trace_type; + extern const char* trace_indent; + + struct trace_mark_base: basic_mark_base + { + explicit + trace_mark_base (const char* name, const void* data = nullptr); + }; + using trace_mark = butl::diag_mark; + + // using tracer = trace_mark; + class tracer: public trace_mark + { + public: using trace_mark::trace_mark; + }; + + // fail + // + struct fail_mark_base: basic_mark_base + { + explicit + fail_mark_base (const char* type, + const char* indent = "\n ", + const void* data = nullptr) + : basic_mark_base (type, + indent, + nullptr, + data, + [](const diag_record& r) + { + r.flush (); + throw failed (); + }) {} + }; + + using fail_mark = butl::diag_mark; + + struct fail_end_base + { + [[noreturn]] void + operator() (const diag_record& r) const + { + // If we just throw then the record's destructor will see an active + // exception and will not flush the record. + // + r.flush (); + throw failed (); + } + }; + using fail_end = butl::diag_noreturn_end; + + extern fail_mark fail; + extern const fail_end endf; + + // Map to systemd severity prefixes (see sd-daemon(3) for details). Note + // that here we assume we will never have location (like file name which + // would end up being before the prefix). + // + // If with_critical is true, then distinguish between fail (critical error, + // daemon terminates) and error (non-fatal error, daemon continues to run). + // Note that this means we should be careful not to use fail to report + // normal errors and vice-versa. + // + void + systemd_diagnostics (bool with_critical); +} + +#endif // BBOT_DIAGNOSTICS_HXX diff --git a/bbot/machine b/bbot/machine deleted file mode 100644 index f99d11b..0000000 --- a/bbot/machine +++ /dev/null @@ -1,82 +0,0 @@ -// file : bbot/machine -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_MACHINE -#define BBOT_MACHINE - -#include -#include - -namespace bbot -{ - // A running build machine (container, vm, etc). - // - // Note that if the machine is destroyed while it is still running, the - // destructor will block until the machine process terminates. - // - class machine - { - public: - // Shut the machine down cleanly waiting up to the specified number of - // seconds for completion. Update the timeout and return false if the - // machine is still running, true if the machine exited successfully, and - // throw failed otherwise. - // - virtual bool - shutdown (size_t& seconds) = 0; - - // Force the machine down. - // - virtual void - forcedown () = 0; - - // Suspend the machine. - // - virtual void - suspend () = 0; - - // Wait for the machine to terminate up to the specified number of - // seconds. Update the timeout and return false if the machine is still - // running, true if the machine exited successfully, and throw failed - // otherwise. - // - virtual bool - wait (size_t& seconds) = 0; - - bool - wait () - { - size_t sec (~0); // Wait indefinitely. - return wait (sec); - } - - // Print information about the machine (as info diagnostics) that can be - // useful for debugging (e.g., how to connect/login, etc). - // - virtual void - print_info (diag_record&) = 0; - - public: - const string mac; // MAC address (inside the machine). - - public: - virtual - ~machine () = default; - - protected: - machine (string m) - : mac (move (m)) {} - }; - - class machine_manifest; - - unique_ptr - start_machine (const dir_path&, - const machine_manifest&, - const optional& mac, - const string& br_iface, - uint16_t tftp_port); -} - -#endif // BBOT_MACHINE diff --git a/bbot/machine-manifest b/bbot/machine-manifest deleted file mode 100644 index ba27071..0000000 --- a/bbot/machine-manifest +++ /dev/null @@ -1,118 +0,0 @@ -// file : bbot/machine-manifest -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_MACHINE_MANIFEST -#define BBOT_MACHINE_MANIFEST - -#include - -#include - -#include // machine_header - -#include -#include - -#include - -namespace bbot -{ - // Machine type. - // - enum class machine_type {kvm, nspawn}; - - string - to_string (machine_type); - - machine_type - to_machine_type (const string&); // Throws invalid_argument. - - // Machine. - // - class machine_manifest: public machine_header_manifest - { - public: - machine_type type; - optional mac; // Required in bootstrapped machine manifest. - optional options; // Note: could be quoted. - - strings - unquoted_options () const; // Return empty if absent. - - machine_manifest (std::string i, - std::string n, - std::string s, - machine_type t, - optional m, - optional o) - : machine_header_manifest (std::move (i), - std::move (n), - std::move (s)), - type (t), - mac (std::move (m)), - options (std::move (o)) {} - - public: - machine_manifest () = default; // VC export. - machine_manifest (butl::manifest_parser&, bool ignore_unknown = false); - machine_manifest (butl::manifest_parser&, - butl::manifest_name_value start, - bool ignore_unknown = false); - - void - serialize (butl::manifest_serializer&) const; - }; - - // Toolchain. - // - class toolchain_manifest - { - public: - - // Toolchain id (SHAXXX). - // - string id; - - explicit - toolchain_manifest (string i): id (i) {} - - public: - toolchain_manifest () = default; // VC export. - toolchain_manifest (butl::manifest_parser&, bool ignore_unknown = false); - toolchain_manifest (butl::manifest_parser&, - butl::manifest_name_value start, - bool ignore_unknown = false); - - void - serialize (butl::manifest_serializer&) const; - }; - - // The manifest stored in -/ consists of the machine - // manifest (original), toolchain manifest, and bootstrap manifest. - // - class bootstrapped_machine_manifest - { - public: - machine_manifest machine; - toolchain_manifest toolchain; - bootstrap_manifest bootstrap; - - bootstrapped_machine_manifest (machine_manifest m, - toolchain_manifest t, - bootstrap_manifest b) - : machine (move (m)), toolchain (move (t)), bootstrap (move (b)) {} - - public: - bootstrapped_machine_manifest () = default; // VC export. - bootstrapped_machine_manifest (butl::manifest_parser&, - bool ignore_unknown = false); - - void - serialize (butl::manifest_serializer&) const; - }; - - using bootstrapped_machine_manifests = vector; -} - -#endif // BBOT_MACHINE_MANIFEST diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx index acb9d27..54ed43f 100644 --- a/bbot/machine-manifest.cxx +++ b/bbot/machine-manifest.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include #include #include diff --git a/bbot/machine-manifest.hxx b/bbot/machine-manifest.hxx new file mode 100644 index 0000000..fa6139f --- /dev/null +++ b/bbot/machine-manifest.hxx @@ -0,0 +1,118 @@ +// file : bbot/machine-manifest.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_MACHINE_MANIFEST_HXX +#define BBOT_MACHINE_MANIFEST_HXX + +#include + +#include + +#include // machine_header + +#include +#include + +#include + +namespace bbot +{ + // Machine type. + // + enum class machine_type {kvm, nspawn}; + + string + to_string (machine_type); + + machine_type + to_machine_type (const string&); // Throws invalid_argument. + + // Machine. + // + class machine_manifest: public machine_header_manifest + { + public: + machine_type type; + optional mac; // Required in bootstrapped machine manifest. + optional options; // Note: could be quoted. + + strings + unquoted_options () const; // Return empty if absent. + + machine_manifest (std::string i, + std::string n, + std::string s, + machine_type t, + optional m, + optional o) + : machine_header_manifest (std::move (i), + std::move (n), + std::move (s)), + type (t), + mac (std::move (m)), + options (std::move (o)) {} + + public: + machine_manifest () = default; // VC export. + machine_manifest (butl::manifest_parser&, bool ignore_unknown = false); + machine_manifest (butl::manifest_parser&, + butl::manifest_name_value start, + bool ignore_unknown = false); + + void + serialize (butl::manifest_serializer&) const; + }; + + // Toolchain. + // + class toolchain_manifest + { + public: + + // Toolchain id (SHAXXX). + // + string id; + + explicit + toolchain_manifest (string i): id (i) {} + + public: + toolchain_manifest () = default; // VC export. + toolchain_manifest (butl::manifest_parser&, bool ignore_unknown = false); + toolchain_manifest (butl::manifest_parser&, + butl::manifest_name_value start, + bool ignore_unknown = false); + + void + serialize (butl::manifest_serializer&) const; + }; + + // The manifest stored in -/ consists of the machine + // manifest (original), toolchain manifest, and bootstrap manifest. + // + class bootstrapped_machine_manifest + { + public: + machine_manifest machine; + toolchain_manifest toolchain; + bootstrap_manifest bootstrap; + + bootstrapped_machine_manifest (machine_manifest m, + toolchain_manifest t, + bootstrap_manifest b) + : machine (move (m)), toolchain (move (t)), bootstrap (move (b)) {} + + public: + bootstrapped_machine_manifest () = default; // VC export. + bootstrapped_machine_manifest (butl::manifest_parser&, + bool ignore_unknown = false); + + void + serialize (butl::manifest_serializer&) const; + }; + + using bootstrapped_machine_manifests = vector; +} + +#endif // BBOT_MACHINE_MANIFEST_HXX diff --git a/bbot/machine.cxx b/bbot/machine.cxx index 86448cf..bf0c0bf 100644 --- a/bbot/machine.cxx +++ b/bbot/machine.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include #include // sleep() @@ -12,8 +12,8 @@ #include // snprintf() #include // strcpy() -#include -#include +#include +#include using namespace std; using namespace butl; diff --git a/bbot/machine.hxx b/bbot/machine.hxx new file mode 100644 index 0000000..9ea0d48 --- /dev/null +++ b/bbot/machine.hxx @@ -0,0 +1,82 @@ +// file : bbot/machine.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_MACHINE_HXX +#define BBOT_MACHINE_HXX + +#include +#include + +namespace bbot +{ + // A running build machine (container, vm, etc). + // + // Note that if the machine is destroyed while it is still running, the + // destructor will block until the machine process terminates. + // + class machine + { + public: + // Shut the machine down cleanly waiting up to the specified number of + // seconds for completion. Update the timeout and return false if the + // machine is still running, true if the machine exited successfully, and + // throw failed otherwise. + // + virtual bool + shutdown (size_t& seconds) = 0; + + // Force the machine down. + // + virtual void + forcedown () = 0; + + // Suspend the machine. + // + virtual void + suspend () = 0; + + // Wait for the machine to terminate up to the specified number of + // seconds. Update the timeout and return false if the machine is still + // running, true if the machine exited successfully, and throw failed + // otherwise. + // + virtual bool + wait (size_t& seconds) = 0; + + bool + wait () + { + size_t sec (~0); // Wait indefinitely. + return wait (sec); + } + + // Print information about the machine (as info diagnostics) that can be + // useful for debugging (e.g., how to connect/login, etc). + // + virtual void + print_info (diag_record&) = 0; + + public: + const string mac; // MAC address (inside the machine). + + public: + virtual + ~machine () = default; + + protected: + machine (string m) + : mac (move (m)) {} + }; + + class machine_manifest; + + unique_ptr + start_machine (const dir_path&, + const machine_manifest&, + const optional& mac, + const string& br_iface, + uint16_t tftp_port); +} + +#endif // BBOT_MACHINE_HXX diff --git a/bbot/tftp b/bbot/tftp deleted file mode 100644 index 5433b89..0000000 --- a/bbot/tftp +++ /dev/null @@ -1,45 +0,0 @@ -// file : bbot/tftp -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_TFTP -#define BBOT_TFTP - -#include -#include - -namespace bbot -{ - // A TFTP server "wrapper" over tftpd-hpa. - // - // In a nutshell, we are pretending to be inetd and when a request arrives, - // spawn tftpd-hpa to handle it. - // - class tftp_server - { - public: - // The map argument specifies the path mapping rules, one per line (see - // the tftpd-hpa --map-file|-m option for details). If port is 0, then - // it is automatically assigned. - // - tftp_server (const string& map, uint16_t port); - - // Return the assigned port. - // - uint16_t - port () const; - - // Wait for a TFTP request for up to the specified number of seconds. - // Update the timeout value as well as return true if a request was - // served and false otherwise. - // - bool - serve (size_t& seconds); - - private: - auto_fd fd_; - auto_rmfile map_; - }; -} - -#endif // BBOT_TFTP diff --git a/bbot/tftp.cxx b/bbot/tftp.cxx index 862a0e4..70cc85d 100644 --- a/bbot/tftp.cxx +++ b/bbot/tftp.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include #include // htonl() #include // sockaddr_in @@ -11,7 +11,7 @@ #include // memset() -#include +#include using namespace std; using namespace butl; diff --git a/bbot/tftp.hxx b/bbot/tftp.hxx new file mode 100644 index 0000000..c9a88c9 --- /dev/null +++ b/bbot/tftp.hxx @@ -0,0 +1,45 @@ +// file : bbot/tftp.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_TFTP_HXX +#define BBOT_TFTP_HXX + +#include +#include + +namespace bbot +{ + // A TFTP server "wrapper" over tftpd-hpa. + // + // In a nutshell, we are pretending to be inetd and when a request arrives, + // spawn tftpd-hpa to handle it. + // + class tftp_server + { + public: + // The map argument specifies the path mapping rules, one per line (see + // the tftpd-hpa --map-file|-m option for details). If port is 0, then + // it is automatically assigned. + // + tftp_server (const string& map, uint16_t port); + + // Return the assigned port. + // + uint16_t + port () const; + + // Wait for a TFTP request for up to the specified number of seconds. + // Update the timeout value as well as return true if a request was + // served and false otherwise. + // + bool + serve (size_t& seconds); + + private: + auto_fd fd_; + auto_rmfile map_; + }; +} + +#endif // BBOT_TFTP_HXX diff --git a/bbot/types b/bbot/types deleted file mode 100644 index e4af01e..0000000 --- a/bbot/types +++ /dev/null @@ -1,107 +0,0 @@ -// file : bbot/types -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_TYPES -#define BBOT_TYPES - -#include -#include -#include // unique_ptr, shared_ptr -#include // pair -#include // size_t, nullptr_t -#include // uint{8,16,32,64}_t -#include -#include -#include // function, reference_wrapper - -#include // ios_base::failure -#include // exception -#include // logic_error, invalid_argument, runtime_error -#include - -#include -#include -#include -#include - -namespace bbot -{ - // Commonly-used types. - // - using std::uint8_t; - using std::uint16_t; - using std::uint32_t; - using std::uint64_t; - - using std::size_t; - using std::nullptr_t; - - using std::pair; - using std::string; - using std::function; - using std::reference_wrapper; - - using std::unique_ptr; - using std::shared_ptr; - using std::weak_ptr; - - using std::vector; - - using strings = vector; - using cstrings = vector; - - using std::istream; - using std::ostream; - - // Exceptions. While is included, there is no using for - // std::exception -- use qualified. - // - using std::logic_error; - using std::invalid_argument; - using std::runtime_error; - using std::system_error; - using io_error = std::ios_base::failure; - - // - // - using butl::optional; - using butl::nullopt; - - // - // - using butl::vector_view; - - // - // - using butl::small_vector; - - // - // - using butl::path; - using butl::dir_path; - using butl::basic_path; - using butl::invalid_path; - - using paths = std::vector; - using dir_paths = std::vector; -} - -// In order to be found (via ADL) these have to be either in std:: or in -// butl::. The latter is bad idea since libbutl includes the default -// implementation. -// -namespace std -{ - // Custom path printing (canonicalized, with trailing slash for directories). - // - inline ostream& - operator<< (ostream& os, const ::butl::path& p) - { - string r (p.representation ()); - ::butl::path::traits::canonicalize (r); - return os << r; - } -} - -#endif // BBOT_TYPES diff --git a/bbot/types-parsers b/bbot/types-parsers deleted file mode 100644 index de3deb8..0000000 --- a/bbot/types-parsers +++ /dev/null @@ -1,38 +0,0 @@ -// file : bbot/types-parsers -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -// CLI parsers, included into the generated source files. -// - -#ifndef BBOT_TYPES_PARSERS -#define BBOT_TYPES_PARSERS - -#include - -namespace bbot -{ - namespace cli - { - class scanner; - - template - struct parser; - - template <> - struct parser - { - static void - parse (path&, bool&, scanner&); - }; - - template <> - struct parser - { - static void - parse (dir_path&, bool&, scanner&); - }; - } -} - -#endif // BBOT_TYPES_PARSERS diff --git a/bbot/types-parsers.cxx b/bbot/types-parsers.cxx index 83a67d6..1d0a250 100644 --- a/bbot/types-parsers.cxx +++ b/bbot/types-parsers.cxx @@ -2,9 +2,9 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include -#include // bbot::cli namespace +#include // bbot::cli namespace namespace bbot { diff --git a/bbot/types-parsers.hxx b/bbot/types-parsers.hxx new file mode 100644 index 0000000..eef3418 --- /dev/null +++ b/bbot/types-parsers.hxx @@ -0,0 +1,38 @@ +// file : bbot/types-parsers.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +// CLI parsers, included into the generated source files. +// + +#ifndef BBOT_TYPES_PARSERS_HXX +#define BBOT_TYPES_PARSERS_HXX + +#include + +namespace bbot +{ + namespace cli + { + class scanner; + + template + struct parser; + + template <> + struct parser + { + static void + parse (path&, bool&, scanner&); + }; + + template <> + struct parser + { + static void + parse (dir_path&, bool&, scanner&); + }; + } +} + +#endif // BBOT_TYPES_PARSERS_HXX diff --git a/bbot/types.hxx b/bbot/types.hxx new file mode 100644 index 0000000..20f9f23 --- /dev/null +++ b/bbot/types.hxx @@ -0,0 +1,107 @@ +// file : bbot/types.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_TYPES_HXX +#define BBOT_TYPES_HXX + +#include +#include +#include // unique_ptr, shared_ptr +#include // pair +#include // size_t, nullptr_t +#include // uint{8,16,32,64}_t +#include +#include +#include // function, reference_wrapper + +#include // ios_base::failure +#include // exception +#include // logic_error, invalid_argument, runtime_error +#include + +#include +#include +#include +#include + +namespace bbot +{ + // Commonly-used types. + // + using std::uint8_t; + using std::uint16_t; + using std::uint32_t; + using std::uint64_t; + + using std::size_t; + using std::nullptr_t; + + using std::pair; + using std::string; + using std::function; + using std::reference_wrapper; + + using std::unique_ptr; + using std::shared_ptr; + using std::weak_ptr; + + using std::vector; + + using strings = vector; + using cstrings = vector; + + using std::istream; + using std::ostream; + + // Exceptions. While is included, there is no using for + // std::exception -- use qualified. + // + using std::logic_error; + using std::invalid_argument; + using std::runtime_error; + using std::system_error; + using io_error = std::ios_base::failure; + + // + // + using butl::optional; + using butl::nullopt; + + // + // + using butl::vector_view; + + // + // + using butl::small_vector; + + // + // + using butl::path; + using butl::dir_path; + using butl::basic_path; + using butl::invalid_path; + + using paths = std::vector; + using dir_paths = std::vector; +} + +// In order to be found (via ADL) these have to be either in std:: or in +// butl::. The latter is bad idea since libbutl includes the default +// implementation. +// +namespace std +{ + // Custom path printing (canonicalized, with trailing slash for directories). + // + inline ostream& + operator<< (ostream& os, const ::butl::path& p) + { + string r (p.representation ()); + ::butl::path::traits::canonicalize (r); + return os << r; + } +} + +#endif // BBOT_TYPES_HXX diff --git a/bbot/utility b/bbot/utility deleted file mode 100644 index 3424f2b..0000000 --- a/bbot/utility +++ /dev/null @@ -1,164 +0,0 @@ -// file : bbot/utility -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_UTILITY -#define BBOT_UTILITY - -#include // make_shared() -#include // to_string(), stoull() -#include // move(), forward(), declval(), make_pair() -#include // assert() -#include // make_move_iterator() - -#include - -#include -#include -#include -#include // casecmp(), reverse_iterate(), etc -#include -#include - -#include -#include - -namespace bbot -{ - using std::move; - using std::forward; - using std::declval; - - using std::make_pair; - using std::make_shared; - using std::make_move_iterator; - using std::to_string; - using std::stoull; - - // - // - using butl::casecmp; - using butl::reverse_iterate; - - using butl::exception_guard; - using butl::make_exception_guard; - - // - // - using butl::auto_fd; - - // - // - using butl::auto_rmdir; - using butl::auto_rmfile; - - // Process execution. - // - class tracer; - - using butl::process; - using butl::process_exit; - using butl::process_error; - - template - void - run_io (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); - - template - process_exit::code_type - run_io_exit (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); - - template - process - run_io_start (tracer&, - I&& in, - O&& out, - E&& err, - const dir_path& cwd, - const P&, - A&&...); - - template - void - run_io_finish (tracer&, process&, const P&); - - template - process_exit::code_type - run_io_finish_exit (tracer&, process&, const P&); - - template - inline void - run (tracer& t, const P& p, A&&... a) - { - run_io (t, butl::fdnull (), 2, 2, p, forward (a)...); - } - - template - inline process_exit::code_type - run_exit (tracer& t, const P& p, A&&... a) - { - return run_io_exit ( - t, butl::fdnull (), 2, 2, p, forward (a)...); - } - - void - run_trace (tracer&, const char*[], size_t); - - // The curl process wrapper (command line tracing, etc). - // - class http_curl: public butl::curl - { - public: - template - http_curl (tracer&, - I&& in, - O&& out, - method_type, - const string& url, - A&&... options); - }; - - class tftp_curl: public butl::curl - { - public: - template - tftp_curl (tracer&, - I&& in, - O&& out, - method_type, - const string& url, - A&&... options); - }; - - // Manifest parsing and serialization. - // - // For parsing, if path is '-', then read from stdin. - // - template - T - parse_manifest (const path&, const char* what, bool ignore_unknown = true); - - template - T - parse_manifest (istream&, - const string& name, - const char* what, - bool fail_hard = true, - bool ignore_unknown = true); - - template - void - serialize_manifest (const T&, const path&, const char* what); - - template - void - serialize_manifest (const T&, - ostream&, - const string& name, - const char* what, - bool fail_hard = true); -} - -#include - -#endif // BBOT_UTILITY diff --git a/bbot/utility.cxx b/bbot/utility.cxx index 6fcc463..ea62ac2 100644 --- a/bbot/utility.cxx +++ b/bbot/utility.cxx @@ -2,9 +2,9 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : TBC; see accompanying LICENSE file -#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/bbot/utility.hxx b/bbot/utility.hxx new file mode 100644 index 0000000..50756dd --- /dev/null +++ b/bbot/utility.hxx @@ -0,0 +1,164 @@ +// file : bbot/utility.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_UTILITY_HXX +#define BBOT_UTILITY_HXX + +#include // make_shared() +#include // to_string(), stoull() +#include // move(), forward(), declval(), make_pair() +#include // assert() +#include // make_move_iterator() + +#include + +#include +#include +#include +#include // casecmp(), reverse_iterate(), etc +#include +#include + +#include +#include + +namespace bbot +{ + using std::move; + using std::forward; + using std::declval; + + using std::make_pair; + using std::make_shared; + using std::make_move_iterator; + using std::to_string; + using std::stoull; + + // + // + using butl::casecmp; + using butl::reverse_iterate; + + using butl::exception_guard; + using butl::make_exception_guard; + + // + // + using butl::auto_fd; + + // + // + using butl::auto_rmdir; + using butl::auto_rmfile; + + // Process execution. + // + class tracer; + + using butl::process; + using butl::process_exit; + using butl::process_error; + + template + void + run_io (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); + + template + process_exit::code_type + run_io_exit (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); + + template + process + run_io_start (tracer&, + I&& in, + O&& out, + E&& err, + const dir_path& cwd, + const P&, + A&&...); + + template + void + run_io_finish (tracer&, process&, const P&); + + template + process_exit::code_type + run_io_finish_exit (tracer&, process&, const P&); + + template + inline void + run (tracer& t, const P& p, A&&... a) + { + run_io (t, butl::fdnull (), 2, 2, p, forward (a)...); + } + + template + inline process_exit::code_type + run_exit (tracer& t, const P& p, A&&... a) + { + return run_io_exit ( + t, butl::fdnull (), 2, 2, p, forward (a)...); + } + + void + run_trace (tracer&, const char*[], size_t); + + // The curl process wrapper (command line tracing, etc). + // + class http_curl: public butl::curl + { + public: + template + http_curl (tracer&, + I&& in, + O&& out, + method_type, + const string& url, + A&&... options); + }; + + class tftp_curl: public butl::curl + { + public: + template + tftp_curl (tracer&, + I&& in, + O&& out, + method_type, + const string& url, + A&&... options); + }; + + // Manifest parsing and serialization. + // + // For parsing, if path is '-', then read from stdin. + // + template + T + parse_manifest (const path&, const char* what, bool ignore_unknown = true); + + template + T + parse_manifest (istream&, + const string& name, + const char* what, + bool fail_hard = true, + bool ignore_unknown = true); + + template + void + serialize_manifest (const T&, const path&, const char* what); + + template + void + serialize_manifest (const T&, + ostream&, + const string& name, + const char* what, + bool fail_hard = true); +} + +#include + +#endif // BBOT_UTILITY_HXX diff --git a/bbot/utility.txx b/bbot/utility.txx index 231bd8f..c35db33 100644 --- a/bbot/utility.txx +++ b/bbot/utility.txx @@ -9,7 +9,7 @@ #include #include -#include +#include namespace bbot { diff --git a/bbot/version-impl.in b/bbot/version-impl.in deleted file mode 100644 index baf6f4f..0000000 --- a/bbot/version-impl.in +++ /dev/null @@ -1,87 +0,0 @@ -// file : bbot/version-impl.in -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#ifndef BBOT_VERSION // Note: using the version macro itself. - -// Note: using build2 standard versioning scheme. The numeric version format -// is AAABBBCCCDDDE where: -// -// AAA - major version number -// BBB - minor version number -// CCC - bugfix version number -// DDD - alpha / beta (DDD + 500) version number -// E - final (0) / snapshot (1) -// -// When DDDE is not 0, 1 is subtracted from AAABBBCCC. For example: -// -// Version AAABBBCCCDDDE -// -// 0.1.0 0000010000000 -// 0.1.2 0000010010000 -// 1.2.3 0010020030000 -// 2.2.0-a.1 0020019990010 -// 3.0.0-b.2 0029999995020 -// 2.2.0-a.1.z 0020019990011 -// -#define BBOT_VERSION $bbot.version.project_number$ULL -#define BBOT_VERSION_STR "$bbot.version.project$" -#define BBOT_VERSION_ID "$bbot.version.project_id$" - -#define BBOT_VERSION_MAJOR $bbot.version.major$ -#define BBOT_VERSION_MINOR $bbot.version.minor$ -#define BBOT_VERSION_PATCH $bbot.version.patch$ - -#define BBOT_PRE_RELEASE $bbot.version.pre_release$ - -#define BBOT_SNAPSHOT $bbot.version.snapshot_sn$ULL -#define BBOT_SNAPSHOT_ID "$bbot.version.snapshot_id$" - -#include - -$libbutl.check(LIBBUTL_VERSION, LIBBUTL_SNAPSHOT)$ - -#include - -$libbbot.check(LIBBBOT_VERSION, LIBBBOT_SNAPSHOT)$ - -// User agent. -// -#if defined(_WIN32) -# if defined(__MINGW32__) -# define BBOT_OS "MinGW" -# else -# define BBOT_OS "Windows" -# endif -#elif defined(__linux) -# define BBOT_OS "GNU/Linux" -#elif defined(__APPLE__) -# define BBOT_OS "MacOS" -#elif defined(__CYGWIN__) -# define BBOT_OS "Cygwin" -#elif defined(__FreeBSD__) -# define BBOT_OS "FreeBSD" -#elif defined(__OpenBSD__) -# define BBOT_OS "OpenBSD" -#elif defined(__NetBSD__) -# define BBOT_OS "NetBSD" -#elif defined(__sun) -# define BBOT_OS "Solaris" -#elif defined(__hpux) -# define BBOT_OS "HP-UX" -#elif defined(_AIX) -# define BBOT_OS "AIX" -#elif defined(__unix) -# define BBOT_OS "Unix" -#elif defined(__posix) -# define BBOT_OS "Posix" -#else -# define BBOT_OS "Other" -#endif - -#define BBOT_USER_AGENT \ - "bbot/" BBOT_VERSION_STR " (" BBOT_OS "; +https://build2.org)" \ - " libbbot/" LIBBBOT_VERSION_STR \ - " libbutl/" LIBBUTL_VERSION_STR - -#endif // BBOT_VERSION diff --git a/bbot/version.hxx.in b/bbot/version.hxx.in new file mode 100644 index 0000000..9f451e8 --- /dev/null +++ b/bbot/version.hxx.in @@ -0,0 +1,87 @@ +// file : bbot/version.hxx.in -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_VERSION // Note: using the version macro itself. + +// Note: using build2 standard versioning scheme. The numeric version format +// is AAABBBCCCDDDE where: +// +// AAA - major version number +// BBB - minor version number +// CCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) +// +// When DDDE is not 0, 1 is subtracted from AAABBBCCC. For example: +// +// Version AAABBBCCCDDDE +// +// 0.1.0 0000010000000 +// 0.1.2 0000010010000 +// 1.2.3 0010020030000 +// 2.2.0-a.1 0020019990010 +// 3.0.0-b.2 0029999995020 +// 2.2.0-a.1.z 0020019990011 +// +#define BBOT_VERSION $bbot.version.project_number$ULL +#define BBOT_VERSION_STR "$bbot.version.project$" +#define BBOT_VERSION_ID "$bbot.version.project_id$" + +#define BBOT_VERSION_MAJOR $bbot.version.major$ +#define BBOT_VERSION_MINOR $bbot.version.minor$ +#define BBOT_VERSION_PATCH $bbot.version.patch$ + +#define BBOT_PRE_RELEASE $bbot.version.pre_release$ + +#define BBOT_SNAPSHOT $bbot.version.snapshot_sn$ULL +#define BBOT_SNAPSHOT_ID "$bbot.version.snapshot_id$" + +#include + +$libbutl.check(LIBBUTL_VERSION, LIBBUTL_SNAPSHOT)$ + +#include + +$libbbot.check(LIBBBOT_VERSION, LIBBBOT_SNAPSHOT)$ + +// User agent. +// +#if defined(_WIN32) +# if defined(__MINGW32__) +# define BBOT_OS "MinGW" +# else +# define BBOT_OS "Windows" +# endif +#elif defined(__linux) +# define BBOT_OS "GNU/Linux" +#elif defined(__APPLE__) +# define BBOT_OS "MacOS" +#elif defined(__CYGWIN__) +# define BBOT_OS "Cygwin" +#elif defined(__FreeBSD__) +# define BBOT_OS "FreeBSD" +#elif defined(__OpenBSD__) +# define BBOT_OS "OpenBSD" +#elif defined(__NetBSD__) +# define BBOT_OS "NetBSD" +#elif defined(__sun) +# define BBOT_OS "Solaris" +#elif defined(__hpux) +# define BBOT_OS "HP-UX" +#elif defined(_AIX) +# define BBOT_OS "AIX" +#elif defined(__unix) +# define BBOT_OS "Unix" +#elif defined(__posix) +# define BBOT_OS "Posix" +#else +# define BBOT_OS "Other" +#endif + +#define BBOT_USER_AGENT \ + "bbot/" BBOT_VERSION_STR " (" BBOT_OS "; +https://build2.org)" \ + " libbbot/" LIBBBOT_VERSION_STR \ + " libbutl/" LIBBUTL_VERSION_STR + +#endif // BBOT_VERSION diff --git a/bbot/worker.cxx b/bbot/worker.cxx index af1429c..f777e30 100644 --- a/bbot/worker.cxx +++ b/bbot/worker.cxx @@ -13,14 +13,14 @@ #include #include -#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include using namespace std; using namespace butl; diff --git a/build/root.build b/build/root.build index b299a5d..4661de1 100644 --- a/build/root.build +++ b/build/root.build @@ -6,7 +6,7 @@ cxx.std = latest using cxx -hxx{*}: extension = +hxx{*}: extension = hxx ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx diff --git a/buildfile b/buildfile index 3ff0861..6b5add5 100644 --- a/buildfile +++ b/buildfile @@ -2,7 +2,8 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : TBC; see accompanying LICENSE file -./: bbot/ etc/ unit-tests/ doc{INSTALL LICENSE NEWS README version} file{manifest} +./: bbot/ etc/ unit-tests/ doc{INSTALL LICENSE NEWS README version} \ + file{manifest} doc{version}: file{manifest} # Generated by the version module. doc{version}: dist = true diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..35ec43f --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +test/ +test-*/ diff --git a/unit-tests/.gitignore b/unit-tests/.gitignore index e54525b..2e508a9 100644 --- a/unit-tests/.gitignore +++ b/unit-tests/.gitignore @@ -1 +1,3 @@ driver +test/ +test-*/ diff --git a/unit-tests/bootstrap-manifest/driver.cxx b/unit-tests/bootstrap-manifest/driver.cxx index 46e64bc..1412c21 100644 --- a/unit-tests/bootstrap-manifest/driver.cxx +++ b/unit-tests/bootstrap-manifest/driver.cxx @@ -8,11 +8,11 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include using namespace std; using namespace butl; -- cgit v1.1