From 4f9022f24c4591391637121c7274d9855b37bd93 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 May 2012 11:09:13 +0200 Subject: Add support for options file inclusion New include-path prefixes, c++: and cli:, are now recognized (e.g., include ;). Without a prefix, the include declarations is considered to be c++-include unless the path ends with the .cli extension. The cli-included files are loaded and parsed. Currently, only inclusion relative to the current file is supported. Duplicate inclusions are detected and ignored based on the absolute filesystem path. If a file cli-includes another file, then the runtime code is assumed to come from the included file and is not generated. --- cli/generator.cxx | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'cli/generator.cxx') diff --git a/cli/generator.cxx b/cli/generator.cxx index 842fc54..8b4b244 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -158,6 +158,19 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) process_names (ctx); } + // Check if we need to generate the runtime code. If we include + // another options file, then we assume the runtime is generated + // there. + // + bool runtime (true); + for (semantics::cli_unit::includes_iterator i (unit.includes_begin ()); + runtime && i != unit.includes_end (); + ++i) + { + if (i->is_a ()) + runtime = false; + } + // // ofstream hxx (hxx_path.string ().c_str ()); @@ -237,7 +250,9 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) << "#define " << guard << endl << endl; - generate_runtime_header (ctx); + if (runtime) + generate_runtime_header (ctx); + generate_header (ctx); if (inl) @@ -256,7 +271,10 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) { cxx_filter filt (ixx); context ctx (ixx, unit, ops); - generate_runtime_inline (ctx); + + if (runtime) + generate_runtime_inline (ctx); + generate_inline (ctx); } @@ -270,10 +288,13 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) (br ? '>' : '"') << endl << endl; - if (!inl) - generate_runtime_inline (ctx); + if (runtime) + { + if (!inl) + generate_runtime_inline (ctx); - generate_runtime_source (ctx); + generate_runtime_source (ctx); + } if (!inl) generate_inline (ctx); -- cgit v1.1