blob: 18e5b68dd2e89e1a1e56b3de8608d6e03473a40e [file] [log] [blame]
Nan Zhangdb0b9a32017-02-27 10:12:13 -08001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package python
16
17// This file contains the "Base" module type for building Python program.
18
19import (
20 "fmt"
21 "path/filepath"
22 "regexp"
Nan Zhangdb0b9a32017-02-27 10:12:13 -080023 "strings"
24
25 "github.com/google/blueprint"
Nan Zhangd4e641b2017-07-12 12:55:28 -070026 "github.com/google/blueprint/proptools"
Nan Zhangdb0b9a32017-02-27 10:12:13 -080027
28 "android/soong/android"
29)
30
31func init() {
Paul Duffind0890452021-03-17 21:57:08 +000032 registerPythonMutators(android.InitRegistrationContext)
33}
34
35func registerPythonMutators(ctx android.RegistrationContext) {
36 ctx.PreDepsMutators(RegisterPythonPreDepsMutators)
Liz Kammerdd849a82020-06-12 16:38:45 -070037}
38
Liz Kammerd737d022020-11-16 15:42:51 -080039// Exported to support other packages using Python modules in tests.
Liz Kammerdd849a82020-06-12 16:38:45 -070040func RegisterPythonPreDepsMutators(ctx android.RegisterMutatorsContext) {
Colin Crosse20113d2020-11-22 19:37:44 -080041 ctx.BottomUp("python_version", versionSplitMutator()).Parallel()
Nan Zhangdb0b9a32017-02-27 10:12:13 -080042}
43
Liz Kammerd737d022020-11-16 15:42:51 -080044// the version-specific properties that apply to python modules.
Nan Zhangd4e641b2017-07-12 12:55:28 -070045type VersionProperties struct {
Liz Kammerd737d022020-11-16 15:42:51 -080046 // whether the module is required to be built with this version.
47 // Defaults to true for Python 3, and false otherwise.
Liz Kammer59c0eae2021-09-17 17:48:05 -040048 Enabled *bool
Nan Zhangdb0b9a32017-02-27 10:12:13 -080049
Liz Kammerd737d022020-11-16 15:42:51 -080050 // list of source files specific to this Python version.
51 // Using the syntax ":module", srcs may reference the outputs of other modules that produce source files,
52 // e.g. genrule or filegroup.
Colin Cross27b922f2019-03-04 22:35:41 -080053 Srcs []string `android:"path,arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070054
Liz Kammerd737d022020-11-16 15:42:51 -080055 // list of source files that should not be used to build the Python module for this version.
56 // This is most useful to remove files that are not common to all Python versions.
Colin Cross27b922f2019-03-04 22:35:41 -080057 Exclude_srcs []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080058
Liz Kammerd737d022020-11-16 15:42:51 -080059 // list of the Python libraries used only for this Python version.
Nan Zhangd4e641b2017-07-12 12:55:28 -070060 Libs []string `android:"arch_variant"`
61
Liz Kammerd737d022020-11-16 15:42:51 -080062 // whether the binary is required to be built with embedded launcher for this version, defaults to false.
Liz Kammer59c0eae2021-09-17 17:48:05 -040063 Embedded_launcher *bool // TODO(b/174041232): Remove this property
Nan Zhangdb0b9a32017-02-27 10:12:13 -080064}
65
Liz Kammerd737d022020-11-16 15:42:51 -080066// properties that apply to all python modules
Nan Zhangd4e641b2017-07-12 12:55:28 -070067type BaseProperties struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -080068 // the package path prefix within the output artifact at which to place the source/data
69 // files of the current module.
70 // eg. Pkg_path = "a/b/c"; Other packages can reference this module by using
71 // (from a.b.c import ...) statement.
Nan Zhangbea09752018-05-31 12:49:33 -070072 // if left unspecified, all the source/data files path is unchanged within zip file.
Liz Kammer59c0eae2021-09-17 17:48:05 -040073 Pkg_path *string
Nan Zhangd4e641b2017-07-12 12:55:28 -070074
75 // true, if the Python module is used internally, eg, Python std libs.
Liz Kammer59c0eae2021-09-17 17:48:05 -040076 Is_internal *bool
Nan Zhangdb0b9a32017-02-27 10:12:13 -080077
78 // list of source (.py) files compatible both with Python2 and Python3 used to compile the
79 // Python module.
80 // srcs may reference the outputs of other modules that produce source files like genrule
81 // or filegroup using the syntax ":module".
82 // Srcs has to be non-empty.
Colin Cross27b922f2019-03-04 22:35:41 -080083 Srcs []string `android:"path,arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070084
85 // list of source files that should not be used to build the C/C++ module.
86 // This is most useful in the arch/multilib variants to remove non-common files
Colin Cross27b922f2019-03-04 22:35:41 -080087 Exclude_srcs []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080088
89 // list of files or filegroup modules that provide data that should be installed alongside
90 // the test. the file extension can be arbitrary except for (.py).
Colin Cross27b922f2019-03-04 22:35:41 -080091 Data []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080092
Colin Cross1bc63932020-11-22 20:12:45 -080093 // list of java modules that provide data that should be installed alongside the test.
94 Java_data []string
95
Nan Zhangdb0b9a32017-02-27 10:12:13 -080096 // list of the Python libraries compatible both with Python2 and Python3.
Nan Zhangd4e641b2017-07-12 12:55:28 -070097 Libs []string `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080098
99 Version struct {
Liz Kammerd737d022020-11-16 15:42:51 -0800100 // Python2-specific properties, including whether Python2 is supported for this module
101 // and version-specific sources, exclusions and dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700102 Py2 VersionProperties `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800103
Liz Kammerd737d022020-11-16 15:42:51 -0800104 // Python3-specific properties, including whether Python3 is supported for this module
105 // and version-specific sources, exclusions and dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700106 Py3 VersionProperties `android:"arch_variant"`
107 } `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800108
109 // the actual version each module uses after variations created.
110 // this property name is hidden from users' perspectives, and soong will populate it during
111 // runtime.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700112 Actual_version string `blueprint:"mutated"`
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700113
Liz Kammerd737d022020-11-16 15:42:51 -0800114 // whether the module is required to be built with actual_version.
115 // this is set by the python version mutator based on version-specific properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700116 Enabled *bool `blueprint:"mutated"`
117
Liz Kammerd737d022020-11-16 15:42:51 -0800118 // whether the binary is required to be built with embedded launcher for this actual_version.
119 // this is set by the python version mutator based on version-specific properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700120 Embedded_launcher *bool `blueprint:"mutated"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800121}
122
Liz Kammerd737d022020-11-16 15:42:51 -0800123// Used to store files of current module after expanding dependencies
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800124type pathMapping struct {
125 dest string
126 src android.Path
127}
128
Cole Faust4d247e62023-01-23 10:14:58 -0800129type PythonLibraryModule struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800130 android.ModuleBase
Nan Zhanga3fc4ba2017-07-20 17:43:37 -0700131 android.DefaultableModuleBase
Jingwen Chen13b9b422021-03-08 07:32:28 -0500132 android.BazelModuleBase
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800133
Nan Zhangb8fa1972017-12-22 16:12:00 -0800134 properties BaseProperties
135 protoProperties android.ProtoProperties
Nan Zhangd4e641b2017-07-12 12:55:28 -0700136
137 // initialize before calling Init
138 hod android.HostOrDeviceSupported
139 multilib android.Multilib
140
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800141 // the Python files of current module after expanding source dependencies.
142 // pathMapping: <dest: runfile_path, src: source_path>
143 srcsPathMappings []pathMapping
144
145 // the data files of current module after expanding source dependencies.
146 // pathMapping: <dest: runfile_path, src: source_path>
147 dataPathMappings []pathMapping
148
Cole Faust5c503d12023-01-24 11:48:08 -0800149 // The zip file containing the current module's source/data files.
Nan Zhang1db85402017-12-18 13:20:23 -0800150 srcsZip android.Path
Cole Faust5c503d12023-01-24 11:48:08 -0800151
152 // The zip file containing the current module's source/data files, with the
153 // source files precompiled.
154 precompiledSrcsZip android.Path
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800155}
156
Liz Kammerd737d022020-11-16 15:42:51 -0800157// newModule generates new Python base module
Cole Faust4d247e62023-01-23 10:14:58 -0800158func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *PythonLibraryModule {
159 return &PythonLibraryModule{
Nan Zhangd4e641b2017-07-12 12:55:28 -0700160 hod: hod,
161 multilib: multilib,
162 }
163}
164
Liz Kammerd737d022020-11-16 15:42:51 -0800165// interface implemented by Python modules to provide source and data mappings and zip to python
166// modules that depend on it
167type pythonDependency interface {
168 getSrcsPathMappings() []pathMapping
169 getDataPathMappings() []pathMapping
170 getSrcsZip() android.Path
Cole Faust5c503d12023-01-24 11:48:08 -0800171 getPrecompiledSrcsZip() android.Path
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800172}
173
Liz Kammerd737d022020-11-16 15:42:51 -0800174// getSrcsPathMappings gets this module's path mapping of src source path : runfiles destination
Cole Faust4d247e62023-01-23 10:14:58 -0800175func (p *PythonLibraryModule) getSrcsPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800176 return p.srcsPathMappings
177}
178
Liz Kammerd737d022020-11-16 15:42:51 -0800179// getSrcsPathMappings gets this module's path mapping of data source path : runfiles destination
Cole Faust4d247e62023-01-23 10:14:58 -0800180func (p *PythonLibraryModule) getDataPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800181 return p.dataPathMappings
182}
183
Liz Kammerd737d022020-11-16 15:42:51 -0800184// getSrcsZip returns the filepath where the current module's source/data files are zipped.
Cole Faust4d247e62023-01-23 10:14:58 -0800185func (p *PythonLibraryModule) getSrcsZip() android.Path {
Nan Zhang1db85402017-12-18 13:20:23 -0800186 return p.srcsZip
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800187}
188
Cole Faust5c503d12023-01-24 11:48:08 -0800189// getSrcsZip returns the filepath where the current module's source/data files are zipped.
190func (p *PythonLibraryModule) getPrecompiledSrcsZip() android.Path {
191 return p.precompiledSrcsZip
192}
193
Cole Faust4d247e62023-01-23 10:14:58 -0800194func (p *PythonLibraryModule) getBaseProperties() *BaseProperties {
195 return &p.properties
196}
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800197
Cole Faust4d247e62023-01-23 10:14:58 -0800198var _ pythonDependency = (*PythonLibraryModule)(nil)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800199
Cole Faust4d247e62023-01-23 10:14:58 -0800200func (p *PythonLibraryModule) init() android.Module {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800201 p.AddProperties(&p.properties, &p.protoProperties)
Nan Zhangd4e641b2017-07-12 12:55:28 -0700202 android.InitAndroidArchModule(p, p.hod, p.multilib)
Nan Zhanga3fc4ba2017-07-20 17:43:37 -0700203 android.InitDefaultableModule(p)
Cole Faust4d247e62023-01-23 10:14:58 -0800204 android.InitBazelModule(p)
Nan Zhangd4e641b2017-07-12 12:55:28 -0700205 return p
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800206}
207
Liz Kammerd737d022020-11-16 15:42:51 -0800208// Python-specific tag to transfer information on the purpose of a dependency.
209// This is used when adding a dependency on a module, which can later be accessed when visiting
210// dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700211type dependencyTag struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800212 blueprint.BaseDependencyTag
Nan Zhangd4e641b2017-07-12 12:55:28 -0700213 name string
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800214}
215
Liz Kammerd737d022020-11-16 15:42:51 -0800216// Python-specific tag that indicates that installed files of this module should depend on installed
217// files of the dependency
Colin Crosse9fe2942020-11-10 18:12:15 -0800218type installDependencyTag struct {
219 blueprint.BaseDependencyTag
Liz Kammerd737d022020-11-16 15:42:51 -0800220 // embedding this struct provides the installation dependency requirement
Colin Crosse9fe2942020-11-10 18:12:15 -0800221 android.InstallAlwaysNeededDependencyTag
222 name string
223}
224
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800225var (
Cole Faust5c503d12023-01-24 11:48:08 -0800226 pythonLibTag = dependencyTag{name: "pythonLib"}
227 javaDataTag = dependencyTag{name: "javaData"}
228 // The python interpreter, with soong module name "py3-launcher" or "py3-launcher-autorun".
Cole Faust909d2372023-02-13 23:17:40 +0000229 launcherTag = dependencyTag{name: "launcher"}
230 launcherSharedLibTag = installDependencyTag{name: "launcherSharedLib"}
Cole Faust5c503d12023-01-24 11:48:08 -0800231 // The python interpreter built for host so that we can precompile python sources.
232 // This only works because the precompiled sources don't vary by architecture.
233 // The soong module name is "py3-launcher".
Cole Faust909d2372023-02-13 23:17:40 +0000234 hostLauncherTag = dependencyTag{name: "hostLauncher"}
235 hostlauncherSharedLibTag = dependencyTag{name: "hostlauncherSharedLib"}
236 hostStdLibTag = dependencyTag{name: "hostStdLib"}
237 pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
238 pyExt = ".py"
239 protoExt = ".proto"
240 pyVersion2 = "PY2"
241 pyVersion3 = "PY3"
242 internalPath = "internal"
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800243)
244
Cole Faust4d247e62023-01-23 10:14:58 -0800245type basePropertiesProvider interface {
246 getBaseProperties() *BaseProperties
247}
248
Liz Kammerd737d022020-11-16 15:42:51 -0800249// versionSplitMutator creates version variants for modules and appends the version-specific
250// properties for a given variant to the properties in the variant module
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800251func versionSplitMutator() func(android.BottomUpMutatorContext) {
252 return func(mctx android.BottomUpMutatorContext) {
Cole Faust4d247e62023-01-23 10:14:58 -0800253 if base, ok := mctx.Module().(basePropertiesProvider); ok {
254 props := base.getBaseProperties()
255 var versionNames []string
Liz Kammerd737d022020-11-16 15:42:51 -0800256 // collect version specific properties, so that we can merge version-specific properties
257 // into the module's overall properties
Cole Faust4d247e62023-01-23 10:14:58 -0800258 var versionProps []VersionProperties
Liz Kammerdd849a82020-06-12 16:38:45 -0700259 // PY3 is first so that we alias the PY3 variant rather than PY2 if both
260 // are available
Cole Faust4d247e62023-01-23 10:14:58 -0800261 if proptools.BoolDefault(props.Version.Py3.Enabled, true) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800262 versionNames = append(versionNames, pyVersion3)
Cole Faust4d247e62023-01-23 10:14:58 -0800263 versionProps = append(versionProps, props.Version.Py3)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800264 }
Cole Faust4d247e62023-01-23 10:14:58 -0800265 if proptools.BoolDefault(props.Version.Py2.Enabled, false) {
Liz Kammerdd849a82020-06-12 16:38:45 -0700266 versionNames = append(versionNames, pyVersion2)
Cole Faust4d247e62023-01-23 10:14:58 -0800267 versionProps = append(versionProps, props.Version.Py2)
Liz Kammerdd849a82020-06-12 16:38:45 -0700268 }
Colin Crosse20113d2020-11-22 19:37:44 -0800269 modules := mctx.CreateLocalVariations(versionNames...)
Liz Kammerd737d022020-11-16 15:42:51 -0800270 // Alias module to the first variant
Liz Kammerdd849a82020-06-12 16:38:45 -0700271 if len(versionNames) > 0 {
272 mctx.AliasVariation(versionNames[0])
273 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800274 for i, v := range versionNames {
275 // set the actual version for Python module.
Cole Faust4d247e62023-01-23 10:14:58 -0800276 newProps := modules[i].(basePropertiesProvider).getBaseProperties()
277 newProps.Actual_version = v
Liz Kammerd737d022020-11-16 15:42:51 -0800278 // append versioned properties for the Python module to the overall properties
Cole Faust4d247e62023-01-23 10:14:58 -0800279 err := proptools.AppendMatchingProperties([]interface{}{newProps}, &versionProps[i], nil)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700280 if err != nil {
281 panic(err)
282 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800283 }
284 }
285 }
286}
287
Liz Kammerd737d022020-11-16 15:42:51 -0800288func anyHasExt(paths []string, ext string) bool {
289 for _, p := range paths {
290 if filepath.Ext(p) == ext {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800291 return true
292 }
293 }
294
295 return false
296}
297
Cole Faust4d247e62023-01-23 10:14:58 -0800298func (p *PythonLibraryModule) anySrcHasExt(ctx android.BottomUpMutatorContext, ext string) bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800299 return anyHasExt(p.properties.Srcs, ext)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800300}
301
Liz Kammerd737d022020-11-16 15:42:51 -0800302// DepsMutator mutates dependencies for this module:
Colin Crossd079e0b2022-08-16 10:27:33 -0700303// - handles proto dependencies,
304// - if required, specifies launcher and adds launcher dependencies,
305// - applies python version mutations to Python dependencies
Cole Faust4d247e62023-01-23 10:14:58 -0800306func (p *PythonLibraryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Crossfe17f6f2019-03-28 19:30:56 -0700307 android.ProtoDeps(ctx, &p.protoProperties)
308
Colin Crosse20113d2020-11-22 19:37:44 -0800309 versionVariation := []blueprint.Variation{
310 {"python_version", p.properties.Actual_version},
Nan Zhangb8fa1972017-12-22 16:12:00 -0800311 }
Colin Crosse20113d2020-11-22 19:37:44 -0800312
Liz Kammerd737d022020-11-16 15:42:51 -0800313 // If sources contain a proto file, add dependency on libprotobuf-python
314 if p.anySrcHasExt(ctx, protoExt) && p.Name() != "libprotobuf-python" {
Colin Crosse20113d2020-11-22 19:37:44 -0800315 ctx.AddVariationDependencies(versionVariation, pythonLibTag, "libprotobuf-python")
316 }
Liz Kammerd737d022020-11-16 15:42:51 -0800317
318 // Add python library dependencies for this python version variation
Colin Crosse20113d2020-11-22 19:37:44 -0800319 ctx.AddVariationDependencies(versionVariation, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700320
Colin Cross1bc63932020-11-22 20:12:45 -0800321 // Emulate the data property for java_data but with the arch variation overridden to "common"
322 // so that it can point to java modules.
323 javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
324 ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
Cole Faust5c503d12023-01-24 11:48:08 -0800325
Cole Faust909d2372023-02-13 23:17:40 +0000326 p.AddDepsOnPythonLauncherAndStdlib(ctx, hostStdLibTag, hostLauncherTag, hostlauncherSharedLibTag, false, ctx.Config().BuildOSTarget)
Cole Faust5c503d12023-01-24 11:48:08 -0800327}
328
Cole Faust909d2372023-02-13 23:17:40 +0000329// AddDepsOnPythonLauncherAndStdlib will make the current module depend on the python stdlib,
330// launcher (interpreter), and the launcher's shared libraries. If autorun is true, it will use
331// the autorun launcher instead of the regular one. This function acceps a targetForDeps argument
332// as the target to use for these dependencies. For embedded launcher python binaries, the launcher
333// that will be embedded will be under the same target as the python module itself. But when
334// precompiling python code, we need to get the python launcher built for host, even if we're
335// compiling the python module for device, so we pass a different target to this function.
Cole Faust5c503d12023-01-24 11:48:08 -0800336func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.BottomUpMutatorContext,
Cole Faust909d2372023-02-13 23:17:40 +0000337 stdLibTag, launcherTag, launcherSharedLibTag blueprint.DependencyTag,
Cole Faust5c503d12023-01-24 11:48:08 -0800338 autorun bool, targetForDeps android.Target) {
339 var stdLib string
340 var launcherModule string
Cole Faust909d2372023-02-13 23:17:40 +0000341 // Add launcher shared lib dependencies. Ideally, these should be
342 // derived from the `shared_libs` property of the launcher. TODO: read these from
343 // the python launcher itself using ctx.OtherModuleProvider() or similar on the result
344 // of ctx.AddFarVariationDependencies()
345 launcherSharedLibDeps := []string{
346 "libsqlite",
347 }
348 // Add launcher-specific dependencies for bionic
349 if targetForDeps.Os.Bionic() {
350 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc", "libdl", "libm")
351 }
352 if targetForDeps.Os == android.LinuxMusl && !ctx.Config().HostStaticBinaries() {
353 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc_musl")
354 }
Cole Faust5c503d12023-01-24 11:48:08 -0800355
356 switch p.properties.Actual_version {
357 case pyVersion2:
358 stdLib = "py2-stdlib"
359
360 launcherModule = "py2-launcher"
361 if autorun {
362 launcherModule = "py2-launcher-autorun"
363 }
364
Cole Faust909d2372023-02-13 23:17:40 +0000365 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
Cole Faust5c503d12023-01-24 11:48:08 -0800366 case pyVersion3:
367 stdLib = "py3-stdlib"
368
369 launcherModule = "py3-launcher"
370 if autorun {
371 launcherModule = "py3-launcher-autorun"
372 }
373 if ctx.Config().HostStaticBinaries() && targetForDeps.Os == android.LinuxMusl {
374 launcherModule += "-static"
375 }
Cole Faust909d2372023-02-13 23:17:40 +0000376 if ctx.Device() {
377 launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
378 }
Cole Faust5c503d12023-01-24 11:48:08 -0800379 default:
380 panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
381 p.properties.Actual_version, ctx.ModuleName()))
382 }
383 targetVariations := targetForDeps.Variations()
384 if ctx.ModuleName() != stdLib {
385 stdLibVariations := make([]blueprint.Variation, 0, len(targetVariations)+1)
386 stdLibVariations = append(stdLibVariations, blueprint.Variation{Mutator: "python_version", Variation: p.properties.Actual_version})
387 stdLibVariations = append(stdLibVariations, targetVariations...)
388 // Using AddFarVariationDependencies for all of these because they can be for a different
389 // platform, like if the python module itself was being compiled for device, we may want
390 // the python interpreter built for host so that we can precompile python sources.
391 ctx.AddFarVariationDependencies(stdLibVariations, stdLibTag, stdLib)
392 }
393 ctx.AddFarVariationDependencies(targetVariations, launcherTag, launcherModule)
Cole Faust909d2372023-02-13 23:17:40 +0000394 ctx.AddFarVariationDependencies(targetVariations, launcherSharedLibTag, launcherSharedLibDeps...)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800395}
396
Cole Faust4d247e62023-01-23 10:14:58 -0800397// GenerateAndroidBuildActions performs build actions common to all Python modules
398func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Liz Kammerd737d022020-11-16 15:42:51 -0800399 expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800400
401 // expand data files from "data" property.
Colin Cross8a497952019-03-05 22:25:09 -0800402 expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800403
Colin Cross1bc63932020-11-22 20:12:45 -0800404 // Emulate the data property for java_data dependencies.
405 for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
406 expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
407 }
408
Liz Kammerd737d022020-11-16 15:42:51 -0800409 // Validate pkg_path property
Nan Zhang1db85402017-12-18 13:20:23 -0800410 pkgPath := String(p.properties.Pkg_path)
411 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800412 // TODO: export validation from android/paths.go handling to replace this duplicated functionality
Nan Zhang1db85402017-12-18 13:20:23 -0800413 pkgPath = filepath.Clean(String(p.properties.Pkg_path))
414 if pkgPath == ".." || strings.HasPrefix(pkgPath, "../") ||
415 strings.HasPrefix(pkgPath, "/") {
Nan Zhangd4e641b2017-07-12 12:55:28 -0700416 ctx.PropertyErrorf("pkg_path",
417 "%q must be a relative path contained in par file.",
Nan Zhangea568a42017-11-08 21:20:04 -0800418 String(p.properties.Pkg_path))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700419 return
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800420 }
Liz Kammerd737d022020-11-16 15:42:51 -0800421 }
422 // If property Is_internal is set, prepend pkgPath with internalPath
423 if proptools.BoolDefault(p.properties.Is_internal, false) {
424 pkgPath = filepath.Join(internalPath, pkgPath)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800425 }
426
Liz Kammerd737d022020-11-16 15:42:51 -0800427 // generate src:destination path mappings for this module
Nan Zhang1db85402017-12-18 13:20:23 -0800428 p.genModulePathMappings(ctx, pkgPath, expandedSrcs, expandedData)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800429
Liz Kammerd737d022020-11-16 15:42:51 -0800430 // generate the zipfile of all source and data files
Nan Zhang1db85402017-12-18 13:20:23 -0800431 p.srcsZip = p.createSrcsZip(ctx, pkgPath)
Cole Faust5c503d12023-01-24 11:48:08 -0800432 p.precompiledSrcsZip = p.precompileSrcs(ctx)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800433}
434
Liz Kammerd737d022020-11-16 15:42:51 -0800435func isValidPythonPath(path string) error {
436 identifiers := strings.Split(strings.TrimSuffix(path, filepath.Ext(path)), "/")
437 for _, token := range identifiers {
438 if !pathComponentRegexp.MatchString(token) {
439 return fmt.Errorf("the path %q contains invalid subpath %q. "+
440 "Subpaths must be at least one character long. "+
441 "The first character must an underscore or letter. "+
442 "Following characters may be any of: letter, digit, underscore, hyphen.",
443 path, token)
444 }
445 }
446 return nil
447}
448
449// For this module, generate unique pathMappings: <dest: runfiles_path, src: source_path>
450// for python/data files expanded from properties.
Cole Faust4d247e62023-01-23 10:14:58 -0800451func (p *PythonLibraryModule) genModulePathMappings(ctx android.ModuleContext, pkgPath string,
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800452 expandedSrcs, expandedData android.Paths) {
453 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
Nan Zhangb8fa1972017-12-22 16:12:00 -0800454 // check current module duplicates.
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800455 destToPySrcs := make(map[string]string)
456 destToPyData := make(map[string]string)
457
458 for _, s := range expandedSrcs {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800459 if s.Ext() != pyExt && s.Ext() != protoExt {
460 ctx.PropertyErrorf("srcs", "found non (.py|.proto) file: %q!", s.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800461 continue
462 }
Nan Zhang1db85402017-12-18 13:20:23 -0800463 runfilesPath := filepath.Join(pkgPath, s.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800464 if err := isValidPythonPath(runfilesPath); err != nil {
465 ctx.PropertyErrorf("srcs", err.Error())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800466 }
Liz Kammerd737d022020-11-16 15:42:51 -0800467 if !checkForDuplicateOutputPath(ctx, destToPySrcs, runfilesPath, s.String(), p.Name(), p.Name()) {
468 p.srcsPathMappings = append(p.srcsPathMappings, pathMapping{dest: runfilesPath, src: s})
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800469 }
470 }
471
472 for _, d := range expandedData {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800473 if d.Ext() == pyExt || d.Ext() == protoExt {
474 ctx.PropertyErrorf("data", "found (.py|.proto) file: %q!", d.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800475 continue
476 }
Nan Zhang1db85402017-12-18 13:20:23 -0800477 runfilesPath := filepath.Join(pkgPath, d.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800478 if !checkForDuplicateOutputPath(ctx, destToPyData, runfilesPath, d.String(), p.Name(), p.Name()) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800479 p.dataPathMappings = append(p.dataPathMappings,
480 pathMapping{dest: runfilesPath, src: d})
481 }
482 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800483}
484
Liz Kammerd737d022020-11-16 15:42:51 -0800485// createSrcsZip registers build actions to zip current module's sources and data.
Cole Faust4d247e62023-01-23 10:14:58 -0800486func (p *PythonLibraryModule) createSrcsZip(ctx android.ModuleContext, pkgPath string) android.Path {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800487 relativeRootMap := make(map[string]android.Paths)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800488 var protoSrcs android.Paths
Cole Faust5c503d12023-01-24 11:48:08 -0800489 addPathMapping := func(path pathMapping) {
Liz Kammerd737d022020-11-16 15:42:51 -0800490 // handle proto sources separately
Nan Zhangb8fa1972017-12-22 16:12:00 -0800491 if path.src.Ext() == protoExt {
492 protoSrcs = append(protoSrcs, path.src)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800493 } else {
Cole Faust4d247e62023-01-23 10:14:58 -0800494 relativeRoot := strings.TrimSuffix(path.src.String(), path.src.Rel())
495 relativeRootMap[relativeRoot] = append(relativeRootMap[relativeRoot], path.src)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800496 }
497 }
Cole Faust5c503d12023-01-24 11:48:08 -0800498
499 // "srcs" or "data" properties may contain filegroups so it might happen that
500 // the root directory for each source path is different.
501 for _, path := range p.srcsPathMappings {
502 addPathMapping(path)
503 }
504 for _, path := range p.dataPathMappings {
505 addPathMapping(path)
506 }
507
Nan Zhangb8fa1972017-12-22 16:12:00 -0800508 var zips android.Paths
509 if len(protoSrcs) > 0 {
Colin Cross19878da2019-03-28 14:45:07 -0700510 protoFlags := android.GetProtoFlags(ctx, &p.protoProperties)
511 protoFlags.OutTypeFlag = "--python_out"
512
Cole Faustcaf766b2022-10-21 16:07:56 -0700513 if pkgPath != "" {
Cole Faust43ac21f2022-09-19 11:19:52 -0700514 pkgPathStagingDir := android.PathForModuleGen(ctx, "protos_staged_for_pkg_path")
515 rule := android.NewRuleBuilder(pctx, ctx)
516 var stagedProtoSrcs android.Paths
517 for _, srcFile := range protoSrcs {
518 stagedProtoSrc := pkgPathStagingDir.Join(ctx, pkgPath, srcFile.Rel())
519 rule.Command().Text("mkdir -p").Flag(filepath.Base(stagedProtoSrc.String()))
520 rule.Command().Text("cp -f").Input(srcFile).Output(stagedProtoSrc)
521 stagedProtoSrcs = append(stagedProtoSrcs, stagedProtoSrc)
522 }
523 rule.Build("stage_protos_for_pkg_path", "Stage protos for pkg_path")
524 protoSrcs = stagedProtoSrcs
Cole Faust43ac21f2022-09-19 11:19:52 -0700525 }
526
Nan Zhangb8fa1972017-12-22 16:12:00 -0800527 for _, srcFile := range protoSrcs {
Cole Faustcaf766b2022-10-21 16:07:56 -0700528 zip := genProto(ctx, srcFile, protoFlags)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800529 zips = append(zips, zip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800530 }
531 }
532
Nan Zhangb8fa1972017-12-22 16:12:00 -0800533 if len(relativeRootMap) > 0 {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800534 // in order to keep stable order of soong_zip params, we sort the keys here.
Liz Kammerd737d022020-11-16 15:42:51 -0800535 roots := android.SortedStringKeys(relativeRootMap)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800536
Cole Faust01243362022-06-02 12:11:12 -0700537 // Use -symlinks=false so that the symlinks in the bazel output directory are followed
538 parArgs := []string{"-symlinks=false"}
Nan Zhangf0c4e432018-05-22 14:50:18 -0700539 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800540 // use package path as path prefix
Nan Zhangf0c4e432018-05-22 14:50:18 -0700541 parArgs = append(parArgs, `-P `+pkgPath)
542 }
Liz Kammerd737d022020-11-16 15:42:51 -0800543 paths := android.Paths{}
544 for _, root := range roots {
545 // specify relative root of file in following -f arguments
546 parArgs = append(parArgs, `-C `+root)
547 for _, path := range relativeRootMap[root] {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800548 parArgs = append(parArgs, `-f `+path.String())
Liz Kammerd737d022020-11-16 15:42:51 -0800549 paths = append(paths, path)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800550 }
551 }
552
553 origSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".py.srcszip")
554 ctx.Build(pctx, android.BuildParams{
555 Rule: zip,
556 Description: "python library archive",
557 Output: origSrcsZip,
Liz Kammerd737d022020-11-16 15:42:51 -0800558 // as zip rule does not use $in, there is no real need to distinguish between Inputs and Implicits
559 Implicits: paths,
Nan Zhangb8fa1972017-12-22 16:12:00 -0800560 Args: map[string]string{
561 "args": strings.Join(parArgs, " "),
562 },
563 })
564 zips = append(zips, origSrcsZip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800565 }
Liz Kammerd737d022020-11-16 15:42:51 -0800566 // we may have multiple zips due to separate handling of proto source files
Nan Zhangb8fa1972017-12-22 16:12:00 -0800567 if len(zips) == 1 {
568 return zips[0]
569 } else {
570 combinedSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".srcszip")
571 ctx.Build(pctx, android.BuildParams{
572 Rule: combineZip,
573 Description: "combine python library archive",
574 Output: combinedSrcsZip,
575 Inputs: zips,
576 })
577 return combinedSrcsZip
578 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800579}
580
Cole Faust5c503d12023-01-24 11:48:08 -0800581func (p *PythonLibraryModule) precompileSrcs(ctx android.ModuleContext) android.Path {
582 // To precompile the python sources, we need a python interpreter and stdlib built
583 // for host. We then use those to compile the python sources, which may be used on either
584 // host of device. Python bytecode is architecture agnostic, so we're essentially
585 // "cross compiling" for device here purely by virtue of host and device python bytecode
586 // being the same.
587 var stdLib android.Path
588 var launcher android.Path
589 if ctx.ModuleName() == "py3-stdlib" || ctx.ModuleName() == "py2-stdlib" {
590 stdLib = p.srcsZip
591 } else {
592 ctx.VisitDirectDepsWithTag(hostStdLibTag, func(module android.Module) {
593 if dep, ok := module.(pythonDependency); ok {
594 stdLib = dep.getPrecompiledSrcsZip()
595 }
596 })
597 }
598 ctx.VisitDirectDepsWithTag(hostLauncherTag, func(module android.Module) {
599 if dep, ok := module.(IntermPathProvider); ok {
600 optionalLauncher := dep.IntermPathForModuleOut()
601 if optionalLauncher.Valid() {
602 launcher = optionalLauncher.Path()
603 }
Cole Faust909d2372023-02-13 23:17:40 +0000604 }
605 })
606 var launcherSharedLibs android.Paths
607 var ldLibraryPath []string
608 ctx.VisitDirectDepsWithTag(hostlauncherSharedLibTag, func(module android.Module) {
609 if dep, ok := module.(IntermPathProvider); ok {
610 optionalPath := dep.IntermPathForModuleOut()
611 if optionalPath.Valid() {
612 launcherSharedLibs = append(launcherSharedLibs, optionalPath.Path())
613 ldLibraryPath = append(ldLibraryPath, filepath.Dir(optionalPath.Path().String()))
Cole Faust5c503d12023-01-24 11:48:08 -0800614 }
615 }
616 })
617
618 out := android.PathForModuleOut(ctx, ctx.ModuleName()+".srcszipprecompiled")
619 if stdLib == nil || launcher == nil {
620 // This shouldn't happen in a real build because we'll error out when adding dependencies
621 // on the stdlib and launcher if they don't exist. But some tests set
622 // AllowMissingDependencies.
623 return out
624 }
625 ctx.Build(pctx, android.BuildParams{
626 Rule: precompile,
627 Input: p.srcsZip,
628 Output: out,
629 Implicits: launcherSharedLibs,
630 Description: "Precompile the python sources of " + ctx.ModuleName(),
631 Args: map[string]string{
632 "stdlibZip": stdLib.String(),
633 "launcher": launcher.String(),
634 "ldLibraryPath": strings.Join(ldLibraryPath, ":"),
635 },
636 })
637 return out
638}
639
Cole Faust4d247e62023-01-23 10:14:58 -0800640// isPythonLibModule returns whether the given module is a Python library PythonLibraryModule or not
Nan Zhangd4e641b2017-07-12 12:55:28 -0700641func isPythonLibModule(module blueprint.Module) bool {
Cole Faust4d247e62023-01-23 10:14:58 -0800642 if _, ok := module.(*PythonLibraryModule); ok {
643 if _, ok := module.(*PythonBinaryModule); !ok {
644 return true
645 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700646 }
647 return false
648}
649
Liz Kammerd737d022020-11-16 15:42:51 -0800650// collectPathsFromTransitiveDeps checks for source/data files for duplicate paths
651// for module and its transitive dependencies and collects list of data/source file
652// zips for transitive dependencies.
Cole Faust5c503d12023-01-24 11:48:08 -0800653func (p *PythonLibraryModule) collectPathsFromTransitiveDeps(ctx android.ModuleContext, precompiled bool) android.Paths {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800654 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
655 // check duplicates.
656 destToPySrcs := make(map[string]string)
657 destToPyData := make(map[string]string)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800658 for _, path := range p.srcsPathMappings {
659 destToPySrcs[path.dest] = path.src.String()
660 }
661 for _, path := range p.dataPathMappings {
662 destToPyData[path.dest] = path.src.String()
663 }
664
Colin Cross6b753602018-06-21 13:03:07 -0700665 seen := make(map[android.Module]bool)
666
Cole Faust4d247e62023-01-23 10:14:58 -0800667 var result android.Paths
668
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800669 // visit all its dependencies in depth first.
Colin Cross6b753602018-06-21 13:03:07 -0700670 ctx.WalkDeps(func(child, parent android.Module) bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800671 // we only collect dependencies tagged as python library deps
Colin Cross6b753602018-06-21 13:03:07 -0700672 if ctx.OtherModuleDependencyTag(child) != pythonLibTag {
673 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800674 }
Colin Cross6b753602018-06-21 13:03:07 -0700675 if seen[child] {
676 return false
677 }
678 seen[child] = true
Nan Zhangb8fa1972017-12-22 16:12:00 -0800679 // Python modules only can depend on Python libraries.
Colin Cross6b753602018-06-21 13:03:07 -0700680 if !isPythonLibModule(child) {
Liz Kammerd737d022020-11-16 15:42:51 -0800681 ctx.PropertyErrorf("libs",
Nan Zhangd4e641b2017-07-12 12:55:28 -0700682 "the dependency %q of module %q is not Python library!",
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxd75507f2021-08-20 21:02:43 +0000683 ctx.OtherModuleName(child), ctx.ModuleName())
Nan Zhangd4e641b2017-07-12 12:55:28 -0700684 }
Liz Kammerd737d022020-11-16 15:42:51 -0800685 // collect source and data paths, checking that there are no duplicate output file conflicts
686 if dep, ok := child.(pythonDependency); ok {
687 srcs := dep.getSrcsPathMappings()
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800688 for _, path := range srcs {
Liz Kammerd737d022020-11-16 15:42:51 -0800689 checkForDuplicateOutputPath(ctx, destToPySrcs,
Colin Cross6b753602018-06-21 13:03:07 -0700690 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800691 }
Liz Kammerd737d022020-11-16 15:42:51 -0800692 data := dep.getDataPathMappings()
693 for _, path := range data {
694 checkForDuplicateOutputPath(ctx, destToPyData,
695 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
696 }
Cole Faust5c503d12023-01-24 11:48:08 -0800697 if precompiled {
698 result = append(result, dep.getPrecompiledSrcsZip())
699 } else {
700 result = append(result, dep.getSrcsZip())
701 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800702 }
Colin Cross6b753602018-06-21 13:03:07 -0700703 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800704 })
Cole Faust4d247e62023-01-23 10:14:58 -0800705 return result
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800706}
707
Liz Kammerd737d022020-11-16 15:42:51 -0800708// chckForDuplicateOutputPath checks whether outputPath has already been included in map m, which
709// would result in two files being placed in the same location.
710// If there is a duplicate path, an error is thrown and true is returned
711// Otherwise, outputPath: srcPath is added to m and returns false
712func checkForDuplicateOutputPath(ctx android.ModuleContext, m map[string]string, outputPath, srcPath, curModule, otherModule string) bool {
713 if oldSrcPath, found := m[outputPath]; found {
Nan Zhangbea09752018-05-31 12:49:33 -0700714 ctx.ModuleErrorf("found two files to be placed at the same location within zip %q."+
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800715 " First file: in module %s at path %q."+
716 " Second file: in module %s at path %q.",
Liz Kammerd737d022020-11-16 15:42:51 -0800717 outputPath, curModule, oldSrcPath, otherModule, srcPath)
718 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800719 }
Liz Kammerd737d022020-11-16 15:42:51 -0800720 m[outputPath] = srcPath
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800721
Liz Kammerd737d022020-11-16 15:42:51 -0800722 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800723}
Nan Zhangea568a42017-11-08 21:20:04 -0800724
Liz Kammerd737d022020-11-16 15:42:51 -0800725// InstallInData returns true as Python is not supported in the system partition
Cole Faust4d247e62023-01-23 10:14:58 -0800726func (p *PythonLibraryModule) InstallInData() bool {
Nan Zhangd9ec5e72017-12-01 20:00:31 +0000727 return true
728}
729
Nan Zhangea568a42017-11-08 21:20:04 -0800730var Bool = proptools.Bool
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800731var BoolDefault = proptools.BoolDefault
Nan Zhangea568a42017-11-08 21:20:04 -0800732var String = proptools.String