From fa98e5148a93481cf659fadc4339839004f92147 Mon Sep 17 00:00:00 2001 From: Dmitry Arkhipov Date: Thu, 16 May 2024 23:08:36 +0300 Subject: [PATCH] use install- features instead of package module --- Jamfile | 4 +- boost-install-dirs.jam | 55 +-------- boost-install.jam | 250 +++++++++++++++-------------------------- 3 files changed, 94 insertions(+), 215 deletions(-) diff --git a/Jamfile b/Jamfile index 7d25aae..7ad3e6a 100644 --- a/Jamfile +++ b/Jamfile @@ -2,9 +2,11 @@ # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) +import make ; + project /boost/tools/boost_install ; # BoostConfigVersion.cmake -generate BoostConfigVersion.cmake : : @boost-install%generate-cmake-config-version Boost $(BOOST_VERSION) ; +make BoostConfigVersion.cmake : : @boost-install%make-cmake-config-version : $(BOOST_VERSION) ; explicit BoostConfigVersion.cmake ; diff --git a/boost-install-dirs.jam b/boost-install-dirs.jam index 5c9f3d4..5985152 100644 --- a/boost-install-dirs.jam +++ b/boost-install-dirs.jam @@ -6,60 +6,9 @@ import modules ; import boostcpp ; import package ; import path ; +import stage ; -# includedir - -rule includedir -{ - if ! $(.includedir) - { - local paths = [ package.paths Boost ] ; - .includedir = [ $(paths).includedir ] ; - } - - return $(.includedir) ; -} - -# bindir - -rule bindir -{ - if ! $(.bindir) - { - local paths = [ package.paths Boost ] ; - .bindir = [ $(paths).bindir ] ; - } - - return $(.bindir) ; -} - -# libdir - -rule libdir -{ - if ! $(.libdir) - { - local paths = [ package.paths Boost ] ; - .libdir = [ $(paths).libdir ] ; - } - - return $(.libdir) ; -} - -# cmakedir - -rule cmakedir -{ - if ! $(.cmakedir) - { - package.add-path-option cmakedir : cmake : libdir ; - - local paths = [ package.paths Boost ] ; - .cmakedir = [ $(paths).get cmakedir ] ; - } - - return $(.cmakedir) ; -} +stage.add-install-dir cmakedir : cmake : libdir ; # header-subdir diff --git a/boost-install.jam b/boost-install.jam index d2c645c..c939527 100644 --- a/boost-install.jam +++ b/boost-install.jam @@ -2,6 +2,7 @@ # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) +import make ; import modules ; import boostcpp ; import property-set ; @@ -10,23 +11,17 @@ import project ; import common ; import print ; import os ; +import property ; import feature ; import package ; import sequence ; import set ; +import stage ; import type ; import path ; import regex ; import ./boost-install-dirs ; -feature.feature library-type : : free ; -feature.feature boost-install.dependency : : free ; -feature.feature boost-install.cmakedir : : free ; -feature.feature boost-install.includedir : : free ; -feature.feature boost-install.libdir : : free ; -feature.feature boost-install.lib-target-type : : free ; -feature.feature boost-install.dll-target : : free ; - if "--verbose" in [ modules.peek : ARGV ] { .info-enabled = 1 ; @@ -53,6 +48,19 @@ local rule .debug ( messages * ) } } +local rule flags-to-vars ( ps ) +{ + for local opt in [ $(ps).get ] + { + local match = [ MATCH (.*)=(.*) : $(opt) ] ; + if $(match) + { + # assigns to variables which assumed to exist in outside scope + $(match[1]) += $(match[2-]) ; + } + } +} + # generate-cmake-variant- local rule remap-library ( lib ) @@ -116,12 +124,19 @@ rule generate-cmake-variant- ( target : sources * : properties * ) local ps = [ property-set.create $(properties) ] ; + local project ; + local name ; + local library-type ; + local lib-target-type ; + local dll-target ; + local dependency ; + flags-to-vars $(ps) ; + print.output $(target) ; local version = [ $(ps).get ] ; .info " version=" $(version) ; - local name = [ $(ps).get ] ; .info " name=" $(name) ; local variant = [ $(ps).get ] ; @@ -433,7 +448,6 @@ rule generate-cmake-variant- ( target : sources * : properties * ) print.text "# Target file name: $(fname)" "" : true ; - local lib-target-type = [ $(ps).get ] ; .info " lib-target-type=" $(lib-target-type) ; local loc-prop = LOCATION ; @@ -445,8 +459,6 @@ rule generate-cmake-variant- ( target : sources * : properties * ) .info " loc-prop=" $(loc-prop) ; - local dll-target = [ $(ps).get ] ; - local dll-name ; if $(dll-target) @@ -507,7 +519,7 @@ rule generate-cmake-variant- ( target : sources * : properties * ) : true ; } - local deps = [ MATCH "boost_(.*)" : [ $(ps).get ] ] headers ; + local deps = [ MATCH "boost_(.*)" : $(dependency) ] headers ; .info " deps=" $(deps) ; if $(deps) @@ -519,7 +531,7 @@ rule generate-cmake-variant- ( target : sources * : properties * ) : true ; } - local deps2 = [ set.difference [ $(ps).get ] : boost_$(deps) ] ; + local deps2 = [ set.difference $(dependency) : boost_$(deps) ] ; .info " deps2=" $(deps2) ; local deps3 ; @@ -547,10 +559,6 @@ rule generate-cmake-variant- ( target : sources * : properties * ) } } -actions generate-cmake-variant- -{ -} - # tag local rule tag ( name : type ? : property-set ) @@ -655,7 +663,7 @@ rule generate-cmake-variant ( project name : property-set : sources * ) local dll-target = [ get-dll-target $(sources) ] ; local other-names = [ get-dependency-names $(sources) ] ; - property-set = [ $(property-set).add-raw $(other-names) ] ; + property-set = [ $(property-set).add-raw dependency=$(other-names) ] ; local result ; @@ -672,13 +680,13 @@ rule generate-cmake-variant ( project name : property-set : sources * ) .debug " dll-target=" [ $(dll-target).name ] ; } - local tag = [ tag $(name) : : $(property-set) ] ; - - property-set = [ $(property-set).add-raw $(lib-target-type) ] ; - property-set = [ $(property-set).add-raw $(dll-target) ] ; + property-set = [ $(property-set).add-raw lib-target-type=$(lib-target-type) ] ; + property-set = [ $(property-set).add-raw dll-target=$(dll-target) ] ; local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ; + local tag = [ tag $(name) : : $(property-set) ] ; + result += [ new file-target $(tag) : : $(project) : $(a) ] ; } @@ -725,30 +733,38 @@ local rule get-dir ( name : dir ) } } -rule generate-cmake-config- ( target : sources * : properties * ) +# make-cmake-config + +rule make-cmake-config ( target : sources * : properties * ) { - .info generate-cmake-config- $(target) ":" $(sources) ; + .info make-cmake-config $(target) ":" $(sources) ; local ps = [ property-set.create $(properties) ] ; + local name ; + local library-type ; + local header-subdir ; + flags-to-vars $(ps) ; + print.output $(target) ; local version = [ $(ps).get ] ; .info " version=" $(version) ; - local name = [ $(ps).get ] ; .info " name=" $(name) ; - local library-type = [ $(ps).get ] ; .info " library-type=" $(library-type) ; - local cmakedir = [ $(ps).get ] ; + local cmakedir = [ stage.get-dir cmakedir : $(ps) : Boost ] ; .info " cmakedir=" $(cmakedir) ; - local includedir = [ $(ps).get ] ; + local includedir = [ stage.get-dir includedir : $(ps) : Boost ] ; + includedir = [ path.join $(includedir) $(header-subdir) ] ; + includedir = [ path.relative-to $(cmakedir) $(includedir) ] ; .info " includedir=" $(includedir) ; - local libdir = [ $(ps).get ] ; + local libdir = [ stage.get-dir libdir : $(ps) : Boost ] ; + libdir = [ path.relative-to $(cmakedir) $(libdir) ] ; .info " libdir=" $(libdir) ; local lname = [ MATCH boost_(.*) : $(name) ] ; @@ -952,51 +968,14 @@ rule generate-cmake-config- ( target : sources * : properties * ) } } -actions generate-cmake-config- -{ -} - -# generate-cmake-config +# make-cmake-config-version -rule generate-cmake-config ( project name : property-set : sources * ) +rule make-cmake-config-version ( target : sources * : properties * ) { - .debug generate-cmake-config $(name) ; - - local pname = [ $(property-set).get ] ; - local version = [ $(property-set).get ] ; - local location = [ $(property-set).get ] ; - local library-type = [ $(property-set).get ] ; - local cmakedir = [ $(property-set).get ] ; - local includedir = [ $(property-set).get ] ; - local libdir = [ $(property-set).get ] ; - - local ps = [ property-set.create - $(pname) $(version) $(location) - $(library-type) - $(cmakedir) - $(includedir) - $(libdir) ] ; - - local result ; - - local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ; - - result += [ new file-target $(name) : : $(project) : $(a) ] ; - - return $(result) ; -} + .info make-cmake-config-version $(target) ":" $(sources) ; -# generate-cmake-config-version- - -rule generate-cmake-config-version- ( target : sources * : properties * ) -{ - .info generate-cmake-config-version- $(target) ":" $(sources) ; - - local ps = [ property-set.create $(properties) ] ; - - print.output $(target) ; - - local version = [ $(ps).get ] ; + local version = [ property.select : $(properties) ] ; + local version = $(version:G=) ; .info " version=" $(version) ; print.output $(target) ; @@ -1019,34 +998,9 @@ rule generate-cmake-config-version- ( target : sources * : properties * ) : true ; } -actions generate-cmake-config-version- -{ -} - -# generate-cmake-config-version - -rule generate-cmake-config-version ( project name : property-set : sources * ) -{ - .debug generate-cmake-config-version $(name) ; - - local pname = [ $(property-set).get ] ; - local version = [ $(property-set).get ] ; - local location = [ $(property-set).get ] ; - - local ps = [ property-set.create $(pname) $(version) $(location) ] ; - - local result ; - - local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ; - - result += [ new file-target $(name) : : $(project) : $(a) ] ; - - return $(result) ; -} - # install-cmake-config- -local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name ) +local rule install-cmake-config- ( install-or-stage : version : name : requirements * ) { #.debug install-cmake-config- $(name) ; @@ -1054,7 +1008,7 @@ local rule install-cmake-config- ( install-or-stage : location : includedir : li if [ MATCH boost_(.*) : $(name) ] { - local loc = $(location)/$(name)-$(version) ; + local loc = (cmakedir)/$(name)-$(version) ; local library-type = UNKNOWN ; @@ -1063,19 +1017,18 @@ local rule install-cmake-config- ( install-or-stage : location : includedir : li library-type = INTERFACE ; } - local reqs = $(name) $(version) $(library-type) $(location) $(includedir) $(libdir) ; + local reqs = $(version) library-type=$(library-type) name=$(name) ; - r += [ generate $(install-or-stage)/$(name)-config.cmake : $(name) : @boost-install%generate-cmake-config $(reqs) ] ; - r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : $(loc) ] ; + r += [ make $(install-or-stage)/$(name)-config.cmake : $(name) : @boost-install%make-cmake-config : $(reqs) $(requirements) ] ; + r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : $(loc) $(requirements) ] ; - r += [ generate $(install-or-stage)/$(name)-config-version.cmake : $(name) : @boost-install%generate-cmake-config-version $(reqs) ] ; - r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : $(loc) ] ; + r += [ make $(install-or-stage)/$(name)-config-version.cmake : $(name) : @boost-install%make-cmake-config-version : $(reqs) $(requirements) ] ; + r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : $(loc) $(requirements) ] ; if $(library-type) != INTERFACE { - local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : @boost-install%generate-cmake-variant $(reqs) ] ; - r += $(v) ; - r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : $(loc) ] ; + r += [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : @boost-install%generate-cmake-variant $(reqs) ] ; + r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(install-or-stage)/$(name)-variant.cmake : $(loc) $(requirements) ] ; } } else @@ -1088,9 +1041,8 @@ local rule install-cmake-config- ( install-or-stage : location : includedir : li # install-or-stage-cmake-config # -# includedir, libdir, cmakedir should be in canonical path.make format -rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir ) +rule install-or-stage-cmake-config ( name * : install-or-stage ) { local p = [ project.current ] ; @@ -1101,8 +1053,18 @@ rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : li } else { - includedir = [ path.relative-to $(cmakedir) $(includedir) ] ; - libdir = [ path.relative-to $(cmakedir) $(libdir) ] ; + local reqs ; + if $(install-or-stage) = stage + { + local libdir = [ boost-install-dirs.stage-libdir ] ; + local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ; + reqs = $(libdir) $(includedir) ; + } + else + { + local subdir = [ boost-install-dirs.header-subdir ] ; + reqs = header-subdir=$(subdir) ; + } local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ; @@ -1110,7 +1072,7 @@ rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : li for local nm in $(name) { - configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ; + configs += [ install-cmake-config- $(install-or-stage) : $(BOOST_VERSION) : $(nm) : $(reqs) ] ; } # Target install/stage-detect-toolset @@ -1118,19 +1080,19 @@ rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : li local boost-install-dir = [ modules.binding $(__name__) ] ; boost-install-dir = $(boost-install-dir:D) ; - install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : $(cmakedir) BoostDetectToolset-$(BOOST_VERSION).cmake ; + install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : (cmakedir) BoostDetectToolset-$(BOOST_VERSION).cmake $(reqs) ; $(p).mark-target-as-explicit $(install-or-stage)-detect-toolset ; # Target install/stage-boost-config - install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : $(cmakedir)/Boost-$(BOOST_VERSION) ; + install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : (cmakedir)/Boost-$(BOOST_VERSION) $(reqs) ; $(p).mark-target-as-explicit $(install-or-stage)-boost-config ; # Target install/stage-boost-config-version project.load [ path.make $(boost-install-dir) ] ; - install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : $(cmakedir)/Boost-$(BOOST_VERSION) ; + install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : (cmakedir)/Boost-$(BOOST_VERSION) $(reqs) ; $(p).mark-target-as-explicit $(install-or-stage)-boost-config-version ; # Target install/stage-cmake-config @@ -1146,26 +1108,12 @@ rule install-cmake-config ( name * ) { #.debug install-cmake-config $(name) ; - local includedir = [ boost-install-dirs.includedir ] ; - local libdir = [ boost-install-dirs.libdir ] ; - local cmakedir = [ boost-install-dirs.cmakedir ] ; - local header-subdir = [ boost-install-dirs.header-subdir ] ; - - if $(header-subdir) - { - includedir = $(includedir)/$(header-subdir) ; - } - - install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ; + install-or-stage-cmake-config $(name) : install ; } rule stage-cmake-config ( name * ) { - local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ; - local libdir = [ boost-install-dirs.stage-libdir ] ; - local cmakedir = $(libdir)/cmake ; - - install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ; + install-or-stage-cmake-config $(name) : stage ; } # stage-cmake-config @@ -1244,7 +1192,7 @@ rule generate-dependencies ( project name ? : property-set : sources * ) # boost-install -local rule install-stage-subdir ( properties * ) +rule install-subdir ( properties * ) { local ps = [ property-set.create $(properties) ] ; @@ -1262,25 +1210,7 @@ local rule install-stage-subdir ( properties * ) r = $(r:B=$(r:B)-python$(python)) ; } - return $(r) ; -} - -rule stage-subdir ( properties * ) -{ - local r = [ install-stage-subdir $(properties) ] ; - - local libdir = [ boost-install-dirs.stage-libdir ] ; - - return $(libdir)/$(r) ; -} - -rule install-subdir ( properties * ) -{ - local r = [ install-stage-subdir $(properties) ] ; - - local libdir = [ boost-install-dirs.libdir ] ; - - return $(libdir)/$(r) ; + return (libdir)/$(r:E=) ; } rule boost-install ( libraries * ) @@ -1308,20 +1238,17 @@ rule boost-install ( libraries * ) local p = [ project.current ] ; - local libdir = [ boost-install-dirs.libdir ] ; - local bindir = [ boost-install-dirs.bindir ] ; - - install install-libraries-static : $(libraries) : $(libdir) on STATIC_LIB ; + install install-libraries-static : $(libraries) : (libdir) on STATIC_LIB ; $(p).mark-target-as-explicit install-libraries-static ; alias install-libraries-shared : install-libraries-shared- ; alias install-libraries-shared : install-libraries-shared-cygwin : cygwin ; $(p).mark-target-as-explicit install-libraries-shared ; - install install-libraries-shared- : $(libraries) : $(libdir) SHARED_LIB PDB on on ; + install install-libraries-shared- : $(libraries) : (libdir) SHARED_LIB PDB on on ; $(p).mark-target-as-explicit install-libraries-shared- ; - install install-libraries-shared-cygwin : $(libraries) : $(bindir) SHARED_LIB PDB on on ; + install install-libraries-shared-cygwin : $(libraries) : (bindir) SHARED_LIB PDB on on ; $(p).mark-target-as-explicit install-libraries-shared-cygwin ; install install-unprefixed-static : $(unprefixed) : STATIC_LIB @boost-install%install-subdir ; @@ -1341,19 +1268,20 @@ rule boost-install ( libraries * ) # Target stage local stage-libdir = [ boost-install-dirs.stage-libdir ] ; + local reqs = $(stage-libdir) ; stage-cmake-config $(libraries) ; - install stage-libraries-static : $(libraries) : $(stage-libdir) on STATIC_LIB ; + install stage-libraries-static : $(libraries) : (libdir) $(reqs) on STATIC_LIB ; $(p).mark-target-as-explicit stage-libraries-static ; - install stage-libraries-shared : $(libraries) : $(stage-libdir) on SHARED_LIB PDB on ; + install stage-libraries-shared : $(libraries) : (libdir) $(reqs) on SHARED_LIB PDB on ; $(p).mark-target-as-explicit stage-libraries-shared ; - install stage-unprefixed-static : $(unprefixed) : STATIC_LIB @boost-install%stage-subdir ; + install stage-unprefixed-static : $(unprefixed) : STATIC_LIB $(reqs) @boost-install%install-subdir ; $(p).mark-target-as-explicit stage-unprefixed-static ; - install stage-unprefixed-shared : $(unprefixed) : SHARED_LIB PDB on @boost-install%stage-subdir ; + install stage-unprefixed-shared : $(unprefixed) : SHARED_LIB $(reqs) PDB on @boost-install%install-subdir ; $(p).mark-target-as-explicit stage-unprefixed-shared ; generate stage-dependencies : $(libraries) : @boost-install%generate-dependencies stage ;