aboutsummaryrefslogtreecommitdiffstats
path: root/python/binary.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2019-02-14 23:17:08 -0800
committerDan Willemsen <dwillemsen@google.com>2019-02-17 12:14:23 -0800
commit6ca390f0b4be216226f31bc05ed5e3bba3105e17 (patch)
tree02f700bed14ed9f6271cbb53f34c1f070bf32e3e /python/binary.go
parent41364fe521b39d01404d3df2703f31897389d0f0 (diff)
downloadbuild_soong-6ca390f0b4be216226f31bc05ed5e3bba3105e17.tar.gz
build_soong-6ca390f0b4be216226f31bc05ed5e3bba3105e17.tar.bz2
build_soong-6ca390f0b4be216226f31bc05ed5e3bba3105e17.zip
Support building a par file that does not automatically run
Mainly so that we can build a `python` prebuilt that acts like the normal python install, though you could also build different ones with more packages pre-installed. Bug: 117811537 Test: move built py2-cmd into prebuilts/build-tools/path/linux-x86/python and build Change-Id: I21215f6fd3754d89f8c65e1dfeb3f2deea23239f
Diffstat (limited to 'python/binary.go')
-rw-r--r--python/binary.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/binary.go b/python/binary.go
index bf9acb41..140f07af 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -42,6 +42,11 @@ type BinaryProperties struct {
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
Test_suites []string `android:"arch_variant"`
+
+ // whether to use `main` when starting the executable. The default is true, when set to
+ // false it will act much like the normal `python` executable, but with the sources and
+ // libraries automatically included in the PYTHONPATH.
+ Autorun *bool `android:"arch_variant"`
}
type binaryDecorator struct {
@@ -74,6 +79,10 @@ func PythonBinaryHostFactory() android.Module {
return module.Init()
}
+func (binary *binaryDecorator) autorun() bool {
+ return BoolDefault(binary.binaryProperties.Autorun, true)
+}
+
func (binary *binaryDecorator) bootstrapperProps() []interface{} {
return []interface{}{&binary.binaryProperties}
}
@@ -82,7 +91,10 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actualVersio
embeddedLauncher bool, srcsPathMappings []pathMapping, srcsZip android.Path,
depsSrcsZips android.Paths) android.OptionalPath {
- main := binary.getPyMainFile(ctx, srcsPathMappings)
+ main := ""
+ if binary.autorun() {
+ main = binary.getPyMainFile(ctx, srcsPathMappings)
+ }
var launcherPath android.OptionalPath
if embeddedLauncher {