-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-146450: Ensure Android gradle build uses custom cross-build dir #148319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
871d87f
7afb698
db873ac
68ba1d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,9 +398,15 @@ def setup_testbed(): | |
| def build_testbed(context): | ||
| setup_sdk() | ||
| setup_testbed() | ||
|
|
||
| # Ensure that CROSS_BUILD_DIR is in the Gradle environment, regardless | ||
| # of whether it was set by environment variable or `--cross-build-dir`. | ||
| env = os.environ.copy() | ||
| env["CROSS_BUILD_DIR"] = CROSS_BUILD_DIR | ||
| run( | ||
| [gradlew, "--console", "plain", "packageDebug", "packageDebugAndroidTest"], | ||
| cwd=TESTBED_DIR, | ||
| env=env, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -645,6 +651,10 @@ async def gradle_task(context): | |
| task_prefix = "connected" | ||
| env["ANDROID_SERIAL"] = context.connected | ||
|
|
||
| # Ensure that CROSS_BUILD_DIR is in the Gradle environment, regardless | ||
| # of whether it was set by environment variable or `--cross-build-dir`. | ||
| env["CROSS_BUILD_DIR"] = CROSS_BUILD_DIR | ||
|
|
||
| if context.ci_mode: | ||
| context.args[0:0] = [ | ||
| # See _add_ci_python_opts in libregrtest/main.py. | ||
|
|
@@ -896,7 +906,7 @@ def add_parser(*args, **kwargs): | |
| help="Delete build directories for the selected target" | ||
| ) | ||
|
|
||
| add_parser("build-testbed", help="Build the testbed app") | ||
| build_testbed = add_parser("build-testbed", help="Build the testbed app") | ||
| test = add_parser("test", help="Run the testbed app") | ||
| package = add_parser("package", help="Make a release package") | ||
| ci = add_parser("ci", help="Run build, package and test") | ||
|
|
@@ -912,6 +922,7 @@ def add_parser(*args, **kwargs): | |
| make_host, | ||
| build, | ||
| package, | ||
| build_testbed, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| test, | ||
| ci, | ||
| ]: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,10 @@ plugins { | |||||||||
|
|
||||||||||
| val ANDROID_DIR = file("../..") | ||||||||||
| val PYTHON_DIR = ANDROID_DIR.parentFile!! | ||||||||||
| val PYTHON_CROSS_DIR = file("$PYTHON_DIR/cross-build") | ||||||||||
| val CROSS_BUILD_DIR = System.getenv("CROSS_BUILD_DIR") ?: "cross-build" | ||||||||||
| val PYTHON_CROSS_DIR = file( | ||||||||||
| if ((File(CROSS_BUILD_DIR)).isAbsolute) CROSS_BUILD_DIR else "$PYTHON_DIR/$CROSS_BUILD_DIR" | ||||||||||
|
Comment on lines
+11
to
+13
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running Gradle from android.py, the environment variable will always be absolute. But if Gradle is run directly, the user would expect relative paths to be resolved not against PYTHON_DIR, but the working directory, which I think
Suggested change
|
||||||||||
| ) | ||||||||||
| val inSourceTree = ( | ||||||||||
| ANDROID_DIR.name == "Android" && file("$PYTHON_DIR/pyconfig.h.in").exists() | ||||||||||
| ) | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say that we could avoid duplication by setting this environment variable in
main. However, running the app outside of this script isn't actually useful in practice, so I suggest instead deleting thebuild-testbedcommand completely.