From 70317569c6dcd9809ed4a8c425777e653ec6ca08 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 May 2017 18:24:31 +0300 Subject: Add hxx extension for headers --- build2/cc/common | 289 ----------------------------------------- build2/cc/common.cxx | 18 +-- build2/cc/common.hxx | 289 +++++++++++++++++++++++++++++++++++++++++ build2/cc/compile | 94 -------------- build2/cc/compile.cxx | 20 +-- build2/cc/compile.hxx | 94 ++++++++++++++ build2/cc/gcc.cxx | 18 +-- build2/cc/guess | 141 -------------------- build2/cc/guess.cxx | 9 +- build2/cc/guess.hxx | 141 ++++++++++++++++++++ build2/cc/init | 64 --------- build2/cc/init.cxx | 12 +- build2/cc/init.hxx | 64 +++++++++ build2/cc/install | 48 ------- build2/cc/install.cxx | 10 +- build2/cc/install.hxx | 48 +++++++ build2/cc/link | 130 ------------------ build2/cc/link.cxx | 26 ++-- build2/cc/link.hxx | 130 ++++++++++++++++++ build2/cc/module | 68 ---------- build2/cc/module.cxx | 16 +-- build2/cc/module.hxx | 68 ++++++++++ build2/cc/msvc.cxx | 20 +-- build2/cc/pkgconfig.cxx | 20 +-- build2/cc/target | 63 --------- build2/cc/target.cxx | 2 +- build2/cc/target.hxx | 63 +++++++++ build2/cc/types | 35 ----- build2/cc/types.hxx | 35 +++++ build2/cc/utility | 51 -------- build2/cc/utility.cxx | 8 +- build2/cc/utility.hxx | 51 ++++++++ build2/cc/windows-manifest.cxx | 16 +-- build2/cc/windows-rpath.cxx | 14 +- 34 files changed, 1088 insertions(+), 1087 deletions(-) delete mode 100644 build2/cc/common create mode 100644 build2/cc/common.hxx delete mode 100644 build2/cc/compile create mode 100644 build2/cc/compile.hxx delete mode 100644 build2/cc/guess create mode 100644 build2/cc/guess.hxx delete mode 100644 build2/cc/init create mode 100644 build2/cc/init.hxx delete mode 100644 build2/cc/install create mode 100644 build2/cc/install.hxx delete mode 100644 build2/cc/link create mode 100644 build2/cc/link.hxx delete mode 100644 build2/cc/module create mode 100644 build2/cc/module.hxx delete mode 100644 build2/cc/target create mode 100644 build2/cc/target.hxx delete mode 100644 build2/cc/types create mode 100644 build2/cc/types.hxx delete mode 100644 build2/cc/utility create mode 100644 build2/cc/utility.hxx (limited to 'build2/cc') diff --git a/build2/cc/common b/build2/cc/common deleted file mode 100644 index 5a459b8..0000000 --- a/build2/cc/common +++ /dev/null @@ -1,289 +0,0 @@ -// file : build2/cc/common -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_COMMON -#define BUILD2_CC_COMMON - -#include -#include - -#include - -#include - -#include - -namespace build2 -{ - namespace cc - { - // Data entries that define a concrete c-family module (e.g., c or cxx). - // These classes are used as a virtual bases by the rules as well as the - // modules. This way the member variables can be referenced as is, without - // any extra decorations (in other words, it is a bunch of data members - // that can be shared between several classes/instances). - // - struct config_data - { - lang x_lang; - - const char* x; // Module name ("c", "cxx"). - const char* x_name; // Compiler name ("c", "c++"). - const char* x_default; // Compiler default ("gcc", "g++"). - - const variable& config_x; - const variable& config_x_poptions; - const variable& config_x_coptions; - const variable& config_x_loptions; - const variable& config_x_libs; - - const variable& x_path; // Compiler process path. - const variable& x_sys_lib_dirs; // System library search directories. - const variable& x_sys_inc_dirs; // Extra header search directories. - - const variable& x_poptions; - const variable& x_coptions; - const variable& x_loptions; - const variable& x_libs; - - const variable& c_poptions; // cc.* - const variable& c_coptions; - const variable& c_loptions; - const variable& c_libs; - - const variable& x_export_poptions; - const variable& x_export_coptions; - const variable& x_export_loptions; - const variable& x_export_libs; - - const variable& c_export_poptions; // cc.export.* - const variable& c_export_coptions; - const variable& c_export_loptions; - const variable& c_export_libs; - - const variable& c_type; // cc.type - const variable& c_system; // cc.system - - const variable& x_std; - - const variable& x_id; - const variable& x_id_type; - const variable& x_id_variant; - - const variable& x_version; - const variable& x_version_major; - const variable& x_version_minor; - const variable& x_version_patch; - const variable& x_version_build; - - const variable& x_signature; - const variable& x_checksum; - - const variable& x_target; - const variable& x_target_cpu; - const variable& x_target_vendor; - const variable& x_target_system; - const variable& x_target_version; - const variable& x_target_class; - }; - - struct data: config_data - { - const char* x_compile; // Rule names. - const char* x_link; - const char* x_install; - const char* x_uninstall; - - // Cached values for some commonly-used variables/values. - // - const string& cid; // x.id - const target_triplet& ctg; // x.target - const string& tsys; // x.target.system - const string& tclass; // x.target.class - - const string& tstd; // Translated x_std value (can be empty). - - const process_path* pkgconfig; // pkgconfig.path (can be NULL). - const dir_paths& sys_lib_dirs; // x.sys_lib_dirs - const dir_paths& sys_inc_dirs; // x.sys_inc_dirs - - const target_type& x_src; // Source target type (c{}, cxx{}). - - // Array of target types that are considered headers. Keep them in the - // most likely to appear order and terminate with NULL. - // - const target_type* const* x_hdr; - - template - bool - x_header (const T& t) const - { - for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) - if (t.is_a (**ht)) - return true; - - return false; - } - - // Array of target types that can be #include'd. Used to reverse-lookup - // extensions to target types. Keep them in the most likely to appear - // order and terminate with NULL. - // - const target_type* const* x_inc; - - // Aggregate-like constructor with from-base support. - // - data (const config_data& cd, - const char* compile, - const char* link, - const char* install, - const char* uninstall, - const string& id, - const target_triplet& tg, - const string& std, - const process_path* pkgc, - const dir_paths& sld, - const dir_paths& sid, - const target_type& src, - const target_type* const* hdr, - const target_type* const* inc) - : config_data (cd), - x_compile (compile), - x_link (link), - x_install (install), - x_uninstall (uninstall), - cid (id), ctg (tg), tsys (ctg.system), tclass (ctg.class_), - tstd (std), - pkgconfig (pkgc), sys_lib_dirs (sld), sys_inc_dirs (sid), - x_src (src), x_hdr (hdr), x_inc (inc) {} - }; - - class common: protected data - { - public: - common (data&& d): data (move (d)) {} - - // Language standard (x.std) mapping. - // - void - append_std (cstrings& args) const - { - if (!tstd.empty ()) - args.push_back (tstd.c_str ()); - } - - void - hash_std (sha256& cs) const - { - if (!tstd.empty ()) - cs.append (tstd); - } - - // Library handling. - // - public: - void - process_libraries ( - action, - const scope&, - lorder, - const dir_paths&, - const file&, - bool, - const function&, - const function&, - const function&, - bool = false) const; - - const target* - search_library (action act, - const dir_paths& sysd, - optional& usrd, - const prerequisite& p) const - { - const target* r (p.target.load (memory_order_consume)); - - if (r == nullptr) - { - if ((r = search_library (act, sysd, usrd, p.key ())) != nullptr) - { - const target* e (nullptr); - if (!p.target.compare_exchange_strong ( - e, r, - memory_order_release, - memory_order_consume)) - assert (e == r); - } - } - - return r; - } - - public: - const file& - resolve_library (action, - const scope&, - name, - lorder, - const dir_paths&, - optional&) const; - - template - static ulock - insert_library (T*&, - const string&, - const dir_path&, - optional, - bool, - tracer&); - - target* - search_library (action, - const dir_paths&, - optional&, - const prerequisite_key&, - bool existing = false) const; - - const target* - search_library_existing (action act, - const dir_paths& sysd, - optional& usrd, - const prerequisite_key& pk) const - { - return search_library (act, sysd, usrd, pk, true); - } - - dir_paths - extract_library_dirs (const scope&) const; - - bool - pkgconfig_extract (action, - const scope&, - bin::lib&, - bin::liba*, - bin::libs*, - const optional&, - const string&, - const dir_path&, - const dir_paths&) const; // pkgconfig.cxx - - // Alternative search logic for VC (msvc.cxx). - // - bin::liba* - msvc_search_static (const process_path&, - const dir_path&, - const prerequisite_key&, - bool existing) const; - - bin::libs* - msvc_search_shared (const process_path&, - const dir_path&, - const prerequisite_key&, - bool existing) const; - - }; - } -} - -#endif // BUILD2_CC_COMMON diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx index 88eb45d..59feb9b 100644 --- a/build2/cc/common.cxx +++ b/build2/cc/common.cxx @@ -2,17 +2,17 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include // import() -#include -#include -#include -#include -#include -#include +#include // import() +#include +#include +#include +#include +#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx new file mode 100644 index 0000000..0c8ff2b --- /dev/null +++ b/build2/cc/common.hxx @@ -0,0 +1,289 @@ +// file : build2/cc/common.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_COMMON_HXX +#define BUILD2_CC_COMMON_HXX + +#include +#include + +#include + +#include + +#include + +namespace build2 +{ + namespace cc + { + // Data entries that define a concrete c-family module (e.g., c or cxx). + // These classes are used as a virtual bases by the rules as well as the + // modules. This way the member variables can be referenced as is, without + // any extra decorations (in other words, it is a bunch of data members + // that can be shared between several classes/instances). + // + struct config_data + { + lang x_lang; + + const char* x; // Module name ("c", "cxx"). + const char* x_name; // Compiler name ("c", "c++"). + const char* x_default; // Compiler default ("gcc", "g++"). + + const variable& config_x; + const variable& config_x_poptions; + const variable& config_x_coptions; + const variable& config_x_loptions; + const variable& config_x_libs; + + const variable& x_path; // Compiler process path. + const variable& x_sys_lib_dirs; // System library search directories. + const variable& x_sys_inc_dirs; // Extra header search directories. + + const variable& x_poptions; + const variable& x_coptions; + const variable& x_loptions; + const variable& x_libs; + + const variable& c_poptions; // cc.* + const variable& c_coptions; + const variable& c_loptions; + const variable& c_libs; + + const variable& x_export_poptions; + const variable& x_export_coptions; + const variable& x_export_loptions; + const variable& x_export_libs; + + const variable& c_export_poptions; // cc.export.* + const variable& c_export_coptions; + const variable& c_export_loptions; + const variable& c_export_libs; + + const variable& c_type; // cc.type + const variable& c_system; // cc.system + + const variable& x_std; + + const variable& x_id; + const variable& x_id_type; + const variable& x_id_variant; + + const variable& x_version; + const variable& x_version_major; + const variable& x_version_minor; + const variable& x_version_patch; + const variable& x_version_build; + + const variable& x_signature; + const variable& x_checksum; + + const variable& x_target; + const variable& x_target_cpu; + const variable& x_target_vendor; + const variable& x_target_system; + const variable& x_target_version; + const variable& x_target_class; + }; + + struct data: config_data + { + const char* x_compile; // Rule names. + const char* x_link; + const char* x_install; + const char* x_uninstall; + + // Cached values for some commonly-used variables/values. + // + const string& cid; // x.id + const target_triplet& ctg; // x.target + const string& tsys; // x.target.system + const string& tclass; // x.target.class + + const string& tstd; // Translated x_std value (can be empty). + + const process_path* pkgconfig; // pkgconfig.path (can be NULL). + const dir_paths& sys_lib_dirs; // x.sys_lib_dirs + const dir_paths& sys_inc_dirs; // x.sys_inc_dirs + + const target_type& x_src; // Source target type (c{}, cxx{}). + + // Array of target types that are considered headers. Keep them in the + // most likely to appear order and terminate with NULL. + // + const target_type* const* x_hdr; + + template + bool + x_header (const T& t) const + { + for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) + if (t.is_a (**ht)) + return true; + + return false; + } + + // Array of target types that can be #include'd. Used to reverse-lookup + // extensions to target types. Keep them in the most likely to appear + // order and terminate with NULL. + // + const target_type* const* x_inc; + + // Aggregate-like constructor with from-base support. + // + data (const config_data& cd, + const char* compile, + const char* link, + const char* install, + const char* uninstall, + const string& id, + const target_triplet& tg, + const string& std, + const process_path* pkgc, + const dir_paths& sld, + const dir_paths& sid, + const target_type& src, + const target_type* const* hdr, + const target_type* const* inc) + : config_data (cd), + x_compile (compile), + x_link (link), + x_install (install), + x_uninstall (uninstall), + cid (id), ctg (tg), tsys (ctg.system), tclass (ctg.class_), + tstd (std), + pkgconfig (pkgc), sys_lib_dirs (sld), sys_inc_dirs (sid), + x_src (src), x_hdr (hdr), x_inc (inc) {} + }; + + class common: protected data + { + public: + common (data&& d): data (move (d)) {} + + // Language standard (x.std) mapping. + // + void + append_std (cstrings& args) const + { + if (!tstd.empty ()) + args.push_back (tstd.c_str ()); + } + + void + hash_std (sha256& cs) const + { + if (!tstd.empty ()) + cs.append (tstd); + } + + // Library handling. + // + public: + void + process_libraries ( + action, + const scope&, + lorder, + const dir_paths&, + const file&, + bool, + const function&, + const function&, + const function&, + bool = false) const; + + const target* + search_library (action act, + const dir_paths& sysd, + optional& usrd, + const prerequisite& p) const + { + const target* r (p.target.load (memory_order_consume)); + + if (r == nullptr) + { + if ((r = search_library (act, sysd, usrd, p.key ())) != nullptr) + { + const target* e (nullptr); + if (!p.target.compare_exchange_strong ( + e, r, + memory_order_release, + memory_order_consume)) + assert (e == r); + } + } + + return r; + } + + public: + const file& + resolve_library (action, + const scope&, + name, + lorder, + const dir_paths&, + optional&) const; + + template + static ulock + insert_library (T*&, + const string&, + const dir_path&, + optional, + bool, + tracer&); + + target* + search_library (action, + const dir_paths&, + optional&, + const prerequisite_key&, + bool existing = false) const; + + const target* + search_library_existing (action act, + const dir_paths& sysd, + optional& usrd, + const prerequisite_key& pk) const + { + return search_library (act, sysd, usrd, pk, true); + } + + dir_paths + extract_library_dirs (const scope&) const; + + bool + pkgconfig_extract (action, + const scope&, + bin::lib&, + bin::liba*, + bin::libs*, + const optional&, + const string&, + const dir_path&, + const dir_paths&) const; // pkgconfig.cxx + + // Alternative search logic for VC (msvc.cxx). + // + bin::liba* + msvc_search_static (const process_path&, + const dir_path&, + const prerequisite_key&, + bool existing) const; + + bin::libs* + msvc_search_shared (const process_path&, + const dir_path&, + const prerequisite_key&, + bool existing) const; + + }; + } +} + +#endif // BUILD2_CC_COMMON_HXX diff --git a/build2/cc/compile b/build2/cc/compile deleted file mode 100644 index 2986b7d..0000000 --- a/build2/cc/compile +++ /dev/null @@ -1,94 +0,0 @@ -// file : build2/cc/compile -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_COMPILE -#define BUILD2_CC_COMPILE - -#include - -#include -#include - -#include - -#include -#include - -namespace build2 -{ - class depdb; - - namespace cc - { - class compile: public rule, virtual common - { - public: - compile (data&&); - - virtual match_result - match (action, target&, const string&) const override; - - virtual recipe - apply (action, target&) const override; - - target_state - perform_update (action, const target&) const; - - target_state - perform_clean (action, const target&) const; - - private: - void - append_lib_options (const scope&, - cstrings&, - const target&, - action, lorder) const; - - void - hash_lib_options (const scope&, - sha256&, - const target&, - action, lorder) const; - - // Mapping of include prefixes (e.g., foo in ) for auto- - // generated headers to directories where they will be generated. - // - // We are using a prefix map of directories (dir_path_map) instead of - // just a map in order to also cover sub-paths (e.g., if - // we continue with the example). Specifically, we need to make sure we - // don't treat foobar as a sub-directory of foo. - // - // @@ The keys should be normalized. - // - using prefix_map = butl::dir_path_map; - - void - append_prefixes (prefix_map&, const target&, const variable&) const; - - void - append_lib_prefixes (const scope&, - prefix_map&, - target&, - action, lorder) const; - - prefix_map - build_prefix_map (const scope&, target&, action, lorder) const; - - // Reverse-lookup target type from extension. - // - const target_type* - map_extension (const scope&, const string&, const string&) const; - - // Header dependency injection. - // - void - inject (action, target&, lorder, const file&, depdb&) const; - - private: - const string rule_id; - }; - } -} - -#endif // BUILD2_CC_COMPILE diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 7e37c44..b8b362d 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -2,22 +2,22 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // exit() #include // cerr -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include // h -#include +#include // h +#include using namespace std; using namespace butl; diff --git a/build2/cc/compile.hxx b/build2/cc/compile.hxx new file mode 100644 index 0000000..bee13f2 --- /dev/null +++ b/build2/cc/compile.hxx @@ -0,0 +1,94 @@ +// file : build2/cc/compile.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_COMPILE_HXX +#define BUILD2_CC_COMPILE_HXX + +#include + +#include +#include + +#include + +#include +#include + +namespace build2 +{ + class depdb; + + namespace cc + { + class compile: public rule, virtual common + { + public: + compile (data&&); + + virtual match_result + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + + target_state + perform_update (action, const target&) const; + + target_state + perform_clean (action, const target&) const; + + private: + void + append_lib_options (const scope&, + cstrings&, + const target&, + action, lorder) const; + + void + hash_lib_options (const scope&, + sha256&, + const target&, + action, lorder) const; + + // Mapping of include prefixes (e.g., foo in ) for auto- + // generated headers to directories where they will be generated. + // + // We are using a prefix map of directories (dir_path_map) instead of + // just a map in order to also cover sub-paths (e.g., if + // we continue with the example). Specifically, we need to make sure we + // don't treat foobar as a sub-directory of foo. + // + // @@ The keys should be normalized. + // + using prefix_map = butl::dir_path_map; + + void + append_prefixes (prefix_map&, const target&, const variable&) const; + + void + append_lib_prefixes (const scope&, + prefix_map&, + target&, + action, lorder) const; + + prefix_map + build_prefix_map (const scope&, target&, action, lorder) const; + + // Reverse-lookup target type from extension. + // + const target_type* + map_extension (const scope&, const string&, const string&) const; + + // Header dependency injection. + // + void + inject (action, target&, lorder, const file&, depdb&) const; + + private: + const string rule_id; + }; + } +} + +#endif // BUILD2_CC_COMPILE_HXX diff --git a/build2/cc/gcc.cxx b/build2/cc/gcc.cxx index c16191a..b5dd236 100644 --- a/build2/cc/gcc.cxx +++ b/build2/cc/gcc.cxx @@ -2,18 +2,18 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include -#include -#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/build2/cc/guess b/build2/cc/guess deleted file mode 100644 index 593bd85..0000000 --- a/build2/cc/guess +++ /dev/null @@ -1,141 +0,0 @@ -// file : build2/cc/guess -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_GUESS -#define BUILD2_CC_GUESS - -#include -#include - -#include - -namespace build2 -{ - namespace cc - { - // Compiler id consisting of a type and optional variant. If the variant - // is not empty, then the id is spelled out as 'type-variant', similar to - // target triplets (this also means that the type cannot contain '-'). - // - // Currently recognized compilers and their ids: - // - // gcc GCC gcc/g++ - // clang Vanilla Clang clang/clang++ - // clang-apple Apple Clang clang/clang++ and the gcc/g++ "alias" - // icc Intel icc/icpc - // msvc Microsoft cl.exe - // - struct compiler_id - { - std::string type; - std::string variant; - - bool - empty () const {return type.empty ();} - - std::string - string () const {return variant.empty () ? type : type + "-" + variant;} - }; - - inline ostream& - operator<< (ostream& os, const compiler_id& id) - { - return os << id.string (); - } - - // Compiler version. Here we map the various compiler version formats to - // something that resembles the MAJOR.MINOR.PATCH-BUILD form of the - // Semantic Versioning. While the MAJOR.MINOR part is relatively - // straightforward, PATCH may be empty and BUILD can contain pretty much - // anything (including spaces). - // - // gcc A.B.C[ ...] {A, B, C, ...} - // clang A.B.C[( |-)...] {A, B, C, ...} - // clang-apple A.B[.C] ... {A, B, C, ...} - // icc A.B[.C.D] ... {A, B, C, D ...} - // msvc A.B.C[.D] {A, B, C, D} - // - // Note that the clang-apple version is a custom Apple version and does - // not correspond to the vanilla clang version. - // - struct compiler_version - { - std::string string; - - // Currently all the compilers that we support have numeric MAJOR, - // MINOR, and PATCH components and it makes sense to represent them as - // integers for easy comparison. If we meet a compiler for which this - // doesn't hold, then we will probably just set these to 0 and let the - // user deal with the string representation. - // - uint64_t major; - uint64_t minor; - uint64_t patch; - std::string build; - }; - - // Compiler information. - // - // The signature is normally the -v/--version line that was used to guess - // the compiler id and its version. - // - // The checksum is used to detect compiler changes. It is calculated in a - // compiler-specific manner (usually the output of -v/--version) and is - // not bulletproof (e.g., it most likely won't detect that the underlying - // assembler or linker has changed). However, it should detect most - // common cases, such as an upgrade to a new version or a configuration - // change. - // - // Note that we assume the checksum incorporates the (default) target so - // that if the compiler changes but only in what it targets, then the - // checksum will still change. This is currently the case for all the - // compilers that we support. - // - // The target is the compiler's traget architecture triplet. Note that - // unlike all the preceding fields, this one takes into account the - // compile options (e.g., -m32). - // - // The cc_pattern is the toolchain program pattern that could sometimes be - // derived for some toolchains. For example, i686-w64-mingw32-*-4.9. - // - // The bin_pattern is the binutils program pattern that could sometimes be - // derived for some toolchains. For example, i686-w64-mingw32-*. If the - // pattern could not be derived, then it could contain a fallback search - // directory, in which case it will end with a directory separator but - // will not contain '*'. - // - struct compiler_info - { - process_path path; - compiler_id id; - compiler_version version; - string signature; - string checksum; - string target; - string cc_pattern; - string bin_pattern; - }; - - // In a sense this is analagous to the language standard which we handle - // via a virtual function in common. However, duplicating this hairy ball - // of fur in multiple places doesn't seem wise, especially considering - // that most of it will be the same, at least for C and C++. - // - compiler_info - guess (lang, - const path& xc, - const strings* c_coptions, - const strings* x_coptions); - - // Given a language, toolchain id, and optionally a pattern, return an - // appropriate default compiler path. - // - // For example, for (lang::cxx, gcc, *-4.9) we will get g++-4.9. - // - path - guess_default (lang, const string& cid, const string* pattern); - } -} - -#endif // BUILD2_CC_GUESS diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx index 8b45420..0569bdc 100644 --- a/build2/cc/guess.cxx +++ b/build2/cc/guess.cxx @@ -2,11 +2,11 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // strlen(), strchr() -#include +#include using namespace std; @@ -946,8 +946,9 @@ namespace build2 // Now we need to map x86, x64, and ARM to the target triplets. The // problem is, there aren't any established ones so we got to invent - // them ourselves. Based on the discussion in , - // we need something in the CPU-VENDOR-OS-ABI form. + // them ourselves. Based on the discussion in + // , we need something in the + // CPU-VENDOR-OS-ABI form. // // The CPU part is fairly straightforward with x86 mapped to 'i386' (or // maybe 'i686'), x64 to 'x86_64', and ARM to 'arm' (it could also diff --git a/build2/cc/guess.hxx b/build2/cc/guess.hxx new file mode 100644 index 0000000..dbd06e3 --- /dev/null +++ b/build2/cc/guess.hxx @@ -0,0 +1,141 @@ +// file : build2/cc/guess.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_GUESS_HXX +#define BUILD2_CC_GUESS_HXX + +#include +#include + +#include + +namespace build2 +{ + namespace cc + { + // Compiler id consisting of a type and optional variant. If the variant + // is not empty, then the id is spelled out as 'type-variant', similar to + // target triplets (this also means that the type cannot contain '-'). + // + // Currently recognized compilers and their ids: + // + // gcc GCC gcc/g++ + // clang Vanilla Clang clang/clang++ + // clang-apple Apple Clang clang/clang++ and the gcc/g++ "alias" + // icc Intel icc/icpc + // msvc Microsoft cl.exe + // + struct compiler_id + { + std::string type; + std::string variant; + + bool + empty () const {return type.empty ();} + + std::string + string () const {return variant.empty () ? type : type + "-" + variant;} + }; + + inline ostream& + operator<< (ostream& os, const compiler_id& id) + { + return os << id.string (); + } + + // Compiler version. Here we map the various compiler version formats to + // something that resembles the MAJOR.MINOR.PATCH-BUILD form of the + // Semantic Versioning. While the MAJOR.MINOR part is relatively + // straightforward, PATCH may be empty and BUILD can contain pretty much + // anything (including spaces). + // + // gcc A.B.C[ ...] {A, B, C, ...} + // clang A.B.C[( |-)...] {A, B, C, ...} + // clang-apple A.B[.C] ... {A, B, C, ...} + // icc A.B[.C.D] ... {A, B, C, D ...} + // msvc A.B.C[.D] {A, B, C, D} + // + // Note that the clang-apple version is a custom Apple version and does + // not correspond to the vanilla clang version. + // + struct compiler_version + { + std::string string; + + // Currently all the compilers that we support have numeric MAJOR, + // MINOR, and PATCH components and it makes sense to represent them as + // integers for easy comparison. If we meet a compiler for which this + // doesn't hold, then we will probably just set these to 0 and let the + // user deal with the string representation. + // + uint64_t major; + uint64_t minor; + uint64_t patch; + std::string build; + }; + + // Compiler information. + // + // The signature is normally the -v/--version line that was used to guess + // the compiler id and its version. + // + // The checksum is used to detect compiler changes. It is calculated in a + // compiler-specific manner (usually the output of -v/--version) and is + // not bulletproof (e.g., it most likely won't detect that the underlying + // assembler or linker has changed). However, it should detect most + // common cases, such as an upgrade to a new version or a configuration + // change. + // + // Note that we assume the checksum incorporates the (default) target so + // that if the compiler changes but only in what it targets, then the + // checksum will still change. This is currently the case for all the + // compilers that we support. + // + // The target is the compiler's traget architecture triplet. Note that + // unlike all the preceding fields, this one takes into account the + // compile options (e.g., -m32). + // + // The cc_pattern is the toolchain program pattern that could sometimes be + // derived for some toolchains. For example, i686-w64-mingw32-*-4.9. + // + // The bin_pattern is the binutils program pattern that could sometimes be + // derived for some toolchains. For example, i686-w64-mingw32-*. If the + // pattern could not be derived, then it could contain a fallback search + // directory, in which case it will end with a directory separator but + // will not contain '*'. + // + struct compiler_info + { + process_path path; + compiler_id id; + compiler_version version; + string signature; + string checksum; + string target; + string cc_pattern; + string bin_pattern; + }; + + // In a sense this is analagous to the language standard which we handle + // via a virtual function in common. However, duplicating this hairy ball + // of fur in multiple places doesn't seem wise, especially considering + // that most of it will be the same, at least for C and C++. + // + compiler_info + guess (lang, + const path& xc, + const strings* c_coptions, + const strings* x_coptions); + + // Given a language, toolchain id, and optionally a pattern, return an + // appropriate default compiler path. + // + // For example, for (lang::cxx, gcc, *-4.9) we will get g++-4.9. + // + path + guess_default (lang, const string& cid, const string* pattern); + } +} + +#endif // BUILD2_CC_GUESS_HXX diff --git a/build2/cc/init b/build2/cc/init deleted file mode 100644 index c969505..0000000 --- a/build2/cc/init +++ /dev/null @@ -1,64 +0,0 @@ -// file : build2/cc/init -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_INIT -#define BUILD2_CC_INIT - -#include -#include - -#include - -namespace build2 -{ - namespace cc - { - bool - core_vars_init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - - bool - core_config_init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - - bool - core_init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - - bool - config_init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - - bool - init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - } -} - -#endif // BUILD2_CC_INIT diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index bc598c3..8d20573 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -2,15 +2,15 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/build2/cc/init.hxx b/build2/cc/init.hxx new file mode 100644 index 0000000..9eab424 --- /dev/null +++ b/build2/cc/init.hxx @@ -0,0 +1,64 @@ +// file : build2/cc/init.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_INIT_HXX +#define BUILD2_CC_INIT_HXX + +#include +#include + +#include + +namespace build2 +{ + namespace cc + { + bool + core_vars_init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + + bool + core_config_init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + + bool + core_init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + + bool + config_init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + + bool + init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + } +} + +#endif // BUILD2_CC_INIT_HXX diff --git a/build2/cc/install b/build2/cc/install deleted file mode 100644 index e229e94..0000000 --- a/build2/cc/install +++ /dev/null @@ -1,48 +0,0 @@ -// file : build2/cc/install -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_INSTALL -#define BUILD2_CC_INSTALL - -#include -#include - -#include - -#include -#include - -namespace build2 -{ - namespace cc - { - class link; - - class install: public build2::install::file_rule, virtual common - { - public: - install (data&&, const link&); - - virtual const target* - filter (action, const target&, prerequisite_member) const override; - - virtual match_result - match (action, target&, const string&) const override; - - virtual recipe - apply (action, target&) const override; - - virtual void - install_extra (const file&, const install_dir&) const override; - - virtual bool - uninstall_extra (const file&, const install_dir&) const override; - - private: - const link& link_; - }; - } -} - -#endif // BUILD2_CC_INSTALL diff --git a/build2/cc/install.cxx b/build2/cc/install.cxx index e1e5719..e09a62f 100644 --- a/build2/cc/install.cxx +++ b/build2/cc/install.cxx @@ -2,14 +2,14 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include +#include -#include +#include -#include // match() -#include +#include // match() +#include using namespace std; diff --git a/build2/cc/install.hxx b/build2/cc/install.hxx new file mode 100644 index 0000000..b7d92fb --- /dev/null +++ b/build2/cc/install.hxx @@ -0,0 +1,48 @@ +// file : build2/cc/install.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_INSTALL_HXX +#define BUILD2_CC_INSTALL_HXX + +#include +#include + +#include + +#include +#include + +namespace build2 +{ + namespace cc + { + class link; + + class install: public build2::install::file_rule, virtual common + { + public: + install (data&&, const link&); + + virtual const target* + filter (action, const target&, prerequisite_member) const override; + + virtual match_result + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + + virtual void + install_extra (const file&, const install_dir&) const override; + + virtual bool + uninstall_extra (const file&, const install_dir&) const override; + + private: + const link& link_; + }; + } +} + +#endif // BUILD2_CC_INSTALL_HXX diff --git a/build2/cc/link b/build2/cc/link deleted file mode 100644 index 0dace7c..0000000 --- a/build2/cc/link +++ /dev/null @@ -1,130 +0,0 @@ -// file : build2/cc/link -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_LINK -#define BUILD2_CC_LINK - -#include - -#include -#include - -#include - -#include -#include - -namespace build2 -{ - namespace cc - { - class link: public rule, virtual common - { - public: - link (data&&); - - virtual match_result - match (action, target&, const string&) const override; - - virtual recipe - apply (action, target&) const override; - - target_state - perform_update (action, const target&) const; - - target_state - perform_clean (action, const target&) const; - - private: - friend class install; - - // Shared library paths. - // - struct libs_paths - { - // If any (except real) is empty, then it is the same as the next - // one. Except for intermediate, for which empty indicates that it is - // not used. - // - // The libs{} path is always the real path. On Windows the link path - // is the import library. - // - const path link; // What we link: libfoo.so - const path soname; // SONAME: libfoo-1.so, libfoo.so.1 - const path interm; // Intermediate: libfoo.so.1.2 - const path& real; // Real: libfoo.so.1.2.3 - - inline const path& - effect_link () const {return link.empty () ? effect_soname () : link;} - - inline const path& - effect_soname () const {return soname.empty () ? real : soname;} - - // Cleanup pattern used to remove previous versions. If empty, no - // cleanup is performed. The above (current) names are automatically - // filtered out. - // - const path clean; - }; - - libs_paths - derive_libs_paths (file&) const; - - // Library handling. - // - void - append_libraries (strings&, - const file&, bool, - const scope&, action, lorder) const; - - void - hash_libraries (sha256&, - const file&, bool, - const scope&, action, lorder) const; - - void - rpath_libraries (strings&, - const target&, - const scope&, action, lorder, - bool) const; - - // Windows rpath emulation (windows-rpath.cxx). - // - struct windows_dll - { - const string& dll; - const string* pdb; // NULL if none. - string pdb_storage; - - bool operator< (const windows_dll& y) const {return dll < y.dll;} - }; - - using windows_dlls = std::set; - - timestamp - windows_rpath_timestamp (const file&, - const scope&, - action, lorder) const; - - windows_dlls - windows_rpath_dlls (const file&, const scope&, action, lorder) const; - - void - windows_rpath_assembly (const file&, const scope&, action, lorder, - const string&, - timestamp, - bool) const; - - // Windows-specific (windows-manifest.cxx). - // - pair - windows_manifest (const file&, bool rpath_assembly) const; - - private: - const string rule_id; - }; - } -} - -#endif // BUILD2_CC_LINK diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 80281f7..1b2f306 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -2,27 +2,27 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include #include // exit() #include // cerr -#include -#include // file_exists() +#include +#include // file_exists() -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include // c -#include +#include // c +#include using namespace std; using namespace butl; diff --git a/build2/cc/link.hxx b/build2/cc/link.hxx new file mode 100644 index 0000000..4dc722a --- /dev/null +++ b/build2/cc/link.hxx @@ -0,0 +1,130 @@ +// file : build2/cc/link.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_LINK_HXX +#define BUILD2_CC_LINK_HXX + +#include + +#include +#include + +#include + +#include +#include + +namespace build2 +{ + namespace cc + { + class link: public rule, virtual common + { + public: + link (data&&); + + virtual match_result + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + + target_state + perform_update (action, const target&) const; + + target_state + perform_clean (action, const target&) const; + + private: + friend class install; + + // Shared library paths. + // + struct libs_paths + { + // If any (except real) is empty, then it is the same as the next + // one. Except for intermediate, for which empty indicates that it is + // not used. + // + // The libs{} path is always the real path. On Windows the link path + // is the import library. + // + const path link; // What we link: libfoo.so + const path soname; // SONAME: libfoo-1.so, libfoo.so.1 + const path interm; // Intermediate: libfoo.so.1.2 + const path& real; // Real: libfoo.so.1.2.3 + + inline const path& + effect_link () const {return link.empty () ? effect_soname () : link;} + + inline const path& + effect_soname () const {return soname.empty () ? real : soname;} + + // Cleanup pattern used to remove previous versions. If empty, no + // cleanup is performed. The above (current) names are automatically + // filtered out. + // + const path clean; + }; + + libs_paths + derive_libs_paths (file&) const; + + // Library handling. + // + void + append_libraries (strings&, + const file&, bool, + const scope&, action, lorder) const; + + void + hash_libraries (sha256&, + const file&, bool, + const scope&, action, lorder) const; + + void + rpath_libraries (strings&, + const target&, + const scope&, action, lorder, + bool) const; + + // Windows rpath emulation (windows-rpath.cxx). + // + struct windows_dll + { + const string& dll; + const string* pdb; // NULL if none. + string pdb_storage; + + bool operator< (const windows_dll& y) const {return dll < y.dll;} + }; + + using windows_dlls = std::set; + + timestamp + windows_rpath_timestamp (const file&, + const scope&, + action, lorder) const; + + windows_dlls + windows_rpath_dlls (const file&, const scope&, action, lorder) const; + + void + windows_rpath_assembly (const file&, const scope&, action, lorder, + const string&, + timestamp, + bool) const; + + // Windows-specific (windows-manifest.cxx). + // + pair + windows_manifest (const file&, bool rpath_assembly) const; + + private: + const string rule_id; + }; + } +} + +#endif // BUILD2_CC_LINK_HXX diff --git a/build2/cc/module b/build2/cc/module deleted file mode 100644 index 3c5ec61..0000000 --- a/build2/cc/module +++ /dev/null @@ -1,68 +0,0 @@ -// file : build2/cc/module -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_MODULE -#define BUILD2_CC_MODULE - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -namespace build2 -{ - namespace cc - { - struct compiler_info; - - class config_module: public module_base, public virtual config_data - { - public: - explicit - config_module (config_data&& d) : config_data (move (d)) {} - - void - init (scope&, const location&, const variable_map&); - - // Translate the x.std value to the standard-selecting option if there - // is any. - // - virtual string - translate_std (const compiler_info&, scope&, const string&) const = 0; - - string tstd; - - private: - dir_paths - gcc_library_search_paths (process_path&, scope&) const; // gcc.cxx - - dir_paths - msvc_library_search_paths (process_path&, scope&) const; // msvc.cxx - }; - - class module: public module_base, protected virtual common, - link, compile, install - { - public: - explicit - module (data&& d) - : common (move (d)), - link (move (d)), - compile (move (d)), - install (move (d), *this) {} - - void - init (scope&, const location&, const variable_map&); - }; - } -} - -#endif // BUILD2_CC_MODULE diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 7df71ba..6d8c799 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -2,20 +2,20 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // left, setw() -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include +#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/build2/cc/module.hxx b/build2/cc/module.hxx new file mode 100644 index 0000000..643cf89 --- /dev/null +++ b/build2/cc/module.hxx @@ -0,0 +1,68 @@ +// file : build2/cc/module.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_MODULE_HXX +#define BUILD2_CC_MODULE_HXX + +#include +#include + +#include +#include + +#include + +#include +#include +#include + +namespace build2 +{ + namespace cc + { + struct compiler_info; + + class config_module: public module_base, public virtual config_data + { + public: + explicit + config_module (config_data&& d) : config_data (move (d)) {} + + void + init (scope&, const location&, const variable_map&); + + // Translate the x.std value to the standard-selecting option if there + // is any. + // + virtual string + translate_std (const compiler_info&, scope&, const string&) const = 0; + + string tstd; + + private: + dir_paths + gcc_library_search_paths (process_path&, scope&) const; // gcc.cxx + + dir_paths + msvc_library_search_paths (process_path&, scope&) const; // msvc.cxx + }; + + class module: public module_base, protected virtual common, + link, compile, install + { + public: + explicit + module (data&& d) + : common (move (d)), + link (move (d)), + compile (move (d)), + install (move (d), *this) {} + + void + init (scope&, const location&, const variable_map&); + }; + } +} + +#endif // BUILD2_CC_MODULE_HXX diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx index aa9389f..e3765cd 100644 --- a/build2/cc/msvc.cxx +++ b/build2/cc/msvc.cxx @@ -4,19 +4,19 @@ #include // cerr -#include -#include -#include -#include -#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/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index 00ab541..1b67f5f 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -2,19 +2,19 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include -#include -#include -#include -#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/build2/cc/target b/build2/cc/target deleted file mode 100644 index 6992609..0000000 --- a/build2/cc/target +++ /dev/null @@ -1,63 +0,0 @@ -// file : build2/cc/target -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_TARGET -#define BUILD2_CC_TARGET - -#include -#include - -#include - -namespace build2 -{ - namespace cc - { - // This is an abstract base target for all c-common source files. We use - // this arrangement in rule matching to detect "unknown" (to this rule) - // source files that it cannot handle but should not ignore either. For - // example, a C link rule that sees a C++ source file. - // - class cc: public file - { - public: - using file::file; - - public: - static const target_type static_type; - virtual const target_type& dynamic_type () const = 0; - }; - - // There is hardly a c-family compilation without a C header inclusion. - // As a result, this target type is registered for any c-family module. - // - class h: public file - { - public: - using file::file; - - public: - static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} - }; - - // This one we define in cc but the target type is only registered by the - // c module. This way we can implement rule chaining without jumping - // through too many hoops (like resolving target type dynamically) but - // also without relaxing things too much (i.e., the user still won't be - // able to refer to c{} without loading the c module). - // - class c: public cc - { - public: - using cc::cc; - - public: - static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} - }; - } -} - -#endif // BUILD2_CC_TARGET diff --git a/build2/cc/target.cxx b/build2/cc/target.cxx index a734953..5fbf67d 100644 --- a/build2/cc/target.cxx +++ b/build2/cc/target.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include using namespace std; diff --git a/build2/cc/target.hxx b/build2/cc/target.hxx new file mode 100644 index 0000000..4c9e4cb --- /dev/null +++ b/build2/cc/target.hxx @@ -0,0 +1,63 @@ +// file : build2/cc/target.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_TARGET_HXX +#define BUILD2_CC_TARGET_HXX + +#include +#include + +#include + +namespace build2 +{ + namespace cc + { + // This is an abstract base target for all c-common source files. We use + // this arrangement in rule matching to detect "unknown" (to this rule) + // source files that it cannot handle but should not ignore either. For + // example, a C link rule that sees a C++ source file. + // + class cc: public file + { + public: + using file::file; + + public: + static const target_type static_type; + virtual const target_type& dynamic_type () const = 0; + }; + + // There is hardly a c-family compilation without a C header inclusion. + // As a result, this target type is registered for any c-family module. + // + class h: public file + { + public: + using file::file; + + public: + static const target_type static_type; + virtual const target_type& dynamic_type () const {return static_type;} + }; + + // This one we define in cc but the target type is only registered by the + // c module. This way we can implement rule chaining without jumping + // through too many hoops (like resolving target type dynamically) but + // also without relaxing things too much (i.e., the user still won't be + // able to refer to c{} without loading the c module). + // + class c: public cc + { + public: + using cc::cc; + + public: + static const target_type static_type; + virtual const target_type& dynamic_type () const {return static_type;} + }; + } +} + +#endif // BUILD2_CC_TARGET_HXX diff --git a/build2/cc/types b/build2/cc/types deleted file mode 100644 index 68d9949..0000000 --- a/build2/cc/types +++ /dev/null @@ -1,35 +0,0 @@ -// file : build2/cc/types -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_TYPES -#define BUILD2_CC_TYPES - -#include -#include - -namespace build2 -{ - namespace cc - { - // Compiler language. - // - enum class lang {c, cxx}; - - inline ostream& - operator<< (ostream& os, lang l) - { - return os << (l == lang::c ? "C" : "C++"); - } - - // Compile/link output type (executable, static, or shared). - // - enum class otype {e, a, s}; - - // Library link order. - // - enum class lorder {a, s, a_s, s_a}; - } -} - -#endif // BUILD2_CC_TYPES diff --git a/build2/cc/types.hxx b/build2/cc/types.hxx new file mode 100644 index 0000000..59ea67f --- /dev/null +++ b/build2/cc/types.hxx @@ -0,0 +1,35 @@ +// file : build2/cc/types.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_TYPES_HXX +#define BUILD2_CC_TYPES_HXX + +#include +#include + +namespace build2 +{ + namespace cc + { + // Compiler language. + // + enum class lang {c, cxx}; + + inline ostream& + operator<< (ostream& os, lang l) + { + return os << (l == lang::c ? "C" : "C++"); + } + + // Compile/link output type (executable, static, or shared). + // + enum class otype {e, a, s}; + + // Library link order. + // + enum class lorder {a, s, a_s, s_a}; + } +} + +#endif // BUILD2_CC_TYPES_HXX diff --git a/build2/cc/utility b/build2/cc/utility deleted file mode 100644 index ee3cb81..0000000 --- a/build2/cc/utility +++ /dev/null @@ -1,51 +0,0 @@ -// file : build2/cc/utility -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CC_UTILITY -#define BUILD2_CC_UTILITY - -#include -#include - -#include -#include - -#include - -namespace build2 -{ - struct variable; - - namespace cc - { - // Compile/link output type. - // - otype - compile_type (const target&); - - otype - link_type (const target&); - - // Library link order. - // - // The reason we pass scope and not the target is because this function is - // called not only for exe/lib but also for obj as part of the library - // meta-information protocol implementation. Normally the bin.*.lib values - // will be project-wide. With this scheme they can be customized on the - // per-directory basis but not per-target which means all exe/lib in the - // same directory have to have the same link order. - // - lorder - link_order (const scope& base, otype); - - // Given the link order return the library member (liba or libs) to link. - // - const target& - link_member (const bin::lib&, action, lorder); - } -} - -#include - -#endif // BUILD2_CC_UTILITY diff --git a/build2/cc/utility.cxx b/build2/cc/utility.cxx index 4a931af..7a03b54 100644 --- a/build2/cc/utility.cxx +++ b/build2/cc/utility.cxx @@ -2,12 +2,12 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include -#include // search() +#include +#include // search() -#include +#include using namespace std; diff --git a/build2/cc/utility.hxx b/build2/cc/utility.hxx new file mode 100644 index 0000000..e0529af --- /dev/null +++ b/build2/cc/utility.hxx @@ -0,0 +1,51 @@ +// file : build2/cc/utility.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_UTILITY_HXX +#define BUILD2_CC_UTILITY_HXX + +#include +#include + +#include +#include + +#include + +namespace build2 +{ + struct variable; + + namespace cc + { + // Compile/link output type. + // + otype + compile_type (const target&); + + otype + link_type (const target&); + + // Library link order. + // + // The reason we pass scope and not the target is because this function is + // called not only for exe/lib but also for obj as part of the library + // meta-information protocol implementation. Normally the bin.*.lib values + // will be project-wide. With this scheme they can be customized on the + // per-directory basis but not per-target which means all exe/lib in the + // same directory have to have the same link order. + // + lorder + link_order (const scope& base, otype); + + // Given the link order return the library member (liba or libs) to link. + // + const target& + link_member (const bin::lib&, action, lorder); + } +} + +#include + +#endif // BUILD2_CC_UTILITY_HXX diff --git a/build2/cc/windows-manifest.cxx b/build2/cc/windows-manifest.cxx index 3a62fcc..d840f67 100644 --- a/build2/cc/windows-manifest.cxx +++ b/build2/cc/windows-manifest.cxx @@ -2,14 +2,14 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include + +#include using namespace std; using namespace butl; diff --git a/build2/cc/windows-rpath.cxx b/build2/cc/windows-rpath.cxx index 0b34963..0078944 100644 --- a/build2/cc/windows-rpath.cxx +++ b/build2/cc/windows-rpath.cxx @@ -4,15 +4,15 @@ #include // E* -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include +#include using namespace std; using namespace butl; -- cgit v1.1