diff options
author | 2022-09-26 17:24:08 +0000 | |
---|---|---|
committer | 2022-09-26 17:24:08 +0000 | |
commit | 2f037821b019e06e14f8beabbbcd7c0007812900 (patch) | |
tree | 202a4c0af9b10d95d77f65be6214b25bf367ef90 /python/builder.go | |
parent | 394a12b3150981364ccd1302c56e08c36c91520a (diff) | |
parent | af4b13dbe4c4063f784777fc4f58b6fd4f727c6a (diff) |
Merge "Add flag to not add top-level modules to PYTHONPATH"
Diffstat (limited to 'python/builder.go')
-rw-r--r-- | python/builder.go | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/python/builder.go b/python/builder.go index 7d7239c55..08d345c92 100644 --- a/python/builder.go +++ b/python/builder.go @@ -44,13 +44,13 @@ var ( hostPar = pctx.AndroidStaticRule("hostPar", blueprint.RuleParams{ - Command: `sed -e 's/%interpreter%/$interp/g' -e 's/%main%/$main/g' $template > $stub && ` + + Command: `sed -e 's/%interpreter%/$interp/g' -e 's/%main%/$main/g' -e 's/ADD_TOP_DIRECTORIES_TO_PATH/$addTopDirectoriesToPath/g' build/soong/python/scripts/stub_template_host.txt > $out.main && ` + `echo "#!/usr/bin/env $interp" >${out}.prefix &&` + - `$mergeParCmd -p --prefix ${out}.prefix -pm $stub $out $srcsZips && ` + - `chmod +x $out && (rm -f $stub; rm -f ${out}.prefix)`, - CommandDeps: []string{"$mergeParCmd"}, + `$mergeParCmd -p --prefix ${out}.prefix -pm $out.main $out $srcsZips && ` + + `chmod +x $out && (rm -f $out.main; rm -f ${out}.prefix)`, + CommandDeps: []string{"$mergeParCmd", "build/soong/python/scripts/stub_template_host.txt"}, }, - "interp", "main", "template", "stub", "srcsZips") + "interp", "main", "srcsZips", "addTopDirectoriesToPath") embeddedPar = pctx.AndroidStaticRule("embeddedPar", blueprint.RuleParams{ @@ -81,7 +81,7 @@ func init() { func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher bool, launcherPath android.OptionalPath, interpreter, main, binName string, - srcsZips android.Paths) android.Path { + srcsZips android.Paths, addTopDirectoriesToPath bool) android.Path { // .intermediate output path for bin executable. binFile := android.PathForModuleOut(ctx, binName) @@ -90,24 +90,20 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher b implicits := srcsZips if !embeddedLauncher { - // the path of stub_template_host.txt from source tree. - template := android.PathForSource(ctx, StubTemplateHost) - implicits = append(implicits, template) - - // intermediate output path for __main__.py - stub := android.PathForModuleOut(ctx, mainFileName).String() - + addDirsString := "False" + if addTopDirectoriesToPath { + addDirsString = "True" + } ctx.Build(pctx, android.BuildParams{ Rule: hostPar, Description: "host python archive", Output: binFile, Implicits: implicits, Args: map[string]string{ - "interp": strings.Replace(interpreter, "/", `\/`, -1), - "main": strings.Replace(main, "/", `\/`, -1), - "template": template.String(), - "stub": stub, - "srcsZips": strings.Join(srcsZips.Strings(), " "), + "interp": strings.Replace(interpreter, "/", `\/`, -1), + "main": strings.Replace(main, "/", `\/`, -1), + "srcsZips": strings.Join(srcsZips.Strings(), " "), + "addTopDirectoriesToPath": addDirsString, }, }) } else if launcherPath.Valid() { |