Skip to content

Commit

Permalink
Update the build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Hurdugaci committed Feb 27, 2016
1 parent 89c6844 commit 4c9dfa4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 77 deletions.
41 changes: 2 additions & 39 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,39 +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 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
)

SET KOREBUILD_DOWNLOAD_ARGS=
IF NOT "%KOREBUILD_VERSION%"=="" (
SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION%
)
IF NOT EXIST %KOREBUILD_FOLDER% (
%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' %*"
36 changes: 36 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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"

Invoke-WebRequest $koreBuildZip -OutFile $localZipFile
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
65 changes: 27 additions & 38 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
#!/usr/bin/env bash
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder

buildFolder=.build
koreBuildFolder=$buildFolder/KoreBuild-dotnet

nugetPath=$buildFolder/nuget.exe

if [ "$(uname)" = "Darwin" ]; then
cachedir=~/Library/Caches/KBuild
ulimit -n 2048
else
if [ -z $XDG_DATA_HOME ]; then
cachedir=$HOME/.local/share
else
cachedir=$XDG_DATA_HOME;
fi
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP
fi
mkdir -p $cachedir
nugetVersion=latest
cacheNuget=$cachedir/nuget.$nugetVersion.exe

nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe

if [ ! -d $buildFolder ]; then
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"

wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null
unzip -q -d $tempFolder $localZipFile

mkdir $buildFolder
fi

if [ ! -f $nugetPath ]; then
if [ ! -f $cacheNuget ]; then
wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null
cp -r $tempFolder/**/build/** $buildFolder

chmod +x $buildFile

# Cleanup
if test ! -d $tempFolder; then
rm -rf $tempFolder
fi

cp $cacheNuget $nugetPath
fi

if [ ! -d $koreBuildFolder ]; then
mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre
chmod +x $koreBuildFolder/build/KoreBuild.sh
fi

makeFile=makefile.shade
if [ ! -e $makeFile ]; then
makeFile=$koreBuildFolder/build/makefile.shade
fi

./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@"
$buildFile -r $repoFolder "$@"

0 comments on commit 4c9dfa4

Please sign in to comment.