Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1fbc792 authored by Cole Faust's avatar Cole Faust
Browse files

Add BUILD_BROKEN_PYTHON_IS_PYTHON2

This provides an escape hatch to undo the effects of
aosp/2417672. It's an enviornment variable instead of
a product config variable because python is often used
during product config.

Bug: 203436762
Test: m nothing and get_build_var with aosp/2458935
Change-Id: I0dd0f7c221427ea487fd7993aef68ce803eaff21
parent 8ecedd4d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -109,6 +109,15 @@ func SetupLitePath(ctx Context, config Config, tmpDir string) {
	prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86")
	myPath = prebuiltsPath + string(os.PathListSeparator) + myPath

	if value, _ := config.Environment().Get("BUILD_BROKEN_PYTHON_IS_PYTHON2"); value == "true" {
		py2Path, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86/py2")
		if info, err := os.Stat(py2Path); err == nil && info.IsDir() {
			myPath = py2Path + string(os.PathListSeparator) + myPath
		}
	} else if value != "" {
		ctx.Fatalf("BUILD_BROKEN_PYTHON_IS_PYTHON2 can only be set to 'true' or an empty string, but got %s\n", value)
	}

	// Set $PATH to be the directories containing the host tool symlinks, and
	// the prebuilts directory for the current host OS.
	config.Environment().Set("PATH", myPath)
@@ -244,6 +253,15 @@ func SetupPath(ctx Context, config Config) {
	prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86")
	myPath = prebuiltsPath + string(os.PathListSeparator) + myPath

	if value, _ := config.Environment().Get("BUILD_BROKEN_PYTHON_IS_PYTHON2"); value == "true" {
		py2Path, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86/py2")
		if info, err := os.Stat(py2Path); err == nil && info.IsDir() {
			myPath = py2Path + string(os.PathListSeparator) + myPath
		}
	} else if value != "" {
		ctx.Fatalf("BUILD_BROKEN_PYTHON_IS_PYTHON2 can only be set to 'true' or an empty string, but got %s\n", value)
	}

	// Replace the $PATH variable with the path_interposer symlinks, and
	// checked-in prebuilts.
	config.Environment().Set("PATH", myPath)