Browse Source

Adding build scripts

Sebastien Ros 8 years ago
parent
commit
541fc3b9bc
5 changed files with 123 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 7 0
      appveyor.yml
  3. 2 0
      build.cmd
  4. 67 0
      build.ps1
  5. 46 0
      build.sh

+ 1 - 0
.gitignore

@@ -156,3 +156,4 @@ Jint.sln.ide/*
 /Jint.sln.GhostDoc.xml
 .vs
 project.lock.json
+.build

+ 7 - 0
appveyor.yml

@@ -0,0 +1,7 @@
+init:
+  - git config --global core.autocrlf true
+build_script:
+  - build.cmd --quiet verify
+clone_depth: 1
+test: off
+deploy: off

+ 2 - 0
build.cmd

@@ -0,0 +1,2 @@
+@ECHO OFF
+PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"

+ 67 - 0
build.ps1

@@ -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/1.0.0.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

+ 46 - 0
build.sh

@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $repoFolder
+
+koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip"
+if [ ! -z $KOREBUILD_ZIP ]; then
+    koreBuildZip=$KOREBUILD_ZIP
+fi
+
+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
+
+$buildFile -r $repoFolder "$@"