First steps for generating nuget packages for ARM64/Android. (dotnet/coreclr#10286)
authorCyd Haselton <chaselton@gmail.com>
Thu, 8 Jun 2017 22:34:04 +0000 (17:34 -0500)
committerGaurav Khanna <gkhanna@microsoft.com>
Thu, 8 Jun 2017 22:34:04 +0000 (15:34 -0700)
* First steps for generating nuget packages for ARM64/Android. Adds Android RIDS and related conditionals to appropriate files

* Additional changes for Android package build

* Revert addition of Android to supported packages

* Allow Android .nuget package build

Adding runtime.Android files for package generation
Adding TODO for reliable generation of __DistroRid for Android

* Added/corrected logic for detecting __DistroRid at commandline
Removed hack and TODO

* Removed newline

* Revert unintentional change to osx rid

* Removed commenting of __DistroRid initialization

* Latest fixes for __DistroRid cmdline detection

Removed __DistroRid initialization (clobbers value set at cmdline)
Removed echo test of __DistroRid in generate nuget pkg function
(Hopefully) fixed cross-build os-release detection

* Removed android.21-arm from supported RIDs

Removed arm32 from supported RIDs until test build can be done or CI for arm32 added (?)

* Fixes for package generation for android

Modified build-android-rootfs.sh so it would generate file w/platform info
Reverted all prior changes to initTargetDistroRid, added new android platform detection

* Fixed conditional for Android

* Added platform generation for Android portable build, if ever needed

* Added information about android_platform

Added help info about android_platform file
Added TODO for dynamic generation of RID based on $__ApiLevel and $__BuildArch

* Syntax cleanup for build.sh

Removed extra space in initTargetDistroRid() logic

* Recommended review changes

removed Android-specific runtime files for packaging
added conditional to have Android use Linux runtime files

* Updated topic branch from master, resolving SPC.ni.dll file nuget pkg issue

* ericstj review changes

Fixed accidental fedora version change
Fixed indenting

* Removed TODO comment; logic already in place, added in earlier commit

* Removed Android OfficialBuildRID

Commit migrated from https://github.com/dotnet/coreclr/commit/b4cbd9dbdc9f1850e5953bc785d2abb6cf0f69c3

src/coreclr/build.sh
src/coreclr/config.json
src/coreclr/cross/build-android-rootfs.sh
src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props
src/coreclr/src/.nuget/dir.props

index 3385a87..a85b137 100755 (executable)
@@ -73,8 +73,13 @@ initTargetDistroRid()
     if [ $__CrossBuild == 1 ]; then
         if [ "$__BuildOS" == "Linux" ]; then
             if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
-                echo "WARNING: Can not determine runtime id for current distro."
-                export __DistroRid=""
+                if [ -e $ROOTFS_DIR/android_platform ]; then
+                    source $ROOTFS_DIR/android_platform
+                    export __DistroRid="$RID"
+                else
+                    echo "WARNING: Can not determine runtime id for current distro."
+                    export __DistroRid=""
+                fi
             else
                 source $ROOTFS_DIR/etc/os-release
                 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
@@ -484,7 +489,8 @@ generate_NugetPackages()
     fi
 
     echo "Generating nuget packages for "$__BuildOS
-
+    echo "DistroRid is "$__DistroRid
+    echo "ROOTFS_DIR is "$ROOTFS_DIR
     # Build the packages
     $__ProjectRoot/run.sh build -Project=$__SourceDir/.nuget/packages.builds -MsBuildLog="/flp:Verbosity=normal;LogFile=$__LogsDir/Nuget_$__BuildOS__$__BuildArch__$__BuildType.log" -BuildTarget -__IntermediatesDir=$__IntermediatesDir -__RootBinDir=$__RootBinDir -BuildNugetPackage=false -UseSharedCompilation=false $__RunArgs $__UnprocessedBuildArgs
 
index a85dcd5..8f3a58b 100644 (file)
@@ -51,7 +51,7 @@
     "FilterToOSGroup": {
       "description": "Specifies the OSGroup.",
       "valueType": "property",
-      "values": [ "Windows_NT", "Linux", "Unix", "OSX" ],
+      "values": [ "Windows_NT", "Linux", "Unix", "OSX", "Android" ],
       "defaultValue": "${OSName}"
     },
     "RestoreNETCorePlatforms": {
@@ -93,7 +93,7 @@
     "__BuildOS": {
       "description": "Specifies the OS to publish packages.",
       "valueType": "property",
-      "values": [ "Linux", "OSX", "FreeBSD", "OpenBSD", "NetBSD", "SunOS", "Windows_NT" ],
+      "values": [ "Linux", "OSX", "FreeBSD", "OpenBSD", "NetBSD", "SunOS", "Windows_NT", "Android" ],
       "defaultValue": "${OSName}"
     },
     "__DistroRid": {
     "RuntimeId": {
       "description": "Specifies the OS to build Core_Root for",
       "valueType": "property",
-      "values": [ "debian.8-x64", "fedora.24-x64", "fedora.25-x64", "opensuse.42.1-x64", "osx.10.12-x64", "rhel.7-x64", "ubuntu.14.04-x64", "ubuntu.16.04-x64", "ubuntu.16.10-x64" ],
+      "values": [ "debian.8-x64", "fedora.24-x64", "fedora.25-x64", "opensuse.42.1-x64", "osx.10.12-x64", "rhel.7-x64", "ubuntu.14.04-x64", "ubuntu.16.04-x64", "ubuntu.16.10-x64", "android.21-arm64" ],
       "defaultValue": "${__RuntimeId}"
     },
     "BatchRestorePackages": {
index 7030837..636618c 100755 (executable)
@@ -15,6 +15,7 @@ usage()
     echo.
     echo "By default, the NDK will be downloaded into the cross/android-rootfs/android-ndk-$__NDK_Version directory. If you already have an NDK installation,"
     echo "you can set the NDK_DIR environment variable to have this script use that installation of the NDK."
+    echo "By default, this script will generate a file, android_platform, in the root of the ROOTFS_DIR directory that contains the RID for the supported and tested Android build: android.21-arm64. This file is to replace '/etc/os-release', which is not available for Android."
     exit 1
 }
 
@@ -136,7 +137,10 @@ dpkg -x $__Android_Cross_Dir/deb/libunwind_1.2.20170304_$__AndroidArch.deb $__An
 
 cp -R $__Android_Cross_Dir/tmp/$__AndroidArch/data/data/com.termux/files/usr/* $__ToolchainDir/sysroot/usr/
 
+# Generate platform file for build.sh script to assign to __DistroRid
+echo "Generating platform file..."
 
+echo "RID=android.21-arm64" > $__ToolchainDir/sysroot/android_platform
 echo Now run:
 echo CONFIG_DIR=\`realpath cross/android/$__BuildArch\` ROOTFS_DIR=\`realpath $__ToolchainDir/sysroot\` ./build.sh cross $__BuildArch skipgenerateversion skipnuget cmakeargs -DENABLE_LLDBPLUGIN=0
 
index 5f244a9..d62f4d6 100644 (file)
@@ -6,7 +6,9 @@
     <_PlatformDoesNotSupportCreatedump Condition="'$(Platform)' == 'x86'">true</_PlatformDoesNotSupportCreatedump>
     <_PlatformDoesNotSupportCreatedump Condition="'$(_runtimeOSFamily)' == 'tizen'">true</_PlatformDoesNotSupportCreatedump>
     <_PlatformDoesNotSupportEventTrace Condition="'$(_runtimeOSFamily)' == 'tizen'">true</_PlatformDoesNotSupportEventTrace>
+    <_PlatformDoesNotSupportEventTrace Condition="'$(Platform)' == 'arm64'">true</_PlatformDoesNotSupportEventTrace>
     <_PlatformDoesNotSupportEventTrace Condition="'$(Platform)' == 'x86'">true</_PlatformDoesNotSupportEventTrace>
+    <_PlatformDoesNotSupportSosPlugin Condition="'$(_runtimeOSFamily)' == 'android'">true</_PlatformDoesNotSupportSosPlugin>
   </PropertyGroup>
   <ItemGroup>
     <NativeBinary Include="$(BinDir)libcoreclr.so" />
@@ -15,7 +17,7 @@
     <NativeBinary Include="$(BinDir)libmscordaccore.so" />
     <NativeBinary Include="$(BinDir)libmscordbi.so" />
     <NativeBinary Include="$(BinDir)libsos.so" />
-    <NativeBinary Include="$(BinDir)libsosplugin.so" />
+    <NativeBinary Condition="'$(_PlatformDoesNotSupportSosPlugin)' != 'true'" Include="$(BinDir)libsosplugin.so" />
     <NativeBinary Include="$(BinDir)System.Globalization.Native.so" />
     <NativeBinary Include="$(BinDir)sosdocsunix.txt" />
     <NativeBinary Include="$(BinDir)System.Private.CoreLib.dll" />
index 2ff88d9..52e9436 100644 (file)
@@ -23,7 +23,7 @@
 
     <RuntimeOS Condition="'$(RuntimeOS)' == ''">$(OSRid)</RuntimeOS>
 
-    <SupportedPackageOSGroups Condition="'$(SupportedPackageOSGroups)' == ''">Windows_NT;OSX;Linux</SupportedPackageOSGroups>
+    <SupportedPackageOSGroups Condition="'$(SupportedPackageOSGroups)' == ''">Windows_NT;OSX;Android;Linux</SupportedPackageOSGroups>
     <SupportedPackageOSGroups>;$(SupportedPackageOSGroups);</SupportedPackageOSGroups>
 
     <!-- Identify OS family based upon the RuntimeOS, which could be distro specific (e.g. osx.10.12) or 
@@ -38,6 +38,7 @@
   <!-- derive an OS Group based on the OS Family -->
   <PropertyGroup>
     <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'osx'">OSX</_derivedPackageTargetOSGroup>
+    <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'android'">Android</_derivedPackageTargetOSGroup>
     <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'win'">Windows_NT</_derivedPackageTargetOSGroup>
     <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(__BuildOS)' != ''">$(__BuildOS)</_derivedPackageTargetOSGroup>
     <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == ''">Linux</_derivedPackageTargetOSGroup>
   <!-- _packageTargetOSGroup is used to control the runtime package imports, don't import runtime package targets for 
        an unsupported OS Group -->
   <PropertyGroup Condition="'$(PackageTargetRuntime)' != '' and '$(_isSupportedOSGroup)' == 'true'">
+    <!-- Android will use Linux package definitions -->
     <_packageTargetOSGroup>$(_derivedPackageTargetOSGroup)</_packageTargetOSGroup>
+    <_packageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == 'Android'">Linux</_packageTargetOSGroup>
   </PropertyGroup>
-
   <PropertyGroup>
     <SkipPackageFileCheck>true</SkipPackageFileCheck>
     <OutputPath>$(PackageOutputPath)</OutputPath>
         <PackageRID Condition="'$(PortableBuild)' == 'true'">osx-$(ArchGroup)</PackageRID>
       </PropertyGroup>
     </When>
+    <When Condition="'$(_runtimeOSFamily)' == 'android'">
+      <PropertyGroup>
+        <PackageRID>android.21-$(ArchGroup)</PackageRID>
+        <!-- Set the platform part of the RID if we are doing a portable build -->
+        <PackageRID Condition="'$(PortableBuild)' == '1'">android-$(ArchGroup)</PackageRID>
+      </PropertyGroup>
+    </When>
     <When Condition="'$(_runtimeOSFamily)' == 'rhel'">
       <PropertyGroup>
         <PackageRID>rhel.7-$(ArchGroup)</PackageRID>
         <SymbolFileExtension>.dwarf</SymbolFileExtension>
       </PropertyGroup>
     </When>
+    <When Condition="'$(_runtimeOSFamily)' == 'android'">
+      <PropertyGroup>
+        <LibraryFileExtension>.so</LibraryFileExtension>
+        <!--symbols included in .so, like Linux, but can be generated externally and if so, uses .debug ext-->
+        <SymbolFileExtension>.debug</SymbolFileExtension>
+      </PropertyGroup>
+    </When>
     <Otherwise>
       <PropertyGroup>
         <LibraryFileExtension>.so</LibraryFileExtension>
     <!-- Include project references for a lineup package to generate the runtime.json file -->
     <ProjectReference Include="@(_buildRidProjects)" />
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>