From 8eef1041c8c28a3c4c0528c072a431db2886764b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Jan 2016 10:07:12 +0200 Subject: Add support for --output-{prefix,suffix} options --- cli/generator.cxx | 16 ++++++++++------ cli/header.cxx | 5 ++++- cli/options.cli | 14 ++++++++++++++ cli/options.cxx | 36 ++++++++++++++++++++++++++++++++++++ cli/options.hxx | 16 ++++++++++++++++ cli/options.ixx | 24 ++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 7 deletions(-) (limited to 'cli') diff --git a/cli/generator.cxx b/cli/generator.cxx index 37092ab..b086089 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -116,6 +116,9 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) path file (p.leaf ()); string base (file.base ().string ()); + const string& pfx (ops.output_prefix ()); + const string& sfx (ops.output_suffix ()); + bool gen_cxx (ops.generate_cxx ()); bool gen_man (ops.generate_man ()); bool gen_html (ops.generate_html ()); @@ -147,9 +150,9 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) { bool inl (!ops.suppress_inline ()); - string hxx_name (base + ops.hxx_suffix ()); - string ixx_name (base + ops.ixx_suffix ()); - string cxx_name (base + ops.cxx_suffix ()); + string hxx_name (pfx + base + sfx + ops.hxx_suffix ()); + string ixx_name (pfx + base + sfx + ops.ixx_suffix ()); + string cxx_name (pfx + base + sfx + ops.cxx_suffix ()); path hxx_path (hxx_name); path ixx_path (ixx_name); @@ -391,7 +394,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) if (!ops.stdout_ ()) { - path man_path (base + ops.man_suffix ()); + path man_path (pfx + base + sfx + ops.man_suffix ()); if (!ops.output_dir ().empty ()) man_path = path (ops.output_dir ()) / man_path; @@ -428,9 +431,10 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) if (!ops.stdout_ ()) { - // Remember to update link derivation if changing this. + // May have to update link derivation in format_line() if changing + // this. // - path html_path (base + ops.html_suffix ()); + path html_path (pfx + base + sfx + ops.html_suffix ()); if (!ops.output_dir ().empty ()) html_path = path (ops.output_dir ()) / html_path; diff --git a/cli/header.cxx b/cli/header.cxx index e2aebd4..4286df6 100644 --- a/cli/header.cxx +++ b/cli/header.cxx @@ -288,7 +288,10 @@ namespace traverse (semantics::cli_includes& i) { generate (i.kind (), - i.file ().base ().string () + options.hxx_suffix ()); + (options.output_prefix () + + i.file ().base ().string () + + options.output_suffix () + + options.hxx_suffix ())); } void diff --git a/cli/options.cli b/cli/options.cli index 0f0d1a9..32a2794 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -364,6 +364,20 @@ class options "Insert the content of at the end of the generated HTML file." }; + std::string --output-prefix + { + "", + "Add at the beginning of the generated output file name(s)." + }; + + std::string --output-suffix + { + "", + "Add at the end of the generated output file name(s). Note that + it is added before any file type-specific suffixes; see \cb{--*-suffix} + below." + }; + std::string --hxx-suffix = ".hxx" { "", diff --git a/cli/options.cxx b/cli/options.cxx index 3e7dbcc..118d8ee 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -640,6 +640,10 @@ options () man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -751,6 +755,10 @@ options (int& argc, man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -865,6 +873,10 @@ options (int start, man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -979,6 +991,10 @@ options (int& argc, man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -1095,6 +1111,10 @@ options (int start, man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -1207,6 +1227,10 @@ options (::cli::scanner& s, man_epilogue_file_specified_ (false), html_epilogue_file_ (), html_epilogue_file_specified_ (false), + output_prefix_ (), + output_prefix_specified_ (false), + output_suffix_ (), + output_suffix_specified_ (false), hxx_suffix_ (".hxx"), hxx_suffix_specified_ (false), ixx_suffix_ (".ixx"), @@ -1382,6 +1406,12 @@ print_usage (::std::ostream& os, ::cli::usage_para p) os << "--html-epilogue-file Insert the content of at the end of the" << ::std::endl << " generated HTML file." << ::std::endl; + os << "--output-prefix Add at the beginning of the generated" << ::std::endl + << " output file name(s)." << ::std::endl; + + os << "--output-suffix Add at the end of the generated output" << ::std::endl + << " file name(s)." << ::std::endl; + os << "--hxx-suffix Use instead of the default '.hxx' to" << ::std::endl << " construct the name of the generated header file." << ::std::endl; @@ -1572,6 +1602,12 @@ struct _cli_options_map_init _cli_options_map_["--html-epilogue-file"] = &::cli::thunk< options, std::string, &options::html_epilogue_file_, &options::html_epilogue_file_specified_ >; + _cli_options_map_["--output-prefix"] = + &::cli::thunk< options, std::string, &options::output_prefix_, + &options::output_prefix_specified_ >; + _cli_options_map_["--output-suffix"] = + &::cli::thunk< options, std::string, &options::output_suffix_, + &options::output_suffix_specified_ >; _cli_options_map_["--hxx-suffix"] = &::cli::thunk< options, std::string, &options::hxx_suffix_, &options::hxx_suffix_specified_ >; diff --git a/cli/options.hxx b/cli/options.hxx index 6171cc0..9794732 100644 --- a/cli/options.hxx +++ b/cli/options.hxx @@ -631,6 +631,18 @@ class options html_epilogue_file_specified () const; const std::string& + output_prefix () const; + + bool + output_prefix_specified () const; + + const std::string& + output_suffix () const; + + bool + output_suffix_specified () const; + + const std::string& hxx_suffix () const; bool @@ -797,6 +809,10 @@ class options bool man_epilogue_file_specified_; std::string html_epilogue_file_; bool html_epilogue_file_specified_; + std::string output_prefix_; + bool output_prefix_specified_; + std::string output_suffix_; + bool output_suffix_specified_; std::string hxx_suffix_; bool hxx_suffix_specified_; std::string ixx_suffix_; diff --git a/cli/options.ixx b/cli/options.ixx index 1d61ecb..ed07f19 100644 --- a/cli/options.ixx +++ b/cli/options.ixx @@ -686,6 +686,30 @@ html_epilogue_file_specified () const } inline const std::string& options:: +output_prefix () const +{ + return this->output_prefix_; +} + +inline bool options:: +output_prefix_specified () const +{ + return this->output_prefix_specified_; +} + +inline const std::string& options:: +output_suffix () const +{ + return this->output_suffix_; +} + +inline bool options:: +output_suffix_specified () const +{ + return this->output_suffix_specified_; +} + +inline const std::string& options:: hxx_suffix () const { return this->hxx_suffix_; -- cgit v1.1