Skip to content
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

Build with Android NDK r19 #2592

Merged
merged 1 commit into from
Jan 25, 2019
Merged

Build with Android NDK r19 #2592

merged 1 commit into from
Jan 25, 2019

Conversation

grendello
Copy link
Contributor

@grendello grendello commented Jan 7, 2019

  • Update gradle to version 5.1 (the latest version)
  • Update gradle android addin to 3.2.1 (required for r18+ as it removes
    dependency on the MIPS toolchain which no longer exists in r18+)
  • Bump all the instances of android:minSdkVersion to 16 since this is the
    lowest NDK API found in NDK r19 and, thus, the lowest API our runtimes can
    run on.
  • Fix AOT build tests by targetting API 16 at the minimum.
  • Introduce the Xamarin.Android.Tools.XABuildConfig class, generated at the
    XA build time, which includes all the necessary information about the NDK
    the native runtime was built with.
  • Put NDK and per-architecture mimum API level in
    Xamarin.Android.Common.props based on the contents of
    build-tools/scripts/Ndk.targets

Future bumps of NDK versions and per-architecture API levels will require
changing just a single file - build-tools/scripts/Ndk.targets - in order to
make the change visible and used by all the other parties.

@grendello grendello requested a review from jonpryor as a code owner January 7, 2019 14:15
@grendello grendello force-pushed the ndk18 branch 4 times, most recently from 262721b to adbf70f Compare January 8, 2019 13:35
@grendello grendello added the full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps) label Jan 8, 2019
@grendello
Copy link
Contributor Author

build

jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Jan 9, 2019
Context: dotnet#2592
Context: https://jenkins.mono-project.com/job/xamarin-android-pr-builder-release/339/console

Recall commit b28856f and the behavior of "forward only"
dependencies: some dependencies can only be easily "upgraded," and not
reverted.  Commit b28856f dealt with MXE, and "solved" the
"downgrade" problem by encoding the MXE hash into the MXE installation
directory, so that multiple MXE installations can exist.

Turns Out™, the NDK is in a similar scenario: because the
`_UnzipFiles` target within `android-toolchain.targets` only executes
when one of the input files has *changed*, e.g. a new NDK `.zip` file
was downloaded, then when the NDK is "downgraded" but the "downgraded"
NDK `.zip` *already existed*, the "older" NDK wouldn't be installed:

 1. PR dotnet#2592 is a PR to update the NDK, and is built on a machine.
    As part of building dotnet#2592, `$HOME/android-toolchain/ndk` is
    upgraded to NDK r18.

 2. As part of upgrading the build machine to NDK r18,
    `$HOME/android-archives` contains `android-ndk-*.zip` files for
    *at least* NDK r14b and r18.

 3. "Later", a different PR is executed on the same build machine.
    This different PR doesn't further change the NDK, i.e. it's still
    specifying NDK r14b, and r14b is already present on the machine.

 4. The NDK is *not* "downgraded" to r14b from r18, and the build
    attempts to use NDK r18.

The build then fails:

	xamarin-android/external/sqlite/dist/sqlite3.c(33031,9): error G3127DA5A: use of undeclared identifier 'ANDROID_FDSAN_OWNER_TYPE_SQLITE'; did you mean 'ANDROID_FDSAN_OWNER_TYPE_FILE'?
	xamarin-android/external/sqlite/dist/sqlite3.c(33616,7): error G3127DA5A: use of undeclared identifier 'ANDROID_FDSAN_OWNER_TYPE_SQLITE'; did you mean 'ANDROID_FDSAN_OWNER_TYPE_FILE'?
	xamarin-android/src/sqlite-xamarin/sqlite-xamarin.targets(27,5): error MSB3073: The command "/Users/builder/android-toolchain/sdk/cmake/3.6.4111459/bin/ninja -v" exited with code 1.

This makes for a brittle build environment.

Support NDK downgrades by embedding the NDK version into the generated
stamp file, e.g. `$HOME/android-toolchain/ndk/.stamp-ndk-r14b`.  This
allows "normal file timestamps" to be used to determine if the NDK
needs to be recreated, which will allow the build machine to recreate
the NDK when the NDK version changes.
jonpryor added a commit that referenced this pull request Jan 9, 2019
Context: #2592
Context: https://jenkins.mono-project.com/job/xamarin-android-pr-builder-release/339/console

Recall commit b28856f and the behavior of "forward only"
dependencies: some dependencies can only be easily "upgraded," and not
reverted.  Commit b28856f dealt with MXE, and "solved" the
"downgrade" problem by encoding the MXE hash into the MXE installation
directory, so that multiple MXE installations can exist.

Turns Out™, the NDK is in a similar scenario: because the
`_UnzipFiles` target within `android-toolchain.targets` only executes
when one of the input files has *changed*, e.g. a new NDK `.zip` file
was downloaded, then when the NDK is "downgraded" but the "downgraded"
NDK `.zip` *already existed*, the "older" NDK wouldn't be installed:

 1. PR #2592 is a PR to update the NDK, and is built on a machine.
    As part of building #2592, `$HOME/android-toolchain/ndk` is
    upgraded to NDK r18.

 2. As part of upgrading the build machine to NDK r18,
    `$HOME/android-archives` contains `android-ndk-*.zip` files for
    *at least* NDK r14b and r18.

 3. "Later", a different PR is executed on the same build machine.
    This different PR doesn't further change the NDK, i.e. it's still
    specifying NDK r14b, and r14b is already present on the machine.

 4. The NDK is *not* "downgraded" to r14b from r18, and the build
    attempts to use NDK r18.

The build then fails:

	xamarin-android/external/sqlite/dist/sqlite3.c(33031,9): error G3127DA5A: use of undeclared identifier 'ANDROID_FDSAN_OWNER_TYPE_SQLITE'; did you mean 'ANDROID_FDSAN_OWNER_TYPE_FILE'?
	xamarin-android/external/sqlite/dist/sqlite3.c(33616,7): error G3127DA5A: use of undeclared identifier 'ANDROID_FDSAN_OWNER_TYPE_SQLITE'; did you mean 'ANDROID_FDSAN_OWNER_TYPE_FILE'?
	xamarin-android/src/sqlite-xamarin/sqlite-xamarin.targets(27,5): error MSB3073: The command "/Users/builder/android-toolchain/sdk/cmake/3.6.4111459/bin/ninja -v" exited with code 1.

This makes for a brittle build environment.

Support NDK downgrades by embedding the NDK version into the generated
stamp file, e.g. `$HOME/android-toolchain/ndk/.stamp-ndk-r14b`.  This
allows "normal file timestamps" to be used to determine if the NDK
needs to be recreated, which will allow the build machine to recreate
the NDK when the NDK version changes.
@grendello grendello force-pushed the ndk18 branch 3 times, most recently from 53b647d to 77332f6 Compare January 14, 2019 08:17
AndroidSupportedTargetJitAbi items with appropriate metadata. Thus we need to do it manually as below -->
<AndroidSupportedTargetJitAbi
Include="armeabi-v7a"
Condition=" $(AndroidSupportedTargetJitAbis.Contains ('armeabi-v7a')) ">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi-v7a:')), along with the other locations in this file.

The rationale now is for "sanity"/"future-proofing"; historically, the issue was armeabi, as AndroidSupportedTargetJitAbis.Contains('armeabi') would match both armeabi and armeabi-v7a. We thus want/need to "wrap" the values in : to ensure that we don't get inadvertent substring mismatches.

This is still an issue for x86, as x86 is a substring of x86_64.


<AndroidSupportedTargetJitAbi
Include="x86"
Condition=" $(AndroidSupportedTargetJitAbis.Contains ('x86')) ">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:')).


<AndroidSupportedTargetJitAbi
Include="x86_64"
Condition=" $(AndroidSupportedTargetJitAbis.Contains ('x86_64')) ">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')).


<AndroidSupportedTargetJitAbi
Include="arm64-v8a"
Condition=" $(AndroidSupportedTargetJitAbis.Contains ('arm64-v8a')) ">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')).

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from b070122 to c3325c6 Compare January 14, 2019 16:31
@jonpryor
Copy link
Member

jonpryor commented Jan 15, 2019

Three further changes:

  1. $(AndroidNdkVersion) should be removed from Configuration.props, and the $(AndroidNdkVersion) value changed within build-tools/android-toolchain/android-toolchain.projitems (or moved to some other file).

  2. Whatever file does contain $(AndroidNdkVersion) needs to be added to the @(VersionFile) item group within build-tools/create-bundle/bundle-path.targets.

  3. Update build-tools/android-toolchain/android-toolchain.projitems to ensure that it uses our new single $(AndroidNdkVersion) value.

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from b5493b1 to b4f255b Compare January 15, 2019 20:01
@grendello
Copy link
Contributor Author

build

3 similar comments
@grendello
Copy link
Contributor Author

build

@grendello
Copy link
Contributor Author

build

@grendello
Copy link
Contributor Author

build

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from f7c97c6 to 26c7869 Compare January 18, 2019 08:38
@grendello grendello requested a review from dellis1972 as a code owner January 18, 2019 08:38
@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I feel like 64mb is small.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An same here :)

@@ -2,6 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_CmakeCommonFlags>-GNinja -DCMAKE_MAKE_PROGRAM=$(NinjaPath)</_CmakeCommonFlags>
<_CmakeAndroidFlags>$(_CmakeCommonFlags) -DANDROID_STL="system" -DANDROID_CPP_FEATURES="" -DANDROID_TOOLCHAIN=clang -DANDROID_NATIVE_API_LEVEL=$(AndroidNdkApiLevel) -DANDROID_PLATFORM=android-$(AndroidNdkApiLevel) -DCMAKE_TOOLCHAIN_FILE=$(AndroidNdkDirectory)\build\cmake\android.toolchain.cmake -DANDROID_NDK=$(AndroidNdkDirectory)</_CmakeAndroidFlags>
<_CmakeAndroidFlags>$(_CmakeCommonFlags) -DANDROID_STL="system" -DANDROID_CPP_FEATURES="" -DANDROID_TOOLCHAIN=clang -DCMAKE_TOOLCHAIN_FILE=$(AndroidNdkDirectory)\build\cmake\android.toolchain.cmake -DANDROID_NDK=$(AndroidNdkDirectory)</_CmakeAndroidFlags>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but if further updates are required to this PR, we should quote the filesystem paths here, e.g. -DCMAKE_TOOLCHAIN_FILE="$(AndroidNdkDirectory)\build\cmake\android.toolchain.cmake", otherwise things could break should spaces appear in the filesystem path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to change this PR some more anyway, we should make this quoting change. ;-)

@@ -102,14 +102,22 @@ internal class ManifestDocument
}
}
public string GetMinimumSdk () {
log.LogWarning ("GetMinimumSdk called");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not going go want to keep these LogWarning() calls in the final merged commit. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but I can't repro it locally, there's nothing in the logs so I need to get the information somehow...

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from 9a3193b to 9268dba Compare January 21, 2019 16:01
@grendello grendello changed the title Build with Android NDK r18 Build with Android NDK r19 Jan 21, 2019
@grendello grendello force-pushed the ndk18 branch 3 times, most recently from 0966979 to 794b0f9 Compare January 21, 2019 17:06
@grendello
Copy link
Contributor Author

The mac build failure is:

BuildJavaLibs:
   "/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/build-tools/gradle/gradlew" assembleDebug --stacktrace --no-daemon
  To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.1/userguide/gradle_daemon.html.
  Daemon will be stopped at the end of the build stopping after processing
  
  > Configure project :library
  Checking the license for package Android SDK Build-Tools 28.0.3 in /Users/builder/android-toolchain/sdk/licenses
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
EXEC : warning : License for package Android SDK Build-Tools 28.0.3 not accepted. [/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding/Xamarin.Android.LibraryProjectZip-LibBinding.csproj]
  A problem occurred configuring project ':library'.
  > Failed to install the following Android SDK packages as some licences have not been accepted.
       build-tools;28.0.3 Android SDK Build-Tools 28.0.3
    To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
    Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
    
    Using Android SDK: /Users/builder/android-toolchain/sdk
  
  * Try:
  Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Exception is:
  org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':library'.
  	at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:79)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:72)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:53)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:198)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
  	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:111)
  	at org.gradle.internal.Factories$1.create(Factories.java:25)
  	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
  	at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
  	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:226)
  	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:220)
  	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:186)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:95)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
  	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:67)
  	at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:693)
  	at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:141)
  	at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
  	at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
  	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:41)
  	at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:302)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
  	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
  	at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:210)
  	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
  	at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:134)
  	at org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:58)
  	at org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:55)
  	at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:82)
  	at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:75)
  	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
  	at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
  	at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:75)
  	at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:55)
  	at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31)
  	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
  	at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:58)
  	at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
  	at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:39)
  	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:49)
  	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:44)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
  	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
  	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:44)
  	at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:49)
  	at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:46)
  	at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:78)
  	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:46)
  	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
  	at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:42)
  	at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:28)
  	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
  	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:52)
  	at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:59)
  	at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:36)
  	at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:68)
  	at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
  	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
  	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
  	at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
  	at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
  	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60)
  	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
  	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
  	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)
  	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)
  	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)
  	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
  	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
  	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
  	at org.gradle.util.Swapper.swap(Swapper.java:38)
  	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:50)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
  	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:81)
  	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
  	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
  	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
  	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
  	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
  	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
  Caused by: com.android.builder.errors.EvalIssueException: Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;28.0.3 Android SDK Build-Tools 28.0.3
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
  
  Using Android SDK: /Users/builder/android-toolchain/sdk
  	at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:194)
  	at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.java:960)
  	at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:732)
  	at com.android.build.gradle.BasePlugin.lambda$null$4(BasePlugin.java:670)
  	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
  	at com.android.build.gradle.BasePlugin.lambda$createTasks$5(BasePlugin.java:666)
  	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1$1.run(DefaultListenerBuildOperationDecorator.java:150)
  	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.reapply(DefaultUserCodeApplicationContext.java:58)
  	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1.run(DefaultListenerBuildOperationDecorator.java:147)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
  	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction.execute(DefaultListenerBuildOperationDecorator.java:144)
  	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
  	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
  	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
  	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
  	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
  	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
  	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
  	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
  	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
  	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
  	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
  	at com.sun.proxy.$Proxy25.afterEvaluate(Unknown Source)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:190)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:187)
  	at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1419)
  	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:196)
  	... 104 more
  
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 8s
/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding/Xamarin.Android.LibraryProjectZip-LibBinding.targets(49,5): error MSB3073: The command " "/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/build-tools/gradle/gradlew" assembleDebug --stacktrace --no-daemon" exited with code 1. [/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding/Xamarin.Android.LibraryProjectZip-LibBinding.csproj]
Done Building Project "/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding/Xamarin.Android.LibraryProjectZip-LibBinding.csproj" (default targets) -- FAILED.
Project "/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/Xamarin.Android-Tests.sln" (1) is building "/Users/builder/jenkins/workspace/xamarin-android-pr-builder-debug/xamarin-android/tests/CodeGen-Binding/Xamarin.Android.FixJavaAbstractMethod-APIv1Binding/Xamarin.Android.FixJavaAbstractMethod-APIv1Binding.csproj" (11) on node 1 (default targets).
_SetLatestTargetFrameworkVersion:
  Found Java SDK version 1.8.0.
  Found Java SDK version 1.8.0.

I'm not quite sure how to make it work on the bots?

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from a154d3c to 74ebb89 Compare January 22, 2019 10:25
@grendello
Copy link
Contributor Author

Attempt to bump Android SDK platform-tools to version 28.0.1 resulted in the following crash, caused by invalid XML in some documents shipped in the annotations.zip file:

Unhandled Exception:
  System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 214.
    at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String[] args) [0x00029] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Throw (System.Int32 pos, System.String res, System.String[] args) [0x0000c] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow (System.Int32 curPos, System.Char quoteChar, System.Xml.XmlTextReaderImpl+NodeData attr) [0x0022e] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseAttributes () [0x0039a] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseElement () [0x001df] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseElementContent () [0x0016f] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Read () [0x00085] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r) [0x00025] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r, System.Xml.Linq.LoadOptions o) [0x00005] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x00024] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.IO.Stream stream, System.Xml.Linq.LoadOptions options) [0x0000f] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.IO.Stream stream) [0x00000] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.ParseArchiveEntry (System.IO.Compression.ZipArchiveEntry entry) [0x00008] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport+<>c.<ParseArchive>b__0_1 (System.IO.Compression.ZipArchiveEntry e) [0x00000] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at System.Linq.Enumerable+SelectManySingleSelectorIterator`2[TSource,TResult].ToArray () [0x00028] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.OrderedEnumerable`1[TElement].ToArray () [0x00000] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.ParseArchive (System.String file) [0x0007f] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.Load (System.String annotationsZipFile) [0x00001] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.Android.Binder.CodeGenerator.GenerateAnnotationAttributes (System.Collections.Generic.List`1[T] gens, System.Collections.Generic.IEnumerable`1[T] zips) [0x00047] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options, Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x00576] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options) [0x00022] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Main (System.String[] args) [0x00014] in <e75075c121bf488b9d4f751516e31972>:0 
  [ERROR] FATAL UNHANDLED EXCEPTION: System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 214.
    at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String[] args) [0x00029] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Throw (System.Int32 pos, System.String res, System.String[] args) [0x0000c] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow (System.Int32 curPos, System.Char quoteChar, System.Xml.XmlTextReaderImpl+NodeData attr) [0x0022e] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseAttributes () [0x0039a] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseElement () [0x001df] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.ParseElementContent () [0x0016f] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.XmlTextReaderImpl.Read () [0x00085] in <1d98512d69054720a4a7c83f446c7a2f>:0 
    at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r) [0x00025] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r, System.Xml.Linq.LoadOptions o) [0x00005] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x00024] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.IO.Stream stream, System.Xml.Linq.LoadOptions options) [0x0000f] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at System.Xml.Linq.XDocument.Load (System.IO.Stream stream) [0x00000] in <b64edd3ee3524a53b5f7997f6bedce46>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.ParseArchiveEntry (System.IO.Compression.ZipArchiveEntry entry) [0x00008] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport+<>c.<ParseArchive>b__0_1 (System.IO.Compression.ZipArchiveEntry e) [0x00000] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at System.Linq.Enumerable+SelectManySingleSelectorIterator`2[TSource,TResult].ToArray () [0x00028] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.OrderedEnumerable`1[TElement].ToArray () [0x00000] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <e3e1ad292bb544dea242d3448e28d3cc>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.ParseArchive (System.String file) [0x0007f] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.AndroidTools.AnnotationSupport.AndroidAnnotationsSupport.Load (System.String annotationsZipFile) [0x00001] in <06e0d9fce2274eaabc07996e13d2ef8e>:0 
    at Xamarin.Android.Binder.CodeGenerator.GenerateAnnotationAttributes (System.Collections.Generic.List`1[T] gens, System.Collections.Generic.IEnumerable`1[T] zips) [0x00047] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options, Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x00576] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options) [0x00022] in <e75075c121bf488b9d4f751516e31972>:0 
    at Xamarin.Android.Binder.CodeGenerator.Main (System.String[] args) [0x00014] in <e75075c121bf488b9d4f751516e31972>:0 
/mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/src/Mono.Android/Mono.Android.targets(97,5): error MSB3073: The command "mono "/mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/generator.exe" --public --product-version=7 --api-level=28 -o "obj/Debug/android-28/mcw" --codegen-target=XAJavaInterop1 --fixup=metadata --preserve-enums --enumflags=enumflags --enumfields=map.csv --enummethods=methodmap.csv --enummetadata=obj/Debug/android-28/mcw/enummetadata --apiversions="/home/builder/android-toolchain/sdk/platform-tools/api/api-versions.xml" --annotations="/home/builder/android-toolchain/sdk/platform-tools/api/annotations.zip" --assembly="Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" --type-map-report=obj/Debug/android-28/mcw/type-mapping.txt --enumdir=obj/Debug/android-28/mcw obj/Debug/android-28/mcw/api.xml" exited with code 1. [/mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/src/Mono.Android/Mono.Android.csproj]
Done Building Project "/mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/src/Mono.Android/Mono.Android.csproj" (default targets) -- FAILED.

The following files have at least a single issue:

android/view/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 206, position 71.
android/preference/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 66, position 101.
android/accounts/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 214.
android/text/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 189, position 114.
android/widget/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 43, position 105.
android/media/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 145, position 142.
android/view/textclassifier/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 143, position 119.
android/hardware/camera2/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 33, position 140.
android/app/slice/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 13, position 140.
android/bluetooth/le/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 83.
android/hardware/camera2/params/annotations.xml failed: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 108.

I've reverted the platform-tools bump to avoid the crash, but we must do something to handle this in the future.

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from d9b6974 to 3b73da5 Compare January 24, 2019 08:39
@@ -117,4 +120,14 @@
WorkingDirectory="$(MonoSourceFullPath)\sdks\builds"
/>
</Target>

<Target Name="_CreateBuildConfig"
DependsOnTargets="GetNDKVersionInfo"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some inputs and outputs on this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no inputs and outputs except for the targets file itself, and it follows the pattern of GetXAVersionInfo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that this target updates XABuildConfig.cs, which means we can have "cascading rebuilds": rebuild android-toolchain, XABuildConfig.cs is updated, then Xamarin.Android.Build.Tasks.csproj and Xamarin.Android.Build.Tests.csproj and all their dependencies need to be rebuilt.

This is a recipe for "Bad Things".

At minimum, we can have an Inputs of ..\scripts\XABuildConfig.cs.in and Outputs of ..\..\bin\Build$(Configuration)\XABuildConfig.cs.

That's not complete, because we need to invalidate when any of the properties changes, but it's a start. We'd probably also want inputs of build-tools\scripts\Ndk.targets (for $(AndroidNdkVersion)), $(AndroidNdkDirectory)\.stamp-ndk-$(AndroidNdkVersion) (for the actual NDK install, which in turn controls $(_NDKRevision) and company, maybe?).

Another issue is that <ReplaceFileContents/> always updates the output file, even if it hasn't actually changed.

Thus, an "ideal" fix would be:

  1. Update <ReplaceFileContents/> so that the output file isn't touched if the contents haven't changed. See also Files.CopyIfChanged() (which might not be usable from the current xa-prep-tasks.dll, but that's fixable).
  2. Add Inputs & Outputs
  3. The Outputs should not be XABuildConfig.cs, but rather a "stamp" file.

For example:

<Target Name="_CreateBuildConfig"
    DependsOnTargets="GetNDKVersionInfo"
    AfterTargets="Build"
    Inputs="..\scripts\XABuildConfig.cs.in;..\scripts\Ndk.targets"
    Outputs="..\..\bin\Build$(Configuration)\.stamp-XABuildConfig.cs">
  <ReplaceFileContents
      SourceFile="..\scripts\XABuildConfig.cs.in"
      DestinationFile="..\..\bin\Build$(Configuration)\XABuildConfig.cs"
      Replacements="@NDK_MINIMUM_API_AVAILABLE@=$(_NDKMinimumApiAvailable);@NDK_RELEASE@=$(AndroidNdkVersion);@NDK_REVISION@=$(_NDKRevision);@NDK_VERSION_MAJOR@=$(_NDKVersionMajor);@NDK_VERSION_MINOR@=$(_NDKVersionMinor);@NDK_VERSION_MICRO@=$(_NDKVersionMicro);@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a);@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a);@NDK_X86_API@=$(AndroidNdkApiLevel_X86);@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64)"
  />
  <Touch Files="..\..\bin\Build$(Configuration)\.stamp-XABuildConfig.cs"  AlwaysCreate="True" />
</Target>

This would reduce/remove the risk of inadvertent rebuild cascades.

if (libPath == null)
throw new Exception("Could not find a valid NDK GCC toolchain library path");
if (libPath == null) {
goto no_toolchain_error;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm... a 'goto' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, nothing wrong with gotos


namespace Xamarin.Android.Tasks
{
public static class NdkUtilOld {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question... Should we keep NdkUtilOld around at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually no, but for now we don't want to force our users to upgrade to NDK r19

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the older NDK version in the name might be better than Old then, such as NdkUtil16 or something.

Or even just a <summary/> command explaining it would be good 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The older NDK version is anything bellow 19 - thus the suffix "Old"...

@@ -22,47 +21,47 @@
<HostOS>Linux</HostOS>
<DestDir>build-tools\$(XABuildToolsFolder)</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="platform-tools_r28.0.0-linux">
<AndroidSdkItem Include="platform-tools_r$(XAPlatformToolsVersion)-linux">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A concern with this kind of change is a variation on
#2592 (comment).

We have a "mono bundle", and the mono bundle is invalidated whenever:

  1. The mono commit hash changes; or
  2. The libzip commit hash changes; or
  3. the llvm commit hash changes; or
  4. The file content hash of all files within the @(VersionFile) item group within build-tools/create-bundle/bundle-path.targets changes.

Ideally, we want to invalidate the mono bundle as infrequently as possible.

Configuration.props is not in @(VersionFile). (Nor do we want it in @(VersionFile), as Configuration.props can be expected to change more frequently.)

Ndk.targets is in @(VersionFile) (yay).

However, now we hit the philosophical questions: how much -- if any! -- of build-tools/android-toolchain should be considered for mono bundle invalidation?

$(AndroidNdkVersion) is in Ndk.targets, which is part of @(VersionFile). That's fine.

$(XAPlatformToolsVersion) is in Configuration.props, which is not part of @(VersionFile). Is that fine?

I think it'll be fine? I don't see anything in $HOME/android-toolchain/sdk//platform-tools which should impact the mono bundle, but we do need to ensure we don't make a mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine. platform-tools are not used in building Mono.

static bool usingNewNDK;
static bool initialized;

public static bool UsingNewNDK => usingNewNDK;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this name, as it's contextually meaningless. It's the "new NDK" now, but it won't be once a newer NDK comes out. I would prefer a more semantically meaningful name, such as UsingNdk19 (which isn't necessarily "wonderful," but at least lets us know when the corresponding logic might be invalidated).

Alternatively, and more "future proof" (lol?), should this instead be an enum, so that we can use a switch in all the places currently checking for UsingNewNDK?

public enum NdkDirectoryLayoutStyle {
    Ndk14,
    Ndk19,
}

@@ -12,17 +12,17 @@
<Target Name="_BuildSqlite" DependsOnTargets="_ConfigureSqlite;_BuildAndroidSqlite" />

<Target Name="_ConfigureSqlite"
Inputs="CMakeLists.txt"
Inputs="CMakeLists.txt;;..\..\build-tools\scripts\Ndk.targets"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one ; is needed here.


public static bool UsingNewNDK => usingNewNDK;

public static void Init (string ndkPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could break if the NDK is updated/replaced while the IDE has an XA project loaded.

I don't know how likely that is to happen. :-)

bool forCompiler = false;

if (String.Compare (tool, "gcc", StringComparison.Ordinal) == 0 ||
String.Compare (tool, "clang", StringComparison.Ordinal) == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code formatting style: indent primarily with tabs, and this expression should be indented more than the following block, e.g.

if (String.Compare (tool, "gcc", StringComparison.Ordinal) == 0 ||
        String.Compare (tool, "clang", StringComparison.Ordinal) == 0) {
    forCompiler = true;
    toolName = "clang";
}

@grendello grendello force-pushed the ndk18 branch 2 times, most recently from 7bddbeb to 9b01735 Compare January 24, 2019 22:43
  * Update gradle to version 5.1 (the latest version)
  * Update gradle android addin to 3.2.1 (required for r18+ as it removes
    dependency on the MIPS toolchain which no longer exists in r18+)
  * Bump all the instances of `android:minSdkVersion` to `16` since this is the
    lowest NDK API found in NDK r19 and, thus, the lowest API our runtimes can
    run on.
  * Fix AOT build tests by targetting API 16 at the minimum.
  * Introduce the `Xamarin.Android.Tools.XABuildConfig` class, generated at the
    XA build time, which includes all the necessary information about the NDK
    the native runtime was built with.
  * Put NDK and per-architecture mimum API level in
    `Xamarin.Android.Common.props` based on the contents of
    `build-tools/scripts/Ndk.targets`
  * Update SDK build-tools to 28.0.3, the minimum required by the updated
    Android gradle plugin
  * Update SDK emulator to the latest version, because we should always try to
    use the latest version of it (assuming blindly that it gets faster and
    faster and faster and... etc)

Future bumps of NDK versions and per-architecture API levels will require
changing just a single file - `build-tools/scripts/Ndk.targets` - in order to
make the change visible and used by all the other parties.
@jonpryor jonpryor merged commit 06e920c into dotnet:master Jan 25, 2019
@grendello grendello deleted the ndk18 branch January 25, 2019 17:43
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants