blob: a078c0b58078d26762398d3921aafb0289d5d4a7 [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() {
Liz Kammerdd849a82020-06-12 16:38:45 -070032 android.PreDepsMutators(RegisterPythonPreDepsMutators)
33}
34
Liz Kammerd737d022020-11-16 15:42:51 -080035// Exported to support other packages using Python modules in tests.
Liz Kammerdd849a82020-06-12 16:38:45 -070036func RegisterPythonPreDepsMutators(ctx android.RegisterMutatorsContext) {
Colin Crosse20113d2020-11-22 19:37:44 -080037 ctx.BottomUp("python_version", versionSplitMutator()).Parallel()
Nan Zhangdb0b9a32017-02-27 10:12:13 -080038}
39
Liz Kammerd737d022020-11-16 15:42:51 -080040// the version-specific properties that apply to python modules.
Nan Zhangd4e641b2017-07-12 12:55:28 -070041type VersionProperties struct {
Liz Kammerd737d022020-11-16 15:42:51 -080042 // whether the module is required to be built with this version.
43 // Defaults to true for Python 3, and false otherwise.
Nan Zhangd4e641b2017-07-12 12:55:28 -070044 Enabled *bool `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080045
Liz Kammerd737d022020-11-16 15:42:51 -080046 // list of source files specific to this Python version.
47 // Using the syntax ":module", srcs may reference the outputs of other modules that produce source files,
48 // e.g. genrule or filegroup.
Colin Cross27b922f2019-03-04 22:35:41 -080049 Srcs []string `android:"path,arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070050
Liz Kammerd737d022020-11-16 15:42:51 -080051 // list of source files that should not be used to build the Python module for this version.
52 // This is most useful to remove files that are not common to all Python versions.
Colin Cross27b922f2019-03-04 22:35:41 -080053 Exclude_srcs []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080054
Liz Kammerd737d022020-11-16 15:42:51 -080055 // list of the Python libraries used only for this Python version.
Nan Zhangd4e641b2017-07-12 12:55:28 -070056 Libs []string `android:"arch_variant"`
57
Liz Kammerd737d022020-11-16 15:42:51 -080058 // whether the binary is required to be built with embedded launcher for this version, defaults to false.
59 Embedded_launcher *bool `android:"arch_variant"` // TODO(b/174041232): Remove this property
Nan Zhangdb0b9a32017-02-27 10:12:13 -080060}
61
Liz Kammerd737d022020-11-16 15:42:51 -080062// properties that apply to all python modules
Nan Zhangd4e641b2017-07-12 12:55:28 -070063type BaseProperties struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -080064 // the package path prefix within the output artifact at which to place the source/data
65 // files of the current module.
66 // eg. Pkg_path = "a/b/c"; Other packages can reference this module by using
67 // (from a.b.c import ...) statement.
Nan Zhangbea09752018-05-31 12:49:33 -070068 // if left unspecified, all the source/data files path is unchanged within zip file.
Nan Zhangea568a42017-11-08 21:20:04 -080069 Pkg_path *string `android:"arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070070
71 // true, if the Python module is used internally, eg, Python std libs.
72 Is_internal *bool `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080073
74 // list of source (.py) files compatible both with Python2 and Python3 used to compile the
75 // Python module.
76 // srcs may reference the outputs of other modules that produce source files like genrule
77 // or filegroup using the syntax ":module".
78 // Srcs has to be non-empty.
Colin Cross27b922f2019-03-04 22:35:41 -080079 Srcs []string `android:"path,arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070080
81 // list of source files that should not be used to build the C/C++ module.
82 // This is most useful in the arch/multilib variants to remove non-common files
Colin Cross27b922f2019-03-04 22:35:41 -080083 Exclude_srcs []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080084
85 // list of files or filegroup modules that provide data that should be installed alongside
86 // the test. the file extension can be arbitrary except for (.py).
Colin Cross27b922f2019-03-04 22:35:41 -080087 Data []string `android:"path,arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080088
Colin Cross1bc63932020-11-22 20:12:45 -080089 // list of java modules that provide data that should be installed alongside the test.
90 Java_data []string
91
Nan Zhangdb0b9a32017-02-27 10:12:13 -080092 // list of the Python libraries compatible both with Python2 and Python3.
Nan Zhangd4e641b2017-07-12 12:55:28 -070093 Libs []string `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080094
95 Version struct {
Liz Kammerd737d022020-11-16 15:42:51 -080096 // Python2-specific properties, including whether Python2 is supported for this module
97 // and version-specific sources, exclusions and dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -070098 Py2 VersionProperties `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -080099
Liz Kammerd737d022020-11-16 15:42:51 -0800100 // Python3-specific properties, including whether Python3 is supported for this module
101 // and version-specific sources, exclusions and dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700102 Py3 VersionProperties `android:"arch_variant"`
103 } `android:"arch_variant"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800104
105 // the actual version each module uses after variations created.
106 // this property name is hidden from users' perspectives, and soong will populate it during
107 // runtime.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700108 Actual_version string `blueprint:"mutated"`
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700109
Liz Kammerd737d022020-11-16 15:42:51 -0800110 // whether the module is required to be built with actual_version.
111 // this is set by the python version mutator based on version-specific properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700112 Enabled *bool `blueprint:"mutated"`
113
Liz Kammerd737d022020-11-16 15:42:51 -0800114 // whether the binary is required to be built with embedded launcher for this actual_version.
115 // this is set by the python version mutator based on version-specific properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700116 Embedded_launcher *bool `blueprint:"mutated"`
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800117}
118
Liz Kammerd737d022020-11-16 15:42:51 -0800119// Used to store files of current module after expanding dependencies
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800120type pathMapping struct {
121 dest string
122 src android.Path
123}
124
Nan Zhangd4e641b2017-07-12 12:55:28 -0700125type Module struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800126 android.ModuleBase
Nan Zhanga3fc4ba2017-07-20 17:43:37 -0700127 android.DefaultableModuleBase
Jingwen Chen13b9b422021-03-08 07:32:28 -0500128 android.BazelModuleBase
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800129
Nan Zhangb8fa1972017-12-22 16:12:00 -0800130 properties BaseProperties
131 protoProperties android.ProtoProperties
Nan Zhangd4e641b2017-07-12 12:55:28 -0700132
133 // initialize before calling Init
134 hod android.HostOrDeviceSupported
135 multilib android.Multilib
136
Liz Kammerd737d022020-11-16 15:42:51 -0800137 // interface used to bootstrap .par executable when embedded_launcher is true
138 // this should be set by Python modules which are runnable, e.g. binaries and tests
139 // bootstrapper might be nil (e.g. Python library module).
Nan Zhangd4e641b2017-07-12 12:55:28 -0700140 bootstrapper bootstrapper
141
Liz Kammerd737d022020-11-16 15:42:51 -0800142 // interface that implements functions required for installation
143 // this should be set by Python modules which are runnable, e.g. binaries and tests
144 // installer might be nil (e.g. Python library module).
Nan Zhangd4e641b2017-07-12 12:55:28 -0700145 installer installer
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800146
147 // the Python files of current module after expanding source dependencies.
148 // pathMapping: <dest: runfile_path, src: source_path>
149 srcsPathMappings []pathMapping
150
151 // the data files of current module after expanding source dependencies.
152 // pathMapping: <dest: runfile_path, src: source_path>
153 dataPathMappings []pathMapping
154
Nan Zhang1db85402017-12-18 13:20:23 -0800155 // the zip filepath for zipping current module source/data files.
156 srcsZip android.Path
Nan Zhangd4e641b2017-07-12 12:55:28 -0700157
Nan Zhang1db85402017-12-18 13:20:23 -0800158 // dependency modules' zip filepath for zipping current module source/data files.
159 depsSrcsZips android.Paths
Nan Zhangd4e641b2017-07-12 12:55:28 -0700160
161 // (.intermediate) module output path as installation source.
162 installSource android.OptionalPath
163
Liz Kammerd737d022020-11-16 15:42:51 -0800164 // Map to ensure sub-part of the AndroidMk for this module is only added once
Nan Zhang5323f8e2017-05-10 13:37:54 -0700165 subAndroidMkOnce map[subAndroidMkProvider]bool
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800166}
167
Liz Kammerd737d022020-11-16 15:42:51 -0800168// newModule generates new Python base module
Nan Zhangd4e641b2017-07-12 12:55:28 -0700169func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
170 return &Module{
171 hod: hod,
172 multilib: multilib,
173 }
174}
175
Liz Kammerd737d022020-11-16 15:42:51 -0800176// bootstrapper interface should be implemented for runnable modules, e.g. binary and test
Nan Zhangd4e641b2017-07-12 12:55:28 -0700177type bootstrapper interface {
178 bootstrapperProps() []interface{}
Nan Zhang1db85402017-12-18 13:20:23 -0800179 bootstrap(ctx android.ModuleContext, ActualVersion string, embeddedLauncher bool,
180 srcsPathMappings []pathMapping, srcsZip android.Path,
181 depsSrcsZips android.Paths) android.OptionalPath
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800182
183 autorun() bool
Nan Zhangd4e641b2017-07-12 12:55:28 -0700184}
185
Liz Kammerd737d022020-11-16 15:42:51 -0800186// installer interface should be implemented for installable modules, e.g. binary and test
Nan Zhangd4e641b2017-07-12 12:55:28 -0700187type installer interface {
188 install(ctx android.ModuleContext, path android.Path)
Logan Chien02880e42018-11-06 17:30:35 +0800189 setAndroidMkSharedLibs(sharedLibs []string)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800190}
191
Liz Kammerd737d022020-11-16 15:42:51 -0800192// interface implemented by Python modules to provide source and data mappings and zip to python
193// modules that depend on it
194type pythonDependency interface {
195 getSrcsPathMappings() []pathMapping
196 getDataPathMappings() []pathMapping
197 getSrcsZip() android.Path
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800198}
199
Liz Kammerd737d022020-11-16 15:42:51 -0800200// getSrcsPathMappings gets this module's path mapping of src source path : runfiles destination
201func (p *Module) getSrcsPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800202 return p.srcsPathMappings
203}
204
Liz Kammerd737d022020-11-16 15:42:51 -0800205// getSrcsPathMappings gets this module's path mapping of data source path : runfiles destination
206func (p *Module) getDataPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800207 return p.dataPathMappings
208}
209
Liz Kammerd737d022020-11-16 15:42:51 -0800210// getSrcsZip returns the filepath where the current module's source/data files are zipped.
211func (p *Module) getSrcsZip() android.Path {
Nan Zhang1db85402017-12-18 13:20:23 -0800212 return p.srcsZip
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800213}
214
Liz Kammerd737d022020-11-16 15:42:51 -0800215var _ pythonDependency = (*Module)(nil)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800216
Liz Kammerd8dceb02020-11-24 08:36:14 -0800217var _ android.AndroidMkEntriesProvider = (*Module)(nil)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800218
Liz Kammerd737d022020-11-16 15:42:51 -0800219func (p *Module) init(additionalProps ...interface{}) android.Module {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800220 p.AddProperties(&p.properties, &p.protoProperties)
Liz Kammerd737d022020-11-16 15:42:51 -0800221
222 // Add additional properties for bootstrapping/installation
223 // This is currently tied to the bootstrapper interface;
224 // however, these are a combination of properties for the installation and bootstrapping of a module
Nan Zhangd4e641b2017-07-12 12:55:28 -0700225 if p.bootstrapper != nil {
226 p.AddProperties(p.bootstrapper.bootstrapperProps()...)
227 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800228
Nan Zhangd4e641b2017-07-12 12:55:28 -0700229 android.InitAndroidArchModule(p, p.hod, p.multilib)
Nan Zhanga3fc4ba2017-07-20 17:43:37 -0700230 android.InitDefaultableModule(p)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800231
Nan Zhangd4e641b2017-07-12 12:55:28 -0700232 return p
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800233}
234
Liz Kammerd737d022020-11-16 15:42:51 -0800235// Python-specific tag to transfer information on the purpose of a dependency.
236// This is used when adding a dependency on a module, which can later be accessed when visiting
237// dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700238type dependencyTag struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800239 blueprint.BaseDependencyTag
Nan Zhangd4e641b2017-07-12 12:55:28 -0700240 name string
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800241}
242
Liz Kammerd737d022020-11-16 15:42:51 -0800243// Python-specific tag that indicates that installed files of this module should depend on installed
244// files of the dependency
Colin Crosse9fe2942020-11-10 18:12:15 -0800245type installDependencyTag struct {
246 blueprint.BaseDependencyTag
Liz Kammerd737d022020-11-16 15:42:51 -0800247 // embedding this struct provides the installation dependency requirement
Colin Crosse9fe2942020-11-10 18:12:15 -0800248 android.InstallAlwaysNeededDependencyTag
249 name string
250}
251
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800252var (
Logan Chien02880e42018-11-06 17:30:35 +0800253 pythonLibTag = dependencyTag{name: "pythonLib"}
Colin Cross1bc63932020-11-22 20:12:45 -0800254 javaDataTag = dependencyTag{name: "javaData"}
Logan Chien02880e42018-11-06 17:30:35 +0800255 launcherTag = dependencyTag{name: "launcher"}
Colin Crosse9fe2942020-11-10 18:12:15 -0800256 launcherSharedLibTag = installDependencyTag{name: "launcherSharedLib"}
Liz Kammerd737d022020-11-16 15:42:51 -0800257 pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
Logan Chien02880e42018-11-06 17:30:35 +0800258 pyExt = ".py"
259 protoExt = ".proto"
260 pyVersion2 = "PY2"
261 pyVersion3 = "PY3"
262 initFileName = "__init__.py"
263 mainFileName = "__main__.py"
264 entryPointFile = "entry_point.txt"
265 parFileExt = ".zip"
Liz Kammerd737d022020-11-16 15:42:51 -0800266 internalPath = "internal"
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800267)
268
Liz Kammerd737d022020-11-16 15:42:51 -0800269// versionSplitMutator creates version variants for modules and appends the version-specific
270// properties for a given variant to the properties in the variant module
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800271func versionSplitMutator() func(android.BottomUpMutatorContext) {
272 return func(mctx android.BottomUpMutatorContext) {
Nan Zhangd4e641b2017-07-12 12:55:28 -0700273 if base, ok := mctx.Module().(*Module); ok {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800274 versionNames := []string{}
Liz Kammerd737d022020-11-16 15:42:51 -0800275 // collect version specific properties, so that we can merge version-specific properties
276 // into the module's overall properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700277 versionProps := []VersionProperties{}
Liz Kammerdd849a82020-06-12 16:38:45 -0700278 // PY3 is first so that we alias the PY3 variant rather than PY2 if both
279 // are available
Liz Kammerd737d022020-11-16 15:42:51 -0800280 if proptools.BoolDefault(base.properties.Version.Py3.Enabled, true) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800281 versionNames = append(versionNames, pyVersion3)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700282 versionProps = append(versionProps, base.properties.Version.Py3)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800283 }
Liz Kammerd737d022020-11-16 15:42:51 -0800284 if proptools.BoolDefault(base.properties.Version.Py2.Enabled, false) {
Liz Kammerdd849a82020-06-12 16:38:45 -0700285 versionNames = append(versionNames, pyVersion2)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700286 versionProps = append(versionProps, base.properties.Version.Py2)
Liz Kammerdd849a82020-06-12 16:38:45 -0700287 }
Colin Crosse20113d2020-11-22 19:37:44 -0800288 modules := mctx.CreateLocalVariations(versionNames...)
Liz Kammerd737d022020-11-16 15:42:51 -0800289 // Alias module to the first variant
Liz Kammerdd849a82020-06-12 16:38:45 -0700290 if len(versionNames) > 0 {
291 mctx.AliasVariation(versionNames[0])
292 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800293 for i, v := range versionNames {
294 // set the actual version for Python module.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700295 modules[i].(*Module).properties.Actual_version = v
Liz Kammerd737d022020-11-16 15:42:51 -0800296 // append versioned properties for the Python module to the overall properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700297 err := proptools.AppendMatchingProperties([]interface{}{&modules[i].(*Module).properties}, &versionProps[i], nil)
298 if err != nil {
299 panic(err)
300 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800301 }
302 }
303 }
304}
305
Liz Kammerd737d022020-11-16 15:42:51 -0800306// HostToolPath returns a path if appropriate such that this module can be used as a host tool,
307// fulfilling HostToolProvider interface.
Nan Zhangb8bdacf2017-12-06 15:13:10 -0800308func (p *Module) HostToolPath() android.OptionalPath {
309 if p.installer == nil {
310 // python_library is just meta module, and doesn't have any installer.
311 return android.OptionalPath{}
312 }
Liz Kammerd737d022020-11-16 15:42:51 -0800313 // TODO: This should only be set when building host binaries -- tests built for device would be
314 // setting this incorrectly.
Nan Zhangb8bdacf2017-12-06 15:13:10 -0800315 return android.OptionalPathForPath(p.installer.(*binaryDecorator).path)
316}
317
Liz Kammerd737d022020-11-16 15:42:51 -0800318// OutputFiles returns output files based on given tag, returns an error if tag is unsupported.
Liz Kammere0070ee2020-06-22 11:52:59 -0700319func (p *Module) OutputFiles(tag string) (android.Paths, error) {
320 switch tag {
321 case "":
322 if outputFile := p.installSource; outputFile.Valid() {
323 return android.Paths{outputFile.Path()}, nil
324 }
325 return android.Paths{}, nil
326 default:
327 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
328 }
329}
330
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700331func (p *Module) isEmbeddedLauncherEnabled() bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800332 return p.installer != nil && Bool(p.properties.Embedded_launcher)
Nan Zhangd4e641b2017-07-12 12:55:28 -0700333}
334
Liz Kammerd737d022020-11-16 15:42:51 -0800335func anyHasExt(paths []string, ext string) bool {
336 for _, p := range paths {
337 if filepath.Ext(p) == ext {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800338 return true
339 }
340 }
341
342 return false
343}
344
Liz Kammerd737d022020-11-16 15:42:51 -0800345func (p *Module) anySrcHasExt(ctx android.BottomUpMutatorContext, ext string) bool {
346 return anyHasExt(p.properties.Srcs, ext)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800347}
348
Liz Kammerd737d022020-11-16 15:42:51 -0800349// DepsMutator mutates dependencies for this module:
350// * handles proto dependencies,
351// * if required, specifies launcher and adds launcher dependencies,
352// * applies python version mutations to Python dependencies
Nan Zhangd4e641b2017-07-12 12:55:28 -0700353func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Crossfe17f6f2019-03-28 19:30:56 -0700354 android.ProtoDeps(ctx, &p.protoProperties)
355
Colin Crosse20113d2020-11-22 19:37:44 -0800356 versionVariation := []blueprint.Variation{
357 {"python_version", p.properties.Actual_version},
Nan Zhangb8fa1972017-12-22 16:12:00 -0800358 }
Colin Crosse20113d2020-11-22 19:37:44 -0800359
Liz Kammerd737d022020-11-16 15:42:51 -0800360 // If sources contain a proto file, add dependency on libprotobuf-python
361 if p.anySrcHasExt(ctx, protoExt) && p.Name() != "libprotobuf-python" {
Colin Crosse20113d2020-11-22 19:37:44 -0800362 ctx.AddVariationDependencies(versionVariation, pythonLibTag, "libprotobuf-python")
363 }
Liz Kammerd737d022020-11-16 15:42:51 -0800364
365 // Add python library dependencies for this python version variation
Colin Crosse20113d2020-11-22 19:37:44 -0800366 ctx.AddVariationDependencies(versionVariation, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700367
Liz Kammerd737d022020-11-16 15:42:51 -0800368 // If this module will be installed and has an embedded launcher, we need to add dependencies for:
369 // * standard library
370 // * launcher
371 // * shared dependencies of the launcher
372 if p.installer != nil && p.isEmbeddedLauncherEnabled() {
373 var stdLib string
374 var launcherModule string
375 // Add launcher shared lib dependencies. Ideally, these should be
376 // derived from the `shared_libs` property of the launcher. However, we
377 // cannot read the property at this stage and it will be too late to add
378 // dependencies later.
379 launcherSharedLibDeps := []string{
380 "libsqlite",
381 }
382 // Add launcher-specific dependencies for bionic
383 if ctx.Target().Os.Bionic() {
384 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc", "libdl", "libm")
385 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700386
Liz Kammerd737d022020-11-16 15:42:51 -0800387 switch p.properties.Actual_version {
388 case pyVersion2:
389 stdLib = "py2-stdlib"
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800390
Liz Kammerd737d022020-11-16 15:42:51 -0800391 launcherModule = "py2-launcher"
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800392 if p.bootstrapper.autorun() {
393 launcherModule = "py2-launcher-autorun"
394 }
Liz Kammerd737d022020-11-16 15:42:51 -0800395 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
Logan Chien02880e42018-11-06 17:30:35 +0800396
Liz Kammerd737d022020-11-16 15:42:51 -0800397 case pyVersion3:
398 stdLib = "py3-stdlib"
Logan Chien02880e42018-11-06 17:30:35 +0800399
Liz Kammerd737d022020-11-16 15:42:51 -0800400 launcherModule = "py3-launcher"
Dan Willemsen8d4d7be2019-11-04 19:21:04 -0800401 if p.bootstrapper.autorun() {
402 launcherModule = "py3-launcher-autorun"
403 }
Dan Willemsen8d4d7be2019-11-04 19:21:04 -0800404
Dan Willemsend7a1dee2020-01-20 22:08:20 -0800405 if ctx.Device() {
Liz Kammerd737d022020-11-16 15:42:51 -0800406 launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
Dan Willemsend7a1dee2020-01-20 22:08:20 -0800407 }
Liz Kammerd737d022020-11-16 15:42:51 -0800408 default:
409 panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
410 p.properties.Actual_version, ctx.ModuleName()))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700411 }
Liz Kammerd737d022020-11-16 15:42:51 -0800412 ctx.AddVariationDependencies(versionVariation, pythonLibTag, stdLib)
413 ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherTag, launcherModule)
414 ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherSharedLibTag, launcherSharedLibDeps...)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800415 }
Colin Cross1bc63932020-11-22 20:12:45 -0800416
417 // Emulate the data property for java_data but with the arch variation overridden to "common"
418 // so that it can point to java modules.
419 javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
420 ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800421}
422
Nan Zhangd4e641b2017-07-12 12:55:28 -0700423func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Liz Kammerd737d022020-11-16 15:42:51 -0800424 p.generatePythonBuildActions(ctx)
Nan Zhang5323f8e2017-05-10 13:37:54 -0700425
Liz Kammerd737d022020-11-16 15:42:51 -0800426 // Only Python binary and test modules have non-empty bootstrapper.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700427 if p.bootstrapper != nil {
Liz Kammerd737d022020-11-16 15:42:51 -0800428 // if the module is being installed, we need to collect all transitive dependencies to embed in
429 // the final par
430 p.collectPathsFromTransitiveDeps(ctx)
431 // bootstrap the module, including resolving main file, getting launcher path, and
432 // registering actions to build the par file
433 // bootstrap returns the binary output path
Nan Zhangd4e641b2017-07-12 12:55:28 -0700434 p.installSource = p.bootstrapper.bootstrap(ctx, p.properties.Actual_version,
Liz Kammerd737d022020-11-16 15:42:51 -0800435 p.isEmbeddedLauncherEnabled(), p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
Nan Zhang5323f8e2017-05-10 13:37:54 -0700436 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700437
Liz Kammerd737d022020-11-16 15:42:51 -0800438 // Only Python binary and test modules have non-empty installer.
Logan Chien02880e42018-11-06 17:30:35 +0800439 if p.installer != nil {
440 var sharedLibs []string
Liz Kammerd737d022020-11-16 15:42:51 -0800441 // if embedded launcher is enabled, we need to collect the shared library depenendencies of the
442 // launcher
Logan Chien02880e42018-11-06 17:30:35 +0800443 ctx.VisitDirectDeps(func(dep android.Module) {
444 if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
445 sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
446 }
447 })
448 p.installer.setAndroidMkSharedLibs(sharedLibs)
449
Liz Kammerd737d022020-11-16 15:42:51 -0800450 // Install the par file from installSource
Logan Chien02880e42018-11-06 17:30:35 +0800451 if p.installSource.Valid() {
452 p.installer.install(ctx, p.installSource.Path())
453 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700454 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800455}
456
Liz Kammerd737d022020-11-16 15:42:51 -0800457// generatePythonBuildActions performs build actions common to all Python modules
458func (p *Module) generatePythonBuildActions(ctx android.ModuleContext) {
459 expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800460 requiresSrcs := true
461 if p.bootstrapper != nil && !p.bootstrapper.autorun() {
462 requiresSrcs = false
463 }
464 if len(expandedSrcs) == 0 && requiresSrcs {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800465 ctx.ModuleErrorf("doesn't have any source files!")
466 }
467
468 // expand data files from "data" property.
Colin Cross8a497952019-03-05 22:25:09 -0800469 expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800470
Colin Cross1bc63932020-11-22 20:12:45 -0800471 // Emulate the data property for java_data dependencies.
472 for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
473 expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
474 }
475
Liz Kammerd737d022020-11-16 15:42:51 -0800476 // Validate pkg_path property
Nan Zhang1db85402017-12-18 13:20:23 -0800477 pkgPath := String(p.properties.Pkg_path)
478 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800479 // TODO: export validation from android/paths.go handling to replace this duplicated functionality
Nan Zhang1db85402017-12-18 13:20:23 -0800480 pkgPath = filepath.Clean(String(p.properties.Pkg_path))
481 if pkgPath == ".." || strings.HasPrefix(pkgPath, "../") ||
482 strings.HasPrefix(pkgPath, "/") {
Nan Zhangd4e641b2017-07-12 12:55:28 -0700483 ctx.PropertyErrorf("pkg_path",
484 "%q must be a relative path contained in par file.",
Nan Zhangea568a42017-11-08 21:20:04 -0800485 String(p.properties.Pkg_path))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700486 return
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800487 }
Liz Kammerd737d022020-11-16 15:42:51 -0800488 }
489 // If property Is_internal is set, prepend pkgPath with internalPath
490 if proptools.BoolDefault(p.properties.Is_internal, false) {
491 pkgPath = filepath.Join(internalPath, pkgPath)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800492 }
493
Liz Kammerd737d022020-11-16 15:42:51 -0800494 // generate src:destination path mappings for this module
Nan Zhang1db85402017-12-18 13:20:23 -0800495 p.genModulePathMappings(ctx, pkgPath, expandedSrcs, expandedData)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800496
Liz Kammerd737d022020-11-16 15:42:51 -0800497 // generate the zipfile of all source and data files
Nan Zhang1db85402017-12-18 13:20:23 -0800498 p.srcsZip = p.createSrcsZip(ctx, pkgPath)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800499}
500
Liz Kammerd737d022020-11-16 15:42:51 -0800501func isValidPythonPath(path string) error {
502 identifiers := strings.Split(strings.TrimSuffix(path, filepath.Ext(path)), "/")
503 for _, token := range identifiers {
504 if !pathComponentRegexp.MatchString(token) {
505 return fmt.Errorf("the path %q contains invalid subpath %q. "+
506 "Subpaths must be at least one character long. "+
507 "The first character must an underscore or letter. "+
508 "Following characters may be any of: letter, digit, underscore, hyphen.",
509 path, token)
510 }
511 }
512 return nil
513}
514
515// For this module, generate unique pathMappings: <dest: runfiles_path, src: source_path>
516// for python/data files expanded from properties.
Nan Zhang1db85402017-12-18 13:20:23 -0800517func (p *Module) genModulePathMappings(ctx android.ModuleContext, pkgPath string,
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800518 expandedSrcs, expandedData android.Paths) {
519 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
Nan Zhangb8fa1972017-12-22 16:12:00 -0800520 // check current module duplicates.
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800521 destToPySrcs := make(map[string]string)
522 destToPyData := make(map[string]string)
523
524 for _, s := range expandedSrcs {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800525 if s.Ext() != pyExt && s.Ext() != protoExt {
526 ctx.PropertyErrorf("srcs", "found non (.py|.proto) file: %q!", s.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800527 continue
528 }
Nan Zhang1db85402017-12-18 13:20:23 -0800529 runfilesPath := filepath.Join(pkgPath, s.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800530 if err := isValidPythonPath(runfilesPath); err != nil {
531 ctx.PropertyErrorf("srcs", err.Error())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800532 }
Liz Kammerd737d022020-11-16 15:42:51 -0800533 if !checkForDuplicateOutputPath(ctx, destToPySrcs, runfilesPath, s.String(), p.Name(), p.Name()) {
534 p.srcsPathMappings = append(p.srcsPathMappings, pathMapping{dest: runfilesPath, src: s})
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800535 }
536 }
537
538 for _, d := range expandedData {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800539 if d.Ext() == pyExt || d.Ext() == protoExt {
540 ctx.PropertyErrorf("data", "found (.py|.proto) file: %q!", d.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800541 continue
542 }
Nan Zhang1db85402017-12-18 13:20:23 -0800543 runfilesPath := filepath.Join(pkgPath, d.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800544 if !checkForDuplicateOutputPath(ctx, destToPyData, runfilesPath, d.String(), p.Name(), p.Name()) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800545 p.dataPathMappings = append(p.dataPathMappings,
546 pathMapping{dest: runfilesPath, src: d})
547 }
548 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800549}
550
Liz Kammerd737d022020-11-16 15:42:51 -0800551// createSrcsZip registers build actions to zip current module's sources and data.
Nan Zhang1db85402017-12-18 13:20:23 -0800552func (p *Module) createSrcsZip(ctx android.ModuleContext, pkgPath string) android.Path {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800553 relativeRootMap := make(map[string]android.Paths)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800554 pathMappings := append(p.srcsPathMappings, p.dataPathMappings...)
555
Nan Zhangb8fa1972017-12-22 16:12:00 -0800556 var protoSrcs android.Paths
Liz Kammerd737d022020-11-16 15:42:51 -0800557 // "srcs" or "data" properties may contain filegroup so it might happen that
558 // the root directory for each source path is different.
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800559 for _, path := range pathMappings {
Liz Kammerd737d022020-11-16 15:42:51 -0800560 // handle proto sources separately
Nan Zhangb8fa1972017-12-22 16:12:00 -0800561 if path.src.Ext() == protoExt {
562 protoSrcs = append(protoSrcs, path.src)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800563 } else {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800564 var relativeRoot string
565 relativeRoot = strings.TrimSuffix(path.src.String(), path.src.Rel())
566 if v, found := relativeRootMap[relativeRoot]; found {
567 relativeRootMap[relativeRoot] = append(v, path.src)
568 } else {
569 relativeRootMap[relativeRoot] = android.Paths{path.src}
570 }
571 }
572 }
573 var zips android.Paths
574 if len(protoSrcs) > 0 {
Colin Cross19878da2019-03-28 14:45:07 -0700575 protoFlags := android.GetProtoFlags(ctx, &p.protoProperties)
576 protoFlags.OutTypeFlag = "--python_out"
577
Nan Zhangb8fa1972017-12-22 16:12:00 -0800578 for _, srcFile := range protoSrcs {
Colin Cross19878da2019-03-28 14:45:07 -0700579 zip := genProto(ctx, srcFile, protoFlags, pkgPath)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800580 zips = append(zips, zip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800581 }
582 }
583
Nan Zhangb8fa1972017-12-22 16:12:00 -0800584 if len(relativeRootMap) > 0 {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800585 // in order to keep stable order of soong_zip params, we sort the keys here.
Liz Kammerd737d022020-11-16 15:42:51 -0800586 roots := android.SortedStringKeys(relativeRootMap)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800587
588 parArgs := []string{}
Nan Zhangf0c4e432018-05-22 14:50:18 -0700589 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800590 // use package path as path prefix
Nan Zhangf0c4e432018-05-22 14:50:18 -0700591 parArgs = append(parArgs, `-P `+pkgPath)
592 }
Liz Kammerd737d022020-11-16 15:42:51 -0800593 paths := android.Paths{}
594 for _, root := range roots {
595 // specify relative root of file in following -f arguments
596 parArgs = append(parArgs, `-C `+root)
597 for _, path := range relativeRootMap[root] {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800598 parArgs = append(parArgs, `-f `+path.String())
Liz Kammerd737d022020-11-16 15:42:51 -0800599 paths = append(paths, path)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800600 }
601 }
602
603 origSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".py.srcszip")
604 ctx.Build(pctx, android.BuildParams{
605 Rule: zip,
606 Description: "python library archive",
607 Output: origSrcsZip,
Liz Kammerd737d022020-11-16 15:42:51 -0800608 // as zip rule does not use $in, there is no real need to distinguish between Inputs and Implicits
609 Implicits: paths,
Nan Zhangb8fa1972017-12-22 16:12:00 -0800610 Args: map[string]string{
611 "args": strings.Join(parArgs, " "),
612 },
613 })
614 zips = append(zips, origSrcsZip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800615 }
Liz Kammerd737d022020-11-16 15:42:51 -0800616 // we may have multiple zips due to separate handling of proto source files
Nan Zhangb8fa1972017-12-22 16:12:00 -0800617 if len(zips) == 1 {
618 return zips[0]
619 } else {
620 combinedSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".srcszip")
621 ctx.Build(pctx, android.BuildParams{
622 Rule: combineZip,
623 Description: "combine python library archive",
624 Output: combinedSrcsZip,
625 Inputs: zips,
626 })
627 return combinedSrcsZip
628 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800629}
630
Liz Kammerd737d022020-11-16 15:42:51 -0800631// isPythonLibModule returns whether the given module is a Python library Module or not
632// This is distinguished by the fact that Python libraries are not installable, while other Python
633// modules are.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700634func isPythonLibModule(module blueprint.Module) bool {
635 if m, ok := module.(*Module); ok {
Liz Kammerd737d022020-11-16 15:42:51 -0800636 // Python library has no bootstrapper or installer
637 if m.bootstrapper == nil && m.installer == nil {
638 return true
Nan Zhangd4e641b2017-07-12 12:55:28 -0700639 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700640 }
641 return false
642}
643
Liz Kammerd737d022020-11-16 15:42:51 -0800644// collectPathsFromTransitiveDeps checks for source/data files for duplicate paths
645// for module and its transitive dependencies and collects list of data/source file
646// zips for transitive dependencies.
647func (p *Module) collectPathsFromTransitiveDeps(ctx android.ModuleContext) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800648 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
649 // check duplicates.
650 destToPySrcs := make(map[string]string)
651 destToPyData := make(map[string]string)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800652 for _, path := range p.srcsPathMappings {
653 destToPySrcs[path.dest] = path.src.String()
654 }
655 for _, path := range p.dataPathMappings {
656 destToPyData[path.dest] = path.src.String()
657 }
658
Colin Cross6b753602018-06-21 13:03:07 -0700659 seen := make(map[android.Module]bool)
660
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800661 // visit all its dependencies in depth first.
Colin Cross6b753602018-06-21 13:03:07 -0700662 ctx.WalkDeps(func(child, parent android.Module) bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800663 // we only collect dependencies tagged as python library deps
Colin Cross6b753602018-06-21 13:03:07 -0700664 if ctx.OtherModuleDependencyTag(child) != pythonLibTag {
665 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800666 }
Colin Cross6b753602018-06-21 13:03:07 -0700667 if seen[child] {
668 return false
669 }
670 seen[child] = true
Nan Zhangb8fa1972017-12-22 16:12:00 -0800671 // Python modules only can depend on Python libraries.
Colin Cross6b753602018-06-21 13:03:07 -0700672 if !isPythonLibModule(child) {
Liz Kammerd737d022020-11-16 15:42:51 -0800673 ctx.PropertyErrorf("libs",
Nan Zhangd4e641b2017-07-12 12:55:28 -0700674 "the dependency %q of module %q is not Python library!",
Liz Kammerd737d022020-11-16 15:42:51 -0800675 ctx.ModuleName(), ctx.OtherModuleName(child))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700676 }
Liz Kammerd737d022020-11-16 15:42:51 -0800677 // collect source and data paths, checking that there are no duplicate output file conflicts
678 if dep, ok := child.(pythonDependency); ok {
679 srcs := dep.getSrcsPathMappings()
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800680 for _, path := range srcs {
Liz Kammerd737d022020-11-16 15:42:51 -0800681 checkForDuplicateOutputPath(ctx, destToPySrcs,
Colin Cross6b753602018-06-21 13:03:07 -0700682 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800683 }
Liz Kammerd737d022020-11-16 15:42:51 -0800684 data := dep.getDataPathMappings()
685 for _, path := range data {
686 checkForDuplicateOutputPath(ctx, destToPyData,
687 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
688 }
689 p.depsSrcsZips = append(p.depsSrcsZips, dep.getSrcsZip())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800690 }
Colin Cross6b753602018-06-21 13:03:07 -0700691 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800692 })
693}
694
Liz Kammerd737d022020-11-16 15:42:51 -0800695// chckForDuplicateOutputPath checks whether outputPath has already been included in map m, which
696// would result in two files being placed in the same location.
697// If there is a duplicate path, an error is thrown and true is returned
698// Otherwise, outputPath: srcPath is added to m and returns false
699func checkForDuplicateOutputPath(ctx android.ModuleContext, m map[string]string, outputPath, srcPath, curModule, otherModule string) bool {
700 if oldSrcPath, found := m[outputPath]; found {
Nan Zhangbea09752018-05-31 12:49:33 -0700701 ctx.ModuleErrorf("found two files to be placed at the same location within zip %q."+
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800702 " First file: in module %s at path %q."+
703 " Second file: in module %s at path %q.",
Liz Kammerd737d022020-11-16 15:42:51 -0800704 outputPath, curModule, oldSrcPath, otherModule, srcPath)
705 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800706 }
Liz Kammerd737d022020-11-16 15:42:51 -0800707 m[outputPath] = srcPath
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800708
Liz Kammerd737d022020-11-16 15:42:51 -0800709 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800710}
Nan Zhangea568a42017-11-08 21:20:04 -0800711
Liz Kammerd737d022020-11-16 15:42:51 -0800712// InstallInData returns true as Python is not supported in the system partition
Nan Zhangd9ec5e72017-12-01 20:00:31 +0000713func (p *Module) InstallInData() bool {
714 return true
715}
716
Nan Zhangea568a42017-11-08 21:20:04 -0800717var Bool = proptools.Bool
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800718var BoolDefault = proptools.BoolDefault
Nan Zhangea568a42017-11-08 21:20:04 -0800719var String = proptools.String