Skip to content

Commit

Permalink
implement configurable installation prefixes that use features (#503)
Browse files Browse the repository at this point in the history
* a feature to control install prefix for install targets

* usable default for install-prefix on Windows

* additional named installation prefixes based on Autotools

* allow users to add named installation directories

* fix named directories <location> handling when requesting a subproject build

* examples for named installation directories

* document named install directories-related functions, make get-package-name more conveninent to users

* feature to allow staging into a location different than active install-prefix

* support for getting relative paths with stage.get-dir
  • Loading branch information
grisumbras authored May 28, 2020
1 parent b613e6d commit 51ad471
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 7 deletions.
4 changes: 4 additions & 0 deletions doc/src/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ include::../../src/tools/features/dependency-feature.jam[tag=impl-doc]
include::../../src/tools/features/force-include-feature.jam[tag=doc]
include::../../src/tools/features/include-feature.jam[tag=doc]
include::../../src/tools/features/optimization-feature.jam[tag=inline-doc]
include::../../src/tools/stage.jam[tag=features-doc]
include::../../src/tools/features/instruction-set-feature.jam[tag=doc]
include::../../src/tools/features/library-feature.jam[tag=doc]
include::../../src/tools/features/find-lib-feature.jam[tag=path-doc]
Expand All @@ -255,6 +256,7 @@ include::../../src/tools/features/rtti-feature.jam[tag=doc]
include::../../src/tools/features/runtime-feature.jam[tag=doc]
include::../../src/tools/features/search-feature.jam[tag=doc]
include::../../src/tools/features/source-feature.jam[tag=doc]
include::../../src/tools/stage.jam[tag=features2-doc]
include::../../src/tools/features/stdlib-feature.jam[tag=doc]
include::../../src/tools/features/strip-feature.jam[tag=doc]
include::../../src/tools/features/dll-feature.jam[tag=suppress-doc]
Expand Down Expand Up @@ -890,6 +892,8 @@ include::regex.adoc[]

include::sequence.adoc[]

include::../../src/tools/stage.jam[tag=doc]

include::type.adoc[]

:leveloffset: -2
Expand Down
Empty file added example/named-install-dirs/a
Empty file.
49 changes: 49 additions & 0 deletions example/named-install-dirs/build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# showcasing several default install directories
install a1 : a : <location>(bindir) ;
install a2 : a : <location>(libdir)/a2 ;
install (sbindir)/a3 : a ;

# using a custom prefix; the file will be installed into foo/bar/bin/a4
install (bindir)/a4 : a : <install-prefix>foo/bar ;

# this one deduces installed package name to be the basename of the project
# directory, so e.g. on Linux the file will be installed installed into
# /usr/local/share/doc/<name of project's directory>/a5
install (docdir)/a5 : a : <install-prefix>bar/baz ;

# use a custom named directory; its default on Linux is /usr/local/share/xyz/
import stage ;
stage.add-install-dir foodir : xyz : datadir ;
install (foodir)/a6 : a ;


# another custom named directory, this one appends package name like docdir;
# so, e.g. on Linux it defaults to /usr/local/lib/named-install-dirs
stage.add-install-dir privatedir : "" : libdir : package-suffix ;
install (privatedir)/a7 : a ;

# using stage.get-package-name
make a8 : a : @write-dirs : <staging-prefix>p/q/r <install-bindir>/bin ;

rule write-dirs ( target : sources * : properties * )
{
import property-set ;
import print ;
local ps = [ property-set.create $(properties) ] ;
local pn = [ stage.get-package-name $(ps) ] ;
print.output $(target) ;
print.text
[ stage.get-dir docdir : $(ps) : $(pn) ]
[ stage.get-dir docdir : $(ps) : $(pn) : staged ]
[ stage.get-dir docdir : $(ps) : $(pn) : relative ]
[ stage.get-dir docdir : $(ps) : $(pn) : relative staged ]
[ stage.get-dir bindir : $(ps) : $(pn) : relative ]
: overwrite
;
}

# using staging prefix; on Linux installs into q/r/s/share/a9
install (datarootdir)/a9 : a : <staging-prefix>q/r/s ;


build-project x ;
5 changes: 5 additions & 0 deletions example/named-install-dirs/x/build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# this subproject showcases installed package name deduction

project subx ;
build-project y ;
build-project z ;
4 changes: 4 additions & 0 deletions example/named-install-dirs/x/y/build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# this subproject doesn't have a name, so its default package name is deduced
# from its parent

install (docdir)/y1 : ../../a ;
6 changes: 6 additions & 0 deletions example/named-install-dirs/x/z/build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this subproject does have a name, so its name is used as its default package
# name

project subz ;

install (docdir)/z1 : ../../a ;
Loading

0 comments on commit 51ad471

Please sign in to comment.