From 1c7e248bb71973193e8e7100870a3597c10b74d8 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Tue, 9 Aug 2016 14:51:44 -0400 Subject: [PATCH] [build] Package build artifacts with `make jenkins` Update the `make jenkins` target to package up the `bin` directory for (hopeful) use on other machines. The generated package is named: oss-xamarin-android_vVERSION_OS-ARCH_BRANCH_COMMIT.zip where: * **VERSION** is the new `$(ProductVersion)` MSBuild property along with the number of commits since `$(ProductVersion)` was *changed* * **OS** is the name of the OS that built the package * **ARCH** is the OS architecture * **BRANCH** is the git branch being built (usually `master`) * **COMMIT** is the git commit that was built. For example: oss-xamarin.android_v7.0.99.0_Darwin-x86_64_jonp-zip-output_c4eab00.zip The package file is *not* an installer, just a ZIP package, but should contain everything needed to *create* an installer. This also copies `tools/scripts/xabuild` into the appropriate `bin/$(Configuration)/bin` directories so that an `xabuild` script is installed as part of the package, and `xabuild` is updated to setup the various environment variables accordingly so it is invokable from the `bin/$(Configuration)/bin` directories. --- Configuration.props | 1 + build-tools/scripts/BuildEverything.mk | 27 +++++++++++++- samples/HelloWorld/HelloWorld.csproj | 2 +- tools/scripts/xabuild | 49 ++++++++++++++++++++------ 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/Configuration.props b/Configuration.props index f117c7c6378..916e8e3afaa 100644 --- a/Configuration.props +++ b/Configuration.props @@ -12,6 +12,7 @@ Condition=" '$(DoNotLoadOSProperties)' != 'True' " /> + 7.0.99 Windows $(HostCc64) $(HostCxx64) diff --git a/build-tools/scripts/BuildEverything.mk b/build-tools/scripts/BuildEverything.mk index e630e5d69d6..aebedaaa8aa 100644 --- a/build-tools/scripts/BuildEverything.mk +++ b/build-tools/scripts/BuildEverything.mk @@ -1,3 +1,18 @@ +PRODUCT_VERSION = $(shell $(MSBUILD) $(MSBUILD_FLAGS) /p:DoNotLoadOSProperties=True /nologo /v:minimal /t:GetProductVersion build-tools/scripts/Info.targets | tr -d '[[:space:]]') + +GIT_BRANCH = $(shell LANG=C git rev-parse --abbrev-ref HEAD | tr -d '[[:space:]]' | tr -C a-zA-Z0-9- _) +GIT_COMMIT = $(shell LANG=C git log --no-color --first-parent -n1 --pretty=format:%h) + +# In which commit did $(PRODUCT_VERSION) change? 00000000 if uncommitted +-commit-of-last-version-change = $(shell LANG=C git blame Configuration.props | grep '' | grep -v grep | sed 's/ .*//') + +# How many commits have passed since $(-commit-of-last-version-change)? +# "0" when commit hash is invalid (e.g. 00000000) +-num-commits-since-version-change = $(shell LANG=C git log $(-commit-of-last-version-change)..HEAD --oneline 2>/dev/null | wc -l | sed 's/ //g') + +ZIP_OUTPUT = oss-xamarin.android_v$(PRODUCT_VERSION).$(-num-commits-since-version-change)_$(OS)-$(OS_ARCH)_$(GIT_BRANCH)_$(GIT_COMMIT).zip + + # $(ALL_API_LEVELS) and $(ALL_FRAMEWORKS) must be kept in sync w/ each other ALL_API_LEVELS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 # this was different when API Level 21 was "L". Same could happen in the future. @@ -58,7 +73,7 @@ FRAMEWORK_ASSEMBLIES = \ $(FRAMEWORKS:%=bin/Debug/lib/xbuild-frameworks/MonoAndroid/%/Mono.Android.dll) \ $(FRAMEWORKS:%=bin/Release/lib/xbuild-frameworks/MonoAndroid/%/Mono.Android.dll) -leeroy jenkins: prepare $(RUNTIME_LIBRARIES) $(TASK_ASSEMBLIES) $(FRAMEWORK_ASSEMBLIES) +leeroy jenkins: prepare $(RUNTIME_LIBRARIES) $(TASK_ASSEMBLIES) $(FRAMEWORK_ASSEMBLIES) $(ZIP_OUTPUT) $(TASK_ASSEMBLIES): bin/%/lib/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll: $(MSBUILD) $(MSBUILD_FLAGS) /p:Configuration=$* $(_MSBUILD_ARGS) $(SOLUTION) @@ -71,3 +86,13 @@ $(FRAMEWORK_ASSEMBLIES): $(RUNTIME_LIBRARIES): $(MSBUILD) $(MSBUILD_FLAGS) /p:Configuration=Debug $(_MSBUILD_ARGS) $(SOLUTION) $(MSBUILD) $(MSBUILD_FLAGS) /p:Configuration=Release $(_MSBUILD_ARGS) $(SOLUTION) + +_BUNDLE_ZIPS = $(wildcard bin/*/bundle-*.zip) + +package-oss-name: + @echo ZIP_OUTPUT=$(ZIP_OUTPUT) + +package-oss $(ZIP_OUTPUT): + if [ -d bin/Debug/bin ] ; then cp tools/scripts/xabuild bin/Debug/bin ; fi + if [ -d bin/Release/bin ] ; then cp tools/scripts/xabuild bin/Release/bin ; fi + zip -r "$(ZIP_OUTPUT)" bin $(_BUNDLE_ZIPS:%=--exclude %) diff --git a/samples/HelloWorld/HelloWorld.csproj b/samples/HelloWorld/HelloWorld.csproj index 29ebf50835d..b018bdcf560 100644 --- a/samples/HelloWorld/HelloWorld.csproj +++ b/samples/HelloWorld/HelloWorld.csproj @@ -16,7 +16,7 @@ Assets true - + $(AndroidFrameworkVersion) diff --git a/tools/scripts/xabuild b/tools/scripts/xabuild index 0b3578e3f51..ed8172607d2 100755 --- a/tools/scripts/xabuild +++ b/tools/scripts/xabuild @@ -1,26 +1,53 @@ #!/bin/bash -e -topdir="$(cd `dirname "$0"`/../.. && pwd)" + +name=$(basename "$0") if [ -z "$CONFIGURATION" ] ; then CONFIGURATION=Debug fi +xabuilddir="$(cd `dirname "$0"` && pwd)" + +if [[ "$xabuilddir" == */tools/scripts ]] ; then + topdir="$xabuilddir/../../bin/$CONFIGURATION" + Paths_targets="$xabuilddir/../../build-tools/scripts/Paths.targets" +elif [[ "$xabuilddir" == */bin ]] ; then + topdir="$xabuilddir/.." +else + (>&2 echo "$name: Could not determine location to Xamarin.Android locations.") + exit 1 +fi + if [ -z "$MSBUILD" ] ; then MSBUILD=xbuild fi -export TARGETS_DIR="$topdir/bin/$CONFIGURATION/lib/xbuild" -export MSBuildExtensionsPath="$TARGETS_DIR" -export MONO_ANDROID_PATH="$topdir/bin/$CONFIGURATION" -export XBUILD_FRAMEWORK_FOLDERS_PATH="$topdir/bin/$CONFIGURATION/lib/xbuild-frameworks" -ANDROID_NDK_PATH=$(xbuild /nologo /v:minimal /t:GetAndroidNdkFullPath $topdir/build-tools/scripts/Paths.targets) -ANDROID_SDK_PATH=$(xbuild /nologo /v:minimal /t:GetAndroidSdkFullPath $topdir/build-tools/scripts/Paths.targets) +if [ -z "$ANDROID_NDK_PATH" -a -f "$Paths_targets" ] ; then + ANDROID_NDK_PATH=$($MSBUILD /nologo /v:minimal /t:GetAndroidNdkFullPath "$Paths_targets") + ANDROID_NDK_PATH=$(echo $ANDROID_NDK_PATH | sed 's/^\w*//g') + export ANDROID_NDK_PATH +fi + +if [ -z "$ANDROID_SDK_PATH" -a -f "$Paths_targets" ] ; then + ANDROID_SDK_PATH=$($MSBUILD /nologo /v:minimal /t:GetAndroidSdkFullPath "$Paths_targets") + ANDROID_SDK_PATH=$(echo $ANDROID_SDK_PATH | sed 's/^\w*//g') + export ANDROID_SDK_PATH +fi -ANDROID_NDK_PATH=$(echo $ANDROID_NDK_PATH | sed 's/^\w*//g') -ANDROID_SDK_PATH=$(echo $ANDROID_SDK_PATH | sed 's/^\w*//g') +if [ -z "$ANDROID_NDK_PATH" ] ; then + >&2 echo "$name: Could not determine Android NDK path. Please export the \$ANDROID_NDK_PATH environment variable." + exit 1 +fi + +if [ -z "$ANDROID_SDK_PATH" ] ; then + >&2 echo "$name: Could not determine Android SDK path. Please export the \$ANDROID_SDK_PATH environment variable." + exit 1 +fi -export ANDROID_NDK_PATH -export ANDROID_SDK_PATH +export TARGETS_DIR="$topdir/lib/xbuild" +export MSBuildExtensionsPath="$TARGETS_DIR" +export MONO_ANDROID_PATH="$topdir" +export XBUILD_FRAMEWORK_FOLDERS_PATH="$topdir/lib/xbuild-frameworks" exec $MSBUILD /p:Configuration=$CONFIGURATION $MSBUILD_OPTIONS \ /p:AndroidNdkDirectory="$ANDROID_NDK_PATH" \