Skip to content

Commit 4d94d34

Browse files
committed
[build] Install mono in make prepare-image-dependencies
I have been told that the `prepare-image-dependencies.sh` script should also install `mono`, to ensure that the required mono exists. Add a `@PKG_URLS@` variable to `prepare-image-dependencies.sh.in` to support downloading and installing our minimum specified mono version. Additionally, I discovered that `xbuild` bugs are still around; I just keep forgetting their specifics. Case in point: [Jenkins build #712][xa712] uploaded [`prepare-image-dependencies.sh`][sh], and it's not good: [xa712]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/ [sh]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/712/Azure/processDownloadRequest/xamarin-android/prepare-image-dependencies.sh https://dl.google.com/android/repository/build-tools_r26.0.1-macosx.zip sdk/build-tools\$(XABuildToolsFolder) ... https://dl.google.com/android/repository/android-15_r03.zip sdk/platforms\android-15 MSBuild properties contained within item metadata -- specifically `%(AndroidSdkItem.DestDir)` -- aren't fully expanded, resulting in the above value of `$(XABuildToolsFolder)`, which *should* be `26.0.1`. Similarly, some install paths are using `\` (backslash) when they should contain `/` (forward slash). Jenkins has been updated to explicitly use `msbuild`: $ make prepare-image-dependencies MSBUILD=msbuild However, `\r` characters now appear in `prepare-image-dependencies.sh`. Fix this by having the `PrepareImageDependencies` target emit the MSBuild-generated file into an intermediate file, then fix it up using **tr**(1). Finally, correct the `brew install` command so that any errors are ignored, for if a brew package is already installed, re-installing it will result in an error.
1 parent a5fba94 commit 4d94d34

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ endif # msbuild
116116
prepare-image-dependencies:
117117
$(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/PrepareImageDependencies.targets /t:PrepareImageDependencies \
118118
/p:AndroidSupportedHostJitAbis=mxe-Win32:mxe-Win64
119+
cat bin/Build$(CONFIGURATION)/prepare-image-dependencies.sh | tr -d '\r' > prepare-image-dependencies.sh
119120

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

build-tools/scripts/PrepareImageDependencies.targets

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,26 @@
3232
Include="@(RequiredProgram->'%(Homebrew)')"
3333
/>
3434
</ItemGroup>
35+
<ItemGroup>
36+
<_DarwinPkg
37+
Condition=" '$(HostOS)' == 'Darwin' And '%(RequiredProgram.Identity)' == 'mono' "
38+
Include="%(RequiredProgram.DarwinMinimumUrl)"
39+
/>
40+
</ItemGroup>
3541
<PropertyGroup>
3642
<_Packages>@(_Package->'%(Identity)', '
3743
')</_Packages>
3844
<_Dirs>@(_Dir->'%(Identity)', '
3945
')</_Dirs>
4046
<_Brews>@(_Brew->'%(Identity)', '
4147
')</_Brews>
48+
<_DarwinPkgs>@(_DarwinPkg->'%(Identity)', '
49+
')</_DarwinPkgs>
4250
</PropertyGroup>
4351
<ReplaceFileContents
4452
SourceFile="$(MSBuildThisFileDirectory)prepare-image-dependencies.sh.in"
45-
DestinationFile="$(MSBuildThisFileDirectory)\..\..\prepare-image-dependencies.sh"
46-
Replacements="@TOOLCHAIN_DIRS@=$(_Dirs);@PACKAGES@=$(_Packages);@BREWS@=$(_Brews)">
53+
DestinationFile="$(MSBuildThisFileDirectory)\..\..\bin\Build$(Configuration)\prepare-image-dependencies.sh"
54+
Replacements="@TOOLCHAIN_DIRS@=$(_Dirs);@PACKAGES@=$(_Packages);@BREWS@=$(_Brews);@PKG_URLS@=$(_DarwinPkgs)">
4755
</ReplaceFileContents>
4856
</Target>
4957
</Project>

build-tools/scripts/prepare-image-dependencies.sh.in

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ BREW_PACKAGES="
1717
@BREWS@
1818
"
1919

20+
PKG_URLS="
21+
@PKG_URLS@
22+
"
23+
2024
function Download ()
2125
{
2226
local url="$1"
@@ -68,5 +72,14 @@ echo "$BREW_PACKAGES" | while read line ; do
6872
if [ -z "$line" ]; then
6973
continue
7074
fi
71-
brew install $line
75+
brew install $line || true
76+
done
77+
78+
echo "$PKG_URLS" | while read line ; do
79+
if [ -z "$line" ]; then
80+
continue
81+
fi
82+
Download $line
83+
pkg=`basename "$line"`
84+
sudo installer -pkg "$ARCHIVE_PATH/$pkg" -target /
7285
done

0 commit comments

Comments
 (0)