Skip to content

Commit

Permalink
[build] Package build artifacts with make jenkins (dotnet#153)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonpryor authored and grendello committed Aug 9, 2016
1 parent 2943bb1 commit 1eebbe3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 13 deletions.
1 change: 1 addition & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Condition=" '$(DoNotLoadOSProperties)' != 'True' "
/>
<PropertyGroup>
<ProductVersion>7.0.99</ProductVersion>
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
<HostCc Condition=" '$(HostCc)' == '' ">$(HostCc64)</HostCc>
<HostCxx Condition=" '$(HostCxx)' == '' ">$(HostCxx64)</HostCxx>
Expand Down
27 changes: 26 additions & 1 deletion build-tools/scripts/BuildEverything.mk
Original file line number Diff line number Diff line change
@@ -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 '<ProductVersion>' | 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.
Expand Down Expand Up @@ -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)
Expand All @@ -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 %)
2 changes: 1 addition & 1 deletion samples/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
</PropertyGroup>
<Import Project="..\..\..\Configuration.props" />
<Import Project="..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
Expand Down
49 changes: 38 additions & 11 deletions tools/scripts/xabuild
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down

0 comments on commit 1eebbe3

Please sign in to comment.