Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating build scripts to use new korebuild and adding a hack to fix …
…build
- Loading branch information
1 parent
d68895b
commit 4f9f88c
Showing
4 changed files
with
111 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,2 @@ | ||
@ECHO off | ||
SETLOCAL | ||
|
||
SET REPO_FOLDER=%~dp0 | ||
CD %REPO_FOLDER% | ||
|
||
SET BUILD_FOLDER=.build | ||
SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet | ||
SET KOREBUILD_VERSION= | ||
SET KOREBUILD_DOTNET_VERSION=Latest | ||
|
||
SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe | ||
SET NUGET_VERSION=latest | ||
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe | ||
|
||
IF NOT EXIST %BUILD_FOLDER% ( | ||
md %BUILD_FOLDER% | ||
) | ||
|
||
IF NOT EXIST %NUGET_PATH% ( | ||
IF NOT EXIST %CACHED_NUGET% ( | ||
echo Downloading latest version of NuGet.exe... | ||
IF NOT EXIST %LocalAppData%\NuGet ( | ||
md %LocalAppData%\NuGet | ||
) | ||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" | ||
) | ||
|
||
copy %CACHED_NUGET% %NUGET_PATH% > nul | ||
) | ||
|
||
IF NOT EXIST %KOREBUILD_FOLDER% ( | ||
SET KOREBUILD_DOWNLOAD_ARGS= | ||
IF NOT "%KOREBUILD_VERSION%"=="" ( | ||
SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% | ||
) | ||
|
||
%BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% | ||
) | ||
|
||
"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* | ||
@ECHO OFF | ||
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) | ||
{ | ||
while($true) | ||
{ | ||
try | ||
{ | ||
Invoke-WebRequest $url -OutFile $downloadLocation | ||
break | ||
} | ||
catch | ||
{ | ||
$exceptionMessage = $_.Exception.Message | ||
Write-Host "Failed to download '$url': $exceptionMessage" | ||
if ($retries -gt 0) { | ||
$retries-- | ||
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" | ||
Start-Sleep -Seconds 10 | ||
|
||
} | ||
else | ||
{ | ||
$exception = $_.Exception | ||
throw $exception | ||
} | ||
} | ||
} | ||
} | ||
|
||
cd $PSScriptRoot | ||
|
||
$repoFolder = $PSScriptRoot | ||
$env:REPO_FOLDER = $repoFolder | ||
|
||
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" | ||
if ($env:KOREBUILD_ZIP) | ||
{ | ||
$koreBuildZip=$env:KOREBUILD_ZIP | ||
} | ||
|
||
$buildFolder = ".build" | ||
$buildFile="$buildFolder\KoreBuild.ps1" | ||
|
||
if (!(Test-Path $buildFolder)) { | ||
Write-Host "Downloading KoreBuild from $koreBuildZip" | ||
|
||
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() | ||
New-Item -Path "$tempFolder" -Type directory | Out-Null | ||
|
||
$localZipFile="$tempFolder\korebuild.zip" | ||
|
||
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 | ||
|
||
Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) | ||
|
||
New-Item -Path "$buildFolder" -Type directory | Out-Null | ||
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse | ||
|
||
# Cleanup | ||
if (Test-Path $tempFolder) { | ||
Remove-Item -Recurse -Force $tempFolder | ||
} | ||
} | ||
|
||
&"$buildFile" $args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,46 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
cd $repoFolder | ||
|
||
if test `uname` = Darwin; then | ||
cachedir=~/Library/Caches/KBuild | ||
else | ||
if [ -z $XDG_DATA_HOME ]; then | ||
cachedir=$HOME/.local/share | ||
else | ||
cachedir=$XDG_DATA_HOME; | ||
fi | ||
fi | ||
mkdir -p $cachedir | ||
|
||
url=https://www.nuget.org/nuget.exe | ||
|
||
if test ! -f $cachedir/nuget.exe; then | ||
wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null | ||
fi | ||
|
||
if test ! -e .nuget; then | ||
mkdir .nuget | ||
cp $cachedir/nuget.exe .nuget/nuget.exe | ||
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" | ||
if [ ! -z $KOREBUILD_ZIP ]; then | ||
koreBuildZip=$KOREBUILD_ZIP | ||
fi | ||
|
||
if test ! -d packages/KoreBuild; then | ||
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre | ||
mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion | ||
fi | ||
|
||
if ! type k > /dev/null 2>&1; then | ||
source packages/KoreBuild/build/kvm.sh | ||
fi | ||
|
||
if ! type k > /dev/null 2>&1; then | ||
kvm upgrade | ||
buildFolder=".build" | ||
buildFile="$buildFolder/KoreBuild.sh" | ||
|
||
if test ! -d $buildFolder; then | ||
echo "Downloading KoreBuild from $koreBuildZip" | ||
|
||
tempFolder="/tmp/KoreBuild-$(uuidgen)" | ||
mkdir $tempFolder | ||
|
||
localZipFile="$tempFolder/korebuild.zip" | ||
|
||
retries=6 | ||
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) | ||
do | ||
echo "Failed to download '$koreBuildZip'" | ||
if [ "$retries" -le 0 ]; then | ||
exit 1 | ||
fi | ||
retries=$((retries - 1)) | ||
echo "Waiting 10 seconds before retrying. Retries left: $retries" | ||
sleep 10s | ||
done | ||
|
||
unzip -q -d $tempFolder $localZipFile | ||
|
||
mkdir $buildFolder | ||
cp -r $tempFolder/**/build/** $buildFolder | ||
|
||
chmod +x $buildFile | ||
|
||
# Cleanup | ||
if test ! -d $tempFolder; then | ||
rm -rf $tempFolder | ||
fi | ||
fi | ||
|
||
mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" | ||
$buildFile -r $repoFolder "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters