@set args=%*
@powershell "iex((@('')*3+(cat '%~f0'|select -skip 3))-join[char]10)"
@exit /b %ERRORLEVEL%

$args = @( ([regex]'"([^"]*)"').Replace($env:args,{
        $args[0].Groups[1] -replace " ",[char]1
    }) -split " " | ForEach-Object{ $_ -replace [char]1," " })

set GO "go.exe" -option constant

set CMD "Cmd" -option constant

Set-PSDebug -strict
$VerbosePreference = "Continue"

function Do-Copy($src,$dst){
    Write-Verbose "$ copy '$src' '$dst'"
    Copy-Item $src $dst
}

function Do-Remove($file){
    if( Test-Path $file ){
        Write-Verbose "$ del '$file'"
        Remove-Item $file
    }
}

function Make-Dir($folder){
    if( -not (Test-Path $folder) ){
        Write-Verbose "$ mkdir '$folder'"
        New-Item $folder -type directory | Out-Null
    }
}

Add-Type -Assembly System.Windows.Forms
function Ask-Copy($src,$dst){
    $fname = (Join-Path $dst (Split-Path $src -Leaf))
    if( Test-Path $fname ){
        if( "Yes" -ne [System.Windows.Forms.MessageBox]::Show(
            'Override "{0}" by default ?' -f $fname,
            "NYAGOS Install", "YesNo","Question","button2") ){
            return
        }
    }
    Do-Copy $src $dst
}

function ForEach-GoDir{
    Get-ChildItem . -Recurse |
    Where-Object{ $_.Extension -eq '.go' } |
    ForEach-Object{ Split-Path $_.FullName -Parent } |
    Sort-Object |
    Get-Unique
}

function Go-Fmt{
    $status = $true
    git status -s | %{
        $fname = $_.Substring(3)
        $arrow = $fname.IndexOf(" -> ")
        if( $arrow -ge 0 ){
            $fname = $fname.Substring($arrow+4)
        }
        if( $fname -like "*.go" -and (Test-Path($fname)) ){
            $prop = Get-ItemProperty($fname)
            if( $prop.Mode -like "?a*" ){
                Write-Verbose "$ $GO fmt $fname"
                & $GO fmt $fname
                if( $LastExitCode -ne 0 ){
                    $status = $false
                }else{
                    attrib -a $fname
                }
            }
        }
    }
    if( -not $status ){
        Write-Warning "Some of '$GO fmt' failed."
    }
    return $status
}

function Make-SysO($version) {
    Download-Exe "github.com/josephspurrier/goversioninfo/cmd/goversioninfo" "goversioninfo.exe"
    if( $version -match "^\d+[\._]\d+[\._]\d+[\._]\d+$" ){
        $v = $version.Split("[\._]")
    }else{
        $v = @(0,0,0,0)
        if( $version -eq $null -or $version -eq "" ){
            $version = "0.0.0_0"
        }
    }
    Write-Verbose "version=$version"

    .\goversioninfo.exe `
        "-file-version=$version" `
        "-product-version=$version" `
        "-icon=nyagos.ico" `
        ("-ver-major=" + $v[0]) `
        ("-ver-minor=" + $v[1]) `
        ("-ver-patch=" + $v[2]) `
        ("-ver-build=" + $v[3]) `
        ("-product-ver-major=" + $v[0]) `
        ("-product-ver-minor=" + $v[1]) `
        ("-product-ver-patch=" + $v[2]) `
        ("-product-ver-build=" + $v[3]) `
        "-o" nyagos.syso `
        versioninfo.json
}

function Download-Exe($url,$exename){
    if( Test-Path $exename ){
        Write-Verbose -Message ("Found {0}" -f $exename)
        return
    }
    Write-Verbose -Message ("{0} not found." -f $exename)
    Write-Verbose -Message ("$ $GO get -d " + $url)
    & $GO get -d $url
    $workdir = (Join-Path (Join-Path (& $GO env GOPATH).Split(";")[0] "src") $url)
    $cwd = (Get-Location)
    Set-Location $workdir
    Write-Verbose -Message ("$ $GO build {0} on {1}" -f $exename,$workdir)
    & $GO build
    Do-Copy $exename $cwd
    Set-Location $cwd
}

function Build($version,$tags) {
    Write-Verbose "Build as version='$version' tags='$tags'"

    if( -not (Go-Fmt) ){
        return
    }
    $saveGOARCH = $env:GOARCH
    $env:GOARCH = (& $go env GOARCH)

    Make-Dir $CMD
    $binDir = (Join-Path $CMD $env:GOARCH)
    Make-Dir $binDir
    $target = (Join-Path $binDir "nyagos.exe")

    Make-SysO $version

    Write-Verbose "$ $GO build -o '$target'"
    & $GO build "-o" $target -ldflags "-s -w -X main.version=$version" $tags
    if( $LastExitCode -eq 0 ){
        Do-Copy $target ".\nyagos.exe"
    }
    $env:GOARCH = $saveGOARCH
}

function Make-Package($arch){
    $zipname = ("nyagos-{0}.zip" -f (& cmd\$arch\nyagos.exe --show-version-only))
    Write-Verbose "$ zip -9 $zipname ...."
    if( Test-Path $zipname ){
        Do-Remove $zipname
    }
    zip -9j $zipname `
        "cmd\$arch\nyagos.exe" `
        .nyagos `
        _nyagos `
        makeicon.cmd `
        LICENSE `
        readme_ja.md `
        readme.md

    zip -9 $zipname `
        nyagos.d\*.lua `
        nyagos.d\catalog\*.lua `
        Doc\*.md
}

switch( $args[0] ){
    "" {
        Build (git describe --tags) ""
    }
    "386"{
        $private:save = $env:GOARCH
        $env:GOARCH = "386"
        Build (git describe --tags) ""
        $env:GOARCH = $save
    }
    "debug" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build "" "-tags=debug"
        $env:GOARCH = $save
    }
    "release" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build (Get-Content Misc\version.txt) ""
        $env:GOARCH = $save
    }
    "clean" {
        foreach( $p in @(`
            (Join-Path $CMD "amd64\nyagos.exe"),`
            (Join-Path $CMD "386\nyagos.exe"),`
            "nyagos.exe",`
            "nyagos.syso",`
            "version.now",`
            "goversioninfo.exe") )
        {
            Do-Remove $p
        }
        ForEach-GoDir | %{
            Write-Verbose "$ $GO clean on $_"
            pushd $_
            & $GO clean
            popd
        }
    }
    "package" {
        $goarch = if( $args[1] ){ $args[1] }else{ (& $go env GOARCH) }
        Make-Package $goarch
    }
    "install" {
        $installDir = $args[1]
        if( $installDir -eq $null -or $installDir -eq "" ){
            $installDir = (
                Select-String 'INSTALLDIR=([^\)"]+)' Misc\version.cmd |
                ForEach-Object{ $_.Matches[0].Groups[1].Value }
            )
            if( -not $installDir ){
                Write-Warning "Usage: make.ps1 install INSTALLDIR"
                exit
            }
            if( -not (Test-Path $installDir) ){
                Write-Warning "$installDir not found."
                exit
            }
            Write-Verbose "installDir=$installDir"
        }
        Write-Output "@set `"INSTALLDIR=$installDir`"" |
            Out-File "Misc\version.cmd" -Encoding Default

        robocopy nyagos.d (Join-Path $installDir "nyagos.d") /E
        Write-Verbose ("ERRORLEVEL=" + $LastExitCode)
        if( $LastExitCode -lt 8 ){
            Remove-Item Variable:LastExitCode
        }
        Ask-Copy "_nyagos" $installDir
        try{
            Do-Copy nyagos.exe $installDir
        }catch{
            $now = (Get-Date -Format "yyyyMMddHHmmss")
            try{
                $old = (Join-Path $installDir "nyagos.exe")
                Rename-Item -path $old -newname ($old + "-" + $now)
                Do-Copy nyagos.exe $installDir
            }catch{
                Write-Host "Could not update installed nyagos.exe"
                Write-Host "Some processes holds nyagos.exe now"
            }
            # [void]([System.Windows.Forms.MessageBox]::Show("Done"))
            timeout /T 3
        }
    }
    "get" {
        if( (git branch --contains) -eq "* master" ){
            Write-Verbose "$GO get -u -v ./..."
            & $GO get -u -v ./...
        } else {
            Write-Verbose "$GO get -v ./..."
            & $GO get -v ./...
        }
    }
    "fmt" {
        Go-Fmt | Out-Null
    }
    "help" {
        Write-Output @'
make                     build as snapshot
make debug   [386|amd64] build as debug version     (tagged as `debug`)
make release [386|amd64] build as release version
make clean               remove all work files
make package [386|amd64] make `nyagos-(VERSION)-(ARCH).zip`
make install [FOLDER]    copy executables to FOLDER or last folder
make fmt                 `go fmt`
make help                show this
'@
    }
    default {
        Write-Warning ("{0} not supported." -f $args[0])
    }
}
if( Test-Path Variable:LastExitCode ){
    exit $LastExitCode
}

# vim:set ft=ps1:

@set args=%*
@powershell "iex((@('')*3+(cat '%~f0'|select -skip 3))-join[char]10)"
@exit /b %ERRORLEVEL%

$args = @( ([regex]'"([^"]*)"').Replace($env:args,{
        $args[0].Groups[1] -replace " ",[char]1
    }) -split " " | ForEach-Object{ $_ -replace [char]1," " })

set GO "go.exe" -option constant

set CMD "Cmd" -option constant

Set-PSDebug -strict
$VerbosePreference = "Continue"

function Do-Copy($src,$dst){
    Write-Verbose "$ copy '$src' '$dst'"
    Copy-Item $src $dst
}

function Do-Rename($old,$new){
    Write-Verbose "$ ren $old $new"
    Rename-Item -path $old -newname $new
}

function Do-Remove($file){
    if( Test-Path $file ){
        Write-Verbose "$ del '$file'"
        Remove-Item $file
    }
}

function Make-Dir($folder){
    if( -not (Test-Path $folder) ){
        Write-Verbose "$ mkdir '$folder'"
        New-Item $folder -type directory | Out-Null
    }
}

function Ask-Copy($src,$dst){
    $fname = (Join-Path $dst (Split-Path $src -Leaf))
    if( Test-Path $fname ){
        Write-Verbose "$fname already exists. Cancel to copy"
    }else{
        Do-Copy $src $dst
    }
}

function ForEach-GoDir{
    Get-ChildItem . -Recurse |
    Where-Object{ $_.Extension -eq '.go' } |
    ForEach-Object{ Split-Path $_.FullName -Parent } |
    Sort-Object |
    Get-Unique
}

function Go-Fmt{
    $status = $true
    git status -s | %{
        $fname = $_.Substring(3)
        $arrow = $fname.IndexOf(" -> ")
        if( $arrow -ge 0 ){
            $fname = $fname.Substring($arrow+4)
        }
        if( $fname -like "*.go" -and (Test-Path($fname)) ){
            $prop = Get-ItemProperty($fname)
            if( $prop.Mode -like "?a*" ){
                Write-Verbose "$ $GO fmt $fname"
                & $GO fmt $fname
                if( $LastExitCode -ne 0 ){
                    $status = $false
                }else{
                    attrib -a $fname
                }
            }
        }
    }
    if( -not $status ){
        Write-Warning "Some of '$GO fmt' failed."
    }
    return $status
}

function Make-SysO($version) {
    Download-Exe "github.com/josephspurrier/goversioninfo/cmd/goversioninfo" "goversioninfo.exe"
    if( $version -match "^\d+[\._]\d+[\._]\d+[\._]\d+$" ){
        $v = $version.Split("[\._]")
    }else{
        $v = @(0,0,0,0)
        if( $version -eq $null -or $version -eq "" ){
            $version = "0.0.0_0"
        }
    }
    Write-Verbose "version=$version"

    .\goversioninfo.exe `
        "-file-version=$version" `
        "-product-version=$version" `
        "-icon=nyagos.ico" `
        ("-ver-major=" + $v[0]) `
        ("-ver-minor=" + $v[1]) `
        ("-ver-patch=" + $v[2]) `
        ("-ver-build=" + $v[3]) `
        ("-product-ver-major=" + $v[0]) `
        ("-product-ver-minor=" + $v[1]) `
        ("-product-ver-patch=" + $v[2]) `
        ("-product-ver-build=" + $v[3]) `
        "-o" nyagos.syso `
        versioninfo.json
}

function Download-Exe($url,$exename){
    if( Test-Path $exename ){
        Write-Verbose -Message ("Found {0}" -f $exename)
        return
    }
    Write-Verbose -Message ("{0} not found." -f $exename)
    Write-Verbose -Message ("$ $GO get -d " + $url)
    & $GO get -d $url
    $workdir = (Join-Path (Join-Path (& $GO env GOPATH).Split(";")[0] "src") $url)
    $cwd = (Get-Location)
    Set-Location $workdir
    Write-Verbose -Message ("$ $GO build {0} on {1}" -f $exename,$workdir)
    & $GO build
    Do-Copy $exename $cwd
    Set-Location $cwd
}

function Build($version,$tags) {
    Write-Verbose "Build as version='$version' tags='$tags'"

    if( -not (Go-Fmt) ){
        return
    }
    $saveGOARCH = $env:GOARCH
    $env:GOARCH = (& $go env GOARCH)

    Make-Dir $CMD
    $binDir = (Join-Path $CMD $env:GOARCH)
    Make-Dir $binDir
    $target = (Join-Path $binDir "nyagos.exe")

    Make-SysO $version

    Write-Verbose "$ $GO build -o '$target'"
    & $GO build "-o" $target -ldflags "-s -w -X main.version=$version" $tags
    if( $LastExitCode -eq 0 ){
        Do-Copy $target ".\nyagos.exe"
    }
    $env:GOARCH = $saveGOARCH
}

function Make-Package($arch){
    $zipname = ("nyagos-{0}.zip" -f (& cmd\$arch\nyagos.exe --show-version-only))
    Write-Verbose "$ zip -9 $zipname ...."
    if( Test-Path $zipname ){
        Do-Remove $zipname
    }
    zip -9j $zipname `
        "cmd\$arch\nyagos.exe" `
        .nyagos `
        _nyagos `
        makeicon.cmd `
        LICENSE `
        readme_ja.md `
        readme.md

    zip -9 $zipname `
        nyagos.d\*.lua `
        nyagos.d\catalog\*.lua `
        Doc\*.md
}

switch( $args[0] ){
    "" {
        Build (git describe --tags) ""
    }
    "386"{
        $private:save = $env:GOARCH
        $env:GOARCH = "386"
        Build (git describe --tags) ""
        $env:GOARCH = $save
    }
    "debug" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build "" "-tags=debug"
        $env:GOARCH = $save
    }
    "release" {
        $private:save = $env:GOARCH
        if( $args[1] ){
            $env:GOARCH = $args[1]
        }
        Build (Get-Content Misc\version.txt) ""
        $env:GOARCH = $save
    }
    "clean" {
        foreach( $p in @(`
            (Join-Path $CMD "amd64\nyagos.exe"),`
            (Join-Path $CMD "386\nyagos.exe"),`
            "nyagos.exe",`
            "nyagos.syso",`
            "version.now",`
            "goversioninfo.exe") )
        {
            Do-Remove $p
        }
        ForEach-GoDir | %{
            Write-Verbose "$ $GO clean on $_"
            pushd $_
            & $GO clean
            popd
        }
    }
    "package" {
        $goarch = if( $args[1] ){ $args[1] }else{ (& $go env GOARCH) }
        Make-Package $goarch
    }
    "install" {
        $installDir = $args[1]
        if( $installDir -eq $null -or $installDir -eq "" ){
            $installDir = (
                Select-String 'INSTALLDIR=([^\)"]+)' Misc\version.cmd |
                ForEach-Object{ $_.Matches[0].Groups[1].Value }
            )
            if( -not $installDir ){
                Write-Warning "Usage: make.ps1 install INSTALLDIR"
                exit
            }
            if( -not (Test-Path $installDir) ){
                Write-Warning "$installDir not found."
                exit
            }
            Write-Verbose "installDir=$installDir"
        }
        Write-Output "@set `"INSTALLDIR=$installDir`"" |
            Out-File "Misc\version.cmd" -Encoding Default

        robocopy nyagos.d (Join-Path $installDir "nyagos.d") /E
        Write-Verbose ("ERRORLEVEL=" + $LastExitCode)
        if( $LastExitCode -lt 8 ){
            Remove-Item Variable:LastExitCode
        }
        Ask-Copy "_nyagos" $installDir
        try{
            Do-Copy nyagos.exe $installDir
        }catch{
            $now = (Get-Date -Format "yyyyMMddHHmmss")
            try{
                $old = (Join-Path $installDir "nyagos.exe")
                Do-Rename $old ($old + "-" + $now)
                Do-Copy nyagos.exe $installDir
            }catch{
                Write-Host "Could not update installed nyagos.exe"
                Write-Host "Some processes holds nyagos.exe now"
            }
        }
    }
    "get" {
        if( (git branch --contains) -eq "* master" ){
            Write-Verbose "$GO get -u -v ./..."
            & $GO get -u -v ./...
        } else {
            Write-Verbose "$GO get -v ./..."
            & $GO get -v ./...
        }
    }
    "fmt" {
        Go-Fmt | Out-Null
    }
    "help" {
        Write-Output @'
make                     build as snapshot
make debug   [386|amd64] build as debug version     (tagged as `debug`)
make release [386|amd64] build as release version
make clean               remove all work files
make package [386|amd64] make `nyagos-(VERSION)-(ARCH).zip`
make install [FOLDER]    copy executables to FOLDER or last folder
make fmt                 `go fmt`
make help                show this
'@
    }
    default {
        Write-Warning ("{0} not supported." -f $args[0])
    }
}
if( Test-Path Variable:LastExitCode ){
    exit $LastExitCode
}

# vim:set ft=ps1:

make.cmd: make install: remove the prompt to copy _nyagos and cancel copying


### application.bat - 201x - Laurent THOMAS ###
echo "Copyright company - 201x"
echo "Build:10:00"
echo "version 1.1"

### application.bat - 201x - Laurent THOMAS ###
version = 2
build_hour="11h00"

echo "Build${build_hour}"
echo "version${version}"

add var to script

add var to script


rem @echo off
set SELF=%~dp0
if "%1" equ "" (
    echo Usage: build_double.bat {node_version}
    echo e.g. build_double.bat 5.9.1
    exit /b -1
)

mkdir "%SELF%\build\nuget\content\edge" > nul 2>&1
mkdir "%SELF%\build\nuget\lib\net40" > nul 2>&1
mkdir "%SELF%\build\nuget\lib\netstandard1.6" > nul 2>&1
mkdir "%SELF%\build\nuget\tools" > nul 2>&1
mkdir "%SELF%\..\src\double\Edge.js\bin\Release\net40" > nul 2>&1

if not exist "%SELF%\build\download.exe" (
	csc /out:"%SELF%\build\download.exe" "%SELF%\download.cs"
)

if not exist "%SELF%\build\unzip.exe" (
 	csc /out:"%SELF%\build\unzip.exe" /r:System.IO.Compression.FileSystem.dll "%SELF%\unzip.cs"
)

if not exist "%SELF%\build\repl.exe" (
	csc /out:"%SELF%\build\repl.exe" "%SELF%\repl.cs"
)

if not exist "%SELF%\build\nuget.exe" (
	"%SELF%\build\download.exe" http://nuget.org/nuget.exe "%SELF%\build\nuget.exe"
)

if not exist "%SELF%\build\%1.zip" (
	"%SELF%\build\download.exe" https://github.com/nodejs/node/archive/v%1.zip "%SELF%\build\%1.zip"
)

if not exist "%SELF%\build\node-%1" (
	rem "%SELF%\build\unzip.exe" "%SELF%\build\%1.zip" "%SELF%\build"
	pushd "%SELF%\build\"
	cscript //B ..\unzip.vbs %1.zip
	popd
)

call :build_node %1 x86 ia32
if %ERRORLEVEL% neq 0 exit /b -1
call :build_node %1 x64 x64
if %ERRORLEVEL% neq 0 exit /b -1

if not exist "%SELF%\build\node-%1-x86\node.exe" (
	"%SELF%\build\download.exe" http://nodejs.org/dist/v%1/win-x86/node.exe "%SELF%\build\node-%1-x86\node.exe"
)

if not exist "%SELF%\build\node-%1-x64\node.exe" (
	"%SELF%\build\download.exe" http://nodejs.org/dist/v%1/win-x64/node.exe "%SELF%\build\node-%1-x64\node.exe"
)

call :build_edge %1 x86
if %ERRORLEVEL% neq 0 exit /b -1
call :build_edge %1 x64
if %ERRORLEVEL% neq 0 exit /b -1

csc /out:"%SELF%\..\src\double\Edge.js\bin\Release\net40\EdgeJs.dll" /target:library "%SELF%\..\src\double\Edge.js\dotnet\EdgeJs.cs"
if %ERRORLEVEL% neq 0 exit /b -1

cd "%SELF%\..\src\double\Edge.js"
dotnet restore
if %ERRORLEVEL% neq 0 exit /b -1
dotnet build --configuration Release

rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework netstandard1.6
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework netstandard2.0
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework net40
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework net45

if %ERRORLEVEL% neq 0 exit /b -1
dotnet pack --configuration Release --no-build

if %ERRORLEVEL% neq 0 (
	echo Failure building Nuget package
	cd "%SELF%"
	exit /b -1
)

cd "%SELF%"
copy /y "%SELF%\..\src\double\Edge.js\bin\Release\*.nupkg" "%SELF%\build\nuget"
echo SUCCESS. Nuget package at %SELF%\build\nuget

exit /b 0

:build_edge

rem takes 2 parameters: 1 - node version, 2 - x86 or x64

if exist "%SELF%\build\nuget\content\edge\%2\edge_nativeclr.node" exit /b 0

set NODEEXE=%SELF%\build\node-%1-%2\node.exe
set GYP=%APPDATA%\npm\node_modules\node-gyp\bin\node-gyp.js

pushd "%SELF%\.."

"%NODEEXE%" "%GYP%" configure --msvs_version=2017
"%SELF%\build\repl.exe" ./build/edge_nativeclr.vcxproj "%USERPROFILE%\.node-gyp\%1\%3\node.lib" "%SELF%build\node-%1-%2\node.lib"
"%NODEEXE%" "%GYP%" build
mkdir "%SELF%\build\nuget\content\edge\%2" > nul 2>&1
copy /y build\release\edge_nativeclr.node "%SELF%\build\nuget\content\edge\%2"
copy /y "%SELF%\build\node-%1-%2\node.dll" "%SELF%\build\nuget\content\edge\%2"

popd

exit /b 0

:build_node

rem takes 2 parameters: 1 - node version, 2 - x86 or x64

if exist "%SELF%\build\node-%1-%2\node.lib" exit /b 0

pushd "%SELF%\build\node-%1"
rmdir /s /q Release
rmdir /s /q build
rmdir /s /q tools\icu\Release

..\repl.exe node.gyp "'executable'" "'shared_library'"
if %ERRORLEVEL% neq 0 (
    echo Cannot update node.gyp
    popd
    exit /b -1
)

call vcbuild.bat release %2
if not exist .\Release\node.dll (
    echo Cannot build node.dll for %1-%2
    popd
    exit /b -1
)

mkdir "%SELF%\build\node-%1-%2"
copy /y .\Release\node.* "%SELF%\build\node-%1-%2"
echo Finished building Node shared library %1

popd
exit /b 0

rem @echo off
set SELF=%~dp0
if "%1" equ "" (
    echo Usage: build_double.bat {node_version}
    echo e.g. build_double.bat 5.9.1
    exit /b -1
)

mkdir "%SELF%\build\nuget\content\edge" > nul 2>&1
mkdir "%SELF%\build\nuget\lib\net40" > nul 2>&1
mkdir "%SELF%\build\nuget\lib\netstandard1.6" > nul 2>&1
mkdir "%SELF%\build\nuget\tools" > nul 2>&1
mkdir "%SELF%\..\src\double\Edge.js\bin\Release\net40" > nul 2>&1

if not exist "%SELF%\build\download.exe" (
	csc /out:"%SELF%\build\download.exe" "%SELF%\download.cs"
)

if not exist "%SELF%\build\unzip.exe" (
 	csc /out:"%SELF%\build\unzip.exe" /r:System.IO.Compression.FileSystem.dll "%SELF%\unzip.cs"
)

if not exist "%SELF%\build\repl.exe" (
	csc /out:"%SELF%\build\repl.exe" "%SELF%\repl.cs"
)

if not exist "%SELF%\build\nuget.exe" (
	"%SELF%\build\download.exe" http://nuget.org/nuget.exe "%SELF%\build\nuget.exe"
)

if not exist "%SELF%\build\%1.zip" (
	"%SELF%\build\download.exe" https://github.com/nodejs/node/archive/v%1.zip "%SELF%\build\%1.zip"
)

if not exist "%SELF%\build\node-%1" (
	rem "%SELF%\build\unzip.exe" "%SELF%\build\%1.zip" "%SELF%\build"
	pushd "%SELF%\build\"
	cscript //B ..\unzip.vbs %1.zip
	popd
)

call :build_node %1 x86
if %ERRORLEVEL% neq 0 exit /b -1
call :build_node %1 x64
if %ERRORLEVEL% neq 0 exit /b -1

if not exist "%SELF%\build\node-%1-x86\node.exe" (
	"%SELF%\build\download.exe" http://nodejs.org/dist/v%1/win-x86/node.exe "%SELF%\build\node-%1-x86\node.exe"
)

if not exist "%SELF%\build\node-%1-x64\node.exe" (
	"%SELF%\build\download.exe" http://nodejs.org/dist/v%1/win-x64/node.exe "%SELF%\build\node-%1-x64\node.exe"
)

call :build_edge %1 x86 ia32
if %ERRORLEVEL% neq 0 exit /b -1
call :build_edge %1 x64 x64
if %ERRORLEVEL% neq 0 exit /b -1

csc /out:"%SELF%\..\src\double\Edge.js\bin\Release\net40\EdgeJs.dll" /target:library "%SELF%\..\src\double\Edge.js\dotnet\EdgeJs.cs"
if %ERRORLEVEL% neq 0 exit /b -1

cd "%SELF%\..\src\double\Edge.js"
dotnet restore
if %ERRORLEVEL% neq 0 exit /b -1
dotnet build --configuration Release

rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework netstandard1.6
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework netstandard2.0
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework net40
rem if %ERRORLEVEL% neq 0 exit /b -1
rem dotnet build --configuration Release --framework net45

if %ERRORLEVEL% neq 0 exit /b -1
dotnet pack --configuration Release --no-build

if %ERRORLEVEL% neq 0 (
	echo Failure building Nuget package
	cd "%SELF%"
	exit /b -1
)

cd "%SELF%"
copy /y "%SELF%\..\src\double\Edge.js\bin\Release\*.nupkg" "%SELF%\build\nuget"
echo SUCCESS. Nuget package at %SELF%\build\nuget

exit /b 0

:build_edge

rem takes 2 parameters: 1 - node version, 2 - x86 or x64

if exist "%SELF%\build\nuget\content\edge\%2\edge_nativeclr.node" exit /b 0

set NODEEXE=%SELF%\build\node-%1-%2\node.exe
set GYP=%APPDATA%\npm\node_modules\node-gyp\bin\node-gyp.js

pushd "%SELF%\.."

"%NODEEXE%" "%GYP%" configure --msvs_version=2017
"%SELF%\build\repl.exe" ./build/edge_nativeclr.vcxproj "%USERPROFILE%\.node-gyp\%1\%3\node.lib" "%SELF%build\node-%1-%2\node.lib"
"%NODEEXE%" "%GYP%" build
mkdir "%SELF%\build\nuget\content\edge\%2" > nul 2>&1
copy /y build\release\edge_nativeclr.node "%SELF%\build\nuget\content\edge\%2"
copy /y "%SELF%\build\node-%1-%2\node.dll" "%SELF%\build\nuget\content\edge\%2"

popd

exit /b 0

:build_node

rem takes 2 parameters: 1 - node version, 2 - x86 or x64

if exist "%SELF%\build\node-%1-%2\node.lib" exit /b 0

pushd "%SELF%\build\node-%1"
rmdir /s /q Release
rmdir /s /q build
rmdir /s /q tools\icu\Release

..\repl.exe node.gyp "'executable'" "'shared_library'"
if %ERRORLEVEL% neq 0 (
    echo Cannot update node.gyp
    popd
    exit /b -1
)

call vcbuild.bat release %2
if not exist .\Release\node.dll (
    echo Cannot build node.dll for %1-%2
    popd
    exit /b -1
)

mkdir "%SELF%\build\node-%1-%2"
copy /y .\Release\node.* "%SELF%\build\node-%1-%2"
echo Finished building Node shared library %1

popd
exit /b 0

fix incorrect merge.

fix incorrect merge.


@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

SET BASEDIR=%~dp0
SET BASEDIR=%BASEDIR:~0,-1%

SET ARGS=
SET STRIPFIRST=0

FOR %%A IN (%*) DO (
   SET ARGS=!ARGS!,%%~A
   SET STRIPFIRST=1
)

IF NOT "STRIPFIRST" == "0" (SET ARGS=%ARGS:~1%)

CD %BASEDIR%

gradlew.bat grain "-Pargs=%ARGS%"

ENDLOCAL

@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

SET BASEDIR=%~dp0
SET BASEDIR=%BASEDIR:~0,-1%

SET ARGS=
SET STRIPFIRST=0

FOR %%A IN (%*) DO (
   SET ARGS=!ARGS!,%%~A
   SET STRIPFIRST=1
)

IF "%STRIPFIRST%" == "1" (SET ARGS=%ARGS:~1%)

CD %BASEDIR%

gradlew.bat grain "-Pargs=%ARGS%"

ENDLOCAL

Fix stripping leading comma

Fix stripping leading comma


Test run batch file.

Test run batch file.


dnx MessageTemplates.Tests test
xunit.console.clr4 FsMessageTemplates.Tests\bin\Release\FsMessageTemplates.Tests.dll /appveyor

IF ['%APPVEYOR%'] == ['True'] (
	vstest.console /Logger:AppVeyor MessageTemplates.PerfTests\bin\Release\MessageTemplates.PerfTests.dll
) ELSE (
	vstest.console /Logger:timelineLogger MessageTemplates.PerfTests\bin\Release\MessageTemplates.PerfTests.dll
)

dnx MessageTemplates.Tests test

packages\xunit.runner.console\tools\xunit.console.x86.exe FsMessageTemplates.Tests\bin\Release\FsMessageTemplates.Tests.dll

IF ['%APPVEYOR%'] == ['True'] (
	vstest.console /Logger:AppVeyor MessageTemplates.PerfTests\bin\Release\MessageTemplates.PerfTests.dll
) ELSE (
	vstest.console /Logger:timelineLogger MessageTemplates.PerfTests\bin\Release\MessageTemplates.PerfTests.dll
)

use xunit runner from packages

use xunit runner from packages


@Echo Off
SET OLDPATH=%PATH%
SET PLATFORM=x86
SET DEVPATH64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
SET DEVPATH86=C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE;
SET PATH=%PATH%;%DEVPATH86%;%DEVPATH64%
SET Action="Prep"
CHOICE /C PBCE /N /D P /T 3 /M "Build(B) Clean(C) Continue:"
IF %ERRORLEVEL% LEQ 1 (SET Action="Prep" && GOTO Start)
IF %ERRORLEVEL% LEQ 2 (SET Action="Build" && GOTO Start)
IF %ERRORLEVEL% LEQ 3 (SET Action="Clean" && GOTO Start)
IF %ERRORLEVEL% LEQ 4 (SET Action="END" && GOTO Start)

:Start
Echo %Action%
IF %Action%=="Clean" GOTO Clean
IF %Action%=="END" GOTO END

:Prep
Echo Packed Skin.zip
IF EXIST "%CD%\Browser\Skin.zip" del /F /Q /S "%CD%\Browser\Skin.zip"
pushd "%CD%\Browser\Skin\"
..\..\Bin\7z.exe a ..\Skin.zip *
popd popd
Echo.

IF NOT EXIST "%CD%\Bin\cef.pak" (
pushd "%CD%\Bin\"
IF NOT EXIST cef_binary_3.2623.1401.gb90a3be.zip (
wget https://github.com/sanwer/libcef/releases/download/latest/cef_binary_3.2623.1401.gb90a3be.zip
IF "%errorlevel%"=="1" GOTO error
)
7z.exe x cef_binary_3.2623.1401.gb90a3be.zip
popd popd
Echo.
)
IF NOT EXIST "%CD%\Bin\cef.pak" GOTO error

IF %Action%=="Prep" GOTO END
IF %Action%=="Build" GOTO Build

:Build
Echo Build Release Version
DEVENV Browser.sln /build "Release|Win32"
IF "%ERRORLEVEL%"=="1" GOTO Error
Echo Build Release Version End
GOTO Package

:Package
Echo Package
pushd "%CD%\Bin\"
IF EXIST Browser.zip DEL /F /Q /S Browser.zip
7z.exe a Browser.zip Browser.exe locales PepperFlash cef.pak cef_100_percent.pak cef_extensions.pak d3dcompiler_43.dll d3dcompiler_47.dll icudtl.dat libcef.dll libEGL.dll libGLESv2.dll natives_blob.bin DuiLib.dll
popd popd
GOTO End

:Clean
Echo Clean Temp File
DEL /F /Q /S /A *.sdf *.user *.ilk *.ipch
DEL /F /Q /S /A .\Bin\Browser.exe .\Bin\Browser.pdb .\Bin\Browser_d.exe .\Bin\Browser_d.pdb .\Bin\Browser.zip
DEL /F /Q /S /A .\Bin\DuiLib.exe .\Bin\DuiLib.pdb .\Bin\DuiLib_d.dll .\Bin\DuiLib_d.pdb
IF EXIST .\Bin\Debug RD /S /Q .\Bin\Debug
IF EXIST .\Bin\Release RD /S /Q .\Bin\Release
IF EXIST .\Bin\x64 RD /S /Q .\Bin\x64
IF EXIST .\Lib RD /S /Q .\Lib
IF EXIST .\ipch RD /S /Q .\ipch
IF EXIST .vs RD /S /Q .vs
IF EXIST .\Browser\Skin.zip DEL /F /Q /S .\Browser\Skin.zip
SET PATH=%OLDPATH%
exit /B 0

:Error
SET PATH=%OLDPATH%
Echo [ERROR]: There was an error building the component
PAUSE
EXIT /B 1

:End
SET PATH=%OLDPATH%

@Echo Off
SET OLDPATH=%PATH%
SET PLATFORM=x86
SET DEVPATH64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
SET DEVPATH86=C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE;
SET PATH=%PATH%;%DEVPATH86%;%DEVPATH64%
SET Action="Prep"
CHOICE /C PBCE /N /D P /T 3 /M "Build(B) Clean(C) Continue:"
IF %ERRORLEVEL% LEQ 1 (SET Action="Prep" && GOTO Start)
IF %ERRORLEVEL% LEQ 2 (SET Action="Build" && GOTO Start)
IF %ERRORLEVEL% LEQ 3 (SET Action="Clean" && GOTO Start)
IF %ERRORLEVEL% LEQ 4 (SET Action="END" && GOTO Start)

:Start
Echo %Action%
IF %Action%=="Clean" GOTO Clean
IF %Action%=="END" GOTO END

:Prep
Echo Packed Skin.zip
IF EXIST "%CD%\Browser\Skin.zip" del /F /Q /S "%CD%\Browser\Skin.zip"
pushd "%CD%\Browser\Skin\"
..\..\Bin\7z.exe a ..\Skin.zip *
popd popd
Echo.

IF NOT EXIST "%CD%\Bin\cef.pak" (
pushd "%CD%\Bin\"
IF NOT EXIST cef_binary_3.2623.1401.gb90a3be.zip (
Rem wget https://github.com/sanwer/libcef/releases/download/latest/cef_binary_3.2623.1401.gb90a3be.zip
wget http://files.git.oschina.net/group1/M00/01/E7/PaAvDFm7e8CAYvlMBd6DJ5NhPGc663.zip?token=206a44f4482dcf8e9a288468c79a9107&ts=1506732571&attname=cef_binary_3.2623.1401.gb90a3be.zip
IF "%errorlevel%"=="1" GOTO error
)
7z.exe x cef_binary_3.2623.1401.gb90a3be.zip
popd popd
Echo.
)
IF NOT EXIST "%CD%\Bin\cef.pak" GOTO error

IF %Action%=="Prep" GOTO END
IF %Action%=="Build" GOTO Build

:Build
Echo Build Release Version
DEVENV Browser.sln /build "Release|Win32"
IF "%ERRORLEVEL%"=="1" GOTO Error
Echo Build Release Version End
GOTO Package

:Package
Echo Package
pushd "%CD%\Bin\"
IF EXIST Browser.zip DEL /F /Q /S Browser.zip
7z.exe a Browser.zip Browser.exe locales PepperFlash cef.pak cef_100_percent.pak cef_extensions.pak d3dcompiler_43.dll d3dcompiler_47.dll icudtl.dat libcef.dll libEGL.dll libGLESv2.dll natives_blob.bin DuiLib.dll
popd popd
GOTO End

:Clean
Echo Clean Temp File
DEL /F /Q /S /A *.sdf *.user *.ilk *.ipch
DEL /F /Q /S /A .\Bin\Browser.exe .\Bin\Browser.pdb .\Bin\Browser_d.exe .\Bin\Browser_d.pdb .\Bin\Browser.zip
DEL /F /Q /S /A .\Bin\DuiLib.exe .\Bin\DuiLib.pdb .\Bin\DuiLib_d.dll .\Bin\DuiLib_d.pdb
IF EXIST .\Bin\Debug RD /S /Q .\Bin\Debug
IF EXIST .\Bin\Release RD /S /Q .\Bin\Release
IF EXIST .\Bin\x64 RD /S /Q .\Bin\x64
IF EXIST .\Lib RD /S /Q .\Lib
IF EXIST .\ipch RD /S /Q .\ipch
IF EXIST .vs RD /S /Q .vs
IF EXIST .\Browser\Skin.zip DEL /F /Q /S .\Browser\Skin.zip
SET PATH=%OLDPATH%
exit /B 0

:Error
SET PATH=%OLDPATH%
Echo [ERROR]: There was an error building the component
PAUSE
EXIT /B 1

:End
SET PATH=%OLDPATH%

更新cef_binary地址


:: would be better to build a native binary, but this seems broken.
:: dart pub get
:: dart compile exe bin\sass.dart -o %LIBRARY_BIN%\sass.exe

npm i -g sass@%PKG_VERSION%

:: would be better to build a native binary, but this seems broken.
:: error looks like this:
::
:: (%PREFIX%) %SRC_DIR%>dart compile exe bin\sass.dart -o %PREFIX%\Library\bin\sass.exe
:: Unhandled exception:
:: Crash when compiling null,
:: at character offset null:
:: Bad state: No element
:: #0      List.single (dart:core-patch/growable_array.dart:353:22)
:: #1      ClassBuilderImpl.buildTypeWithBuiltArguments (package:front_end/src/fasta/builder/class_builder.dart:324:44)
:: #2      ClassBuilderImpl.buildType (package:front_end/src/fasta/builder/class_builder.dart:335:12)

:: may be related to https://github.com/flutter/flutter/issues/92757

:: dart pub get
:: dart compile exe bin\sass.dart -o %LIBRARY_BIN%\sass.exe

npm i -g sass@%PKG_VERSION%

document errors

document errors


:: Build tcplotter command-line utilities using cmake

:: Change working directory to archive directory
cd "%PKG_NAME%"

:: Create build directory
cd "src"
mkdir build
if errorlevel 1 exit 1
cd build
if errorlevel 1 exit 1

:: Build with cmake
cmake -G "MinGW Makefiles" ..
if errorlevel 1 exit 1
cmake --build -DCMAKE_CXX_STANDARD=11 .
if errorlevel 1 exit 1

:: Install executables to bin directory
cmake --build . --target install --prefix=%PREFIX%
if errorlevel 1 exit 1

:: Install tcplotter
cd "%SRC_DIR%"
$PYTHON -m pip install . -vv

:: Build tcplotter command-line utilities using cmake

:: Change working directory to archive directory
cd "%PKG_NAME%"

:: Create build directory
cd "src"
mkdir build
if errorlevel 1 exit 1
cd build
if errorlevel 1 exit 1

:: Build with cmake
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 ..
if errorlevel 1 exit 1
cmake --build .
if errorlevel 1 exit 1

:: Install executables to bin directory
cmake --build . --target install --prefix=%PREFIX%
if errorlevel 1 exit 1

:: Install tcplotter
cd "%SRC_DIR%"
$PYTHON -m pip install . -vv

Fix typo in Windows build

Fix typo in Windows build


echo ON

"%PYTHON%" setup.py install --standard-lib
if errorlevel 1 exit 1

if not exist %PREFIX%\etc\conda\activate.d mkdir %PREFIX%\etc\conda\activate.d
if errorlevel 1 exit 1
if not exist %PREFIX%\etc\conda\deactivate.d mkdir -p %PREFIX%\etc\conda\deactivate.d
type NUL > %PREFIX%\etc\conda\activate.d\scons_vars.bat
if errorlevel 1 exit 1
type NUL > %PREFIX%\etc\conda\deactivate.d\scons_vars.bat
if errorlevel 1 exit 1

echo set "CONDA_PREFIX=%CONDA_PREFIX:\=/%" > %PREFIX%\etc\conda\activate.d\scons_vars.bat
echo set SCONSFLAGS="--site-dir=%CONDA_PREFIX%\share\site_scons" > %PREFIX%\etc\conda\activate.d\scons_vars.bat
if errorlevel 1 exit 1
echo set SCONSFLAGS= > %PREFIX%\etc\conda\deactivate.d\scons_vars.bat
if errorlevel 1 exit 1

if not exist %PREFIX%\share\site_scons mkdir %PREFIX%\share\site_scons
if errorlevel 1 exit 1
if not exist %PREFIX%\share\site_scons\site_init.py type NUL > %PREFIX%\share\site_scons\site_init.py
if errorlevel 1 exit 1
if not exist %PREFIX%\share\site_scons\site_tools mkdir %PREFIX%\share\site_scons\site_tools
if errorlevel 1 exit 1

copy %RECIPE_DIR%\prefix.py %PREFIX%\share\site_scons\site_tools\prefix.py
if errorlevel 1 exit 1

echo OFF

echo ON

"%PYTHON%" setup.py install --standard-lib
if errorlevel 1 exit 1

if not exist %PREFIX%\etc\conda\activate.d mkdir %PREFIX%\etc\conda\activate.d
if errorlevel 1 exit 1
if not exist %PREFIX%\etc\conda\deactivate.d mkdir -p %PREFIX%\etc\conda\deactivate.d
type NUL > %PREFIX%\etc\conda\activate.d\scons_vars.bat
if errorlevel 1 exit 1
type NUL > %PREFIX%\etc\conda\deactivate.d\scons_vars.bat
if errorlevel 1 exit 1

echo set "CONDA_PREFIX=%CONDA_PREFIX:/=\%" > %PREFIX%\etc\conda\activate.d\scons_vars.bat
echo set SCONSFLAGS="--site-dir=%CONDA_PREFIX%\share\site_scons" > %PREFIX%\etc\conda\activate.d\scons_vars.bat
if errorlevel 1 exit 1
echo set SCONSFLAGS= > %PREFIX%\etc\conda\deactivate.d\scons_vars.bat
if errorlevel 1 exit 1

if not exist %PREFIX%\share\site_scons mkdir %PREFIX%\share\site_scons
if errorlevel 1 exit 1
if not exist %PREFIX%\share\site_scons\site_init.py type NUL > %PREFIX%\share\site_scons\site_init.py
if errorlevel 1 exit 1
if not exist %PREFIX%\share\site_scons\site_tools mkdir %PREFIX%\share\site_scons\site_tools
if errorlevel 1 exit 1

copy %RECIPE_DIR%\prefix.py %PREFIX%\share\site_scons\site_tools\prefix.py
if errorlevel 1 exit 1

echo OFF

Correct site_scons path for windows

Correct site_scons path for windows


@rem Licensed to the .NET Foundation under one or more agreements.
@rem The .NET Foundation licenses this file to you under the MIT license.
@rem See the LICENSE file in the project root for more information.

@echo off
@if defined _echo echo on

setlocal
  set ERRORLEVEL=
  set BENCHVIEW_RUN_TYPE=local
  set CORECLR_REPO=%CD%
  set TEST_FILE_EXT=exe
  set TEST_ARCH=x64
  set TEST_ARCHITECTURE=x64
  set TEST_CONFIG=Release
  set IS_SCENARIO_TEST=
  set USAGE_DISPLAYED=

  call :parse_command_line_arguments %*
  if defined USAGE_DISPLAYED exit /b %ERRORLEVEL%

  call :set_test_architecture || exit /b 1
  call :verify_core_overlay   || exit /b 1
  call :set_perf_run_log      || exit /b 1
  call :setup_sandbox         || exit /b 1

  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" restore "%CORECLR_REPO%\tests\src\Common\PerfHarness\project.json"                                        || exit /b 1
  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" publish "%CORECLR_REPO%\tests\src\Common\PerfHarness\project.json" -c Release -o "%CORECLR_REPO%\sandbox" || exit /b 1

  rem TODO: Remove the version of the package to copy. e.g.) if multiple version exist, then error out?
  call :run_cmd xcopy /sy "%CORECLR_REPO%\packages\Microsoft.Diagnostics.Tracing.TraceEvent\1.0.3-alpha-experimental\lib\native"\* . >> %RUNLOG%  || exit /b 1
  call :run_cmd xcopy /sy "%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root"\* . >> %RUNLOG%                         || exit /b 1

  rem find and stage the tests
  for /R %CORECLR_PERF% %%T in (*.%TEST_FILE_EXT%) do (
    call :run_benchmark %%T || (
      IF /I NOT "%BENCHVIEW_RUN_TYPE%" == "local" exit /b 1
    )
  )

  rem optionally upload results to benchview
  if not [%BENCHVIEW_PATH%] == [] (
    call :upload_to_benchview
  )

  exit /b %ERRORLEVEL%

:run_benchmark
rem ****************************************************************************
rem   Executes the xUnit Performance benchmarks
rem ****************************************************************************
setlocal
  set BENCHNAME=%~n1
  set BENCHDIR=%~p1
  set PERFOUT=perf-%BENCHNAME%
  set XMLOUT=%PERFOUT%.xml

  rem copy benchmark and any input files
  call :run_cmd xcopy /s %~1 . >> %RUNLOG%  || exit /b 1
  if exist "%BENCHDIR%*.txt" (
    call :run_cmd xcopy /s %BENCHDIR%*.txt . >> %RUNLOG%  || exit /b 1
  )

  set CORE_ROOT=%CORECLR_REPO%\sandbox

  rem setup additional environment variables
  if DEFINED TEST_ENV (
    if EXIST "%TEST_ENV%" (
        call "%TEST_ENV%"
    )
  )

  set BENCHNAME_LOG_FILE_NAME=%BENCHNAME%.log
  if defined IS_SCENARIO_TEST (
    call :run_cmd corerun.exe "%CORECLR_REPO%\sandbox\%BENCHNAME%.%TEST_FILE_EXT%" --perf:runid Perf 1>"%BENCHNAME_LOG_FILE_NAME%" 2>&1
  ) else (
    call :run_cmd corerun.exe PerfHarness.dll "%CORECLR_REPO%\sandbox\%BENCHNAME%.%TEST_FILE_EXT%" --perf:runid Perf 1>"%BENCHNAME_LOG_FILE_NAME%" 2>&1
  )

  IF %ERRORLEVEL% NEQ 0 (
    call :print_error corerun.exe exited with %ERRORLEVEL% code.
    if exist "%BENCHNAME_LOG_FILE_NAME%" type "%BENCHNAME_LOG_FILE_NAME%"
    exit /b 1
  )

  rem optionally generate results for benchview
  if not [%BENCHVIEW_PATH%] == [] (
    call :generate_results_for_benchview || exit /b 1
  ) else (
    type "%XMLOUT%" | findstr /i /c:"test name"
  )

  rem Save off the results to the root directory for recovery later in Jenkins
  call :run_cmd xcopy "Perf-%BENCHNAME%*.xml" "%CORECLR_REPO%\" || exit /b 1
  call :run_cmd xcopy "Perf-%BENCHNAME%*.etl" "%CORECLR_REPO%\" || exit /b 1

  exit /b 0

:parse_command_line_arguments
rem ****************************************************************************
rem   Parses the script's command line arguments.
rem ****************************************************************************
  IF /I [%~1] == [-testBinLoc] (
    set CORECLR_PERF=%CORECLR_REPO%\%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-scenarioTest] (
    set IS_SCENARIO_TEST=1
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-runtype] (
    set BENCHVIEW_RUN_TYPE=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-library] (
    set TEST_FILE_EXT=dll
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-uploadtobenchview] (
    set BENCHVIEW_PATH=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-arch] (
    set TEST_ARCHITECTURE=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-testEnv] (
    set TEST_ENV=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-configuration] (
    set TEST_CONFIG=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )

  if /I [%~1] == [-?] (
    call :USAGE
    exit /b 0
  )
  if /I [%~1] == [-help] (
    call :USAGE
    exit /b 0
  )
  if [%CORECLR_PERF%] == [] (
    call :USAGE
  )

  exit /b %ERRORLEVEL%

:set_test_architecture
rem ****************************************************************************
rem   Sets the test architecture.
rem ****************************************************************************
  IF /I [%TEST_ARCHITECTURE%] == [x86jit32] (
      set TEST_ARCH=x86
  ) ELSE (
      set TEST_ARCH=%TEST_ARCHITECTURE%
  )
  exit /b 0

:verify_core_overlay
rem ****************************************************************************
rem   Verify that the Core_Root folder exist.
rem ****************************************************************************
  set CORECLR_OVERLAY=%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root
  if NOT EXIST "%CORECLR_OVERLAY%" (
    call :print_error Can't find test overlay directory '%CORECLR_OVERLAY%'. Please build and run Release CoreCLR tests.
    exit /B 1
  )
  exit /b 0

:set_perf_run_log
rem ****************************************************************************
rem   Sets the script's output log file.
rem ****************************************************************************
  if NOT EXIST "%CORECLR_REPO%\bin\Logs" (
    call :print_error Cannot find the Logs folder '%CORECLR_REPO%\bin\Logs'.
    exit /b 1
  )
  set RUNLOG=%CORECLR_REPO%\bin\Logs\perfrun.log
  exit /b 0

:setup_sandbox
rem ****************************************************************************
rem   Creates the sandbox folder used by the script to copy binaries locally,
rem   and execute benchmarks.
rem ****************************************************************************
  if exist sandbox rd /s /q sandbox
  if exist sandbox call :print_error Failed to remove the sandbox folder& exit /b 1
  if not exist sandbox mkdir sandbox
  if not exist sandbox call :print_error Failed to create the sandbox folder& exit /b 1
  cd sandbox
  exit /b 0

:generate_results_for_benchview
rem ****************************************************************************
rem   Generates results for BenchView, by appending new data to the existing
rem   measurement.json file.
rem ****************************************************************************
  set BENCHVIEW_MEASUREMENT_PARSER=xunit
  if defined IS_SCENARIO_TEST set BENCHVIEW_MEASUREMENT_PARSER=xunitscenario

  set LV_MEASUREMENT_ARGS=
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% %BENCHVIEW_MEASUREMENT_PARSER%
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% "Perf-%BENCHNAME%.xml"
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --better desc
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --drop-first-value
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --append
  call :run_cmd py.exe "%BENCHVIEW_PATH%\measurement.py" %LV_MEASUREMENT_ARGS%
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Failed to generate BenchView measurement data.
    exit /b 1
  )
endlocal& exit /b %ERRORLEVEL%

:upload_to_benchview
rem ****************************************************************************
rem   Generates BenchView's submission data and upload it
rem ****************************************************************************
setlocal
  set LV_SUBMISSION_ARGS=
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --build ..\build.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --machine-data ..\machinedata.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --metadata ..\submission-metadata.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --group "CoreCLR"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --type "%BENCHVIEW_RUN_TYPE%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config-name "%TEST_CONFIG%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config Configuration "%TEST_CONFIG%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config OS "Windows_NT"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --arch "%TEST_ARCHITECTURE%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --machinepool "PerfSnake"
  call :run_cmd py.exe "%BENCHVIEW_PATH%\submission.py" measurement.json %LV_SUBMISSION_ARGS%
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Creating BenchView submission data failed.
    exit /b 1
  )

  call :run_cmd py.exe "%BENCHVIEW_PATH%\upload.py" submission.json --container coreclr
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Uploading to BenchView failed.
    exit /b 1
  )
  exit /b %ERRORLEVEL%

:USAGE
rem ****************************************************************************
rem   Script's usage.
rem ****************************************************************************
  set USAGE_DISPLAYED=1
  echo run-xunit-perf.cmd -testBinLoc ^<path_to_tests^> [-library] [-arch] ^<x86^|x64^> [-configuration] ^<Release^|Debug^> [-uploadToBenchview] ^<path_to_benchview_tools^> [-runtype] ^<rolling^|private^> [-scenarioTest]
  echo/
  echo For the path to the tests you can pass a parent directory and the script will grovel for
  echo all tests in subdirectories and run them.
  echo The library flag denotes whether the tests are build as libraries (.dll) or an executable (.exe)
  echo Architecture defaults to x64 and configuration defaults to release.
  echo -uploadtoBenchview is used to specify a path to the Benchview tooling and when this flag is
  echo set we will upload the results of the tests to the coreclr container in benchviewupload.
  echo Runtype sets the runtype that we upload to Benchview, rolling for regular runs, and private for
  echo PRs.
  echo -scenarioTest should be included if you are running a scenario benchmark.
  exit /b %ERRORLEVEL%

:print_error
rem ****************************************************************************
rem   Function wrapper that unifies how errors are output by the script.
rem   Functions output to the standard error.
rem ****************************************************************************
  echo [%DATE%][%TIME:~0,-3%][ERROR] %*   1>&2
  exit /b %ERRORLEVEL%

:print_to_console
rem ****************************************************************************
rem   Sends text to the console screen, no matter what (even when the script's
rem   output is redirected). This can be useful to provide information on where
rem   the script is executing.
rem ****************************************************************************
  if defined _debug (
    echo [%DATE%][%TIME:~0,-3%] %* >CON
  )
  echo [%DATE%][%TIME:~0,-3%] %*
  exit /b %ERRORLEVEL%

:run_cmd
rem ****************************************************************************
rem   Function wrapper used to send the command line being executed to the
rem   console screen, before the command is executed.
rem ****************************************************************************
  if "%~1" == "" (
    call :print_error No command was specified.
    exit /b 1
  )

  call :print_to_console $ %*
  call %*
  exit /b %ERRORLEVEL%

@rem Licensed to the .NET Foundation under one or more agreements.
@rem The .NET Foundation licenses this file to you under the MIT license.
@rem See the LICENSE file in the project root for more information.

@echo off
@if defined _echo echo on

setlocal
  set ERRORLEVEL=
  set BENCHVIEW_RUN_TYPE=local
  set CORECLR_REPO=%CD%
  set TEST_FILE_EXT=exe
  set TEST_ARCH=x64
  set TEST_ARCHITECTURE=x64
  set TEST_CONFIG=Release
  set IS_SCENARIO_TEST=
  set USAGE_DISPLAYED=

  call :parse_command_line_arguments %*
  if defined USAGE_DISPLAYED exit /b %ERRORLEVEL%

  call :set_test_architecture || exit /b 1
  call :verify_core_overlay   || exit /b 1
  call :set_perf_run_log      || exit /b 1
  call :setup_sandbox         || exit /b 1

  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" restore "%CORECLR_REPO%\tests\src\Common\PerfHarness\project.json"                                        || exit /b 1
  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" publish "%CORECLR_REPO%\tests\src\Common\PerfHarness\project.json" -c Release -o "%CORECLR_REPO%\sandbox" || exit /b 1

  rem TODO: Remove the version of the package to copy. e.g.) if multiple version exist, then error out?
  call :run_cmd xcopy /sy "%CORECLR_REPO%\packages\Microsoft.Diagnostics.Tracing.TraceEvent\1.0.3-alpha-experimental\lib\native"\* . >> %RUNLOG%  || exit /b 1
  call :run_cmd xcopy /sy "%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root"\* . >> %RUNLOG%                         || exit /b 1

  rem find and stage the tests
  set /A "LV_FAILURES=0"
  for /R %CORECLR_PERF% %%T in (*.%TEST_FILE_EXT%) do (
    rem Skip known failures
    call :run_benchmark %%T || (
      set /A "LV_FAILURES+=1"
    )
  )

  rem optionally upload results to benchview
  if not [%BENCHVIEW_PATH%] == [] (
    call :upload_to_benchview || exit /b 1
  )

  rem Numbers are limited to 32-bits of precision (Int32.MAX == 2^32 - 1).
  if %LV_FAILURES% NEQ 0 (
    call :print_error %LV_FAILURES% benchmarks has failed.
    exit /b %LV_FAILURES%
  )

  exit /b %ERRORLEVEL%

:run_benchmark
rem ****************************************************************************
rem   Executes the xUnit Performance benchmarks
rem ****************************************************************************
setlocal
  set BENCHNAME=%~n1
  set BENCHDIR=%~p1
  set PERFOUT=perf-%BENCHNAME%
  set XMLOUT=%PERFOUT%.xml

  rem copy benchmark and any input files
  call :run_cmd xcopy /s %~1 . >> %RUNLOG%  || exit /b 1
  if exist "%BENCHDIR%*.txt" (
    call :run_cmd xcopy /s %BENCHDIR%*.txt . >> %RUNLOG%  || exit /b 1
  )

  set CORE_ROOT=%CORECLR_REPO%\sandbox

  rem setup additional environment variables
  if DEFINED TEST_ENV (
    if EXIST "%TEST_ENV%" (
        call "%TEST_ENV%"
    )
  )

  set BENCHNAME_LOG_FILE_NAME=%BENCHNAME%.log
  if defined IS_SCENARIO_TEST (
    call :run_cmd corerun.exe "%CORECLR_REPO%\sandbox\%BENCHNAME%.%TEST_FILE_EXT%" --perf:runid Perf 1>"%BENCHNAME_LOG_FILE_NAME%" 2>&1
  ) else (
    call :run_cmd corerun.exe PerfHarness.dll "%CORECLR_REPO%\sandbox\%BENCHNAME%.%TEST_FILE_EXT%" --perf:runid Perf 1>"%BENCHNAME_LOG_FILE_NAME%" 2>&1
  )

  IF %ERRORLEVEL% NEQ 0 (
    call :print_error corerun.exe exited with %ERRORLEVEL% code.
    if exist "%BENCHNAME_LOG_FILE_NAME%" type "%BENCHNAME_LOG_FILE_NAME%"
    exit /b 1
  )

  rem optionally generate results for benchview
  if not [%BENCHVIEW_PATH%] == [] (
    call :generate_results_for_benchview || exit /b 1
  ) else (
    type "%XMLOUT%" | findstr /i /c:"test name"
  )

  rem Save off the results to the root directory for recovery later in Jenkins
  call :run_cmd xcopy "Perf-%BENCHNAME%*.xml" "%CORECLR_REPO%\" || exit /b 1
  call :run_cmd xcopy "Perf-%BENCHNAME%*.etl" "%CORECLR_REPO%\" || exit /b 1

  exit /b 0

:parse_command_line_arguments
rem ****************************************************************************
rem   Parses the script's command line arguments.
rem ****************************************************************************
  IF /I [%~1] == [-testBinLoc] (
    set CORECLR_PERF=%CORECLR_REPO%\%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-scenarioTest] (
    set IS_SCENARIO_TEST=1
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-runtype] (
    set BENCHVIEW_RUN_TYPE=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-library] (
    set TEST_FILE_EXT=dll
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-uploadtobenchview] (
    set BENCHVIEW_PATH=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-arch] (
    set TEST_ARCHITECTURE=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-testEnv] (
    set TEST_ENV=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )
  IF /I [%~1] == [-configuration] (
    set TEST_CONFIG=%~2
    shift
    shift
    goto :parse_command_line_arguments
  )

  if /I [%~1] == [-?] (
    call :USAGE
    exit /b 0
  )
  if /I [%~1] == [-help] (
    call :USAGE
    exit /b 0
  )
  if [%CORECLR_PERF%] == [] (
    call :USAGE
  )

  exit /b %ERRORLEVEL%

:set_test_architecture
rem ****************************************************************************
rem   Sets the test architecture.
rem ****************************************************************************
  IF /I [%TEST_ARCHITECTURE%] == [x86jit32] (
      set TEST_ARCH=x86
  ) ELSE (
      set TEST_ARCH=%TEST_ARCHITECTURE%
  )
  exit /b 0

:verify_core_overlay
rem ****************************************************************************
rem   Verify that the Core_Root folder exist.
rem ****************************************************************************
  set CORECLR_OVERLAY=%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root
  if NOT EXIST "%CORECLR_OVERLAY%" (
    call :print_error Can't find test overlay directory '%CORECLR_OVERLAY%'. Please build and run Release CoreCLR tests.
    exit /B 1
  )
  exit /b 0

:set_perf_run_log
rem ****************************************************************************
rem   Sets the script's output log file.
rem ****************************************************************************
  if NOT EXIST "%CORECLR_REPO%\bin\Logs" (
    call :print_error Cannot find the Logs folder '%CORECLR_REPO%\bin\Logs'.
    exit /b 1
  )
  set RUNLOG=%CORECLR_REPO%\bin\Logs\perfrun.log
  exit /b 0

:setup_sandbox
rem ****************************************************************************
rem   Creates the sandbox folder used by the script to copy binaries locally,
rem   and execute benchmarks.
rem ****************************************************************************
  if exist sandbox rd /s /q sandbox
  if exist sandbox call :print_error Failed to remove the sandbox folder& exit /b 1
  if not exist sandbox mkdir sandbox
  if not exist sandbox call :print_error Failed to create the sandbox folder& exit /b 1
  cd sandbox
  exit /b 0

:generate_results_for_benchview
rem ****************************************************************************
rem   Generates results for BenchView, by appending new data to the existing
rem   measurement.json file.
rem ****************************************************************************
  set BENCHVIEW_MEASUREMENT_PARSER=xunit
  if defined IS_SCENARIO_TEST set BENCHVIEW_MEASUREMENT_PARSER=xunitscenario

  set LV_MEASUREMENT_ARGS=
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% %BENCHVIEW_MEASUREMENT_PARSER%
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% "Perf-%BENCHNAME%.xml"
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --better desc
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --drop-first-value
  set LV_MEASUREMENT_ARGS=%LV_MEASUREMENT_ARGS% --append
  call :run_cmd py.exe "%BENCHVIEW_PATH%\measurement.py" %LV_MEASUREMENT_ARGS%
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Failed to generate BenchView measurement data.
    exit /b 1
  )
endlocal& exit /b %ERRORLEVEL%

:upload_to_benchview
rem ****************************************************************************
rem   Generates BenchView's submission data and upload it
rem ****************************************************************************
setlocal
  set LV_SUBMISSION_ARGS=
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --build ..\build.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --machine-data ..\machinedata.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --metadata ..\submission-metadata.json
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --group "CoreCLR"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --type "%BENCHVIEW_RUN_TYPE%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config-name "%TEST_CONFIG%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config Configuration "%TEST_CONFIG%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --config OS "Windows_NT"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --arch "%TEST_ARCHITECTURE%"
  set LV_SUBMISSION_ARGS=%LV_SUBMISSION_ARGS% --machinepool "PerfSnake"
  call :run_cmd py.exe "%BENCHVIEW_PATH%\submission.py" measurement.json %LV_SUBMISSION_ARGS%
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Creating BenchView submission data failed.
    exit /b 1
  )

  call :run_cmd py.exe "%BENCHVIEW_PATH%\upload.py" submission.json --container coreclr
  IF %ERRORLEVEL% NEQ 0 (
    call :print_error Uploading to BenchView failed.
    exit /b 1
  )
  exit /b %ERRORLEVEL%

:USAGE
rem ****************************************************************************
rem   Script's usage.
rem ****************************************************************************
  set USAGE_DISPLAYED=1
  echo run-xunit-perf.cmd -testBinLoc ^<path_to_tests^> [-library] [-arch] ^<x86^|x64^> [-configuration] ^<Release^|Debug^> [-uploadToBenchview] ^<path_to_benchview_tools^> [-runtype] ^<rolling^|private^> [-scenarioTest]
  echo/
  echo For the path to the tests you can pass a parent directory and the script will grovel for
  echo all tests in subdirectories and run them.
  echo The library flag denotes whether the tests are build as libraries (.dll) or an executable (.exe)
  echo Architecture defaults to x64 and configuration defaults to release.
  echo -uploadtoBenchview is used to specify a path to the Benchview tooling and when this flag is
  echo set we will upload the results of the tests to the coreclr container in benchviewupload.
  echo Runtype sets the runtype that we upload to Benchview, rolling for regular runs, and private for
  echo PRs.
  echo -scenarioTest should be included if you are running a scenario benchmark.
  exit /b %ERRORLEVEL%

:print_error
rem ****************************************************************************
rem   Function wrapper that unifies how errors are output by the script.
rem   Functions output to the standard error.
rem ****************************************************************************
  echo [%DATE%][%TIME:~0,-3%][ERROR] %*   1>&2
  exit /b %ERRORLEVEL%

:print_to_console
rem ****************************************************************************
rem   Sends text to the console screen, no matter what (even when the script's
rem   output is redirected). This can be useful to provide information on where
rem   the script is executing.
rem ****************************************************************************
  if defined _debug (
    echo [%DATE%][%TIME:~0,-3%] %* >CON
  )
  echo [%DATE%][%TIME:~0,-3%] %*
  exit /b %ERRORLEVEL%

:run_cmd
rem ****************************************************************************
rem   Function wrapper used to send the command line being executed to the
rem   console screen, before the command is executed.
rem ****************************************************************************
  if "%~1" == "" (
    call :print_error No command was specified.
    exit /b 1
  )

  call :print_to_console $ %*
  call %*
  exit /b %ERRORLEVEL%

:skip_failures
rem ****************************************************************************
rem   Skip known failures
rem ****************************************************************************
  IF /I [%TEST_ARCHITECTURE%] == [x86jit32] (
    IF /I "%~1" == "CscBench" (
      rem https://github.com/dotnet/coreclr/issues/11088
      exit /b 1
    )
    IF /I "%~1" == "SciMark2" (
      rem https://github.com/dotnet/coreclr/issues/11089
      exit /b 1
    )
  )
  exit /b 0

Allow to run all benchmarks and even upload, but fail the job.


@echo off

set scriptsdir=%~dp0
set root=%scriptsdir%\..
set project=%1
set version=%2

if "%project%"=="" (
	echo Please invoke the build script with a project name as its first argument.
	echo.
	goto exit_fail
)

if "%version%"=="" (
	echo Please invoke the build script with a version as its second argument.
	echo.
	goto exit_fail
)

set Version=%version%

pushd %root%

dotnet restore
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

dotnet build "%root%\migr8\migr8.csproj" -c Release
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

dotnet build "%root%\migr8.npgsql\migr8.npgsql.csproj" -c Release
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

popd

goto exit_success
:exit_fail
exit /b 1
:exit_success

@echo off

set scriptsdir=%~dp0
set root=%scriptsdir%\..
set project=%1
set version=%2

if "%project%"=="" (
	echo Please invoke the build script with a project name as its first argument.
	echo.
	goto exit_fail
)

if "%version%"=="" (
	echo Please invoke the build script with a version as its second argument.
	echo.
	goto exit_fail
)

set Version=%version%

pushd %root%

dotnet restore
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

dotnet build "%root%\migr8\migr8.csproj" -c Release
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

dotnet build "%root%\migr8.npgsql\migr8.npgsql.csproj" -c Release
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

dotnet build "%root%\migr8.mysql\migr8.mysql.csproj" -c Release
if %ERRORLEVEL% neq 0 (
	popd
 	goto exit_fail
)

popd

goto exit_success
:exit_fail
exit /b 1
:exit_success

Add mysql project to build process

Add mysql project to build process


taskkill.exe /F /IM java.exe
taskkill.exe /F /IM javaW.exe
java -jar myrobotlab.jar -service python Python webGui WebGui -invoke python execFile %cd%/MyaiBot-Pictures.py

taskkill.exe /F /IM java.exe
taskkill.exe /F /IM javaW.exe
java -jar myrobotlab.jar -service python Python webGui WebGui -invoke python execFile %cd%/MyaiBot.py

Update mrl.bat (#27)

Update mrl.bat (#27)


REM  install Anaconda 2018.2 in C:\anaconda3 (without VS, without PATH)
REM  Start->Anaconda3->Anaconda-Prompt

pip install numpy==1.16.0

pip install pyqt5==5.11.3

pip install hdf5plugin

pip install silx

pip install srxraylib

pip install syned

pip install wofry

pip install oasys-canvas-core

pip install oasys-widget-core

pip install oasys1

conda install -c conda-forge xraylib=3.3.0

REM
REM   try: python -m oasys.canvas -l4 --force-discovery
REM   Oasys should start (with no add-ons)
REM
REM  Use the Optioons->AddOns to install the addons from the Oasys menu bar

REM  install Anaconda 2018.2 in C:\anaconda3 (without VS, without PATH)
REM  Start->Anaconda3->Anaconda-Prompt

pip install numpy==1.16.0

pip install pyqt5==5.11.3

pip install hdf5plugin

pip install silx

#pip install srxraylib

# for the moment oasys1-srwpy 1.0.2 is not available for windows, so use older version

pip install https://files.pythonhosted.org/packages/08/6e/34d810ca5acfbab9850ed887dc9362683f4dc895aa9e7da543d7a072d121/oasys_srwpy-1.0.0-cp37-cp37m-win_amd64.whl

pip install syned

pip install wofry

pip install oasys-canvas-core

pip install oasys-widget-core

pip install oasys1

conda install -c conda-forge xraylib=3.3.0

REM
REM   try: python -m oasys.canvas -l4 --force-discovery
REM   Oasys should start (with no add-ons)
REM
REM  Use the Optioons->AddOns to install the addons from the Oasys menu bar

Update install_oasys_windows.bat

Update install_oasys_windows.bat


REM work in progress
REM Setup a non-production BigFix Eval Server with SQL Developer Edition.

REM http://software.bigfix.com/download/bes/95/BigFix-BES-9.5.9.62.exe
REM http://download.microsoft.com/download/2/5/0/2508F7B4-6DDE-4C3E-B1FA-E1EB66F2F79F/SQLServer2016-SSEI-Dev.exe

SET BASEFOLDER=C:\Windows\Temp

REM Open folder:
start "" %BASEFOLDER%

REM Download SQLServer Developer Edition:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://download.microsoft.com/download/2/5/0/2508F7B4-6DDE-4C3E-B1FA-E1EB66F2F79F/SQLServer2016-SSEI-Dev.exe', '%BASEFOLDER%\SQLServer-SSEI-Dev.exe') }" -ExecutionPolicy Bypass
REM Install SQLServer Developer Edition:
REM https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2017
%BASEFOLDER%\SQLServer-SSEI-Dev.exe /Q /ACTION=Install /IACCEPTSQLSERVERLICENSETERMS /MEDIAPATH="%BASEFOLDER%\SQLServerMedia"

REM https://github.com/jgstew/bigfix-content/blob/f36708ebf7af38f84a286f3b79131faccb1d2e9c/fixlet/Install%20SQL%20Server%20Management%20Studio%2016.5.1%20-%20Windows.bes
REM Download SQL Server Management Studio:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/0/5/B/05B2AF8F-906F-4C57-A58E-5780F64F9D62/SSMS-Setup-ENU.exe', '%BASEFOLDER%\SSMS-Setup-ENU.exe') }" -ExecutionPolicy Bypass
REM https://download.microsoft.com/download/0/5/B/05B2AF8F-906F-4C57-A58E-5780F64F9D62/SSMS-Setup-ENU.exe
REM Install SQL Server Management Studio:
%BASEFOLDER%\SSMS-Setup-ENU.exe /install /quiet /norestart

REM for some reason, this didn't create a start menu shortcut it seems for SQL Server Management Studio

REM Download BigFix Root Server:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/95/BigFix-BES-9.5.9.62.exe', '%BASEFOLDER%\BigFix-BES.exe') }" -ExecutionPolicy Bypass
REM Install:
REM %BASEFOLDER%\BigFix-BES.exe

REM press any key to continue....
pause

Update bigfix_setup_root_eval.bat

Update bigfix_setup_root_eval.bat


@echo off

setlocal EnableDelayedExpansion

for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime (
	set CURR_DATE_TIME=%%j
)

set curr_year=%CURR_DATE_TIME:~0,4%
set curr_month=%CURR_DATE_TIME:~4,2%

:: Make sure this is a decent name and not generic
set exe_name=odin.exe

:: Debug = 0, Release = 1
if "%1" == "1" (
	set release_mode=1
) else if "%1" == "release" (
	set release_mode=1
) else (
	set release_mode=0
)

:: Normal = 0, CI Nightly = 1
if "%2" == "1" (
	set nightly=1
) else (
	set nightly=0
)

set odin_version_raw="dev-%curr_year%-%curr_month%"

set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\"

for /f %%i in ('git rev-parse --short HEAD') do set GIT_SHA=%%i
if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\"
if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY

if %release_mode% EQU 0 ( rem Debug
	set compiler_flags=%compiler_flags% -Od -MDd -Z7
) else ( rem Release
	set compiler_flags=%compiler_flags% -O2 -MT -Z7
	set compiler_defines=%compiler_defines% -DNO_ARRAY_BOUNDS_CHECK
)

set compiler_warnings= ^
	-W4 -WX ^
	-wd4100 -wd4101 -wd4127 -wd4146 ^
	-wd4456 -wd4457

set compiler_includes= ^
	/Isrc\
set libs= ^
	kernel32.lib ^
	bin\llvm\windows\LLVM-C.lib

set linker_flags= -incremental:no -opt:ref -subsystem:console

if %release_mode% EQU 0 ( rem Debug
	set linker_flags=%linker_flags% -debug
) else ( rem Release
	set linker_flags=%linker_flags% -debug
)

set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings% %compiler_defines%
set linker_settings=%libs% %linker_flags%

del *.pdb > NUL 2> NUL
del *.ilk > NUL 2> NUL

rem cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
rem if %errorlevel% neq 0 goto end_of_build

odin run examples/bug
rem odin build examples/demo -use-separate-modules
rem odin run examples/demo -o:minimal
rem odin run examples/demo -o:size
rem odin run examples/demo -o:speed -keep-temp-files
rem odin run examples/demo -o:speed -keep-temp-files

rem set small_hellope_flags=-strict-style -no-bounds-check -default-to-nil-allocator -disable-assert -no-crt -o:size
rem set small_hellope_flags=-strict-style -no-bounds-check -default-to-nil-allocator -disable-assert -o:size

rem odin build examples/small_hellope %small_hellope_flags% -build-mode:asm
rem odin run examples/small_hellope %small_hellope_flags% -keep-temp-files
rem FOR /F "usebackq" %%A IN ('small_hellope.exe') DO echo %%~zA

rem cl /nologo examples\small_hellope\small_hellope.c /O1 /link Kernel32.lib -out:small_hellope_c.exe /NODEFAULTLIB /entry:mainCRTStartup /subsystem:console
rem small_hellope_c.exe
rem FOR /F "usebackq" %%A IN ('small_hellope_c.exe') DO echo %%~zA

rem odin run examples/demo
rem odin run examples/sdl2 -vet
rem odin check examples/all -vet
rem odin run examples/bug

rem odin check examples/wasm -strict-style -target:wasi_wasm32
rem odin check examples/demo -strict-style
rem odin build examples/wasm -strict-style -target:wasi_wasm32 -keep-temp-files
rem "C:\Program Files\WAVM\bin\wavm.exe" disassemble wasm.wasm > wasm.wast
rem "C:\Program Files\WAVM\bin\wavm.exe" run --abi=wasi --function=weird_add wasm.wasm 2 3

rem wasmer inspect wasm.wasm
rem wasmer run wasm.wasm

rem odin run examples/demo -strict-style

rem call build_vendor.bat
rem if %errorlevel% neq 0 goto end_of_build

rem if %release_mode% EQU 0 odin check examples/bug -strict-style

rem odin run examples/demo -strict-style

del *.obj > NUL 2> NUL

:end_of_build

@echo off

setlocal EnableDelayedExpansion

for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime (
	set CURR_DATE_TIME=%%j
)

set curr_year=%CURR_DATE_TIME:~0,4%
set curr_month=%CURR_DATE_TIME:~4,2%

:: Make sure this is a decent name and not generic
set exe_name=odin.exe

:: Debug = 0, Release = 1
if "%1" == "1" (
	set release_mode=1
) else if "%1" == "release" (
	set release_mode=1
) else (
	set release_mode=0
)

:: Normal = 0, CI Nightly = 1
if "%2" == "1" (
	set nightly=1
) else (
	set nightly=0
)

set odin_version_raw="dev-%curr_year%-%curr_month%"

set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\"

for /f %%i in ('git rev-parse --short HEAD') do set GIT_SHA=%%i
if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\"
if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY

if %release_mode% EQU 0 ( rem Debug
	set compiler_flags=%compiler_flags% -Od -MDd -Z7
) else ( rem Release
	set compiler_flags=%compiler_flags% -O2 -MT -Z7
	set compiler_defines=%compiler_defines% -DNO_ARRAY_BOUNDS_CHECK
)

set compiler_warnings= ^
	-W4 -WX ^
	-wd4100 -wd4101 -wd4127 -wd4146 ^
	-wd4456 -wd4457

set compiler_includes= ^
	/Isrc\
set libs= ^
	kernel32.lib ^
	bin\llvm\windows\LLVM-C.lib

set linker_flags= -incremental:no -opt:ref -subsystem:console

if %release_mode% EQU 0 ( rem Debug
	set linker_flags=%linker_flags% -debug
) else ( rem Release
	set linker_flags=%linker_flags% -debug
)

set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings% %compiler_defines%
set linker_settings=%libs% %linker_flags%

del *.pdb > NUL 2> NUL
del *.ilk > NUL 2> NUL

cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
if %errorlevel% neq 0 goto end_of_build

call build_vendor.bat
if %errorlevel% neq 0 goto end_of_build

if %release_mode% EQU 0 odin run examples/demo

del *.obj > NUL 2> NUL

:end_of_build

Revert build.bat

Revert build.bat


set /p versionNumber=

"C:\Program Files\Microsoft F#\v4.0\fsc.exe" -o:Unquote.dll --noframework --define:TRACE --optimize+ -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Compiler.dll" -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Compiler.Interactive.Settings.dll" -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Core.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Linq.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Metadata.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Parallel.Seq.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Numerics.dll" --target:library --warn:3 --warnaserror:76 --vserrors --LCID:1033 --utf8output --fullpaths --flaterrors "C:\Users\Stephen\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.fs" Unquote\Printf.fs Unquote\RegexUtils.fs Unquote\Sprint.fs Unquote\Reduce.fs Unquote\TypeExt.fs Unquote\ExprExt.fs Unquote\Operators.fs

7z a -tzip builds\Unquote-%versionNumber%.zip Unquote.dll LICENSE NOTICE readme.html
del Unquote.dll
pause

set /p versionNumber=

"C:\Program Files\Microsoft F#\v4.0\fsc.exe" -o:Unquote.dll --noframework --define:TRACE --optimize+ -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Compiler.dll" -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Compiler.Interactive.Settings.dll" -r:"C:\Program Files\FSharp-2.0.0.0\v4.0\bin\FSharp.Core.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Linq.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Metadata.dll" -r:"C:\Program Files\FSharpPowerPack-2.0.0.0\\bin\FSharp.PowerPack.Parallel.Seq.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Numerics.dll" --target:library --warn:3 --warnaserror:76 --vserrors --LCID:1033 --utf8output --fullpaths --flaterrors "C:\Users\Stephen\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.fs" Unquote\Printf.fs Unquote\Utils.fs Unquote\RegexUtils.fs Unquote\Sprint.fs Unquote\Reduce.fs Unquote\TypeExt.fs Unquote\ExprExt.fs Unquote\Operators.fs

7z a -tzip builds\Unquote-%versionNumber%.zip Unquote.dll LICENSE NOTICE
del Unquote.dll
pause

update build script to exclude old readme.html, and include Utils.fs


@echo off

dotnet build %~dp0\src\git-istage.sln /nologo

@echo off

dotnet build %~dp0src\git-istage.sln /p:OutDir=%~dp0bin /nologo

Fix output directory

Fix output directory


@echo off
SETLOCAL

cls

.paket\paket.bootstrapper.exe
if errorlevel 1 (
  exit /b %errorlevel%
)

.paket\paket.exe restore
if errorlevel 1 (
  exit /b %errorlevel%
)

SET TARGET=Default

IF NOT [%1]==[] (SET TARGET=%~1)

"packages\build\FAKE\tools\Fake.exe" "build.fsx" "target="%TARGET%""

@echo off
SETLOCAL

cls

.paket\paket.bootstrapper.exe
if errorlevel 1 (
  exit /b %errorlevel%
)

.paket\paket.exe restore
if errorlevel 1 (
  exit /b %errorlevel%
)

SET FAKE_PATH=packages\build\FAKE\tools\Fake.exe

IF [%1]==[] (
    "%FAKE_PATH%" "build.fsx" "Default"
) ELSE (
    "%FAKE_PATH%" "build.fsx" %*
)

Support target and args in build.cmd on Windows.

For example, enable `build.cmd CreateNuget -st` by passing all args from build.cmd to
FAKE, if build.cmd has at least one arg.


cls
call "C:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
cl /c /DEBUG ring_vmmysql.c -I"..\..\include" -I"..\..\libdepwin\mysql\include"
link /DEBUG ring_vmmysql.obj  ..\..\lib\ring.lib ..\..\libdepwin\MySQL\lib\libmysql.lib /DLL /OUT:..\..\bin\ring_mysql.dll /SUBSYSTEM:CONSOLE,"5.01"
del ring_vmmysql.obj

cls
call ../../src/locatevc.bat
cl /c /DEBUG ring_vmmysql.c -I"..\..\include" -I"..\..\libdepwin\mysql\include"
link /DEBUG ring_vmmysql.obj  ..\..\lib\ring.lib ..\..\libdepwin\MySQL\lib\libmysql.lib /DLL /OUT:..\..\bin\ring_mysql.dll /SUBSYSTEM:CONSOLE,"5.01"
del ring_vmmysql.obj

Update RingMySQL - buildvc.bat - use locatevc.bat


@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements.  See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership.  The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License.  You may obtain a copy of the License at
@REM
@REM    http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied.  See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------

@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM     e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM ----------------------------------------------------------------------------

@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%

set MAVEN_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@echo Preparing to Execute Maven in Debug Mode

@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")

@REM Execute a user defined script before this one
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"

set ERROR_CODE=0

@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal

@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome

echo.
echo ERROR: JAVA_HOME not found in your environment.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation
echo.
goto error

:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome

echo.
echo ERROR: JAVA_HOME is set to an invalid directory.
echo JAVA_HOME = "%JAVA_HOME%"
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation
echo.
goto error

:chkMHome
if not "%M2_HOME%"=="" goto valMHome

if "%OS%"=="Windows_NT" SET "M2_HOME=%~dp0.."
if "%OS%"=="WINNT" SET "M2_HOME=%~dp0.."
if not "%M2_HOME%"=="" goto valMHome

echo.
echo ERROR: M2_HOME not found in your environment.
echo Please set the M2_HOME variable in your environment to match the
echo location of the Maven installation
echo.
goto error

:valMHome

:stripMHome
if not "_%M2_HOME:~-1%"=="_\" goto checkMBat
set "M2_HOME=%M2_HOME:~0,-1%"
goto stripMHome

:checkMBat
if exist "%M2_HOME%\bin\mvn.bat" goto init

echo.
echo ERROR: M2_HOME is set to an invalid directory.
echo M2_HOME = "%M2_HOME%"
echo Please set the M2_HOME variable in your environment to match the
echo location of the Maven installation
echo.
goto error
@REM ==== END VALIDATION ====

:init
@REM Decide how to startup depending on the version of windows

@REM -- Windows NT with Novell Login
if "%OS%"=="WINNT" goto WinNTNovell

@REM -- Win98ME
if NOT "%OS%"=="Windows_NT" goto Win9xArg

:WinNTNovell

@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTArgs

@REM -- Regular WinNT shell
set MAVEN_CMD_LINE_ARGS=%*
goto endInit

@REM The 4NT Shell from jp software
:4NTArgs
set MAVEN_CMD_LINE_ARGS=%$
goto endInit

:Win9xArg
@REM Slurp the command line arguments.  This loop allows for an unlimited number
@REM of agruments (up to the command line limit, anyway).
set MAVEN_CMD_LINE_ARGS=
:Win9xApp
if %1a==a goto endInit
set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
shift
goto Win9xApp

@REM Reaching here means variables are defined and arguments have been captured
:endInit
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTCWJars

@REM -- Regular WinNT shell
for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
goto runm2

@REM The 4NT Shell from jp software
:4NTCWJars
for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i"
goto runm2

@REM Start MAVEN2
:runm2
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
%MAVEN_JAVA_EXE% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end

:error
if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal
set ERROR_CODE=1

:end
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT
if "%OS%"=="WINNT" goto endNT

@REM For old DOS remove the set variables from ENV - we assume they were not set
@REM before we started - at least we don't leave any baggage around
set MAVEN_JAVA_EXE=
set MAVEN_CMD_LINE_ARGS=
goto postExec

:endNT
@endlocal & set ERROR_CODE=%ERROR_CODE%

:postExec
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause

if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%

exit /B %ERROR_CODE%

@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements.  See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership.  The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License.  You may obtain a copy of the License at
@REM
@REM    http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied.  See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------

@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM     e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM ----------------------------------------------------------------------------

@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%

@echo Preparing to Execute Maven in Debug Mode

@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")

@REM Execute a user defined script before this one
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"

set ERROR_CODE=0

@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal

set MAVEN_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome

echo.
echo ERROR: JAVA_HOME not found in your environment.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation
echo.
goto error

:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome

echo.
echo ERROR: JAVA_HOME is set to an invalid directory.
echo JAVA_HOME = "%JAVA_HOME%"
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation
echo.
goto error

:chkMHome
if not "%M2_HOME%"=="" goto valMHome

if "%OS%"=="Windows_NT" SET "M2_HOME=%~dp0.."
if "%OS%"=="WINNT" SET "M2_HOME=%~dp0.."
if not "%M2_HOME%"=="" goto valMHome

echo.
echo ERROR: M2_HOME not found in your environment.
echo Please set the M2_HOME variable in your environment to match the
echo location of the Maven installation
echo.
goto error

:valMHome

:stripMHome
if not "_%M2_HOME:~-1%"=="_\" goto checkMBat
set "M2_HOME=%M2_HOME:~0,-1%"
goto stripMHome

:checkMBat
if exist "%M2_HOME%\bin\mvn.bat" goto init

echo.
echo ERROR: M2_HOME is set to an invalid directory.
echo M2_HOME = "%M2_HOME%"
echo Please set the M2_HOME variable in your environment to match the
echo location of the Maven installation
echo.
goto error
@REM ==== END VALIDATION ====

:init
@REM Decide how to startup depending on the version of windows

@REM -- Windows NT with Novell Login
if "%OS%"=="WINNT" goto WinNTNovell

@REM -- Win98ME
if NOT "%OS%"=="Windows_NT" goto Win9xArg

:WinNTNovell

@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTArgs

@REM -- Regular WinNT shell
set MAVEN_CMD_LINE_ARGS=%*
goto endInit

@REM The 4NT Shell from jp software
:4NTArgs
set MAVEN_CMD_LINE_ARGS=%$
goto endInit

:Win9xArg
@REM Slurp the command line arguments.  This loop allows for an unlimited number
@REM of agruments (up to the command line limit, anyway).
set MAVEN_CMD_LINE_ARGS=
:Win9xApp
if %1a==a goto endInit
set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1
shift
goto Win9xApp

@REM Reaching here means variables are defined and arguments have been captured
:endInit
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTCWJars

@REM -- Regular WinNT shell
for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
goto runm2

@REM The 4NT Shell from jp software
:4NTCWJars
for %%i in ("%M2_HOME%\boot\plexus-classworlds-*") do set CLASSWORLDS_JAR="%%i"
goto runm2

@REM Start MAVEN2
:runm2
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
%MAVEN_JAVA_EXE% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end

:error
if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal
set ERROR_CODE=1

:end
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT
if "%OS%"=="WINNT" goto endNT

@REM For old DOS remove the set variables from ENV - we assume they were not set
@REM before we started - at least we don't leave any baggage around
set MAVEN_JAVA_EXE=
set MAVEN_CMD_LINE_ARGS=
goto postExec

:endNT
@endlocal & set ERROR_CODE=%ERROR_CODE%

:postExec
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause

if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%

exit /B %ERROR_CODE%

[MNG-4509] set MAVEN_DEBUG_OPTS after setlocal so that it is clear after mvnDebug.bat is done

git-svn-id: d3061b52f177ba403f02f0a296a85518da96c313@894928 13f79535-47bb-0310-9956-ffa450edef68


@echo off
SETLOCAL EnableDelayedExpansion

set startdir=%CD%

if "%1" == "" (
    echo Must give the path to R source as first argument to copyR.cmd!
    exit /b
)
set SOURCEDIR=%1

if "%2" == "" (
    echo Must give the path to R destination as second argument to copyR.cmd!
    exit /b
)
set DESTDIR=%2

SET ARCH=%3
if "%3"=="" (
    SET ARCH=x64
    echo ARCH was not specified so defaulting to x64
)

echo Copying R %ARCH% from %SOURCEDIR% to %DESTDIR%

rmdir /Q /S %DESTDIR%
mkdir  %DESTDIR%

cd %DESTDIR%
mkdir bin
cd bin
COPY %SOURCEDIR%\bin\*.exe /Y
COPY %SOURCEDIR%\bin\*.sh /Y
XCOPY %SOURCEDIR%\bin\%ARCH% /E /I %ARCH%
cd ..

mkdir modules
XCOPY %SOURCEDIR%\modules\%ARCH% /E /I modules\%ARCH%

XCOPY %SOURCEDIR%\etc /E /I etc
XCOPY %SOURCEDIR%\share /E /I share

mkdir library
cd library

Echo Copying necessary parts of R-libraries
cd %SOURCEDIR%\library
FOR /D %%G in ("*") DO (
    cd %SOURCEDIR%\library

    mkdir %DESTDIR%\library\%%G
    cd %DESTDIR%\library\%%G

    COPY %SOURCEDIR%\library\%%G\INDEX INDEX /Y >nul
    COPY %SOURCEDIR%\library\%%G\NAMESPACE NAMESPACE /Y >nul
    COPY %SOURCEDIR%\library\%%G\DESCRIPTION DESCRIPTION /Y >nul
    COPY %SOURCEDIR%\library\%%G\*.R . /Y >nul

    if exist %SOURCEDIR%\library\%%G\R    ( XCOPY %SOURCEDIR%\library\%%G\R    /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\Meta ( XCOPY %SOURCEDIR%\library\%%G\Meta /Q /E /I Meta >nul )

    if exist %SOURCEDIR%\library\%%G\afm  ( XCOPY %SOURCEDIR%\library\%%G\afm  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\enc  ( XCOPY %SOURCEDIR%\library\%%G\enc  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\icc  ( XCOPY %SOURCEDIR%\library\%%G\icc  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\po   ( XCOPY %SOURCEDIR%\library\%%G\po   /Q /E /I R >nul )

    if exist %SOURCEDIR%\library\%%G\libs (
        mkdir %DESTDIR%\library\%%G\libs
        cd %DESTDIR%\library\%%G\libs

        COPY %SOURCEDIR%\library\%%G\libs\* /Y >nul
        XCOPY %SOURCEDIR%\library\%%G\libs\%ARCH% /Q /E /I %ARCH% >nul
        cd %DESTDIR%\library\%%G
    )
)

echo Done!
cd %STARTDIR%

endlocal

@echo off
SETLOCAL EnableDelayedExpansion

set startdir=%CD%

if "%1" == "" (
    echo Must give the path to R source as first argument to copyR.cmd!
    exit /b
)
set SOURCEDIR=%1

if "%2" == "" (
    echo Must give the path to R destination as second argument to copyR.cmd!
    exit /b
)
set DESTDIR=%2

SET ARCH=%3
if "%3"=="" (
    SET ARCH=x64
    echo ARCH was not specified so defaulting to x64
)

echo Copying R %ARCH% from %SOURCEDIR% to %DESTDIR%

rmdir /Q /S %DESTDIR%
mkdir  %DESTDIR%

cd %DESTDIR%
mkdir bin
cd bin
COPY %SOURCEDIR%\bin\*.exe /Y
COPY %SOURCEDIR%\bin\*.sh /Y
XCOPY %SOURCEDIR%\bin\%ARCH% /E /I %ARCH%
cd ..

mkdir modules
XCOPY %SOURCEDIR%\modules\%ARCH% /E /I modules\%ARCH%

XCOPY %SOURCEDIR%\etc /E /I etc
XCOPY %SOURCEDIR%\share /E /I share

mkdir library
cd library

Echo Copying necessary parts of R-libraries
cd %SOURCEDIR%\library
FOR /D %%G in ("*") DO (
    cd %SOURCEDIR%\library

    mkdir %DESTDIR%\library\%%G
    cd %DESTDIR%\library\%%G

    COPY %SOURCEDIR%\library\%%G\INDEX INDEX /Y >nul
    COPY %SOURCEDIR%\library\%%G\NAMESPACE NAMESPACE /Y >nul
    COPY %SOURCEDIR%\library\%%G\DESCRIPTION DESCRIPTION /Y >nul
    COPY %SOURCEDIR%\library\%%G\*.R . /Y >nul

    if exist %SOURCEDIR%\library\%%G\R    ( XCOPY %SOURCEDIR%\library\%%G\R    /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\Meta ( XCOPY %SOURCEDIR%\library\%%G\Meta /Q /E /I Meta >nul )

    if exist %SOURCEDIR%\library\%%G\afm  ( XCOPY %SOURCEDIR%\library\%%G\afm  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\enc  ( XCOPY %SOURCEDIR%\library\%%G\enc  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\icc  ( XCOPY %SOURCEDIR%\library\%%G\icc  /Q /E /I R >nul )
    if exist %SOURCEDIR%\library\%%G\po   ( XCOPY %SOURCEDIR%\library\%%G\po   /Q /E /I R >nul )

    rem for issue https://github.com/jasp-stats/jasp-test-release/issues/416#issuecomment-591899068
    if "%%G"=="viridisLite" ( XCOPY %SOURCEDIR%\library\%%G\data   /Q /E /I R >nul )

    if exist %SOURCEDIR%\library\%%G\libs (
        mkdir %DESTDIR%\library\%%G\libs
        cd %DESTDIR%\library\%%G\libs

        COPY %SOURCEDIR%\library\%%G\libs\* /Y >nul
        XCOPY %SOURCEDIR%\library\%%G\libs\%ARCH% /Q /E /I %ARCH% >nul
        cd %DESTDIR%\library\%%G
    )
)

echo Done!
cd %STARTDIR%

endlocal

Copy data folder of viridsLite Fixes comment https://github.com/jasp-stats/jasp-test-release/issues/416#issuecomment-591899068


@ECHO OFF

IF "%MAVEN_OPTS%" == "" (
    ECHO The environment variable 'MAVEN_OPTS' is not set, setting it for you

    SET springloadedfile=%HOME%\.m2\repository\org\springframework\springloaded\1.2.5.RELEASE\springloaded-1.2.5.RELEASE.jar

    if not exist %springloadedfile% (
      mvn validate -Psetup
    )

    :: Spring loaded can be used with the Share AMP project in 5.1
    :: (i.e. it does not have the same problem as Repo AMP and AIO)
    SET MAVEN_OPTS=-javaagent:"%springloadedfile%" -noverify
)
ECHO MAVEN_OPTS is set to '%MAVEN_OPTS%'
mvn clean install -Pamp-to-war

@ECHO OFF

mvn clean install -Pamp-to-war

Fix for share-amp/run.bat

Fix for share-amp/run.bat


@ECHO OFF

if not "%1" == "" goto continue
for %%i in (imaginary) do for %%j in (yca\%%i\*.yca) do call %0 %%j
goto end

:continue
echo Processing %1
firstify %1 -himlv > %1.txt 2>&1

:end

@ECHO OFF
if "%1" == "goto" shift && goto continue

REM If they enter nothing, do all the benchmarks
set def=imaginary,spectral,real
if not "%1" == "" set def=%1
for %%i in (%def%) do for %%j in (yca\%%i\*.yca) do call %0 goto %%j
goto end

:continue
echo Processing %1
firstify %1 -himlv > %1.txt 2>&1

:end

Add support for specifying what benchmark suite you want to run


@echo off
rem Batch script for running the test suite.
rem Requires the python package `nose` to be installed.
set nosetests=call python -W ignore::DeprecationWarning -m nose

%nosetests% ^
tests/test_provided_code.py ^
tests/test_1_parsing.py ^
tests/test_2_evaluating_simple_expressions.py ^
tests/test_3_evaluating_complex_expressions.py ^
tests/test_4_working_with_variables_and_environments.py ^
tests/test_5_adding_functions_to_the_mix.py ^
tests/test_6_working_with_lists.py ^
tests/test_7_using_the_language.py ^
tests/test_8_final_touches.py ^
tests/test_sanity_checks.py ^
--stop

Create basic run-tests for Windows.

Create basic run-tests for Windows.


java -jar moco-runner-0.9.2-standalone.jar start -p 9000 -c config.json

add windows batch to start moco server

add windows batch to start moco server