aboutsummaryrefslogtreecommitdiffstats
path: root/python/builder.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/builder.go
parent41364fe521b39d01404d3df2703f31897389d0f0 (diff)
downloadandroid_build_soong-6ca390f0b4be216226f31bc05ed5e3bba3105e17.tar.gz
android_build_soong-6ca390f0b4be216226f31bc05ed5e3bba3105e17.tar.bz2
android_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/builder.go')
-rw-r--r--python/builder.go44
1 files changed, 32 insertions, 12 deletions
diff --git a/python/builder.go b/python/builder.go
index e277bfd9..e3b490cf 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -54,7 +54,6 @@ var (
embeddedPar = pctx.AndroidStaticRule("embeddedPar",
blueprint.RuleParams{
- // `echo -n` to trim the newline, since the python code just wants the name
Command: `rm -f $out.main && ` +
`sed 's/ENTRY_POINT/$main/' build/soong/python/scripts/main.py >$out.main &&` +
`$mergeParCmd -p -pm $out.main --prefix $launcher $out $srcsZips && ` +
@@ -62,6 +61,14 @@ var (
CommandDeps: []string{"$mergeParCmd", "$parCmd", "build/soong/python/scripts/main.py"},
},
"main", "srcsZips", "launcher")
+
+ embeddedParNoMain = pctx.AndroidStaticRule("embeddedParNoMain",
+ blueprint.RuleParams{
+ Command: `$mergeParCmd -p --prefix $launcher $out $srcsZips && ` +
+ `chmod +x $out`,
+ CommandDeps: []string{"$mergeParCmd"},
+ },
+ "srcsZips", "launcher")
)
func init() {
@@ -107,17 +114,30 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher b
// added launcherPath to the implicits Ninja dependencies.
implicits = append(implicits, launcherPath.Path())
- ctx.Build(pctx, android.BuildParams{
- Rule: embeddedPar,
- Description: "embedded python archive",
- Output: binFile,
- Implicits: implicits,
- Args: map[string]string{
- "main": strings.Replace(strings.TrimSuffix(main, pyExt), "/", ".", -1),
- "srcsZips": strings.Join(srcsZips.Strings(), " "),
- "launcher": launcherPath.String(),
- },
- })
+ if main == "" {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: embeddedParNoMain,
+ Description: "embedded python archive",
+ Output: binFile,
+ Implicits: implicits,
+ Args: map[string]string{
+ "srcsZips": strings.Join(srcsZips.Strings(), " "),
+ "launcher": launcherPath.String(),
+ },
+ })
+ } else {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: embeddedPar,
+ Description: "embedded python archive",
+ Output: binFile,
+ Implicits: implicits,
+ Args: map[string]string{
+ "main": strings.Replace(strings.TrimSuffix(main, pyExt), "/", ".", -1),
+ "srcsZips": strings.Join(srcsZips.Strings(), " "),
+ "launcher": launcherPath.String(),
+ },
+ })
+ }
}
return binFile