Skip to content

Commit

Permalink
Add jambase source generation to build.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Apr 8, 2019
1 parent bece47c commit 0b9914e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 45 deletions.
43 changes: 31 additions & 12 deletions Jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@ us support more functionality for development of the engine core.
Define custom yyacc tool.
|#

feature.feature yyacc : : dependency free ;
toolset.flags yyacc TOOL <yyacc> ;

exe yyacc
: src/engine/yyacc.cpp
: ;
explicit yyacc ;

feature.feature yyacc : : dependency free ;

toolset.flags yyacc YYACC <yyacc> ;

rule yyacc-gen ( project name : property-set : sources * )
{
local relevant = [ toolset.relevant $(__name__).yyacc ] ;
Expand All @@ -101,21 +100,16 @@ rule yyacc-gen ( project name : property-set : sources * )
return $(targets) ;
}

rule yyacc ( targets * : sources * : properties * )
actions yyacc bind TOOL
{
DEPENDS $(targets) : [ on $(targets) return $(YYACC) ] ;
}

actions yyacc bind YYACC
{
"$(YYACC:E=yyacc)" "$(<)" "$(>)"
"$(TOOL)" "$(<)" "$(>)"
}

generate jamgram.y
: src/engine/jamgram.yy
: <generating-rule>@yyacc-gen
<yyacc>yyacc
<location>src/engine
<yyacc>yyacc <dependency>yyacc
;
explicit jamgram.y ;

Expand Down Expand Up @@ -143,6 +137,30 @@ make jamgram.cpp
<location>src/engine ;
explicit jamgram.cpp ;

#|
Generate the embedded jambase.
|#

feature.feature mkjambase : : dependency free ;
toolset.flags mkjambase TOOL <mkjambase> ;

exe mkjambase
: src/engine/mkjambase.cpp
;
explicit mkjambase ;

actions mkjambase bind TOOL
{
"$(TOOL)" "$(<)" "$(>)"
}

make jambase.cpp
: src/engine/Jambase
: @mkjambase
: <location>src/engine
<mkjambase>mkjambase <dependency>mkjambase ;
explicit jambase.cpp ;

#|
Define the b2 executable. Sources are based on platform.
TODO: Make platform specific source be no-ops when not needed.
Expand All @@ -166,5 +184,6 @@ exe b2
<target-os>vms:<source>$(b2_src_vms)
<target-os>$(unix_os):<source>$(b2_src_unix)
<dependency>jamgram.cpp
<dependency>jambase.cpp
;
explicit b2 ;
32 changes: 1 addition & 31 deletions src/engine/jambase.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/* Generated by mkjambase from Jambase */
const char *jambase[] = {
/* Jambase */
"\n",
"\n",
/* src/engine/Jambase */
"if $(NT)\n",
"{\n",
"SLASH ?= \\\\ ;\n",
"}\n",
"SLASH ?= / ;\n",
"\n",
"\n",
"rule find-to-root ( dir : patterns + )\n",
"{\n",
"local globs = [ GLOB $(dir) : $(patterns) ] ;\n",
Expand All @@ -20,29 +16,20 @@ const char *jambase[] = {
"}\n",
"return $(globs) ;\n",
"}\n",
"\n",
"\n",
".boost-build-file = ;\n",
"\n",
".bootstrap-file = ;\n",
"\n",
"BOOST_BUILD_PATH.user-value = $(BOOST_BUILD_PATH) ;\n",
"\n",
"if ! $(BOOST_BUILD_PATH) && $(UNIX)\n",
"{\n",
"BOOST_BUILD_PATH = /usr/share/boost-build ;\n",
"}\n",
"\n",
"\n",
"rule _poke ( module-name ? : variables + : value * )\n",
"{\n",
"module $(<)\n",
"{\n",
"$(>) = $(3) ;\n",
"}\n",
"}\n",
"\n",
"\n",
"rule boost-build ( dir ? )\n",
"{\n",
"if $(.bootstrap-file)\n",
Expand All @@ -53,14 +40,10 @@ const char *jambase[] = {
"ECHO ;\n",
"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n",
"}\n",
"\n",
"BOOST_BUILD_PATH = $(dir:R=$(.boost-build-file:D)) $(BOOST_BUILD_PATH) ;\n",
"\n",
"_poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ;\n",
"\n",
"local bootstrap-file = [ GLOB $(BOOST_BUILD_PATH) : bootstrap.jam ] ;\n",
".bootstrap-file = $(bootstrap-file[1]) ;\n",
"\n",
"if ! $(.bootstrap-file)\n",
"{\n",
"ECHO \"Unable to load Boost.Build: could not find build system.\" ;\n",
Expand All @@ -74,58 +57,45 @@ const char *jambase[] = {
"ECHO ;\n",
"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n",
"}\n",
"\n",
"if [ MATCH .*(--debug-configuration).* : $(ARGV) ]\n",
"{\n",
"ECHO \"notice: loading Boost.Build from\"\n",
"[ NORMALIZE_PATH $(.bootstrap-file:D) ] ;\n",
"}\n",
"\n",
"include $(.bootstrap-file) ;\n",
"}\n",
"\n",
"\n",
"{\n",
"\n",
"local search-path = $(BOOST_BUILD_PATH) $(BOOST_ROOT) ;\n",
"local self = [ SELF_PATH ] ;\n",
"local boost-build-relative = ../../share/boost-build ;\n",
"local self-based-path = [ NORMALIZE_PATH $(boost-build-relative:R=$(self)) ] ;\n",
"\n",
"local boost-build-files =\n",
"[ find-to-root [ PWD ] : boost-build.jam ]\n",
"[ GLOB $(self-based-path) : boost-build.jam ]\n",
"[ GLOB $(search-path) : boost-build.jam ] ;\n",
"\n",
".boost-build-file = $(boost-build-files[1]) ;\n",
"\n",
"if ! $(.boost-build-file)\n",
"{\n",
"ECHO \"Unable to load Boost.Build: could not find \\\"boost-build.jam\\\"\" ;\n",
"ECHO --------------------------------------------------------------- ;\n",
"\n",
"if ! [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]\n",
"{\n",
"ECHO \"BOOST_ROOT must be set, either in the environment, or \" ;\n",
"ECHO \"on the command-line with -sBOOST_ROOT=..., to the root\" ;\n",
"ECHO \"of the boost installation.\" ;\n",
"ECHO ;\n",
"}\n",
"\n",
"ECHO \"Attempted search from\" [ PWD ] \"up to the root\" ;\n",
"ECHO \"at\" $(self-based-path) ;\n",
"ECHO \"and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: \"$(search-path:J=\", \")\".\" ;\n",
"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n",
"}\n",
"\n",
"if [ MATCH .*(--debug-configuration).* : $(ARGV) ]\n",
"{\n",
"ECHO \"notice: found boost-build.jam at\"\n",
"[ NORMALIZE_PATH $(.boost-build-file) ] ;\n",
"}\n",
"\n",
"include $(.boost-build-file) ;\n",
"\n",
"if ! $(.bootstrap-file)\n",
"{\n",
"ECHO \"Unable to load Boost.Build\" ;\n",
Expand Down
4 changes: 2 additions & 2 deletions src/engine/mkjambase.c → src/engine/mkjambase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main( int argc, char * * argv, char * * envp )
}

/* If the file ends in .c generate a C source file. */
if ( ( p = strrchr( argv[1], '.' ) ) && !strcmp( p, ".c" ) )
if ( ( p = strrchr( argv[1], '.' ) ) && ( !strcmp( p, ".c" ) || !strcmp( p, ".cpp" ) ) )
doDotC++;

/* Now process the files. */
Expand All @@ -62,7 +62,7 @@ int main( int argc, char * * argv, char * * envp )
if ( doDotC )
{
fprintf( fout, "/* Generated by mkjambase from Jambase */\n" );
fprintf( fout, "char *jambase[] = {\n" );
fprintf( fout, "const char *jambase[] = {\n" );
}

for ( ; argc--; ++argv )
Expand Down

0 comments on commit 0b9914e

Please sign in to comment.