Enable Portable Windows RID (dotnet/coreclr#10365)
authorGaurav Khanna <gkhanna@microsoft.com>
Wed, 22 Mar 2017 20:30:49 +0000 (13:30 -0700)
committerGitHub <noreply@github.com>
Wed, 22 Mar 2017 20:30:49 +0000 (13:30 -0700)
* Enable Portable RID support for Windows and OSX.

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

src/coreclr/build.cmd
src/coreclr/build.sh
src/coreclr/config.json
src/coreclr/src/.nuget/dir.props

index e450cf2..13c3fb4 100644 (file)
@@ -98,6 +98,9 @@ set __BuildPackages=1
 set __BuildNativeCoreLib=1
 set __RestoreOptData=1
 
+REM Is this a portable build?
+set __IsPortableBuild=
+
 :Arg_Loop
 if "%1" == "" goto ArgsDone
 
@@ -115,6 +118,8 @@ if /i "%1" == "debug"               (set __BuildTypeDebug=1&set processedArgs=!p
 if /i "%1" == "checked"             (set __BuildTypeChecked=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
 if /i "%1" == "release"             (set __BuildTypeRelease=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
 
+if /i "%1" == "portable"             (set __IsPortableBuild=-portable&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
+
 REM All arguments after this point will be passed through directly to build.cmd on nested invocations
 REM using the "all" argument, and must be added to the __PassThroughArgs variable.
 if [!__PassThroughArgs!]==[] (
@@ -474,7 +479,7 @@ if %__BuildPackages% EQU 1 (
        set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
 
     REM The conditions as to what to build are captured in the builds file.
-    @call %__ProjectDir%\run.cmd build -Project=%__SourceDir%\.nuget\packages.builds -platform=%__BuildArch% -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! %__RunArgs% %__UnprocessedBuildArgs%
+    @call %__ProjectDir%\run.cmd build -Project=%__SourceDir%\.nuget\packages.builds %__IsPortableBuild% -platform=%__BuildArch% -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! %__RunArgs% %__UnprocessedBuildArgs%
 
     if not !errorlevel! == 0 (
         echo %__MsgPrefix%Error: Nuget package generation failed build failed. Refer to the build log files for details:
@@ -643,6 +648,7 @@ echo -sequential: force a non-parallel build ^(default is to build in parallel
 echo     using all processors^).
 echo -officialbuildid=^<ID^>: specify the official build ID to be used by this build.
 echo -Rebuild: passes /t:rebuild to the build projects.
+echo portable : build for portable RID.
 echo.
 echo If "all" is specified, then all build architectures and types are built. If, in addition,
 echo one or more build architectures or types is specified, then only those build architectures
index c48a7a2..7c5f55b 100755 (executable)
@@ -38,7 +38,7 @@ usage()
     echo "skiptests - skip the tests in the 'tests' subdirectory."
     echo "skipnuget - skip building nuget packages."
     echo "skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
-    echo "portableLinux - build for Portable Linux Distribution"
+    echo "portable - build for portable RID."
     echo "verbose - optional argument to enable verbose build output."
     echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
        echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
@@ -85,8 +85,12 @@ initTargetDistroRid()
     fi
 
     # Portable builds target the base RID only for Linux based platforms
-    if [ $__PortableLinux == 1 ]; then
-        export __DistroRid="linux-$__BuildArch"
+    if [ $__PortableBuild == 1 ]; then
+        if [ "$__BuildOS" == "Linux" ]; then
+            export __DistroRid="linux-$__BuildArch"
+        elif [ "$__BuildOS" == "OSX" ]; then
+            export __DistroRid="osx-$__BuildArch"
+        fi
     fi
 }
 
@@ -573,7 +577,7 @@ __DistroRid=""
 __cmakeargs=""
 __SkipGenerateVersion=0
 __DoCrossArchBuild=0
-__PortableLinux=0
+__PortableBuild=0
 __msbuildonunsupportedplatform=0
 __PgoOptDataVersion=""
 __IbcOptDataVersion=""
@@ -630,15 +634,10 @@ while :; do
             __CrossBuild=1
             ;;
             
-        portablelinux)
-            if [ "$__BuildOS" == "Linux" ]; then
-                __PortableLinux=1
-            else
-                echo "ERROR: portableLinux not supported for non-Linux platforms."
-                exit 1
-            fi
+        portable)
+            __PortableBuild=1
             ;;
-            
+
         verbose)
             __VerboseBuild=1
             ;;
index 03a7054..9900b47 100644 (file)
       "values": [ "x86", "x64", "arm", "arm64" ],
       "defaultValue": "${CPUArch}"
     },
+    "PortableBuild": {
+      "description": "Indicates if this is a portable build.",
+      "valueType": "property",
+      "values": [ "0", "1"],
+      "defaultValue": "0"
+    },
     "Rebuild": {
       "description": "Specifies rebuild target.",
       "valueType": "target",
             "RestoreDuringBuild": false
           }
         },
+        "portable": {
+          "description": "Triggers a portable build.",
+          "settings": {
+            "PortableBuild": "1"
+          }
+        },
         "BuildTarget": {
           "description": "Runs the build target.",
           "settings": {
index eb14571..6f9e29c 100644 (file)
     <When Condition="'$(PackageRID)' != ''" />
     <When Condition="'$(_runtimeOSFamily)' == 'win'">
       <PropertyGroup>
-        <PackageRID Condition="'$(ArchGroup)' == 'x86' OR '$(ArchGroup)' == 'x64'">win7-$(ArchGroup)</PackageRID>
-        <PackageRID Condition="'$(ArchGroup)' == 'arm'">win8-$(ArchGroup)</PackageRID>
-        <PackageRID Condition="'$(ArchGroup)' == 'arm64'">win10-$(ArchGroup)</PackageRID>
+        <RIDPlatform>win7</RIDPlatform>
+        <RIDPlatform Condition="'$(ArchGroup)' == 'arm'">win8</RIDPlatform>
+        <RIDPlatform Condition="'$(ArchGroup)' == 'arm64'">win10</RIDPlatform>
+        
+        <!-- Set the platform part of the RID if we are doing a portable build -->
+        <RIDPlatform Condition="'$(PortableBuild)' == '1'">win</RIDPlatform>
+        <PackageRID>$(RIDPlatform)-$(ArchGroup)</PackageRID>
       </PropertyGroup>
     </When>
     <When Condition="'$(_runtimeOSFamily)' == 'osx'">