зеркало из https://github.com/xamarin/AndroidX.git
Use new build script bootstrapper
This commit is contained in:
Родитель
fb97101fef
Коммит
c91b58dd37
|
@ -27,3 +27,4 @@ Resource.designer.cs
|
|||
component.yaml
|
||||
Details.md
|
||||
/generated.targets
|
||||
*.commit
|
111
build.cake
111
build.cake
|
@ -1,15 +1,7 @@
|
|||
#tool nuget:?package=ILRepack&version=2.0.10
|
||||
#tool nuget:?package=XamarinComponent&version=1.1.0.49
|
||||
#tool nuget:?package=Cake.MonoApiTools&version=1.0.10
|
||||
#tool nuget:?package=Microsoft.DotNet.BuildTools.GenAPI&version=1.0.0-beta-00081
|
||||
|
||||
#addin nuget:?package=Cake.Compression&version=0.1.2
|
||||
#addin nuget:?package=Cake.Json&version=1.0.2.13
|
||||
#addin nuget:?package=Cake.XCode&version=2.0.13
|
||||
#addin nuget:?package=Cake.Xamarin&version=1.3.0.15
|
||||
#addin nuget:?package=Cake.Xamarin.Build&version=2.0.18
|
||||
#addin nuget:?package=Cake.FileHelpers&version=1.0.4
|
||||
#addin nuget:?package=Cake.MonoApiTools&version=1.0.10
|
||||
// Loads our list of addins from the tools folder
|
||||
// this assumes using the new bootstrapper build.sh in the root folder
|
||||
// which downloads the required files
|
||||
#load "./tools/addins.cake"
|
||||
|
||||
// From Cake.Xamarin.Build, dumps out versions of things
|
||||
LogSystemInfo ();
|
||||
|
@ -286,7 +278,7 @@ Task ("merge").IsDependentOn ("libs").Does (() =>
|
|||
CopyAttrs = true,
|
||||
AllowMultiple = true,
|
||||
//TargetKind = ILRepack.TargetKind.Dll,
|
||||
Libs = new List<FilePath> {
|
||||
Libs = new List<DirectoryPath> {
|
||||
MONODROID_PATH
|
||||
},
|
||||
});
|
||||
|
@ -308,93 +300,6 @@ Task ("component-setup").Does (() =>
|
|||
}
|
||||
});
|
||||
|
||||
Task ("nuget-setup").IsDependentOn ("buildtasks").IsDependentOn ("externals")
|
||||
.Does (() =>
|
||||
{
|
||||
|
||||
Action<FilePath, FilePath> mergeTargetsFiles = (FilePath fromFile, FilePath intoFile) =>
|
||||
{
|
||||
// Load the doc to append to, and the doc to append
|
||||
var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(intoFile).FullPath);
|
||||
System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace;
|
||||
var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(fromFile).FullPath);
|
||||
System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace;
|
||||
// Add all the elements under <Project> into the existing file's <Project> node
|
||||
foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ())
|
||||
xOrig.Element (nsOrig + "Project").Add (xItemToAdd);
|
||||
|
||||
xOrig.Save (MakeAbsolute (intoFile).FullPath);
|
||||
};
|
||||
|
||||
var templateText = FileReadText ("./template.targets");
|
||||
|
||||
var nugetArtifacts = ARTIFACTS.ToList ();
|
||||
nugetArtifacts.Add (new ArtifactInfo (SUPPORT_PKG_NAME, "support-v4", "Xamarin.Android.Support.v4", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION));
|
||||
|
||||
foreach (var art in nugetArtifacts) {
|
||||
|
||||
var proguardFile = new FilePath(string.Format("./externals/{0}/proguard.txt", art.ArtifactId));
|
||||
|
||||
var targetsText = templateText;
|
||||
var targetsFile = new FilePath(string.Format ("{0}/nuget/{1}.targets", art.ArtifactId, art.NugetId));
|
||||
FileWriteText (targetsFile, targetsText);
|
||||
|
||||
// Transform all .targets files
|
||||
var xTargets = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath);
|
||||
System.Xml.Linq.XNamespace nsTargets = xTargets.Root.Name.Namespace;
|
||||
|
||||
if (FileExists (proguardFile)) {
|
||||
var projElem = xTargets.Element(nsTargets + "Project");
|
||||
|
||||
Information ("Adding {0} to {1}", "proguard.txt", targetsFile);
|
||||
|
||||
projElem.Add (new System.Xml.Linq.XElement (nsTargets + "ItemGroup",
|
||||
new System.Xml.Linq.XElement (nsTargets + "ProguardConfiguration",
|
||||
new System.Xml.Linq.XAttribute ("Include", "$(MSBuildThisFileDirectory)..\\..\\proguard\\proguard.txt"))));
|
||||
}
|
||||
|
||||
xTargets.Save (MakeAbsolute(targetsFile).FullPath);
|
||||
|
||||
// Check for an existing .targets file in this nuget package
|
||||
// we need to merge the generated one with it if it exists
|
||||
// nuget only allows one automatic .targets file in the build/ folder
|
||||
// of the nuget package, which must be named {nuget-package-id}.targets
|
||||
// so we need to merge them all into one
|
||||
var mergeFile = new FilePath (art.ArtifactId + "/nuget/merge.targets");
|
||||
|
||||
if (FileExists (mergeFile)) {
|
||||
Information ("merge.targets found, merging into generated file...");
|
||||
mergeTargetsFiles (mergeFile, targetsFile);
|
||||
}
|
||||
|
||||
|
||||
// Transform all template.nuspec files
|
||||
var nuspecText = FileReadText(art.ArtifactId + "/nuget/template.nuspec");
|
||||
var nuspecFile = new FilePath(art.ArtifactId + "/nuget/" + art.NugetId + ".nuspec");
|
||||
FileWriteText(nuspecFile, nuspecText);
|
||||
var xNuspec = System.Xml.Linq.XDocument.Load (MakeAbsolute(nuspecFile).FullPath);
|
||||
System.Xml.Linq.XNamespace nsNuspec = xNuspec.Root.Name.Namespace;
|
||||
|
||||
// Check if we have a proguard.txt file for this artifact and include it in the nuspec if so
|
||||
if (FileExists (proguardFile)) {
|
||||
Information ("Adding {0} to {1}", "proguard.txt", nuspecFile);
|
||||
var filesElems = xNuspec.Root.Descendants (nsNuspec + "files");
|
||||
|
||||
if (filesElems != null) {
|
||||
var filesElem = filesElems.First();
|
||||
filesElem.Add (new System.Xml.Linq.XElement (nsNuspec + "file",
|
||||
new System.Xml.Linq.XAttribute(nsNuspec + "src", proguardFile.ToString()),
|
||||
new System.Xml.Linq.XAttribute(nsNuspec + "target", "proguard/proguard.txt")));
|
||||
}
|
||||
}
|
||||
|
||||
xNuspec.Save(MakeAbsolute(nuspecFile).FullPath);
|
||||
}
|
||||
});
|
||||
|
||||
Task ("nuget").IsDependentOn ("nuget-setup").IsDependentOn ("nuget-base").IsDependentOn ("libs");
|
||||
//Task ("nuget").IsDependentOn ("nuget-base").IsDependentOn ("libs");
|
||||
|
||||
Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base").IsDependentOn ("libs");
|
||||
|
||||
Task ("clean").IsDependentOn ("clean-base").Does (() =>
|
||||
|
@ -477,7 +382,7 @@ Task ("component-docs").Does (() =>
|
|||
});
|
||||
|
||||
//Task ("libs").IsDependentOn ("nuget-setup").IsDependentOn ("genapi").IsDependentOn ("libs-base");
|
||||
Task ("libs").IsDependentOn ("genapi").IsDependentOn ("libs-base");
|
||||
Task ("libs").IsDependentOn("buildtasks").IsDependentOn ("genapi").IsDependentOn ("libs-base");
|
||||
//Task ("libs").IsDependentOn ("libs-base");
|
||||
|
||||
Task ("genapi").IsDependentOn ("libs-base").IsDependentOn ("externals").Does (() => {
|
||||
|
@ -515,7 +420,7 @@ Task ("genapi").IsDependentOn ("libs-base").IsDependentOn ("externals").Does (()
|
|||
});
|
||||
}
|
||||
|
||||
DotNetBuild ("./AndroidSupport.TypeForwarders.sln", c => c.Configuration = BUILD_CONFIG);
|
||||
MSBuild ("./AndroidSupport.TypeForwarders.sln", c => c.Configuration = BUILD_CONFIG);
|
||||
|
||||
CopyFile ("./support-v4/source/bin/" + BUILD_CONFIG + "/Xamarin.Android.Support.v4.dll", "./output/Xamarin.Android.Support.v4.dll");
|
||||
});
|
||||
|
@ -524,7 +429,7 @@ Task ("buildtasks").Does (() =>
|
|||
{
|
||||
NuGetRestore ("./support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj");
|
||||
|
||||
DotNetBuild ("./support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj", c => c.Configuration = BUILD_CONFIG);
|
||||
MSBuild ("./support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj", c => c.Configuration = BUILD_CONFIG);
|
||||
});
|
||||
|
||||
|
||||
|
|
147
build.ps1
147
build.ps1
|
@ -1,147 +0,0 @@
|
|||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
This is a Powershell script to bootstrap a Cake build.
|
||||
|
||||
.DESCRIPTION
|
||||
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
|
||||
and execute your Cake build script with the parameters you provide.
|
||||
|
||||
.PARAMETER Script
|
||||
The build script to execute.
|
||||
.PARAMETER Target
|
||||
The build script target to run.
|
||||
.PARAMETER Configuration
|
||||
The build configuration to use.
|
||||
.PARAMETER Verbosity
|
||||
Specifies the amount of information to be displayed.
|
||||
.PARAMETER Experimental
|
||||
Tells Cake to use the latest Roslyn release.
|
||||
.PARAMETER WhatIf
|
||||
Performs a dry run of the build script.
|
||||
No tasks will be executed.
|
||||
.PARAMETER Mono
|
||||
Tells Cake to use the Mono scripting engine.
|
||||
|
||||
.LINK
|
||||
http://cakebuild.net
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[string]$Script = "build.cake",
|
||||
[string]$Target = "Default",
|
||||
[string]$Configuration = "Release",
|
||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||
[string]$Verbosity = "Verbose",
|
||||
[switch]$Experimental,
|
||||
[Alias("DryRun","Noop")]
|
||||
[switch]$WhatIf,
|
||||
[switch]$Mono,
|
||||
[switch]$SkipToolPackageRestore,
|
||||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||
[string[]]$ScriptArgs
|
||||
)
|
||||
|
||||
Write-Host "Preparing to run build script..."
|
||||
|
||||
$PS_SCRIPT_ROOT = split-path -parent $MyInvocation.MyCommand.Definition;
|
||||
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
|
||||
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
|
||||
$NUGET_URL = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
|
||||
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
|
||||
$CAKE_PACKAGES_CONFIG = Join-Path $PSScriptRoot "cake.packages.config"
|
||||
|
||||
# Should we use mono?
|
||||
$UseMono = "";
|
||||
if($Mono.IsPresent) {
|
||||
Write-Verbose -Message "Using the Mono based scripting engine."
|
||||
$UseMono = "-mono"
|
||||
}
|
||||
|
||||
# Should we use the new Roslyn?
|
||||
$UseExperimental = "";
|
||||
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
|
||||
Write-Verbose -Message "Using experimental version of Roslyn."
|
||||
$UseExperimental = "-experimental"
|
||||
}
|
||||
|
||||
# Is this a dry run?
|
||||
$UseDryRun = "";
|
||||
if($WhatIf.IsPresent) {
|
||||
$UseDryRun = "-dryrun"
|
||||
}
|
||||
|
||||
# Make sure tools folder exists
|
||||
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
|
||||
Write-Verbose -Message "Creating tools directory..."
|
||||
New-Item -Path $TOOLS_DIR -Type directory | out-null
|
||||
}
|
||||
|
||||
# Make sure that packages.config exist.
|
||||
if (!(Test-Path $PACKAGES_CONFIG)) {
|
||||
if (!(Test-Path $CAKE_PACKAGES_CONFIG)) {
|
||||
Write-Verbose -Message "Downloading packages.config..."
|
||||
try { Invoke-WebRequest -Uri http://cakebuild.net/bootstrapper/packages -OutFile $PACKAGES_CONFIG } catch {
|
||||
Throw "Could not download packages.config."
|
||||
}
|
||||
} else {
|
||||
Write-Verbose -Message "using local cake.packages.config..."
|
||||
Copy-Item $CAKE_PACKAGES_CONFIG $PACKAGES_CONFIG
|
||||
}
|
||||
}
|
||||
|
||||
# Let's just skip this check and always download nuget.exe
|
||||
# Try find NuGet.exe in path if not exists
|
||||
# if (!(Test-Path $NUGET_EXE)) {
|
||||
# Write-Verbose -Message "Trying to find nuget.exe in PATH..."
|
||||
# $existingPaths = $Env:Path -Split ';' | Where-Object { Test-Path $_ }
|
||||
# $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
|
||||
# if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
|
||||
# Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
|
||||
# $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
|
||||
# }
|
||||
#}
|
||||
|
||||
# Try download NuGet.exe if not exists
|
||||
if (!(Test-Path $NUGET_EXE)) {
|
||||
Write-Verbose -Message "Downloading NuGet.exe..."
|
||||
try {
|
||||
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
|
||||
} catch {
|
||||
Throw "Could not download NuGet.exe."
|
||||
}
|
||||
}
|
||||
|
||||
# Save nuget.exe path to environment to be available to child processed
|
||||
$ENV:NUGET_EXE = $NUGET_EXE
|
||||
|
||||
# Restore tools from NuGet?
|
||||
if(-Not $SkipToolPackageRestore.IsPresent)
|
||||
{
|
||||
# Restore packages from NuGet.
|
||||
Push-Location
|
||||
Set-Location $TOOLS_DIR
|
||||
|
||||
Write-Verbose -Message "Restoring tools from NuGet..."
|
||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
||||
|
||||
Pop-Location
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure that Cake has been installed.
|
||||
if (!(Test-Path $CAKE_EXE)) {
|
||||
Throw "Could not find Cake.exe at $CAKE_EXE"
|
||||
}
|
||||
|
||||
# Start Cake
|
||||
Write-Host "Running build script..."
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||
exit $LASTEXITCODE
|
110
build.sh
110
build.sh
|
@ -1,103 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
###############################################################
|
||||
# This is the Cake bootstrapper script that is responsible for
|
||||
# downloading Cake and all specified tools from NuGet.
|
||||
###############################################################
|
||||
|
||||
# Define directories.
|
||||
COMMIT="f61d7eda6d3ce4112a79937c8cceb94ad5aa081c"
|
||||
URL="https://raw.githubusercontent.com/xamarin/XamarinComponents/$COMMIT/Util/Bootstrapper/cake.sh"
|
||||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
TOOLS_DIR=$SCRIPT_DIR/tools
|
||||
export NUGET_EXE=$TOOLS_DIR/nuget.exe
|
||||
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
|
||||
SCRIPT="$SCRIPT_DIR/cake.sh"
|
||||
|
||||
# Define default arguments.
|
||||
SCRIPT="build.cake"
|
||||
TARGET="Default"
|
||||
CONFIGURATION="Release"
|
||||
VERBOSITY="verbose"
|
||||
DRYRUN=
|
||||
SHOW_VERSION=false
|
||||
SCRIPT_ARGUMENTS=()
|
||||
# Get the commit last used to grab these files so we can check if an update's needed
|
||||
commitTxt=""
|
||||
if [ -f "$SCRIPT.commit" ]; then commitTxt=$(cat "$SCRIPT.commit"); fi
|
||||
|
||||
# Parse arguments.
|
||||
for i in "$@"; do
|
||||
case $1 in
|
||||
-s|--script) SCRIPT="$2"; shift ;;
|
||||
-t|--target) TARGET="$2"; shift ;;
|
||||
-c|--configuration) CONFIGURATION="$2"; shift ;;
|
||||
-v|--verbosity) VERBOSITY="$2"; shift ;;
|
||||
-d|--dryrun) DRYRUN="-dryrun" ;;
|
||||
--version) SHOW_VERSION=true ;;
|
||||
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
|
||||
*) SCRIPT_ARGUMENTS+=("$1") ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
# If the cached file's commit doesn't match our desired, or if it's 'master' go download the right version
|
||||
if [[ "$commitTxt" != "$COMMIT" || "$commitTxt" == "master" ]]; then
|
||||
|
||||
# Make sure the tools folder exist.
|
||||
if [ ! -d "$TOOLS_DIR" ]; then
|
||||
mkdir "$TOOLS_DIR"
|
||||
fi
|
||||
echo "Downloading $SCRIPT..."
|
||||
|
||||
# Make sure that packages.config exist.
|
||||
if [ ! -f "$TOOLS_DIR/packages.config" ]; then
|
||||
if [ ! -f "$SCRIPT_DIR/cake.packages.config" ]; then
|
||||
echo "Downloading packages.config..."
|
||||
curl -Lsfo "$TOOLS_DIR/packages.config" http://cakebuild.net/bootstrapper/packages
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "An error occured while downloading packages.config."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "using local cake.packages.config..."
|
||||
cp "$SCRIPT_DIR/cake.packages.config" "$TOOLS_DIR/packages.config"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download NuGet if it does not exist.
|
||||
if [ ! -f "$NUGET_EXE" ]; then
|
||||
echo "Downloading NuGet..."
|
||||
curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe
|
||||
# v3/Latest URL: https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||
# Download the script
|
||||
curl -Lsfo $SCRIPT $URL
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "An error occured while downloading nuget.exe."
|
||||
echo "An error occured while downloading $SCRIPT."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Write out the commit hash used to cache for future runs
|
||||
echo $COMMIT > "$SCRIPT.commit"
|
||||
fi
|
||||
|
||||
# BEGIN TEMP WORKAROUND
|
||||
# There is a bug in Mono's System.IO.Compression
|
||||
# This binary fixes the bug for now
|
||||
# Download System.IO.Compression if it does not exist.
|
||||
SYSIOCOMP=$TOOLS_DIR/System.IO.Compression.dll
|
||||
if [ ! -f "$SYSIOCOMP" ]; then
|
||||
echo "Downloading System.IO.Compression.dll ..."
|
||||
curl -Lsfo "$SYSIOCOMP" http://xamarin-components-binaries.s3.amazonaws.com/System.IO.Compression.dll
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "An error occured while downloading System.IO.Compression.dll."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# END TEMP WORKAROUND
|
||||
|
||||
# Restore tools from NuGet.
|
||||
pushd "$TOOLS_DIR" >/dev/null
|
||||
mono "$NUGET_EXE" install -ExcludeVersion
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not restore NuGet packages."
|
||||
exit 1
|
||||
fi
|
||||
popd >/dev/null
|
||||
|
||||
# Make sure that Cake has been installed.
|
||||
if [ ! -f "$CAKE_EXE" ]; then
|
||||
echo "Could not find Cake.exe at '$CAKE_EXE'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start Cake
|
||||
if $SHOW_VERSION; then
|
||||
exec mono "$CAKE_EXE" -version
|
||||
else
|
||||
exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
|
||||
fi
|
||||
export BOOTSTRAPPER_COMMIT="$COMMIT"
|
||||
sh $SCRIPT $@
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake" version="0.17.0" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче