Skip to content

Commit

Permalink
[r8] add r8 and depot_tools submodules.
Browse files Browse the repository at this point in the history
depot_tools is required to build r8. On Windows it is however not used but
a binary executable zip will be downloaded and used instead.
(see https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up for details)

r8 build is not integrated in the primary Makefile and .sln yet.

(r8 is not a "build tool" but we build msbuild tasks dependencies there too.)
  • Loading branch information
atsushieno committed Apr 4, 2018
1 parent edbef70 commit 9f4b0df
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@
path = external/xamarin-android-tools
url = https://github.com/xamarin/xamarin-android-tools
branch = master
[submodule "external/depot_tools"]
path = external/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
[submodule "external/r8"]
path = external/r8
url = https://r8.googlesource.com/r8
9 changes: 9 additions & 0 deletions build-tools/r8/r8.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
</PropertyGroup>
<Import Project="r8.props" />
<Import Project="..\..\Configuration.props" />
<Import Project="r8.targets" />
</Project>

3 changes: 3 additions & 0 deletions build-tools/r8/r8.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

72 changes: 72 additions & 0 deletions build-tools/r8/r8.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask TaskName="Xamarin.Android.Tasks.Unzip" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.DownloadUri" />

<!-- public targets -->

<Target Name="Build" DependsOnTargets="_SetupDepotTools;_BuildR8;_CopyR8" />
<Target Name="Clean" DependsOnTargets="_CleanR8;_CleanDepotTools" />

<!-- depot_tools -->

<!-- Why do people split files and make build scripts unreadable? That's unacceptable. Therefore properties are here. Always consider code readability. -->
<PropertyGroup>
<_WindowsDepotToolzZipDownload>..\..\bin\Build$(Configuration)\depot_tools.zip</_WindowsDepotToolzZipDownload>
</PropertyGroup>

<Target Name="_SetupDepotTools" DependsOnTargets="_SetupDepotToolsWindows" />
<Target Name="_CleanDepotTools" DependsOnTargets="_CleanDepotToolsWindows" />

<Target Name="_SetupDepotToolsWindows" Condition="$(HostOS) == 'Windows'">
<DownloadUri
SourceUris="https://storage.googleapis.com/chrome-infra/depot_tools.zip"
DestinationFiles="$(_WindowsDepotToolzZipDownload)"
/>
<Unzip
Sources="$(_WindowsDepotToolsZipDownload)"
Destination="bin\Build$(Configuration)\depot_tools"
/>
</Target>

<Target Name="_CleanDepotToolsWindows" Condition="$(HostOS) == 'Windows'">
<RemoveDir Directories="bin\Build$(Configuration)\depot_tools" />
</Target>


<!-- r8 -->

<PropertyGroup>
<_PathToDepotTools Condition="'$(HostOS)' == 'Windows'">..\..\bin\Build$(Configuration)\depot_tools</_PathToDepotTools>
<_PathToDepotTools Condition="'$(HostOS)' != 'Windows'">..\..\external\depot_tools</_PathToDepotTools>
<_Sep Condition="'$(HostOS)' == 'Windows'">;</_Sep>
<_Sep Condition="'$(HostOS)' != 'Windows'">:</_Sep>
<_W Condition="'$(HostOS)' == 'Windows'">"</_W>
<_W Condition="'$(HostOS)' != 'Windows'"></_W> <_EnvForDepotTools>PATH=$(_W)$(_PathToDepotTools)$(_W)$(_Sep)$(PATH)</_EnvForDepotTools>
</PropertyGroup>

<Target Name="_BuildR8" DependsOnTargets="_SetupDepotTools">
<Exec
Command="..\..\external\r8\tools\gradle.py d8 r8"
WorkingDirectory="..\..\external\r8"
EnvironmentVariables="$(_EnvForDepotTools)"
/>
</Target>

<Target Name="_CopyR8">
<Copy
SourceFiles="..\..\external\r8\build\libs\r8.jar"
DestinationFolder="$(XAInstallPrefix)\xbuild\Xamarin\Android\"
SkipUnchangedFiles="true"
/>
</Target>

<Target Name="_CleanR8">
<Exec
Command="..\..\external\r8\tools\gradle.py clean"
WorkingDirectory="..\..\external\r8"
EnvironmentVariables="$(_EnvForDepotTools)"
/>
</Target>

</Project>
1 change: 1 addition & 0 deletions external/depot_tools
Submodule depot_tools added at a16b4c
1 change: 1 addition & 0 deletions external/r8
Submodule r8 added at d7c62c

0 comments on commit 9f4b0df

Please sign in to comment.