blob: 4444a70e6951d147a39511d6de8b4f44f792fc05 [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.
Nan Zhangd4e641b2017-07-12 12:55:28 -070048 Enabled *bool `android:"arch_variant"`
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.
63 Embedded_launcher *bool `android:"arch_variant"` // 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.
Nan Zhangea568a42017-11-08 21:20:04 -080073 Pkg_path *string `android:"arch_variant"`
Nan Zhangd4e641b2017-07-12 12:55:28 -070074
75 // true, if the Python module is used internally, eg, Python std libs.
76 Is_internal *bool `android:"arch_variant"`
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
Nan Zhangd4e641b2017-07-12 12:55:28 -0700129type Module 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
Liz Kammerd737d022020-11-16 15:42:51 -0800141 // interface used to bootstrap .par executable when embedded_launcher is true
142 // this should be set by Python modules which are runnable, e.g. binaries and tests
143 // bootstrapper might be nil (e.g. Python library module).
Nan Zhangd4e641b2017-07-12 12:55:28 -0700144 bootstrapper bootstrapper
145
Liz Kammerd737d022020-11-16 15:42:51 -0800146 // interface that implements functions required for installation
147 // this should be set by Python modules which are runnable, e.g. binaries and tests
148 // installer might be nil (e.g. Python library module).
Nan Zhangd4e641b2017-07-12 12:55:28 -0700149 installer installer
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800150
151 // the Python files of current module after expanding source dependencies.
152 // pathMapping: <dest: runfile_path, src: source_path>
153 srcsPathMappings []pathMapping
154
155 // the data files of current module after expanding source dependencies.
156 // pathMapping: <dest: runfile_path, src: source_path>
157 dataPathMappings []pathMapping
158
Nan Zhang1db85402017-12-18 13:20:23 -0800159 // the zip filepath for zipping current module source/data files.
160 srcsZip android.Path
Nan Zhangd4e641b2017-07-12 12:55:28 -0700161
Nan Zhang1db85402017-12-18 13:20:23 -0800162 // dependency modules' zip filepath for zipping current module source/data files.
163 depsSrcsZips android.Paths
Nan Zhangd4e641b2017-07-12 12:55:28 -0700164
165 // (.intermediate) module output path as installation source.
166 installSource android.OptionalPath
167
Liz Kammerd737d022020-11-16 15:42:51 -0800168 // Map to ensure sub-part of the AndroidMk for this module is only added once
Nan Zhang5323f8e2017-05-10 13:37:54 -0700169 subAndroidMkOnce map[subAndroidMkProvider]bool
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800170}
171
Liz Kammerd737d022020-11-16 15:42:51 -0800172// newModule generates new Python base module
Nan Zhangd4e641b2017-07-12 12:55:28 -0700173func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
174 return &Module{
175 hod: hod,
176 multilib: multilib,
177 }
178}
179
Liz Kammerd737d022020-11-16 15:42:51 -0800180// bootstrapper interface should be implemented for runnable modules, e.g. binary and test
Nan Zhangd4e641b2017-07-12 12:55:28 -0700181type bootstrapper interface {
182 bootstrapperProps() []interface{}
Nan Zhang1db85402017-12-18 13:20:23 -0800183 bootstrap(ctx android.ModuleContext, ActualVersion string, embeddedLauncher bool,
184 srcsPathMappings []pathMapping, srcsZip android.Path,
185 depsSrcsZips android.Paths) android.OptionalPath
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800186
187 autorun() bool
Nan Zhangd4e641b2017-07-12 12:55:28 -0700188}
189
Liz Kammerd737d022020-11-16 15:42:51 -0800190// installer interface should be implemented for installable modules, e.g. binary and test
Nan Zhangd4e641b2017-07-12 12:55:28 -0700191type installer interface {
192 install(ctx android.ModuleContext, path android.Path)
Logan Chien02880e42018-11-06 17:30:35 +0800193 setAndroidMkSharedLibs(sharedLibs []string)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800194}
195
Liz Kammerd737d022020-11-16 15:42:51 -0800196// interface implemented by Python modules to provide source and data mappings and zip to python
197// modules that depend on it
198type pythonDependency interface {
199 getSrcsPathMappings() []pathMapping
200 getDataPathMappings() []pathMapping
201 getSrcsZip() android.Path
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800202}
203
Liz Kammerd737d022020-11-16 15:42:51 -0800204// getSrcsPathMappings gets this module's path mapping of src source path : runfiles destination
205func (p *Module) getSrcsPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800206 return p.srcsPathMappings
207}
208
Liz Kammerd737d022020-11-16 15:42:51 -0800209// getSrcsPathMappings gets this module's path mapping of data source path : runfiles destination
210func (p *Module) getDataPathMappings() []pathMapping {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800211 return p.dataPathMappings
212}
213
Liz Kammerd737d022020-11-16 15:42:51 -0800214// getSrcsZip returns the filepath where the current module's source/data files are zipped.
215func (p *Module) getSrcsZip() android.Path {
Nan Zhang1db85402017-12-18 13:20:23 -0800216 return p.srcsZip
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800217}
218
Liz Kammerd737d022020-11-16 15:42:51 -0800219var _ pythonDependency = (*Module)(nil)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800220
Liz Kammerd8dceb02020-11-24 08:36:14 -0800221var _ android.AndroidMkEntriesProvider = (*Module)(nil)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800222
Liz Kammerd737d022020-11-16 15:42:51 -0800223func (p *Module) init(additionalProps ...interface{}) android.Module {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800224 p.AddProperties(&p.properties, &p.protoProperties)
Liz Kammerd737d022020-11-16 15:42:51 -0800225
226 // Add additional properties for bootstrapping/installation
227 // This is currently tied to the bootstrapper interface;
228 // however, these are a combination of properties for the installation and bootstrapping of a module
Nan Zhangd4e641b2017-07-12 12:55:28 -0700229 if p.bootstrapper != nil {
230 p.AddProperties(p.bootstrapper.bootstrapperProps()...)
231 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800232
Nan Zhangd4e641b2017-07-12 12:55:28 -0700233 android.InitAndroidArchModule(p, p.hod, p.multilib)
Nan Zhanga3fc4ba2017-07-20 17:43:37 -0700234 android.InitDefaultableModule(p)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800235
Nan Zhangd4e641b2017-07-12 12:55:28 -0700236 return p
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800237}
238
Liz Kammerd737d022020-11-16 15:42:51 -0800239// Python-specific tag to transfer information on the purpose of a dependency.
240// This is used when adding a dependency on a module, which can later be accessed when visiting
241// dependencies.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700242type dependencyTag struct {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800243 blueprint.BaseDependencyTag
Nan Zhangd4e641b2017-07-12 12:55:28 -0700244 name string
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800245}
246
Liz Kammerd737d022020-11-16 15:42:51 -0800247// Python-specific tag that indicates that installed files of this module should depend on installed
248// files of the dependency
Colin Crosse9fe2942020-11-10 18:12:15 -0800249type installDependencyTag struct {
250 blueprint.BaseDependencyTag
Liz Kammerd737d022020-11-16 15:42:51 -0800251 // embedding this struct provides the installation dependency requirement
Colin Crosse9fe2942020-11-10 18:12:15 -0800252 android.InstallAlwaysNeededDependencyTag
253 name string
254}
255
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800256var (
Logan Chien02880e42018-11-06 17:30:35 +0800257 pythonLibTag = dependencyTag{name: "pythonLib"}
Colin Cross1bc63932020-11-22 20:12:45 -0800258 javaDataTag = dependencyTag{name: "javaData"}
Logan Chien02880e42018-11-06 17:30:35 +0800259 launcherTag = dependencyTag{name: "launcher"}
Colin Crosse9fe2942020-11-10 18:12:15 -0800260 launcherSharedLibTag = installDependencyTag{name: "launcherSharedLib"}
Liz Kammerd737d022020-11-16 15:42:51 -0800261 pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
Logan Chien02880e42018-11-06 17:30:35 +0800262 pyExt = ".py"
263 protoExt = ".proto"
264 pyVersion2 = "PY2"
265 pyVersion3 = "PY3"
266 initFileName = "__init__.py"
267 mainFileName = "__main__.py"
268 entryPointFile = "entry_point.txt"
269 parFileExt = ".zip"
Liz Kammerd737d022020-11-16 15:42:51 -0800270 internalPath = "internal"
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800271)
272
Liz Kammerd737d022020-11-16 15:42:51 -0800273// versionSplitMutator creates version variants for modules and appends the version-specific
274// properties for a given variant to the properties in the variant module
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800275func versionSplitMutator() func(android.BottomUpMutatorContext) {
276 return func(mctx android.BottomUpMutatorContext) {
Nan Zhangd4e641b2017-07-12 12:55:28 -0700277 if base, ok := mctx.Module().(*Module); ok {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800278 versionNames := []string{}
Liz Kammerd737d022020-11-16 15:42:51 -0800279 // collect version specific properties, so that we can merge version-specific properties
280 // into the module's overall properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700281 versionProps := []VersionProperties{}
Liz Kammerdd849a82020-06-12 16:38:45 -0700282 // PY3 is first so that we alias the PY3 variant rather than PY2 if both
283 // are available
Liz Kammerd737d022020-11-16 15:42:51 -0800284 if proptools.BoolDefault(base.properties.Version.Py3.Enabled, true) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800285 versionNames = append(versionNames, pyVersion3)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700286 versionProps = append(versionProps, base.properties.Version.Py3)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800287 }
Liz Kammerd737d022020-11-16 15:42:51 -0800288 if proptools.BoolDefault(base.properties.Version.Py2.Enabled, false) {
Liz Kammerdd849a82020-06-12 16:38:45 -0700289 versionNames = append(versionNames, pyVersion2)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700290 versionProps = append(versionProps, base.properties.Version.Py2)
Liz Kammerdd849a82020-06-12 16:38:45 -0700291 }
Colin Crosse20113d2020-11-22 19:37:44 -0800292 modules := mctx.CreateLocalVariations(versionNames...)
Liz Kammerd737d022020-11-16 15:42:51 -0800293 // Alias module to the first variant
Liz Kammerdd849a82020-06-12 16:38:45 -0700294 if len(versionNames) > 0 {
295 mctx.AliasVariation(versionNames[0])
296 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800297 for i, v := range versionNames {
298 // set the actual version for Python module.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700299 modules[i].(*Module).properties.Actual_version = v
Liz Kammerd737d022020-11-16 15:42:51 -0800300 // append versioned properties for the Python module to the overall properties
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700301 err := proptools.AppendMatchingProperties([]interface{}{&modules[i].(*Module).properties}, &versionProps[i], nil)
302 if err != nil {
303 panic(err)
304 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800305 }
306 }
307 }
308}
309
Liz Kammerd737d022020-11-16 15:42:51 -0800310// HostToolPath returns a path if appropriate such that this module can be used as a host tool,
311// fulfilling HostToolProvider interface.
Nan Zhangb8bdacf2017-12-06 15:13:10 -0800312func (p *Module) HostToolPath() android.OptionalPath {
313 if p.installer == nil {
314 // python_library is just meta module, and doesn't have any installer.
315 return android.OptionalPath{}
316 }
Liz Kammerd737d022020-11-16 15:42:51 -0800317 // TODO: This should only be set when building host binaries -- tests built for device would be
318 // setting this incorrectly.
Nan Zhangb8bdacf2017-12-06 15:13:10 -0800319 return android.OptionalPathForPath(p.installer.(*binaryDecorator).path)
320}
321
Liz Kammerd737d022020-11-16 15:42:51 -0800322// OutputFiles returns output files based on given tag, returns an error if tag is unsupported.
Liz Kammere0070ee2020-06-22 11:52:59 -0700323func (p *Module) OutputFiles(tag string) (android.Paths, error) {
324 switch tag {
325 case "":
326 if outputFile := p.installSource; outputFile.Valid() {
327 return android.Paths{outputFile.Path()}, nil
328 }
329 return android.Paths{}, nil
330 default:
331 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
332 }
333}
334
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700335func (p *Module) isEmbeddedLauncherEnabled() bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800336 return p.installer != nil && Bool(p.properties.Embedded_launcher)
Nan Zhangd4e641b2017-07-12 12:55:28 -0700337}
338
Liz Kammerd737d022020-11-16 15:42:51 -0800339func anyHasExt(paths []string, ext string) bool {
340 for _, p := range paths {
341 if filepath.Ext(p) == ext {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800342 return true
343 }
344 }
345
346 return false
347}
348
Liz Kammerd737d022020-11-16 15:42:51 -0800349func (p *Module) anySrcHasExt(ctx android.BottomUpMutatorContext, ext string) bool {
350 return anyHasExt(p.properties.Srcs, ext)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800351}
352
Liz Kammerd737d022020-11-16 15:42:51 -0800353// DepsMutator mutates dependencies for this module:
354// * handles proto dependencies,
355// * if required, specifies launcher and adds launcher dependencies,
356// * applies python version mutations to Python dependencies
Nan Zhangd4e641b2017-07-12 12:55:28 -0700357func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Crossfe17f6f2019-03-28 19:30:56 -0700358 android.ProtoDeps(ctx, &p.protoProperties)
359
Colin Crosse20113d2020-11-22 19:37:44 -0800360 versionVariation := []blueprint.Variation{
361 {"python_version", p.properties.Actual_version},
Nan Zhangb8fa1972017-12-22 16:12:00 -0800362 }
Colin Crosse20113d2020-11-22 19:37:44 -0800363
Liz Kammerd737d022020-11-16 15:42:51 -0800364 // If sources contain a proto file, add dependency on libprotobuf-python
365 if p.anySrcHasExt(ctx, protoExt) && p.Name() != "libprotobuf-python" {
Colin Crosse20113d2020-11-22 19:37:44 -0800366 ctx.AddVariationDependencies(versionVariation, pythonLibTag, "libprotobuf-python")
367 }
Liz Kammerd737d022020-11-16 15:42:51 -0800368
369 // Add python library dependencies for this python version variation
Colin Crosse20113d2020-11-22 19:37:44 -0800370 ctx.AddVariationDependencies(versionVariation, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
Liz Kammer7e93e5b2020-10-30 15:44:09 -0700371
Liz Kammerd737d022020-11-16 15:42:51 -0800372 // If this module will be installed and has an embedded launcher, we need to add dependencies for:
373 // * standard library
374 // * launcher
375 // * shared dependencies of the launcher
376 if p.installer != nil && p.isEmbeddedLauncherEnabled() {
377 var stdLib string
378 var launcherModule string
379 // Add launcher shared lib dependencies. Ideally, these should be
380 // derived from the `shared_libs` property of the launcher. However, we
381 // cannot read the property at this stage and it will be too late to add
382 // dependencies later.
383 launcherSharedLibDeps := []string{
384 "libsqlite",
385 }
386 // Add launcher-specific dependencies for bionic
387 if ctx.Target().Os.Bionic() {
388 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc", "libdl", "libm")
389 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700390
Liz Kammerd737d022020-11-16 15:42:51 -0800391 switch p.properties.Actual_version {
392 case pyVersion2:
393 stdLib = "py2-stdlib"
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800394
Liz Kammerd737d022020-11-16 15:42:51 -0800395 launcherModule = "py2-launcher"
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800396 if p.bootstrapper.autorun() {
397 launcherModule = "py2-launcher-autorun"
398 }
Liz Kammerd737d022020-11-16 15:42:51 -0800399 launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
Logan Chien02880e42018-11-06 17:30:35 +0800400
Liz Kammerd737d022020-11-16 15:42:51 -0800401 case pyVersion3:
402 stdLib = "py3-stdlib"
Logan Chien02880e42018-11-06 17:30:35 +0800403
Liz Kammerd737d022020-11-16 15:42:51 -0800404 launcherModule = "py3-launcher"
Dan Willemsen8d4d7be2019-11-04 19:21:04 -0800405 if p.bootstrapper.autorun() {
406 launcherModule = "py3-launcher-autorun"
407 }
Dan Willemsen8d4d7be2019-11-04 19:21:04 -0800408
Dan Willemsend7a1dee2020-01-20 22:08:20 -0800409 if ctx.Device() {
Liz Kammerd737d022020-11-16 15:42:51 -0800410 launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
Dan Willemsend7a1dee2020-01-20 22:08:20 -0800411 }
Liz Kammerd737d022020-11-16 15:42:51 -0800412 default:
413 panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
414 p.properties.Actual_version, ctx.ModuleName()))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700415 }
Liz Kammerd737d022020-11-16 15:42:51 -0800416 ctx.AddVariationDependencies(versionVariation, pythonLibTag, stdLib)
417 ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherTag, launcherModule)
418 ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherSharedLibTag, launcherSharedLibDeps...)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800419 }
Colin Cross1bc63932020-11-22 20:12:45 -0800420
421 // Emulate the data property for java_data but with the arch variation overridden to "common"
422 // so that it can point to java modules.
423 javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
424 ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800425}
426
Nan Zhangd4e641b2017-07-12 12:55:28 -0700427func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Liz Kammerd737d022020-11-16 15:42:51 -0800428 p.generatePythonBuildActions(ctx)
Nan Zhang5323f8e2017-05-10 13:37:54 -0700429
Liz Kammerd737d022020-11-16 15:42:51 -0800430 // Only Python binary and test modules have non-empty bootstrapper.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700431 if p.bootstrapper != nil {
Liz Kammerd737d022020-11-16 15:42:51 -0800432 // if the module is being installed, we need to collect all transitive dependencies to embed in
433 // the final par
434 p.collectPathsFromTransitiveDeps(ctx)
435 // bootstrap the module, including resolving main file, getting launcher path, and
436 // registering actions to build the par file
437 // bootstrap returns the binary output path
Nan Zhangd4e641b2017-07-12 12:55:28 -0700438 p.installSource = p.bootstrapper.bootstrap(ctx, p.properties.Actual_version,
Liz Kammerd737d022020-11-16 15:42:51 -0800439 p.isEmbeddedLauncherEnabled(), p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
Nan Zhang5323f8e2017-05-10 13:37:54 -0700440 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700441
Liz Kammerd737d022020-11-16 15:42:51 -0800442 // Only Python binary and test modules have non-empty installer.
Logan Chien02880e42018-11-06 17:30:35 +0800443 if p.installer != nil {
444 var sharedLibs []string
Liz Kammerd737d022020-11-16 15:42:51 -0800445 // if embedded launcher is enabled, we need to collect the shared library depenendencies of the
446 // launcher
Logan Chien02880e42018-11-06 17:30:35 +0800447 ctx.VisitDirectDeps(func(dep android.Module) {
448 if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
449 sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
450 }
451 })
452 p.installer.setAndroidMkSharedLibs(sharedLibs)
453
Liz Kammerd737d022020-11-16 15:42:51 -0800454 // Install the par file from installSource
Logan Chien02880e42018-11-06 17:30:35 +0800455 if p.installSource.Valid() {
456 p.installer.install(ctx, p.installSource.Path())
457 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700458 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800459}
460
Liz Kammerd737d022020-11-16 15:42:51 -0800461// generatePythonBuildActions performs build actions common to all Python modules
462func (p *Module) generatePythonBuildActions(ctx android.ModuleContext) {
463 expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800464 requiresSrcs := true
465 if p.bootstrapper != nil && !p.bootstrapper.autorun() {
466 requiresSrcs = false
467 }
468 if len(expandedSrcs) == 0 && requiresSrcs {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800469 ctx.ModuleErrorf("doesn't have any source files!")
470 }
471
472 // expand data files from "data" property.
Colin Cross8a497952019-03-05 22:25:09 -0800473 expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800474
Colin Cross1bc63932020-11-22 20:12:45 -0800475 // Emulate the data property for java_data dependencies.
476 for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
477 expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
478 }
479
Liz Kammerd737d022020-11-16 15:42:51 -0800480 // Validate pkg_path property
Nan Zhang1db85402017-12-18 13:20:23 -0800481 pkgPath := String(p.properties.Pkg_path)
482 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800483 // TODO: export validation from android/paths.go handling to replace this duplicated functionality
Nan Zhang1db85402017-12-18 13:20:23 -0800484 pkgPath = filepath.Clean(String(p.properties.Pkg_path))
485 if pkgPath == ".." || strings.HasPrefix(pkgPath, "../") ||
486 strings.HasPrefix(pkgPath, "/") {
Nan Zhangd4e641b2017-07-12 12:55:28 -0700487 ctx.PropertyErrorf("pkg_path",
488 "%q must be a relative path contained in par file.",
Nan Zhangea568a42017-11-08 21:20:04 -0800489 String(p.properties.Pkg_path))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700490 return
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800491 }
Liz Kammerd737d022020-11-16 15:42:51 -0800492 }
493 // If property Is_internal is set, prepend pkgPath with internalPath
494 if proptools.BoolDefault(p.properties.Is_internal, false) {
495 pkgPath = filepath.Join(internalPath, pkgPath)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800496 }
497
Liz Kammerd737d022020-11-16 15:42:51 -0800498 // generate src:destination path mappings for this module
Nan Zhang1db85402017-12-18 13:20:23 -0800499 p.genModulePathMappings(ctx, pkgPath, expandedSrcs, expandedData)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800500
Liz Kammerd737d022020-11-16 15:42:51 -0800501 // generate the zipfile of all source and data files
Nan Zhang1db85402017-12-18 13:20:23 -0800502 p.srcsZip = p.createSrcsZip(ctx, pkgPath)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800503}
504
Liz Kammerd737d022020-11-16 15:42:51 -0800505func isValidPythonPath(path string) error {
506 identifiers := strings.Split(strings.TrimSuffix(path, filepath.Ext(path)), "/")
507 for _, token := range identifiers {
508 if !pathComponentRegexp.MatchString(token) {
509 return fmt.Errorf("the path %q contains invalid subpath %q. "+
510 "Subpaths must be at least one character long. "+
511 "The first character must an underscore or letter. "+
512 "Following characters may be any of: letter, digit, underscore, hyphen.",
513 path, token)
514 }
515 }
516 return nil
517}
518
519// For this module, generate unique pathMappings: <dest: runfiles_path, src: source_path>
520// for python/data files expanded from properties.
Nan Zhang1db85402017-12-18 13:20:23 -0800521func (p *Module) genModulePathMappings(ctx android.ModuleContext, pkgPath string,
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800522 expandedSrcs, expandedData android.Paths) {
523 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
Nan Zhangb8fa1972017-12-22 16:12:00 -0800524 // check current module duplicates.
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800525 destToPySrcs := make(map[string]string)
526 destToPyData := make(map[string]string)
527
528 for _, s := range expandedSrcs {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800529 if s.Ext() != pyExt && s.Ext() != protoExt {
530 ctx.PropertyErrorf("srcs", "found non (.py|.proto) file: %q!", s.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800531 continue
532 }
Nan Zhang1db85402017-12-18 13:20:23 -0800533 runfilesPath := filepath.Join(pkgPath, s.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800534 if err := isValidPythonPath(runfilesPath); err != nil {
535 ctx.PropertyErrorf("srcs", err.Error())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800536 }
Liz Kammerd737d022020-11-16 15:42:51 -0800537 if !checkForDuplicateOutputPath(ctx, destToPySrcs, runfilesPath, s.String(), p.Name(), p.Name()) {
538 p.srcsPathMappings = append(p.srcsPathMappings, pathMapping{dest: runfilesPath, src: s})
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800539 }
540 }
541
542 for _, d := range expandedData {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800543 if d.Ext() == pyExt || d.Ext() == protoExt {
544 ctx.PropertyErrorf("data", "found (.py|.proto) file: %q!", d.String())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800545 continue
546 }
Nan Zhang1db85402017-12-18 13:20:23 -0800547 runfilesPath := filepath.Join(pkgPath, d.Rel())
Liz Kammerd737d022020-11-16 15:42:51 -0800548 if !checkForDuplicateOutputPath(ctx, destToPyData, runfilesPath, d.String(), p.Name(), p.Name()) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800549 p.dataPathMappings = append(p.dataPathMappings,
550 pathMapping{dest: runfilesPath, src: d})
551 }
552 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800553}
554
Liz Kammerd737d022020-11-16 15:42:51 -0800555// createSrcsZip registers build actions to zip current module's sources and data.
Nan Zhang1db85402017-12-18 13:20:23 -0800556func (p *Module) createSrcsZip(ctx android.ModuleContext, pkgPath string) android.Path {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800557 relativeRootMap := make(map[string]android.Paths)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800558 pathMappings := append(p.srcsPathMappings, p.dataPathMappings...)
559
Nan Zhangb8fa1972017-12-22 16:12:00 -0800560 var protoSrcs android.Paths
Liz Kammerd737d022020-11-16 15:42:51 -0800561 // "srcs" or "data" properties may contain filegroup so it might happen that
562 // the root directory for each source path is different.
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800563 for _, path := range pathMappings {
Liz Kammerd737d022020-11-16 15:42:51 -0800564 // handle proto sources separately
Nan Zhangb8fa1972017-12-22 16:12:00 -0800565 if path.src.Ext() == protoExt {
566 protoSrcs = append(protoSrcs, path.src)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800567 } else {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800568 var relativeRoot string
569 relativeRoot = strings.TrimSuffix(path.src.String(), path.src.Rel())
570 if v, found := relativeRootMap[relativeRoot]; found {
571 relativeRootMap[relativeRoot] = append(v, path.src)
572 } else {
573 relativeRootMap[relativeRoot] = android.Paths{path.src}
574 }
575 }
576 }
577 var zips android.Paths
578 if len(protoSrcs) > 0 {
Colin Cross19878da2019-03-28 14:45:07 -0700579 protoFlags := android.GetProtoFlags(ctx, &p.protoProperties)
580 protoFlags.OutTypeFlag = "--python_out"
581
Nan Zhangb8fa1972017-12-22 16:12:00 -0800582 for _, srcFile := range protoSrcs {
Colin Cross19878da2019-03-28 14:45:07 -0700583 zip := genProto(ctx, srcFile, protoFlags, pkgPath)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800584 zips = append(zips, zip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800585 }
586 }
587
Nan Zhangb8fa1972017-12-22 16:12:00 -0800588 if len(relativeRootMap) > 0 {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800589 // in order to keep stable order of soong_zip params, we sort the keys here.
Liz Kammerd737d022020-11-16 15:42:51 -0800590 roots := android.SortedStringKeys(relativeRootMap)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800591
592 parArgs := []string{}
Nan Zhangf0c4e432018-05-22 14:50:18 -0700593 if pkgPath != "" {
Liz Kammerd737d022020-11-16 15:42:51 -0800594 // use package path as path prefix
Nan Zhangf0c4e432018-05-22 14:50:18 -0700595 parArgs = append(parArgs, `-P `+pkgPath)
596 }
Liz Kammerd737d022020-11-16 15:42:51 -0800597 paths := android.Paths{}
598 for _, root := range roots {
599 // specify relative root of file in following -f arguments
600 parArgs = append(parArgs, `-C `+root)
601 for _, path := range relativeRootMap[root] {
Nan Zhangb8fa1972017-12-22 16:12:00 -0800602 parArgs = append(parArgs, `-f `+path.String())
Liz Kammerd737d022020-11-16 15:42:51 -0800603 paths = append(paths, path)
Nan Zhangb8fa1972017-12-22 16:12:00 -0800604 }
605 }
606
607 origSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".py.srcszip")
608 ctx.Build(pctx, android.BuildParams{
609 Rule: zip,
610 Description: "python library archive",
611 Output: origSrcsZip,
Liz Kammerd737d022020-11-16 15:42:51 -0800612 // as zip rule does not use $in, there is no real need to distinguish between Inputs and Implicits
613 Implicits: paths,
Nan Zhangb8fa1972017-12-22 16:12:00 -0800614 Args: map[string]string{
615 "args": strings.Join(parArgs, " "),
616 },
617 })
618 zips = append(zips, origSrcsZip)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800619 }
Liz Kammerd737d022020-11-16 15:42:51 -0800620 // we may have multiple zips due to separate handling of proto source files
Nan Zhangb8fa1972017-12-22 16:12:00 -0800621 if len(zips) == 1 {
622 return zips[0]
623 } else {
624 combinedSrcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".srcszip")
625 ctx.Build(pctx, android.BuildParams{
626 Rule: combineZip,
627 Description: "combine python library archive",
628 Output: combinedSrcsZip,
629 Inputs: zips,
630 })
631 return combinedSrcsZip
632 }
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800633}
634
Liz Kammerd737d022020-11-16 15:42:51 -0800635// isPythonLibModule returns whether the given module is a Python library Module or not
636// This is distinguished by the fact that Python libraries are not installable, while other Python
637// modules are.
Nan Zhangd4e641b2017-07-12 12:55:28 -0700638func isPythonLibModule(module blueprint.Module) bool {
639 if m, ok := module.(*Module); ok {
Liz Kammerd737d022020-11-16 15:42:51 -0800640 // Python library has no bootstrapper or installer
641 if m.bootstrapper == nil && m.installer == nil {
642 return true
Nan Zhangd4e641b2017-07-12 12:55:28 -0700643 }
Nan Zhangd4e641b2017-07-12 12:55:28 -0700644 }
645 return false
646}
647
Liz Kammerd737d022020-11-16 15:42:51 -0800648// collectPathsFromTransitiveDeps checks for source/data files for duplicate paths
649// for module and its transitive dependencies and collects list of data/source file
650// zips for transitive dependencies.
651func (p *Module) collectPathsFromTransitiveDeps(ctx android.ModuleContext) {
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800652 // fetch <runfiles_path, source_path> pairs from "src" and "data" properties to
653 // check duplicates.
654 destToPySrcs := make(map[string]string)
655 destToPyData := make(map[string]string)
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800656 for _, path := range p.srcsPathMappings {
657 destToPySrcs[path.dest] = path.src.String()
658 }
659 for _, path := range p.dataPathMappings {
660 destToPyData[path.dest] = path.src.String()
661 }
662
Colin Cross6b753602018-06-21 13:03:07 -0700663 seen := make(map[android.Module]bool)
664
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800665 // visit all its dependencies in depth first.
Colin Cross6b753602018-06-21 13:03:07 -0700666 ctx.WalkDeps(func(child, parent android.Module) bool {
Liz Kammerd737d022020-11-16 15:42:51 -0800667 // we only collect dependencies tagged as python library deps
Colin Cross6b753602018-06-21 13:03:07 -0700668 if ctx.OtherModuleDependencyTag(child) != pythonLibTag {
669 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800670 }
Colin Cross6b753602018-06-21 13:03:07 -0700671 if seen[child] {
672 return false
673 }
674 seen[child] = true
Nan Zhangb8fa1972017-12-22 16:12:00 -0800675 // Python modules only can depend on Python libraries.
Colin Cross6b753602018-06-21 13:03:07 -0700676 if !isPythonLibModule(child) {
Liz Kammerd737d022020-11-16 15:42:51 -0800677 ctx.PropertyErrorf("libs",
Nan Zhangd4e641b2017-07-12 12:55:28 -0700678 "the dependency %q of module %q is not Python library!",
Liz Kammerd737d022020-11-16 15:42:51 -0800679 ctx.ModuleName(), ctx.OtherModuleName(child))
Nan Zhangd4e641b2017-07-12 12:55:28 -0700680 }
Liz Kammerd737d022020-11-16 15:42:51 -0800681 // collect source and data paths, checking that there are no duplicate output file conflicts
682 if dep, ok := child.(pythonDependency); ok {
683 srcs := dep.getSrcsPathMappings()
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800684 for _, path := range srcs {
Liz Kammerd737d022020-11-16 15:42:51 -0800685 checkForDuplicateOutputPath(ctx, destToPySrcs,
Colin Cross6b753602018-06-21 13:03:07 -0700686 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800687 }
Liz Kammerd737d022020-11-16 15:42:51 -0800688 data := dep.getDataPathMappings()
689 for _, path := range data {
690 checkForDuplicateOutputPath(ctx, destToPyData,
691 path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
692 }
693 p.depsSrcsZips = append(p.depsSrcsZips, dep.getSrcsZip())
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800694 }
Colin Cross6b753602018-06-21 13:03:07 -0700695 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800696 })
697}
698
Liz Kammerd737d022020-11-16 15:42:51 -0800699// chckForDuplicateOutputPath checks whether outputPath has already been included in map m, which
700// would result in two files being placed in the same location.
701// If there is a duplicate path, an error is thrown and true is returned
702// Otherwise, outputPath: srcPath is added to m and returns false
703func checkForDuplicateOutputPath(ctx android.ModuleContext, m map[string]string, outputPath, srcPath, curModule, otherModule string) bool {
704 if oldSrcPath, found := m[outputPath]; found {
Nan Zhangbea09752018-05-31 12:49:33 -0700705 ctx.ModuleErrorf("found two files to be placed at the same location within zip %q."+
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800706 " First file: in module %s at path %q."+
707 " Second file: in module %s at path %q.",
Liz Kammerd737d022020-11-16 15:42:51 -0800708 outputPath, curModule, oldSrcPath, otherModule, srcPath)
709 return true
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800710 }
Liz Kammerd737d022020-11-16 15:42:51 -0800711 m[outputPath] = srcPath
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800712
Liz Kammerd737d022020-11-16 15:42:51 -0800713 return false
Nan Zhangdb0b9a32017-02-27 10:12:13 -0800714}
Nan Zhangea568a42017-11-08 21:20:04 -0800715
Liz Kammerd737d022020-11-16 15:42:51 -0800716// InstallInData returns true as Python is not supported in the system partition
Nan Zhangd9ec5e72017-12-01 20:00:31 +0000717func (p *Module) InstallInData() bool {
718 return true
719}
720
Nan Zhangea568a42017-11-08 21:20:04 -0800721var Bool = proptools.Bool
Dan Willemsen6ca390f2019-02-14 23:17:08 -0800722var BoolDefault = proptools.BoolDefault
Nan Zhangea568a42017-11-08 21:20:04 -0800723var String = proptools.String