# Copyright 2019 Rene Rivera # Copyright 2017 Steven Watanabe # Copyright 2016 Vladimir Prus # Copyright 2017 Edward Diener # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) import path ; import package ; import os ; import feature ; import set ; import toolset ; import bison ; import indirect ; import "class" : new ; import type ; import virtual-target ; path-constant SELF : . ; project b2 : build-dir .build ; #| Build the engine and its dependencies outside of the simple core build scripts. This allows us to keep the core build scripts as simple as possible. And lets us support more functionality for development of the engine core. |# #| Define custom yyacc tool. |# feature.feature yyacc : : dependency free ; toolset.flags yyacc TOOL ; exe yyacc : src/engine/yyacc.cpp : ; explicit yyacc ; rule yyacc-gen ( project name : property-set : sources * ) { local relevant = [ toolset.relevant $(__name__).yyacc ] ; local a = [ new action $(sources[1]) : $(__name__).yyacc : [ $(property-set).add $(relevant) ] ] ; local targets ; for local n in $(name:S=).y $(name:S=)tab.h { targets += [ virtual-target.register [ new file-target $(n) exact : [ type.type $(n) ] : $(project) : $(a) ] ] ; } return $(targets) ; } actions yyacc bind TOOL { "$(TOOL)" "$(<)" "$(>)" } generate jamgram.y : src/engine/jamgram.yy : @yyacc-gen src/engine yyacc yyacc ; explicit jamgram.y ; #| Define grammar translation with Bison. |# rule grammar ( target : source : properties * ) { # LOCATE on $(target) = $(source:D) ; local BISON = [ os.environ BISON ] ; BISON ?= bison ; BISON on $(target) = $(BISON) ; } actions grammar { "$(BISON)" --yacc --defines -o "$(<[1])" "$(>)" } make jamgram.cpp : src/engine/jamgram.y : @grammar : jamgram.y src/engine ; explicit jamgram.cpp ; #| Generate the embedded jambase. |# feature.feature mkjambase : : dependency free ; toolset.flags mkjambase TOOL ; exe mkjambase : src/engine/mkjambase.cpp ; explicit mkjambase ; actions mkjambase bind TOOL { "$(TOOL)" "$(<)" "$(>)" } make jambase.cpp : src/engine/Jambase : @mkjambase : src/engine mkjambase mkjambase ; explicit jambase.cpp ; #| Define the b2 executable. Sources are based on platform. TODO: Make platform specific source be no-ops when not needed. |# local python-exe = [ MATCH --with-python=(.*) : [ modules.peek : ARGV ] ] ; local python-include ; local python-ldlib ; if $(python-exe) { python-include = [ SHELL "$(python-exe) -c \"import sysconfig; print(sysconfig.get_path('include'));\"" : strip-eol ] ; python-libdir = [ SHELL "$(python-exe) -c \"import sysconfig; import os.path; print(sysconfig.get_config_var('LIBDIR'));\"" : strip-eol ] ; python-ldlib = [ MATCH ".*(python.*)" : [ SHELL "$(python-exe) -c \"import sysconfig; import os.path; print(sysconfig.get_config_var('LIBRARY'));\"" : strip-eol ] ] ; python-ldlib = $(python-ldlib:S=) ; lib python : : $(python-ldlib) $(python-libdir) : : $(python-include) HAVE_PYTHON ; } else { alias python ; } local b2_src = [ glob src/engine/*.cpp src/engine/modules/*.cpp : src/engine/*nt.cpp src/engine/*unix.cpp src/engine/*vms.cpp src/engine/yyacc.cpp src/engine/mkjambase.cpp ] ; local b2_src_nt = [ glob src/engine/*nt.cpp ] ; local b2_src_unix = [ glob src/engine/*unix.cpp ] ; local b2_src_vms = [ glob src/engine/*vms.cpp ] ; local unix_os = [ set.difference [ feature.values ] : windows vms ] ; exe b2 : $(b2_src) python : windows:$(b2_src_nt) vms:$(b2_src_vms) $(unix_os):$(b2_src_unix) jamgram.cpp jambase.cpp ; explicit b2 ; #| Installation of the engine, build, and example files. |# local ext = "" ; if [ os.on-windows ] || [ os.on-vms ] { ext = ".exe" ; } package.install boost-build-engine boost-build : # properties : # binaries $(SELF)/src/engine/b2$(ext) ; explicit boost-build-engine ; local examples ; for local e in [ glob-tree-ex $(SELF)/example : * : . .svn ] { if [ CHECK_IF_FILE [ path.native $(e) ] ] { examples += $(e) ; } } package.install-data boost-build-examples : # Which subdir of $prefix/share boost-build : # What to install $(examples) : # What is the root of the directory . ; explicit boost-build-examples ; local .core-sources = $(SELF)/boost-build.jam $(SELF)/src/build-system.jam [ path.glob-tree $(SELF)/src/build : *.jam ] [ path.glob-tree $(SELF)/src/contrib : *.jam ] [ path.glob-tree $(SELF)/src/kernel : *.jam ] [ path.glob-tree $(SELF)/src/options : *.jam ] [ path.glob-tree $(SELF)/src/util : *.jam ] [ path.glob-tree $(SELF)/src/tools : *.jam *.xml *.xsl *.doxyfile *.hpp doxproc.py ] ; if $(python-exe) { .core-sources += [ path.glob-tree $(SELF)/src/build : *.py ] [ path.glob-tree $(SELF)/src/contrib : *.py ] [ path.glob-tree $(SELF)/src/kernel : *.py ] [ path.glob-tree $(SELF)/src/options : *.py ] [ path.glob-tree $(SELF)/src/util : *.py ] [ path.glob-tree $(SELF)/src/tools : *.py : doxproc.py ] ; } package.install-data boost-build-core : # Which subdir of $prefix/share boost-build : # What to install $(.core-sources) : # What is the root of the directory . ; explicit boost-build-core ; #| Only install example files when requested to avoid bloating install footprint. |# if --with-examples in [ modules.peek : ARGV ] { alias install : boost-build-engine boost-build-core boost-build-examples ; } else { alias install : boost-build-engine boost-build-core ; } explicit install ;