diff options
author | Dan Willemsen <dwillemsen@google.com> | 2018-11-29 21:39:59 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2019-02-15 14:33:59 -0800 |
commit | 707542f2989751e9a834e5d0bd30dc23cbcc8d16 (patch) | |
tree | 7a817e7fb8bdf60abfb85d3d8f4194839f7a5528 /python/builder.go | |
parent | 7b88d7c9f6a1b5c8c50a581bb16e685be4ecd0d6 (diff) | |
download | android_build_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.tar.gz android_build_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.tar.bz2 android_build_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.zip |
Simplify python launcher, use __main__.py
Uses more python rather than C++, and skips less of Py_Main.
Test: build/soong/python/tests/runtests.sh
Change-Id: I03997d88e2e16047c96bb4e00e530229c42b3325
Diffstat (limited to 'python/builder.go')
-rw-r--r-- | python/builder.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/python/builder.go b/python/builder.go index cbbe56e4..e277bfd9 100644 --- a/python/builder.go +++ b/python/builder.go @@ -54,15 +54,14 @@ var ( embeddedPar = pctx.AndroidStaticRule("embeddedPar", blueprint.RuleParams{ - // `echo -n` to trim the newline, since the python code just wants the name. - // /bin/sh (used by ninja) on Mac turns off posix mode, and stops supporting -n. - // Explicitly use bash instead. - Command: `/bin/bash -c "echo -n '$main' > $entryPoint" &&` + - `$mergeParCmd -p --prefix $launcher -e $entryPoint $out $srcsZips && ` + - `chmod +x $out && (rm -f $entryPoint)`, - CommandDeps: []string{"$mergeParCmd"}, + // `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 && ` + + `chmod +x $out && rm -rf $out.main`, + CommandDeps: []string{"$mergeParCmd", "$parCmd", "build/soong/python/scripts/main.py"}, }, - "main", "entryPoint", "srcsZips", "launcher") + "main", "srcsZips", "launcher") ) func init() { @@ -108,19 +107,15 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher b // added launcherPath to the implicits Ninja dependencies. implicits = append(implicits, launcherPath.Path()) - // .intermediate output path for entry_point.txt - entryPoint := android.PathForModuleOut(ctx, entryPointFile).String() - 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), - "entryPoint": entryPoint, - "srcsZips": strings.Join(srcsZips.Strings(), " "), - "launcher": launcherPath.String(), + "main": strings.Replace(strings.TrimSuffix(main, pyExt), "/", ".", -1), + "srcsZips": strings.Join(srcsZips.Strings(), " "), + "launcher": launcherPath.String(), }, }) } |