]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/package.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / package.py
1 # Status: ported
2 # Base revision: 64488
3 #
4 # Copyright (c) 2005, 2010 Vladimir Prus.
5 # Copyright 2006 Rene Rivera.
6 #
7 # Use, modification and distribution is subject to the Boost Software
8 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
9 # http://www.boost.org/LICENSE_1_0.txt)
10
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
14 # all.
15
16 # Example usage:
17 #
18 # package.install boost : <properties>
19 # : <binaries>
20 # : <libraries>
21 # : <headers>
22 # ;
23 #
24 # This will install binaries, libraries and headers to the 'proper' location,
25 # given by command line options --prefix, --exec-prefix, --bindir, --libdir and
26 # --includedir.
27 #
28 # The rule is just a convenient wrapper, avoiding the need to define several
29 # 'install' targets.
30 #
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.
35
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
40
41 from b2.build.alias import alias
42
43 from b2.manager import get_manager
44
45 from b2.util import bjam_signature
46 from b2.util.utility import ungrist
47
48
49 import os
50
51 feature.feature("install-default-prefix", [], ["free", "incidental"])
52
53 @bjam_signature((["name", "package_name", "?"], ["requirements", "*"],
54 ["binaries", "*"], ["libraries", "*"], ["headers", "*"]))
55 def install(name, package_name=None, requirements=[], binaries=[], libraries=[], headers=[]):
56
57 requirements = requirements[:]
58 binaries = binaries[:]
59 libraries
60
61 if not package_name:
62 package_name = name
63
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)
71
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
74 # what is needed.
75 install_source_root = property.select('install-source-root', requirements)
76 if install_source_root:
77 requirements = property.change(requirements, 'install-source-root', None)
78
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)
83
84 # First, figure out all locations. Use the default if no prefix option
85 # given.
86 prefix = get_prefix(name, requirements)
87
88 # Architecture dependent files.
89 exec_locate = option.get("exec-prefix", prefix)
90
91 # Binaries.
92 bin_locate = option.get("bindir", os.path.join(prefix, "bin"))
93
94 # Object code libraries.
95 lib_locate = option.get("libdir", os.path.join(prefix, "lib"))
96
97 # Source header files.
98 include_locate = option.get("includedir", os.path.join(prefix, "include"))
99
100 stage.install(name + "-bin", binaries, requirements + ["<location>" + bin_locate])
101
102 alias(name + "-lib", [name + "-lib-shared", name + "-lib-static"])
103
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"])
110
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"])
119
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)
127
128 alias(name, [name + "-bin", name + "-lib", name + "-headers"])
129
130 pt = get_manager().projects().current()
131
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])
134
135 @bjam_signature((["target_name"], ["package_name"], ["data", "*"], ["requirements", "*"]))
136 def install_data(target_name, package_name, data, requirements):
137 if not package_name:
138 package_name = target_name
139
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)
144
145 prefix = get_prefix(package_name, requirements)
146 datadir = option.get("datarootdir", os.path.join(prefix, "share"))
147
148 stage.install(target_name, data,
149 requirements + ["<location>" + os.path.join(datadir, package_name)])
150
151 get_manager().projects().current().mark_targets_as_explicit([target_name])
152
153 def get_prefix(package_name, requirements):
154
155 specified = property.select("install-default-prefix", requirements)
156 if specified:
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.
161 if not prefix:
162 if os.name == "nt":
163 prefix = "C:\\" + package_name
164 elif os.name == "posix":
165 prefix = "/usr/local"
166
167 return prefix
168