Skip to content

Commit

Permalink
Add version and build of cppfront to generated files. (hsutter#791)
Browse files Browse the repository at this point in the history
* Add version and build of cppfront to generated files.

* Add a flag to control the information

* Add version and build of cppfront to generated files.

* Cherry-Picked: Add a flag to control the information
by Herb Sutter

* Added missed file.

---------

Signed-off-by: Herb Sutter <herb.sutter@gmail.com>
Co-authored-by: Ingo Prötel <ingo.proetel@macio.de>
Co-authored-by: Herb Sutter <herb.sutter@gmail.com>
Co-authored-by: Ingo Prötel <git@iprtel.de>
  • Loading branch information
4 people authored Dec 25, 2023
1 parent 210b2a0 commit ec06a73
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,9 @@ class cmdline_processor
-> void
{
help_requested = true;
print("\ncppfront compiler v0.3.0 Build "
print("\ncppfront compiler "
#include "version.info"
" Build "
#include "build.info"
);
print("\nCopyright(c) Herb Sutter All rights reserved\n");
Expand Down
16 changes: 16 additions & 0 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ auto pad(int padding)
//
//-----------------------------------------------------------------------
//
static auto flag_emit_cppfront_info = false;
static cmdline_processor::register_flag cmd_emit_cppfront_info(
9,
"emit-cppfront-info",
"Emit cppfront version/build in output file",
[]{ flag_emit_cppfront_info = true; }
);

static auto flag_clean_cpp1 = false;
static cmdline_processor::register_flag cmd_clean_cpp1(
9,
Expand Down Expand Up @@ -1289,6 +1297,14 @@ class cppfront
|| flag_include_std
)
{
if (flag_emit_cppfront_info) {
printer.print_extra(
"\n// Generated by cppfront "
#include "version.info"
" build "
#include "build.info"
);
}
printer.print_extra( "\n" );
if (cpp1_filename.back() == 'h') {
printer.print_extra( "#ifndef " + cpp1_FILENAME+"_CPP2\n");
Expand Down
1 change: 1 addition & 0 deletions source/version.info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"v0.3.0"

0 comments on commit ec06a73

Please sign in to comment.