From 916060cb53fddb94f64b20d3616e7360c5e91f64 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 13 Jan 2023 19:56:35 +0100 Subject: Capture flags in a class instead of a string and add conversion functions between them. --- src/tools.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'src/tools.h') diff --git a/src/tools.h b/src/tools.h index e6c2264..b1285ec 100644 --- a/src/tools.h +++ b/src/tools.h @@ -5,23 +5,92 @@ #include #include +#include #include "ctor.h" + +std::ostream& operator<<(std::ostream& stream, const ctor::c_opt& opt); +std::ostream& operator<<(std::ostream& stream, const ctor::cxx_opt& opt); +std::ostream& operator<<(std::ostream& stream, const ctor::ld_opt& opt); +std::ostream& operator<<(std::ostream& stream, const ctor::ar_opt& opt); +std::ostream& operator<<(std::ostream& stream, const ctor::asm_opt& opt); + + //! Get tool-chain type from compiler path string ctor::toolchain getToolChain(const std::string& compiler); //! Get tool-chain type from output system (via configuration) ctor::toolchain getToolChain(ctor::output_system system); + + +//! Get tool argument(s) for specific option type matching the supplied +//! tool-chain +std::vector c_option(ctor::toolchain toolchain, + ctor::c_opt option, + const std::string& arg = {}); + +//! Get tool argument(s) for specific option type matching the supplied +//! tool-chain +std::vector cxx_option(ctor::toolchain toolchain, + ctor::cxx_opt option, + const std::string& arg = {}); + //! Get tool argument(s) for specific option type matching the supplied //! tool-chain -std::vector getOption(ctor::toolchain toolchain, - ctor::opt option, +std::vector ld_option(ctor::toolchain toolchain, + ctor::ld_opt option, const std::string& arg = {}); -//! Get opt enum value and argument from string, -//! ie. { opt::InludePath, "foo/bar" } from "-Ifoo/bar" -//! Returns { opt::Custom, flag } if unknown. -std::pair getOption(const std::string& flag, - ctor::toolchain toolchain = ctor::toolchain::gcc); +//! Get tool argument(s) for specific option type matching the supplied +//! tool-chain +std::vector ar_option(ctor::toolchain toolchain, + ctor::ar_opt option, + const std::string& arg = {}); + +//! Get tool argument(s) for specific option type matching the supplied +//! tool-chain +std::vector asm_option(ctor::toolchain toolchain, + ctor::asm_opt option, + const std::string& arg = {}); + + + +//! Get ctor::c_opt enum value and argument from string, +//! ie. { ctor::c_opt::inlude_path, "foo/bar" } from "-Ifoo/bar" +//! Returns { ctor::c_opt::custom, flag } if unknown. +ctor::c_flag c_option(const std::string& flag, ctor::toolchain toolchain); + +//! Get ctor::cxx_opt enum value and argument from string, +//! ie. { ctor::cxx_opt::inlude_path, "foo/bar" } from "-Ifoo/bar" +//! Returns { ctor::cxx_opt::custom, flag } if unknown. +ctor::cxx_flag cxx_option(const std::string& flag, ctor::toolchain toolchain); + +//! Get ctor::ld_opt enum value and argument from string, +//! ie. { ctor::ld_opt::inlude_path, "foo/bar" } from "-Ifoo/bar" +//! Returns { ctor::ld_opt::custom, flag } if unknown. +ctor::ld_flag ld_option(const std::string& flag, ctor::toolchain toolchain); + +//! Get ctor::ar_opt enum value and argument from string, +//! ie. { ctor::ar_opt::inlude_path, "foo/bar" } from "-Ifoo/bar" +//! Returns { ctor::ar_opt::custom, flag } if unknown. +ctor::ar_flag ar_option(const std::string& flag, ctor::toolchain toolchain); + +//! Get ctor::asm_opt enum value and argument from string, +//! ie. { ctor::asm_opt::inlude_path, "foo/bar" } from "-Ifoo/bar" +//! Returns { ctor::asm_opt::custom, flag } if unknown. +ctor::asm_flag asm_option(const std::string& flag, ctor::toolchain toolchain); + + + +std::vector to_strings(ctor::toolchain toolchain, + const ctor::cxx_flag& flag); +std::vector to_strings(ctor::toolchain toolchain, + const ctor::c_flag& flag); +std::vector to_strings(ctor::toolchain toolchain, + const ctor::ld_flag& flag); +std::vector to_strings(ctor::toolchain toolchain, + const ctor::ar_flag& flag); +std::vector to_strings(ctor::toolchain toolchain, + const ctor::asm_flag& flag); -- cgit v1.2.3