]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/package.py
4 # Copyright (c) 2005, 2010 Vladimir Prus.
5 # Copyright 2006 Rene Rivera.
7 # Use, modification and distribution is subject to the Boost Software
8 # License Version 1.0. (See accompanying file LICENSE.txt or
9 # https://www.bfgroup.xyz/b2/LICENSE.txt)
11 # Provides mechanism for installing whole packages into a specific directory
12 # structure. This is opposed to the 'install' rule, that installs a number of
13 # targets to a single directory, and does not care about directory structure at
18 # package.install boost : <properties>
24 # This will install binaries, libraries and headers to the 'proper' location,
25 # given by command line options --prefix, --exec-prefix, --bindir, --libdir and
28 # The rule is just a convenient wrapper, avoiding the need to define several
31 # The only install-related feature is <install-source-root>. It will apply to
32 # headers only and if present, paths of headers relatively to source root will
33 # be retained after installing. If it is not specified, then "." is assumed, so
34 # relative paths in headers are always preserved.
36 import b2
.build
.feature
as feature
37 import b2
.build
.property as property
38 import b2
.util
.option
as option
39 import b2
.tools
.stage
as stage
41 from b2
.build
.alias
import alias
43 from b2
.manager
import get_manager
45 from b2
.util
import bjam_signature
46 from b2
.util
.utility
import ungrist
51 feature
.feature("install-default-prefix", [], ["free", "incidental"])
53 @bjam_signature((["name", "package_name", "?"], ["requirements", "*"],
54 ["binaries", "*"], ["libraries", "*"], ["headers", "*"]))
55 def install(name
, package_name
=None, requirements
=[], binaries
=[], libraries
=[], headers
=[]):
57 requirements
= requirements
[:]
58 binaries
= binaries
[:]
64 if option
.get("prefix"):
65 # If --prefix is explicitly specified on the command line,
66 # then we need wipe away any settings of libdir/includir that
67 # is specified via options in config files.
68 option
.set("bindir", None)
69 option
.set("libdir", None)
70 option
.set("includedir", None)
72 # If <install-source-root> is not specified, all headers are installed to
73 # prefix/include, no matter what their relative path is. Sometimes that is
75 install_source_root
= property.select('install-source-root', requirements
)
76 if install_source_root
:
77 requirements
= property.change(requirements
, 'install-source-root', None)
79 install_header_subdir
= property.select('install-header-subdir', requirements
)
80 if install_header_subdir
:
81 install_header_subdir
= ungrist(install_header_subdir
[0])
82 requirements
= property.change(requirements
, 'install-header-subdir', None)
84 # First, figure out all locations. Use the default if no prefix option
86 prefix
= get_prefix(name
, requirements
)
88 # Architecture dependent files.
89 exec_locate
= option
.get("exec-prefix", prefix
)
92 bin_locate
= option
.get("bindir", os
.path
.join(prefix
, "bin"))
94 # Object code libraries.
95 lib_locate
= option
.get("libdir", os
.path
.join(prefix
, "lib"))
97 # Source header files.
98 include_locate
= option
.get("includedir", os
.path
.join(prefix
, "include"))
100 stage
.install(name
+ "-bin", binaries
, requirements
+ ["<location>" + bin_locate
])
102 alias(name
+ "-lib", [name
+ "-lib-shared", name
+ "-lib-static"])
104 # Since the install location of shared libraries differs on universe
105 # and cygwin, use target alternatives to make different targets.
106 # We should have used indirection conditioanl requirements, but it's
107 # awkward to pass bin-locate and lib-locate from there to another rule.
108 alias(name
+ "-lib-shared", [name
+ "-lib-shared-universe"])
109 alias(name
+ "-lib-shared", [name
+ "-lib-shared-cygwin"], ["<target-os>cygwin"])
111 # For shared libraries, we install both explicitly specified one and the
112 # shared libraries that the installed executables depend on.
113 stage
.install(name
+ "-lib-shared-universe", binaries
+ libraries
,
114 requirements
+ ["<location>" + lib_locate
, "<install-dependencies>on",
115 "<install-type>SHARED_LIB"])
116 stage
.install(name
+ "-lib-shared-cygwin", binaries
+ libraries
,
117 requirements
+ ["<location>" + bin_locate
, "<install-dependencies>on",
118 "<install-type>SHARED_LIB"])
120 # For static libraries, we do not care about executable dependencies, since
121 # static libraries are already incorporated into them.
122 stage
.install(name
+ "-lib-static", libraries
, requirements
+
123 ["<location>" + lib_locate
, "<install-dependencies>on", "<install-type>STATIC_LIB"])
124 stage
.install(name
+ "-headers", headers
, requirements \
125 + ["<location>" + os
.path
.join(include_locate
, s
) for s
in install_header_subdir
]
126 + install_source_root
)
128 alias(name
, [name
+ "-bin", name
+ "-lib", name
+ "-headers"])
130 pt
= get_manager().projects().current()
132 for subname
in ["bin", "lib", "headers", "lib-shared", "lib-static", "lib-shared-universe", "lib-shared-cygwin"]:
133 pt
.mark_targets_as_explicit([name
+ "-" + subname
])
135 @bjam_signature((["target_name"], ["package_name"], ["data", "*"], ["requirements", "*"]))
136 def install_data(target_name
, package_name
, data
, requirements
):
138 package_name
= target_name
140 if option
.get("prefix"):
141 # If --prefix is explicitly specified on the command line,
142 # then we need wipe away any settings of datarootdir
143 option
.set("datarootdir", None)
145 prefix
= get_prefix(package_name
, requirements
)
146 datadir
= option
.get("datarootdir", os
.path
.join(prefix
, "share"))
148 stage
.install(target_name
, data
,
149 requirements
+ ["<location>" + os
.path
.join(datadir
, package_name
)])
151 get_manager().projects().current().mark_targets_as_explicit([target_name
])
153 def get_prefix(package_name
, requirements
):
155 specified
= property.select("install-default-prefix", requirements
)
157 specified
= ungrist(specified
[0])
158 prefix
= option
.get("prefix", specified
)
159 requirements
= property.change(requirements
, "install-default-prefix", None)
160 # Or some likely defaults if neither is given.
163 prefix
= "C:\\" + package_name
164 elif os
.name
== "posix":
165 prefix
= "/usr/local"