Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ ifeq ($(USE_MSBUILD),1)
done
endif # msbuild

prepare-image-dependencies:
$(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/PrepareImageDependencies.targets /t:PrepareImageDependencies \
/p:AndroidSupportedHostJitAbis=mxe-Win32:mxe-Win64

include build-tools/scripts/BuildEverything.mk
include tests/api-compatibility/api-compatibility.mk

Expand Down
49 changes: 49 additions & 0 deletions build-tools/scripts/PrepareImageDependencies.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
</PropertyGroup>
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
<Import Project="..\..\Configuration.props" />
<Import Project="..\android-toolchain\android-toolchain.projitems" />
<Import Project="..\dependencies\dependencies.projitems" />
<Target Name="PrepareImageDependencies">
<ItemGroup>
<_Dir Include="sdk" />
<_Dir Include="ndk" />
<_Dir Include="ant" />
</ItemGroup>
<ItemGroup>
<_Package
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' "
Include="@(AndroidSdkItem->'$(AndroidUri)/%(RelUrl)%(Identity) sdk/%(DestDir)')"
/>
<_Package
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' "
Include="@(AndroidNdkItem->'$(AndroidUri)/%(RelUrl)%(Identity) ndk/%(DestDir)')"
/>
<_Package
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' "
Include="@(AntItem->'$(AntUri)/%(RelUrl)%(Identity) ant/%(DestDir)')"
/>
</ItemGroup>
<ItemGroup>
<_Brew
Condition=" '$(HostOS)' == 'Darwin' And '%(RequiredProgram.Homebrew)' != '' "
Include="@(RequiredProgram->'%(Homebrew)')"
/>
</ItemGroup>
<PropertyGroup>
<_Packages>@(_Package->'%(Identity)', '
')</_Packages>
<_Dirs>@(_Dir->'%(Identity)', '
')</_Dirs>
<_Brews>@(_Brew->'%(Identity)', '
')</_Brews>
</PropertyGroup>
<ReplaceFileContents
SourceFile="$(MSBuildThisFileDirectory)prepare-image-dependencies.sh.in"
DestinationFile="$(MSBuildThisFileDirectory)\..\..\prepare-image-dependencies.sh"
Replacements="@TOOLCHAIN_DIRS@=$(_Dirs);@PACKAGES@=$(_Packages);@BREWS@=$(_Brews)">
</ReplaceFileContents>
</Target>
</Project>
72 changes: 72 additions & 0 deletions build-tools/scripts/prepare-image-dependencies.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash -e
set -o xtrace

ARCHIVE_PATH="$HOME/android-archives"
TOOLCHAIN_PATH="$HOME/android-toolchain"

TOOLCHAIN_DIRS="
@TOOLCHAIN_DIRS@
"

# format: URL path/under/$TOOLCHAIN_PATH
PACKAGES="
@PACKAGES@
"

BREW_PACKAGES="
@BREWS@
"

function Download ()
{
local url="$1"
local archive="$ARCHIVE_PATH/`basename "$url"`"
if [ -f "$archive" ]; then
return
fi
curl -o "$archive" "$url"
}

function Install ()
{
local url="$1"
local subdir="$2"

local file=`basename "$url"`
local archive="$ARCHIVE_PATH/$file"
local targetdir="$TOOLCHAIN_PATH/$subdir"

local flagdir="$TOOLCHAIN_PATH/$(echo $subdir | sed 's#/.*$##g')"
local flagfile="$flagdir/.$file"

mkdir -p "$targetdir"
if [ ! -f "$flagfile" ]; then
local extractdir=`mktemp -d`
unzip -d "$extractdir" "$ARCHIVE_PATH/$file"
mv "$extractdir"/*/* "$targetdir"
touch "$flagfile"
rm -Rf "$extractdir"
fi
}

echo "$TOOLCHAIN_DIRS" | while read line ; do
if [ -z "$line" ]; then
continue
fi
rm -Rf "$TOOLCHAIN_PATH/$line"
done

echo "$PACKAGES" | while read line ; do
if [ -z "$line" ]; then
continue
fi
Download $line
Install $line
done

echo "$BREW_PACKAGES" | while read line ; do
if [ -z "$line" ]; then
continue
fi
brew install $line
done