Skip to content

Commit 688bb35

Browse files
committed
[structure] Rework installation directory structure
Context: #253 (comment) The *intention* is that Jenkins-produced `oss-xamarin.android*.zip` artifacts be usable on Windows, so that side-by-side testing can be perfomed without replacing the system installation. Usage is in [UsingJenkinsBuildArtifacts.md](Documentation/UsingJenkinsBuildArtifacts). This isn't *entirely* the case. It was *apparently* the case at the time of commit 87ca273, but things have bitrotten since, and/or the support was always insufficient. For example, 87ca273 states that it should be possible to use `msbuild /t:TargetFrameworkRootPath=...` to specify the `lib\xbuild-frameworks` directory as the location to find `Mono.Android` framework assemblies. ...and this works! So long as your project *only* uses Xamarin.Android assemblies and projects. PCL assemblies and projects do *not* fall under this umbrella. Consequently, attempting to use PCL assemblies while overriding `$(TargetFrameworkRootPath)` results in a gnarly error: error MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5,Profile=Profile259" were not found. This significantly reduces the usefulness of `oss-xamarin.android*.zip` on Windows. Fix this by TODO ARGH. Additionally, PR #253 mentions that, for filesystem organization, it would be useful if the macOS/Linux directory structure -- `$prefix/bin`, `$prefix/lib/mandroid`, `$prefix/lib/xbuild/Xamarin/Android`, `$prefix/lib/xbuild-frameworks` -- more closely resembled the Windows directory structure of `$MSBuild` and `$ReferenceAssemblies` (as seen in `.vsix` files). This would turn macOS/Linux into using `$xa_prefix/xbuild` and `$xa_prefix/xbuild-frameworks` directories. `$prefix/bin` would only contain `xabuild`. What is currently in `$prefix/lib/mandroid` would be merged with `$xa_prefix/xbuild/Xamarin/Android`. `$xa_prefix`, meanwhile, could become `$prefix/lib/oss-xamarin.android`. This would turn the current macOS structure: $prefix/bin/xabuild $prefix/bin/generator $prefix/bin/cross-arm $prefix/lib/mandroid/generator.exe $prefix/lib/xbuild-frameworks/MonoAndroid/v1.0/mscorlib.dll $prefix/lib/xbuild/Xamarin/Android/Xamarin.Android.Common.targets Into: $prefix/bin/xabuild $prefix/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/mscorlib.dll $prefix/lib/xamarin.android/xbuild/Xamarin/Android/generator.exe $prefix/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets $prefix/lib/xamarin.android/xbuild/Xamarin/Android/Darwin/cross-arm Other notes: * The `bundle-*.zip` filename has been has been changed to include a *hash* of the contents of various files, in particular `build-tools\mono-runtimes.*`. This was instigated via a conversation with @kumpera about making the filename more "idiot-proof": `mono-runtimes.props` contains *compiler flags*, and if any of those change, then *logically* the bundle should differ as well, as the mono runtimes may differ in significant ways. In theory, the `-v18` version should be used to track this, but this is a manual change, easy to overlook. The new `-hHASH` part of the filename should be more automagic. The new `<HashFileContents/>` task in `xa-prep-tasks.dll` is responsible for creating the hash value. * `Configuration.Java.Interop.Override.props` was moved into `build-tools/scripts`, becauase that would cleanup the root directory a bit. * OS-specific binaries are now placed into `$prefix/lib/xamarin.android/xbuild/Xamarin/Android/$(HostOS)`. On a theoretical plus side, this means that the same build directory can contain OS-specific binaries for multiple operating systems. (I don't know if anyone shares a build tree between e.g. macOS and Linux, but if anyone *does*...) * `$(MonoAndroidToolsDirectory)` should be considered *dead*, along with `$(MonoAndroidBinDirectory)`, as these should now *always* be the same directory as where `Xamarin.Android.Build.Tasks.dll` is located, or a `$(HostOS)` sub-directory. * `Xamarin.ProjectTools.csproj` needed to be updated to ensure that the build order was correct. * Remove all `[Obsolete]` and unreferenced members from `Xamarin.Android.Build.Utilities.dll`. There's too much in there, and it makes my head hurt trying to understand the interrelationships between it all. If it's not used, it's gone. * Work around an `xbuild`-ism: `%(_LlvmRuntime.InstallPath)` and `%(_MonoCrossRuntime.InstallPath)` *cannot* use MSBuild properties, e.g. `<InstallPath>$(HostOS)/</InstallPath>` doesn't work as desired; it's instead treated literally. Special-case `%(InstallPath)` until we fully migrate to MSBuild. * The changes to `src/monodroid/jni/Android.mk` are...weird. The removal of `-I$(topdir)/libmonodroid/zip`/etc. is to reduce use of non-existent paths, as `$(topdir)` isn't defined, so that's *actually* `-I/libmonodroid/zip`, which is nonsensical. So far, so good. What's *odd* is the addition of `$(LOCAL_PATH)` to `$(LOCAL_C_INCLUDES)`: This is needed so that `external/mono/support/zlib-helper.c` exports `CreateZStream` and related symbols, otherwise we get a unit test failure in `GzipStreamTest.Compression` due to an `EntryPointNotFoundException`, because `CreateZStream` isn't exported/public. What's odd here is that I don't understand what caused this behavior to change. Previous builds exported `CreateZStream`, otherwise the tests would fail, and I don't understand how any of the other changes in this PR would be at fault, though that's certainly the most plausible explanation. Regardless, `-Ijni` *first* (due to adding `$(LOCAL_PATH)` to `$(LOCAL_C_INCLUDES)`) is the desired behavior, so that `jni/config.h` is included, thus ensuring that `MONO_API` has the required definition when building `zlib-helper.c`.
1 parent 1ea5f07 commit 688bb35

File tree

67 files changed

+436
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+436
-516
lines changed

Configuration.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<PropertyGroup>
2121
<AutoProvision Condition=" '$(AutoProvision)' == '' ">False</AutoProvision>
2222
<AutoProvisionUsesSudo Condition=" '$(AutoProvisionUsesSudo)' == '' ">False</AutoProvisionUsesSudo>
23+
<XAInstallPrefix Condition=" '$(XAInstallPrefix)' == '' ">$(MSBuildThisFileDirectory)\bin\$(Configuration)\lib\xamarin.android\</XAInstallPrefix>
2324
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
2425
<HostCc Condition=" '$(HostCc)' == '' ">$(HostCc64)</HostCc>
2526
<HostCxx Condition=" '$(HostCxx)' == '' ">$(HostCxx64)</HostCxx>

Documentation/DevelopmentTips.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For example, to rebuild Mono for armeabi-v7a:
4545

4646
$ make -C build-tools/mono-runtimes/obj/Debug/armeabi-v7a
4747

48-
# This updates bin/$(Configuration)/lib/xbuild/Xamarin/Android/lib/armeabi-v7a/libmonosgen-2.0.so
48+
# This updates bin/$(Configuration)/lib/xamarin.android/xbuild/Xamarin/Android/lib/armeabi-v7a/libmonosgen-2.0.so
4949
$ xbuild /t:_InstallRuntimes build-tools/mono-runtimes/mono-runtimes.mdproj
5050

5151
# How do I rebuild BCL assemblies?
@@ -65,7 +65,7 @@ varies based on the operating system you're building from:
6565
Once the assemblies have been rebuilt, they can be copied into the appropriate
6666
Xamarin.Android SDK directory by using the `_InstallBcl` target:
6767

68-
# This updates bin/$(Configuration)/lib/xbuild-frameworks/MonoAndroid/v1.0/ASSEMBLY.dll
68+
# This updates bin/$(Configuration)/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ASSEMBLY.dll
6969
$ xbuild build-tools/mono-runtimes/mono-runtimes.mdproj /t:_InstallBcl
7070

7171
# Update Directory

Documentation/UsingJenkinsBuildArtifacts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ For example (using the paths from [Android SDK Setup](#Android_SDK_Setup)):
156156

157157
msbuild /p:AndroidSdkDirectory="C:\xa-sdk\android-sdk" ^
158158
/p:AndroidNdkDirectory="C:\xa-sdk\android-ndk\android-ndk-r14" ^
159-
/p:MonoAndroidBinDirectory="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xbuild\Xamarin\Android" ^
160-
/p:MonoAndroidToolsDirectory="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xbuild\Xamarin\Android" ^
161-
/p:TargetFrameworkRootPath="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xbuild-frameworks" ^
159+
/p:MonoAndroidBinDirectory="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android" ^
160+
/p:MonoAndroidToolsDirectory="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android" ^
161+
/p:TargetFrameworkRootPath="C:\xa-sdk\oss-xamarin.android_v7.2.99.19_Darwin-x86_64_master_3b893cd\bin\Debug\lib\xamarin.android\xbuild-frameworks" ^
162162
/t:SignAndroidPackage ^
163163
samples\HelloWorld\HelloWorld.csproj
164164

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ install::
3232
echo "run 'make all' before you execute 'make install'!"; \
3333
exit 1; \
3434
fi
35+
-mkdir -p "$(prefix)/bin"
3536
-mkdir -p "$(prefix)/lib/mono/xbuild-frameworks"
3637
-mkdir -p "$(prefix)/lib/xamarin.android"
3738
-mkdir -p "$(prefix)/lib/mono/xbuild/Xamarin/"
38-
cp -a "bin/$(CONFIGURATION)/." "$(prefix)/lib/xamarin.android/"
39+
cp -a "bin/$(CONFIGURATION)/lib/xamarin.android/." "$(prefix)/lib/xamarin.android/"
3940
cp tools/scripts/xabuild "$(prefix)/bin/xabuild"
4041
-rm -rf "$(prefix)/lib/mono/xbuild/Xamarin/Android"
4142
-rm -rf "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid"
42-
ln -s "$(prefix)/lib/xamarin.android/lib/xbuild/Xamarin/Android/" "$(prefix)/lib/mono/xbuild/Xamarin/Android"
43-
ln -s "$(prefix)/lib/xamarin.android/lib/xbuild-frameworks/MonoAndroid/" "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid"
43+
ln -s "$(prefix)/lib/xamarin.android/xbuild/Xamarin/Android/" "$(prefix)/lib/mono/xbuild/Xamarin/Android"
44+
ln -s "$(prefix)/lib/xamarin.android/xbuild-frameworks/MonoAndroid/" "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid"
4445

4546
uninstall::
4647
rm -rf "$(prefix)/lib/xamarin.android/" "$(prefix)/bin/xabuild"
@@ -90,7 +91,7 @@ prepare-external: prepare-deps
9091
(cd $(call GetPath,JavaInterop) && make bin/BuildDebug/JdkInfo.props)
9192

9293
prepare-props: prepare-external
93-
cp Configuration.Java.Interop.Override.props external/Java.Interop/Configuration.Override.props
94+
cp build-tools/scripts/Configuration.Java.Interop.Override.props external/Java.Interop/Configuration.Override.props
9495
cp $(call GetPath,MonoSource)/mcs/class/msfinal.pub .
9596

9697
prepare-msbuild: prepare-props

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ The `bin\$(Configuration)` directory, e.g. `bin\Debug`, contains
320320
acts as a *local installation prefix*, in which the directory structure
321321
mirrors that of the OS X Xamarin.Android.framework directory structure:
322322

323-
* `bin\$(Configuration)\lib\xbuild\Xamarin\Android`: MSBuild-related support
323+
* `bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android`: MSBuild-related support
324324
files and required runtimes used by the MSBuild tooling.
325-
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid`: Xamarin.Android
325+
* `bin\$(Configuration)\lib\xamarin.android\xbuild-frameworks\MonoAndroid`: Xamarin.Android
326326
profiles.
327-
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\v1.0`: Xamarin.Android
327+
* `bin\$(Configuration)\lib\xamarin.android\xbuild-frameworks\MonoAndroid\v1.0`: Xamarin.Android
328328
Base Class Library assemblies such as `mscorlib.dll`.
329-
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\*`: Contains
329+
* `bin\$(Configuration)\lib\xamarin.android\xbuild-frameworks\MonoAndroid\*`: Contains
330330
`Mono.Android.dll` for a given Xamarin.Android `$(TargetFrameworkVersion)`.
331331

332332
# Xamarin.Android `$(TargetFrameworkVersion)`s
@@ -354,7 +354,7 @@ For example, to generate `Mono.Android.dll` for API-19 (Android 4.4):
354354

355355
cd src/Mono.Android
356356
xbuild /p:AndroidApiLevel=19 /p:AndroidFrameworkVersion=v4.4
357-
# creates bin\Debug\lib\xbuild-frameworks\MonoAndroid\v4.4\Mono.Android.dll
357+
# creates bin\Debug\lib\xamarin.android\xbuild-frameworks\MonoAndroid\v4.4\Mono.Android.dll
358358

359359
<a name="Samples" />
360360

build-tools/api-xml-adjuster/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ANDROID_SDK_PATH=$(shell find ~/ -maxdepth 1 -name android-sdk-*)
66

77
DOCS_DIR=~/android-toolchain/docs
88

9-
MANDROID = ../../bin/$(CONFIGURATION)/lib/mandroid
9+
MANDROID = ../../bin/$(CONFIGURATION)/lib/xamarin.anroid/xbuild/Xamarin/Android
1010
BUILDBIN = ../../bin/Build$(CONFIGURATION)
1111

1212
CLASS_PARSE = $(MANDROID)/class-parse.exe
@@ -62,7 +62,7 @@ $(ANALYZED_XML): $(API_XML_TOOL) $(CLASS_PARSE_XML)
6262
$(RUN_API_XML_TOOL) $(CLASS_PARSE_XML) $(ANALYZED_XML) || rm -f $(ANALYZED_XML)
6363

6464
$(CLASS_PARSE):
65-
cd $(JAVA_INTEROP_PATH)/tools/class-parse && $(XBUILD) /p:OutputPath=$(TOP)/out/lib/mandroid
65+
cd $(JAVA_INTEROP_PATH)/tools/class-parse && $(XBUILD) /p:OutputPath=$(TOP)/out/lib/xamarin.android/xbuild/Xamarin.Android/
6666

6767
$(API_XML_TOOL):
6868
$(XBUILD)

build-tools/bundle/bundle-path.targets

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.GitCommitHash" />
4+
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.HashFileContents" />
45
<Target Name="_GetHashes">
56
<GitCommitHash
67
WorkingDirectory="$(LibZipSourceFullPath)"
@@ -20,11 +21,19 @@
2021
ToolExe="$(GitToolExe)">
2122
<Output TaskParameter="AbbreviatedCommitHash" PropertyName="_MonoHash" />
2223
</GitCommitHash>
24+
<!-- Files which contribute to the bundle "version" -->
25+
<ItemGroup>
26+
<VersionFile Include="..\mono-runtimes\mono-runtimes.*" />
27+
</ItemGroup>
28+
<HashFileContents
29+
Files="@(VersionFile)">
30+
<Output TaskParameter="AbbreviatedCompleteHash" PropertyName="_VersionHash"/>
31+
</HashFileContents>
2332
</Target>
2433
<Target Name="GetBundleFileName"
2534
DependsOnTargets="_GetHashes">
2635
<PropertyGroup>
27-
<XABundleFileName>bundle-v18-$(Configuration)-$(HostOS)-libzip=$(_LibZipHash),llvm=$(_LlvmHash),mono=$(_MonoHash).zip</XABundleFileName>
36+
<XABundleFileName>bundle-v19-h$(_VersionHash)-$(Configuration)-$(HostOS)-libzip=$(_LibZipHash),llvm=$(_LlvmHash),mono=$(_MonoHash).zip</XABundleFileName>
2837
</PropertyGroup>
2938
</Target>
3039
</Project>

build-tools/bundle/bundle.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<UsingTask AssemblyFile="$(_SourceTopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.Zip" />
4-
<Import Project="..\mono-runtimes\mono-runtimes.props" />
5-
<Import Project="..\mono-runtimes\mono-runtimes.projitems" />
64
<Import Project="..\mono-runtimes\mono-runtimes.targets" />
75
<Import Project="..\libzip\libzip.props" />
86
<Import Project="..\libzip-windows\libzip-windows.props" />

build-tools/create-vsix/create-vsix.targets

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$(PrepareForBuildDependsOn);
1010
AddContent
1111
</PrepareForBuildDependsOn>
12-
<LibDir>..\..\bin\$(Configuration)\lib\</LibDir>
12+
<LibDir>..\..\bin\$(Configuration)\lib\xamarin.android\</LibDir>
1313
</PropertyGroup>
1414
<ItemDefinitionGroup>
1515
<MSBuild>
@@ -36,16 +36,17 @@
3636
</MSBuild>
3737
<MSBuild Remove="$(LibDir)xbuild\Xamarin\Android\lib\host-Darwin\**\*.*" />
3838
<MSBuild Remove="$(LibDir)xbuild\Xamarin\Android\lib\host-Linux\**\*.*" />
39+
<MSBuild Remove="$(LibDir)xbuild\Xamarin\Android\Darwin\**\*.*" />
40+
<MSBuild Remove="$(LibDir)xbuild\Xamarin\Android\Linux\**\*.*" />
3941
<MSBuild Include="..\..\src\Xamarin.Android.Build.Tasks\MSBuild\Xamarin\**\*.*" />
4042
<MSBuild>
4143
<VSIXSubPath Condition=" '%(VSIXSubPath)' == '' ">Xamarin/%(RecursiveDir)</VSIXSubPath>
4244
</MSBuild>
43-
<MSBuild Include="..\..\bin\$(Configuration)\lib\mandroid\**\*.*" />
44-
<MSBuild Remove="..\..\bin\$(Configuration)\lib\mandroid\**\*.d.exe" />
4545
<MSBuild>
4646
<VSIXSubPath Condition=" '%(VSIXSubPath)' == '' ">Xamarin/Android/%(RecursiveDir)</VSIXSubPath>
4747
</MSBuild>
4848
<MSBuild Remove="$(LibDir)xbuild\**\*.d.dll" />
49+
<MSBuild Remove="$(LibDir)xbuild\**\*.d.exe" />
4950
<ReferenceAssemblies Include="$(LibDir)xbuild-frameworks\**\*.*" />
5051
<ReferenceAssemblies>
5152
<VSIXSubPath Condition=" '%(VSIXSubPath)' == '' ">Microsoft/Framework/%(RecursiveDir)</VSIXSubPath>

build-tools/libzip-windows/libzip-windows.mdproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
</PropertyGroup>
1010
<Import Project="..\..\Configuration.props" />
1111
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12-
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
12+
<OutputPath>$(XAInstallPrefix)xbuild\Xamarin\Android\</OutputPath>
1313
</PropertyGroup>
1414
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
15-
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
15+
<OutputPath>$(XAInstallPrefix)xbuild\Xamarin\Android\</OutputPath>
1616
</PropertyGroup>
1717
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
1818
<PropertyGroup>
@@ -24,6 +24,7 @@
2424
<Import Project="libzip-windows.props" />
2525
<Import Project="libzip-windows.projitems" />
2626
<Import Project="libzip-windows.targets" />
27+
<Import Project="..\libzip\libzip.targets" />
2728
<ItemGroup>
2829
<ProjectReference Include="..\android-toolchain\android-toolchain.mdproj">
2930
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>

0 commit comments

Comments
 (0)