@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"
$env:GO111MODULE="on"
Write-Verbose -Message "$ set GO111MODULE=$env:GO111MODULE"

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,[string]$target=$null) {
    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
    if ($target -eq $null) {
        $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 (Join-Path "." ([System.IO.Path]::GetFileName($target)))
    }
    $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
    }
    "linux" {
        $private:os = $env:GOOS
        $private:arch = $env:GOARCH
        $env:GOOS="linux"
        $env:GOARCH="amd64"
        Build -target ".\amd64\nyagos" (Get-Content Misc\version.txt) ""
        $env:GOOS = $os
        $env:GOARCH=$arch
    }
    "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" {
        & $GO get -u
    }
    "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"
$env:GO111MODULE="on"
Write-Verbose -Message "$ set GO111MODULE=$env:GO111MODULE"

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,[string]$target="") {
    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
    if ($target -eq "") {
        $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 (Join-Path "." ([System.IO.Path]::GetFileName($target)))
    }
    $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
    }
    "linux" {
        $private:os = $env:GOOS
        $private:arch = $env:GOARCH
        $env:GOOS="linux"
        $env:GOARCH="amd64"
        Build -target ".\amd64\nyagos" (Get-Content Misc\version.txt) ""
        $env:GOOS = $os
        $env:GOARCH=$arch
    }
    "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" {
        & $GO get -u
    }
    "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:

fix broken making windows-executable

make.cmd: fix broken making windows-executable


@ECHO OFF
REM --------------------------------------------------------
REM make.bat -- builds all the sources into one header file
REM
REM Copyright (C) 2014 Karim Alibhai.
REM --------------------------------------------------------

IF "%1" == "doc" (GOTO :DOC)
IF "%1" == "update" (GOTO :UPDATE)
IF "%1" == "test" (GOTO :TEST)

ECHO.Compiling headers ...
ECHO.#ifndef _LIBVEX_H>libvex.h
ECHO.#define _LIBVEX_H>>libvex.h
FOR /F "tokens=*" %%F in ('dir /b include\*.h') DO TYPE include\%%F >>libvex.h
ECHO.#endif>>libvex.h

ECHO.Compiling source ...
ECHO.#include "libvex.h">libvex.c
ECHO.#ifdef _LIBVEX_H>>libvex.c
FOR /F "tokens=*" %%F in ('dir /b src\*.c') DO TYPE src\%%F >>libvex.c
ECHO.#endif>>libvex.c

GOTO :EOF

:TEST
ECHO.Compiling headers ...
ECHO.#ifndef _LIBVEX_H>libvex.h
ECHO.#define _LIBVEX_H>>libvex.h
ECHO.#define __TEST_LV__>>libvex.h
ECHO.#include "test.h">>libvex.h
FOR /F "tokens=*" %%F in ('dir /b include\*.h') DO TYPE include\%%F >>libvex.h
ECHO.#endif>>libvex.h

ECHO.Compiling source ...
ECHO.#include "libvex.h">libvex.c
ECHO.#ifdef _LIBVEX_H>>libvex.c
FOR /F "tokens=*" %%F in ('dir /b src\*.c') DO TYPE src\%%F >>libvex.c
ECHO.#endif>>libvex.c
GOTO :EOF

:DOC
doxygen
GOTO :EOF

:UPDATE
git pull origin master
GOTO :EOF

@ECHO OFF
REM --------------------------------------------------------
REM make.bat -- builds all the sources into one header file
REM
REM Copyright (C) 2014 Karim Alibhai.
REM --------------------------------------------------------

IF "%1" == "doc" (GOTO :DOC)
IF "%1" == "update" (GOTO :UPDATE)
IF "%1" == "test" (GOTO :TEST)

ECHO.Compiling headers ...
ECHO.#ifndef _LIBVEX_H>libvex.h
ECHO.#define _LIBVEX_H>>libvex.h
FOR /F "tokens=*" %%F in ('dir /b include\*.h') DO TYPE include\%%F >>libvex.h
ECHO.#endif>>libvex.h

ECHO.Compiling source ...
ECHO.#include "libvex.h">libvex.c
ECHO.#ifdef _LIBVEX_H>>libvex.c
FOR /F "tokens=*" %%F in ('dir /b src\*.c') DO TYPE src\%%F >>libvex.c
ECHO.#endif>>libvex.c

GOTO :EOF

:TEST
ECHO.Compiling headers ...
ECHO.#ifndef _LIBVEX_H>test\libvex.h
ECHO.#define _LIBVEX_H>>test\libvex.h
ECHO.#define __TEST_LV__>>test\libvex.h
ECHO.#include "test.h">>test\libvex.h
FOR /F "tokens=*" %%F in ('dir /b include\*.h') DO TYPE include\%%F >>test\libvex.h
ECHO.#endif>>test\libvex.h
ECHO.Compiling source ...
ECHO.#include "libvex.h">test\libvex.c
ECHO.#ifdef _LIBVEX_H>>test\libvex.c
FOR /F "tokens=*" %%F in ('dir /b src\*.c') DO TYPE src\%%F >>test\libvex.c
ECHO.#endif>>test\libvex.c
ECHO.Compiling object files ...
gcc -Itest -c test/libvex.c -o test/libvex.o -Wall
GOTO :EOF

:DOC
doxygen
GOTO :EOF

:UPDATE
git pull origin master
GOTO :EOF

fix testing procedure on windows

fix testing procedure on windows


@ECHO OFF

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
	set SPHINXBUILD=sphinx-build
)

set THIS_DIR=%cd%
set GH_PAGES=\windows\temp

set BUILDDIR=_build
set ALLSPHINXOPTS=-W -d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)

if "%1" == "" goto help

if "%1" == "help" (
	:help
	echo.Please use `make ^<target^>` where ^<target^> is one of
	echo.  html       to make standalone HTML files
	echo.  dirhtml    to make HTML files named index.html in directories
	echo.  singlehtml to make a single large HTML file
	echo.  pickle     to make pickle files
	echo.  json       to make JSON files
	echo.  htmlhelp   to make HTML files and a HTML help project
	echo.  qthelp     to make HTML files and a qthelp project
	echo.  devhelp    to make HTML files and a Devhelp project
	echo.  epub       to make an epub
	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
	echo.  text       to make text files
	echo.  man        to make manual pages
	echo.  texinfo    to make Texinfo files
	echo.  gettext    to make PO message catalogs
	echo.  changes    to make an overview over all changed/added/deprecated items
	echo.  linkcheck  to check all external links for integrity
	echo.  doctest    to run all doctests embedded in the documentation if enabled
	goto end
)

if "%1" == "clean" (
	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
	del /q /s %BUILDDIR%\*
	goto end
)

if "%1" == "html" (
	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
	goto end
)

if "%1" == "dirhtml" (
	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
	goto end
)

if "%1" == "singlehtml" (
	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
	goto end
)

if "%1" == "pickle" (
	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can process the pickle files.
	goto end
)

if "%1" == "json" (
	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can process the JSON files.
	goto end
)

if "%1" == "htmlhelp" (
	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
	goto end
)

if "%1" == "qthelp" (
	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pycswWorkshop.qhcp
	echo.To view the help file:
	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pycswWorkshop.ghc
	goto end
)

if "%1" == "devhelp" (
	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished.
	goto end
)

if "%1" == "epub" (
	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The epub file is in %BUILDDIR%/epub.
	goto end
)

if "%1" == "latex" (
	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
	goto end
)

if "%1" == "text" (
	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The text files are in %BUILDDIR%/text.
	goto end
)

if "%1" == "man" (
	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The manual pages are in %BUILDDIR%/man.
	goto end
)

if "%1" == "texinfo" (
	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
	goto end
)

if "%1" == "gettext" (
	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
	goto end
)

if "%1" == "changes" (
	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
	if errorlevel 1 exit /b 1
	echo.
	echo.The overview file is in %BUILDDIR%/changes.
	goto end
)

if "%1" == "linkcheck" (
	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
	if errorlevel 1 exit /b 1
	echo.
	echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
	goto end
)

if "%1" == "doctest" (
	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
	if errorlevel 1 exit /b 1
	echo.
	echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
	goto end
)

if "%1" == "pdf" (
	%SPHINXBUILD -W -b pdf . %BUILDDIR%/html
	if errorlevel 1 exit /b 1
	goto end
)

if "%1" == "gh-pages" (
	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
	del /q /s %BUILDDIR%\*
	%SPHINXBUILD -W -b pdf . %BUILDDIR%/html
        %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
        if errorlevel 1 exit /b 1
	git clone git@github.com:geopython/pycsw-workshop.git %GH_PAGES%
	cd %GH_PAGES%
	git checkout gh-pages
	xcopy %THIS_DIR%/%BUILDDIR%/html/ %GH_PAGES% /E /Y
	cd %GH_PAGES%
	git add .
	git commit -am "Update live docs"
	git push origin gh-pages
	if errorlevel 1 exit /b 1
	goto end
)
:end

@ECHO OFF

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
	set SPHINXBUILD=sphinx-build
)

set THIS_DIR=%cd%
set GH_PAGES=\windows\temp

set BUILDDIR=_build
set ALLSPHINXOPTS=-W -d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)

if "%1" == "" goto help

if "%1" == "help" (
	:help
	echo.Please use `make ^<target^>` where ^<target^> is one of
	echo.  html       to make standalone HTML files
	echo.  dirhtml    to make HTML files named index.html in directories
	echo.  singlehtml to make a single large HTML file
	echo.  pickle     to make pickle files
	echo.  json       to make JSON files
	echo.  htmlhelp   to make HTML files and a HTML help project
	echo.  qthelp     to make HTML files and a qthelp project
	echo.  devhelp    to make HTML files and a Devhelp project
	echo.  epub       to make an epub
	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
	echo.  text       to make text files
	echo.  man        to make manual pages
	echo.  texinfo    to make Texinfo files
	echo.  gettext    to make PO message catalogs
	echo.  changes    to make an overview over all changed/added/deprecated items
	echo.  linkcheck  to check all external links for integrity
	echo.  doctest    to run all doctests embedded in the documentation if enabled
	goto end
)

if "%1" == "clean" (
	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
	del /q /s %BUILDDIR%\*
	goto end
)

if "%1" == "html" (
	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
	goto end
)

if "%1" == "dirhtml" (
	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
	goto end
)

if "%1" == "singlehtml" (
	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
	goto end
)

if "%1" == "pickle" (
	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can process the pickle files.
	goto end
)

if "%1" == "json" (
	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can process the JSON files.
	goto end
)

if "%1" == "htmlhelp" (
	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
	goto end
)

if "%1" == "qthelp" (
	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pycswWorkshop.qhcp
	echo.To view the help file:
	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pycswWorkshop.ghc
	goto end
)

if "%1" == "devhelp" (
	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished.
	goto end
)

if "%1" == "epub" (
	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The epub file is in %BUILDDIR%/epub.
	goto end
)

if "%1" == "latex" (
	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
	goto end
)

if "%1" == "text" (
	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The text files are in %BUILDDIR%/text.
	goto end
)

if "%1" == "man" (
	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The manual pages are in %BUILDDIR%/man.
	goto end
)

if "%1" == "texinfo" (
	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
	goto end
)

if "%1" == "gettext" (
	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
	if errorlevel 1 exit /b 1
	echo.
	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
	goto end
)

if "%1" == "changes" (
	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
	if errorlevel 1 exit /b 1
	echo.
	echo.The overview file is in %BUILDDIR%/changes.
	goto end
)

if "%1" == "linkcheck" (
	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
	if errorlevel 1 exit /b 1
	echo.
	echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
	goto end
)

if "%1" == "doctest" (
	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
	if errorlevel 1 exit /b 1
	echo.
	echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
	goto end
)

if "%1" == "pdf" (
	%SPHINXBUILD -W -b pdf . %BUILDDIR%/html
	if errorlevel 1 exit /b 1
	goto end
)

if "%1" == "gh-pages" (
	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
	del /q /s %BUILDDIR%\*
	%SPHINXBUILD -W -b pdf . %BUILDDIR%/html
        %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
        if errorlevel 1 exit /b 1
	git clone git@github.com:geopython/pycsw-workshop.git %GH_PAGES%
	cd %GH_PAGES%
	git checkout gh-pages
	xcopy %THIS_DIR%/%BUILDDIR%/html/ %GH_PAGES% /E /Y
	cd %GH_PAGES%
	git add .
	git commit -am "Update live docs"
	REM git push origin gh-pages
	if errorlevel 1 exit /b 1
	goto end
)
:end

Update live docs

Update live docs


Make file

Make file


@echo off

:: check if we have the .iso file (if we don't have it, the VM won't start!)
if not exist %HOME%\.boot2docker\boot2docker.iso (
  echo boot2docker.iso not found in %HOME%\.boot2docker\, downloading it...
  boot2docker download
)

:: check if "boot2docker-vm" exists already
for /f "usebackq tokens=*" %%l in (`VBoxManage list --long vms`) do (
  if "%%l" == "Name:            boot2docker-vm" (
    echo Found existing boot2docker-vm in VirtualBox!
    goto check
  )
)

:init
echo No existing boot2docker-vm found in VirtualBox, initializing...
boot2docker init

:check
:: check if boot2docker is running
for /f "usebackq tokens=*" %%s in (`boot2docker status`) do (
  if %%s == running (
    echo The boot2docker VM is already running, doing nothing
    goto end
  )
)

SETLOCAL

:: make sure we are stopped
echo Making sure the boot2docker VM is stopped...
boot2docker halt

:: check for existence of BK_ROOT env var
if "%BK_ROOT%" == "" (
  echo BK_ROOT env var not set, please make sure to run `set-env.bat` before! Exiting...
  exit /b 1
)

:: replace backward with forward slashes
set BK_ROOT_FWD_SLASH=%BK_ROOT:\=/%
:: convert drive letter to cygwin style (try c, d, e, w)
set BK_ROOT_DRIVE=%BK_ROOT_FWD_SLASH:C:/=/c/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:D:/=/d/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:E:/=/e/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:W:/=/w/%
:: okay, here we go
set BK_ROOT_CYGPATH=%BK_ROOT_DRIVE%

:: add the drive while the VM is still down
echo Adding shared folder "billskitchen" for hostpath %BK_ROOT%
VBoxManage sharedfolder add "boot2docker-vm" --name "billskitchen" --hostpath %BK_ROOT%

:: echo the config for debugging
boot2docker config

:: bring it up
echo Bringing up the boot2docker VM...
boot2docker up --memory=512 --verbose=true

:: mount drive inside vbox
echo Mounting the shared folder inside the VM to %BK_ROOT_CYGPATH%
boot2docker ssh -- sudo mkdir -p %BK_ROOT_CYGPATH%
boot2docker ssh -- sudo mount -t vboxsf billskitchen %BK_ROOT_CYGPATH%

:: set / unset proxy in boot2docker VM
:: for more on proxies, see http://stackoverflow.com/a/29303930/2388971
if "%BK_USE_PROXY%" == "1" (
  echo setting proxy in the boot2docker VM...
  boot2docker ssh "echo 'export HTTP_PROXY=%HTTP_PROXY%; export HTTPS_PROXY=%HTTPS_PROXY%; export NO_PROXY=%NO_PROXY%;' | sudo tee /var/lib/boot2docker/profile"
) else (
  echo making sure no proxy is set in the boot2docker VM...
  boot2docker ssh "sudo rm -rf /var/lib/boot2docker/profile"
)
boot2docker ssh "sudo /etc/init.d/docker restart > /dev/null"
boot2docker ssh "sudo /etc/init.d/docker status"

ENDLOCAL

:end

@echo off

:: check if we have the .iso file (if we don't have it, the VM won't start!)
if not exist %HOME%\.boot2docker\boot2docker.iso (
  echo boot2docker.iso not found in %HOME%\.boot2docker\, downloading it...
  boot2docker download
)

:: check if "boot2docker-vm" exists already
for /f "usebackq tokens=*" %%l in (`VBoxManage list --long vms`) do (
  if "%%l" == "Name:            boot2docker-vm" (
    echo Found existing boot2docker-vm in VirtualBox!
    goto check
  )
)

:init
echo No existing boot2docker-vm found in VirtualBox, initializing...
boot2docker init

:check
:: check if boot2docker is running
for /f "usebackq tokens=*" %%s in (`boot2docker status`) do (
  if %%s == running (
    echo The boot2docker VM is already running, doing nothing
    goto end
  )
)

SETLOCAL

:: make sure we are stopped
echo Making sure the boot2docker VM is stopped...
boot2docker halt

:: check for existence of BK_ROOT env var
if "%BK_ROOT%" == "" (
  echo BK_ROOT env var not set, please make sure to run `set-env.bat` before! Exiting...
  exit /b 1
)

:: replace backward with forward slashes
set BK_ROOT_FWD_SLASH=%BK_ROOT:\=/%
:: convert drive letter to cygwin style (try c, d, e, w)
set BK_ROOT_DRIVE=%BK_ROOT_FWD_SLASH:C:/=/c/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:D:/=/d/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:E:/=/e/%
set BK_ROOT_DRIVE=%BK_ROOT_DRIVE:W:/=/w/%
:: okay, here we go
set BK_ROOT_CYGPATH=%BK_ROOT_DRIVE%

:: add the drive while the VM is still down
echo Adding shared folder "billskitchen" for hostpath %BK_ROOT%
VBoxManage sharedfolder add "boot2docker-vm" --name "billskitchen" --hostpath %BK_ROOT%

:: echo the config for debugging
boot2docker config

:: bring it up
echo Bringing up the boot2docker VM...
boot2docker up --memory=512 --verbose=true

:: mount drive inside vbox
echo Mounting the shared folder inside the VM to %BK_ROOT_CYGPATH%
boot2docker ssh -- sudo mkdir -p %BK_ROOT_CYGPATH%
boot2docker ssh -- sudo mount -t vboxsf billskitchen %BK_ROOT_CYGPATH%

:: set / unset proxy in boot2docker VM
:: for more on proxies, see http://stackoverflow.com/a/29303930/2388971
if "%BK_USE_PROXY%" == "1" (
  echo setting proxy in the boot2docker VM...
  boot2docker ssh "echo 'export HTTP_PROXY=%HTTP_PROXY%; export HTTPS_PROXY=%HTTPS_PROXY%; export NO_PROXY=%NO_PROXY%;' | sudo tee /var/lib/boot2docker/profile"
) else (
  echo making sure no proxy is set in the boot2docker VM...
  boot2docker ssh "sudo rm -rf /var/lib/boot2docker/profile"
)
boot2docker ssh "sudo /etc/init.d/docker restart > /dev/null"
boot2docker ssh "sudo /etc/init.d/docker status"

ENDLOCAL

:: update the DOCKER_HOST as the ip address might change
for /f "usebackq tokens=*" %%s in (`boot2docker ip`) do set b2d_ip=%%s
echo updating DOCKER_HOST env var to "tcp://%b2d_ip%:2376"...
set DOCKER_HOST=tcp://%b2d_ip%:2376

:end

update the DOCKER_HOST env var in `b2d-start` as the ip address might change


@echo off

rem for /l %%a in (1,1,100) do (
set /p var=:
git add *
git commit -m %var%_%date:~0,10%
git push origin master
pause
rem )

@echo off

rem for /l %%a in (1,1,100) do (
set /p var=:
git add *
git commit -m "%var%_%date:~0,10%"
git push origin master
pause
rem )

test space_2017/06/05

test space_2017/06/05


@nuget.exe push *.nupkg -Source https://www.nuget.org/api/v2/package

add push.bat

add push.bat


@echo off
@echo Salt Windows Build Script, which calls the other *.ps1 scripts.
@echo ---------------------------------------------------------------------
@echo.
:: This script builds salt on any machine. It uses the following scripts:
:: - build_env.ps1: Sets up a Python environment will all dependencies salt will
::                  will require
:: - build_pkg.bat: Bundles the contents of the Python directory into a
::                  nullsoft installer binary

:: The script first calls the `build_env.ps1` script to set up a python
:: environment. Then it installs Salt into that python environment using Salt's
:: `setup.py install` command. Finally, it runs the `build_pkg.bat` to create
:: a NullSoft installer in the `installer` directory (pkg\windows\installer)

:: This script accepts two parameters.
::   Version: The version of Salt being built. If not passed, the version will
::            determined using `git describe`
::   Python: The version of Python to build Salt on (Default is 3)

:: These parameters can be passed positionally or as named parameters. Named
:: parameters must be wrapped in quotes.

:: Examples:
::   # To build Salt 3000.3 on Python 3
::   build.bat 3000.3
::   build.bat 3000.3 3

::   # Using named parameters
::   build.bat "Version=3000.3"
::   build.bat "Version=3000.3" "Python=3"

::  # Using a mix
::   build.bat 3000.3 "Python=3"

:: To activate caching, set environment variables
::   SALTREPO_LOCAL_CACHE  for resources from saltstack.com/...
::   SALT_REQ_LOCAL_CACHE  for pip resources specified in req.txt
::   SALT_PIP_LOCAL_CACHE  for pip resources specified in req_pip.txt

:: Make sure the script is run as Admin
@echo Administrative permissions required. Detecting permissions...
@echo ---------------------------------------------------------------------
net session >nul 2>&1
if %errorLevel%==0 (
    echo ...Success: Administrative permissions confirmed.
) else (
    echo ...Failure: This script must be run as Administrator
    goto eof
)
@echo =====================================================================
@echo.

@echo Git required. Detecting git...
@echo ---------------------------------------------------------------------
where git >nul 2>&1
if %errorLevel%==0 (
    echo ...Success: Git found.
) else (
    echo ...Failure: This script needs to call git
    goto eof
)
@echo =====================================================================
@echo.

:: Get Passed Parameters
@echo %0 :: Get Passed Parameters...
@echo ---------------------------------------------------------------------

set "Version="
set "Python="
:: First Parameter
if not "%~1"=="" (
    echo.%1 | FIND /I "=" > nul && (
        :: Named Parameter
        echo Named Parameter
        set "%~1"
    ) || (
        :: Positional Parameter
        echo Positional Parameter
        set "Version=%~1"
    )
)

:: Second Parameter
if not "%~2"=="" (
    echo.%2 | FIND /I "=" > nul && (
        :: Named Parameter
        set "%~2"
    ) || (
        :: Positional Parameter
        set "Python=%~2"
    )
)

:: If Version not defined, Get the version from Git
if "%Version%"=="" (
    for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
)

:: If Python not defined, Assume Python 3
if "%Python%"=="" (
    set Python=3
)

:: Verify valid Python value (3)
:: We may need to add Python 4 in the future (delims=34)
set "x="
for /f "delims=3" %%i in ("%Python%") do set x=%%i
if Defined x (
    echo Invalid Python Version specified. Must be 3. Passed %Python%
    goto eof
)

@echo =====================================================================
@echo.

:: Define Variables
@echo %0 :: Defining Variables...
@echo ---------------------------------------------------------------------
if %Python%==3 (
    Set "PyDir=C:\Python37"
) else (
    :: Placeholder for future version
    :: Set "PyDir=C:\Python4"
)
Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"

Set "CurDir=%~dp0"
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"

@echo =====================================================================
@echo.

:: Create Build Environment
@echo %0 :: Create the Build Environment...
@echo ---------------------------------------------------------------------
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent

if not %errorLevel%==0 (
    echo "%CurDir%build_env.ps1" returned errorlevel %errorLevel%. Aborting %0
    goto eof
)
@echo.

:: Remove build and dist directories
@echo %0 :: Remove build and dist directories...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" clean --all
if not %errorLevel%==0 (
    goto eof
)
If Exist "%SrcDir%\dist" (
    @echo removing %SrcDir%\dist
    rd /S /Q "%SrcDir%\dist"
)
@echo.

:: Install Current Version of salt
@echo %0 :: Install Current Version of salt...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" --quiet install --force
if not %errorLevel%==0 (
    goto eof
)
@echo.

:: Build the Salt Package
@echo %0 :: Build the Salt Package...
@echo ---------------------------------------------------------------------
call "%CurDir%build_pkg.bat" "%Version%" "%Python%"
@echo.

:eof
@echo.
@echo =====================================================================
@echo End of %0
@echo =====================================================================

@echo off
@echo Salt Windows Build Script, which calls the other *.ps1 scripts.
@echo ---------------------------------------------------------------------
@echo.
:: This script builds salt on any machine. It uses the following scripts:
:: - build_env.ps1: Sets up a Python environment will all dependencies salt will
::                  will require
:: - build_pkg.bat: Bundles the contents of the Python directory into a
::                  nullsoft installer binary

:: The script first calls the `build_env.ps1` script to set up a python
:: environment. Then it installs Salt into that python environment using Salt's
:: `setup.py install` command. Finally, it runs the `build_pkg.bat` to create
:: a NullSoft installer in the `installer` directory (pkg\windows\installer)

:: This script accepts two parameters.
::   Version: The version of Salt being built. If not passed, the version will
::            determined using `git describe`. The leading `v` will be removed
::   Python: The version of Python to build Salt on (Default is 3)

:: These parameters can be passed positionally or as named parameters. Named
:: parameters must be wrapped in quotes.

:: Examples:
::   # To build Salt 3000.3 on Python 3
::   build.bat 3000.3
::   build.bat 3000.3 3

::   # Using named parameters
::   build.bat "Version=3000.3"
::   build.bat "Version=3000.3" "Python=3"

::  # Using a mix
::   build.bat 3000.3 "Python=3"

:: To activate caching, set environment variables
::   SALTREPO_LOCAL_CACHE  for resources from saltstack.com/...
::   SALT_REQ_LOCAL_CACHE  for pip resources specified in req.txt
::   SALT_PIP_LOCAL_CACHE  for pip resources specified in req_pip.txt

:: Make sure the script is run as Admin
@echo Administrative permissions required. Detecting permissions...
@echo ---------------------------------------------------------------------
net session >nul 2>&1
if %errorLevel%==0 (
    echo ...Success: Administrative permissions confirmed.
) else (
    echo ...Failure: This script must be run as Administrator
    goto eof
)
@echo =====================================================================
@echo.

@echo Git required. Detecting git...
@echo ---------------------------------------------------------------------
where git >nul 2>&1
if %errorLevel%==0 (
    echo ...Success: Git found.
) else (
    echo ...Failure: This script needs to call git
    goto eof
)
@echo =====================================================================
@echo.

:: Get Passed Parameters
@echo %0 :: Get Passed Parameters...
@echo ---------------------------------------------------------------------

set "Version="
set "Python="
:: First Parameter
if not "%~1"=="" (
    echo.%1 | FIND /I "=" > nul && (
        :: Named Parameter
        echo Named Parameter
        set "%~1"
    ) || (
        :: Positional Parameter
        echo Positional Parameter
        set "Version=%~1"
    )
)

:: Second Parameter
if not "%~2"=="" (
    echo.%2 | FIND /I "=" > nul && (
        :: Named Parameter
        set "%~2"
    ) || (
        :: Positional Parameter
        set "Python=%~2"
    )
)

:: If Version not defined, Get the version from Git
set git=0
if "%Version%"=="" (
    echo Getting version from git
    for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
    set git=1
)
:: Strip off the leading `v` when getting version from git describe
if %git%==1 set Version=%Version:~1%

:: If Python not defined, Assume Python 3
if "%Python%"=="" (
    set Python=3
)

:: Verify valid Python value (3)
:: We may need to add Python 4 in the future (delims=34)
set "x="
for /f "delims=3" %%i in ("%Python%") do set x=%%i
if Defined x (
    echo Invalid Python Version specified. Must be 3. Passed %Python%
    goto eof
)

@echo =====================================================================
@echo.

:: Define Variables
@echo %0 :: Defining Variables...
@echo ---------------------------------------------------------------------
if %Python%==3 (
    Set "PyDir=C:\Python37"
) else (
    :: Placeholder for future version
    :: Set "PyDir=C:\Python4"
)
Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"

Set "CurDir=%~dp0"
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"

@echo =====================================================================
@echo.

:: Create Build Environment
@echo %0 :: Create the Build Environment...
@echo ---------------------------------------------------------------------
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent

if not %errorLevel%==0 (
    echo "%CurDir%build_env.ps1" returned errorlevel %errorLevel%. Aborting %0
    goto eof
)
@echo.

:: Remove build and dist directories
@echo %0 :: Remove build and dist directories...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" clean --all
if not %errorLevel%==0 (
    goto eof
)
If Exist "%SrcDir%\dist" (
    @echo removing %SrcDir%\dist
    rd /S /Q "%SrcDir%\dist"
)
@echo.

:: Install Current Version of salt
@echo %0 :: Install Current Version of salt...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" --quiet install --force
if not %errorLevel%==0 (
    goto eof
)
@echo.

:: Build the Salt Package
@echo %0 :: Build the Salt Package...
@echo ---------------------------------------------------------------------
call "%CurDir%build_pkg.bat" "%Version%" "%Python%"
@echo.

:eof
@echo.
@echo =====================================================================
@echo End of %0
@echo =====================================================================

Remove leading 'v' from git describe

Remove leading 'v' from git describe


@echo off

set COUNT=0

set STARTDIR=%CD%\
set BATDIR=%~dp0
cd /D %BATDIR%

for /f "tokens=*" %%a in (
'forfiles /P %BATDIR% /M burpsuite_*.jar /C "cmd /c echo @fname" ^| find /C "burpsuite"'
) do (
set COUNT=%%a
)

if %COUNT%==1 goto ONE
if %COUNT% gtr 1 goto MANY
goto NONE

:ONE
for %%X in (burpsuite_*.jar) do set BURP_PACKAGE=%%X
goto EXECBURP

:MANY
for %%X in (burpsuite_*.jar) do (
	choice /C:ny /M "Found %COUNT% Burp packages; use %%X"
	if ERRORLEVEL 2 (
		set BURP_PACKAGE=%%X
		goto EXECBURP
	)
)
goto NONE

:NONE
echo ERROR: A necessary Burp Suite package could not be located, or was not selected; download from http://portswigger.net/burp/download.html, or view README file for more instructions.
cd /D %STARTDIR%
pause
goto EOF

:EXECBURP
echo Initializing Burp with package %BURP_PACKAGE%...
java -Xmx1024m -classpath %BURP_PACKAGE%;lib\BurpExtender.jar;lib\sqlitejdbc-v056.jar -Dpython.path=%CD%;%CD%\lib;%CD%\hiccup;%CD%\plugins burp.StartBurp
goto EOF

:EOF
cd %STARTDIR%
exit /B

@echo off

set COUNT=0

set STARTDIR=%CD%\
set BATDIR=%~dps0
cd /D %BATDIR%

for /f "tokens=*" %%a in (
'forfiles /P %BATDIR% /M burpsuite_*.jar /C "cmd /c echo @fname" ^| find /C "burpsuite"'
) do (
set COUNT=%%a
)

if %COUNT%==1 goto ONE
if %COUNT% gtr 1 goto MANY
goto NONE

:ONE
for %%X in (burpsuite_*.jar) do set BURP_PACKAGE=%%X
goto EXECBURP

:MANY
for %%X in (burpsuite_*.jar) do (
	choice /C:ny /M "Found %COUNT% Burp packages; use %%X"
	if ERRORLEVEL 2 (
		set BURP_PACKAGE=%%X
		goto EXECBURP
	)
)
goto NONE

:NONE
echo ERROR: A necessary Burp Suite package could not be located, or was not selected; download from http://portswigger.net/burp/download.html, or view README file for more instructions.
cd /D %STARTDIR%
pause
goto EOF

:EXECBURP
echo Initializing Burp with package %BURP_PACKAGE%...
java -Xmx1024m -classpath %BURP_PACKAGE%;lib\BurpExtender.jar;lib\sqlitejdbc-v056.jar -Dpython.path=%CD%;%CD%\lib;%CD%\hiccup;%CD%\plugins burp.StartBurp
goto EOF

:EOF
cd %STARTDIR%
exit /B

fix for launching from directories with spaces - https://github.com/zynga/hiccup/issues/1


::mvndelete

@echo off
setlocal enabledelayedexpansion

set artifact=%~1
set "gapv=!artifact::= !"

:: g/a/v
if "!gapv!" equ "!artifact!" goto :gav

:gapv
for %%e in (!gapv!) do (
	if defined version goto :error
	if defined packaing if not defined version set version=%%e
	if defined artifactId if not defined version set packaing=%%e
	if defined groupId if not defined artifactId set artifactId=%%e
	if not defined groupId set groupId=%%e
)
goto :delete

:gav
set "gav=!artifact:/= !"
if "!gav!" equ "!gav!" goto :error
for %%e in (!artifact!) do (
	if defined version goto :error
	if defined artifactId if not defined version set version=%%e
	if defined groupId if not defined artifactId set artifactId=%%e
	if not defined groupId set groupId=%%e
)
goto :delete

:delete
pushd %TEMP%
if exist pom.xml del /f pom.xml
for /f "usebackq delims=" %%l in (`mvn help:evaluate -Dexpression^=settings.localRepository`) do (
	set line6=%%l
	set line6=!line6:~0,6!
	if "!line6!" neq "[INFO]" set localRepository=%%l
)
popd
set "target=!localRepository!\!groupId:.=\!\!artifactId!\!version!"
rmdir /s !target!
if exist "!target!" echo folder cannot be removed.
goto :eof

:error
echo invalid format, must be one of :
echo groupId:artifactId:packaing:version
echo groupId/artifactId/version

:exit
endlocal

add mvndelete.bat

add mvndelete.bat


cd ..
set "destination=testcoverage"

rmdir /q /s %destination%
mkdir %destination%
cd content/tests
dotnet test /p:AltCover=true
mv coverage.xml ../../%destination%/coverage.xml

cd ../../%destination%

set "reportgenerator=%UserProfile%\.nuget\packages\reportgenerator\4.0.7\tools\net47\ReportGenerator.exe"
set "targetdir=."

"%reportGenerator%" -reports:coverage.xml -reporttypes:HtmlInline -targetdir:%targetdir%

cd ..
set "destination=testcoverage"

rmdir /q /s %destination%
mkdir %destination%
cd content/tests
dotnet test /p:AltCover=true
mv coverage.xml ../../%destination%/coverage.xml

cd ../../%destination%

set "reportgenerator=%UserProfile%\.nuget\packages\reportgenerator\4.0.11\tools\net47\ReportGenerator.exe"
set "targetdir=."

"%reportGenerator%" -reports:coverage.xml -reporttypes:HtmlInline -targetdir:%targetdir%

Update to tools for reportgenerator

Update to tools for reportgenerator


@echo off

REM Emacs
XCOPY /Y /Q emacs\.emacs "%APPDATA%\.emacs"

REM nano
XCOPY /Y /Q nano\.nanorc "%USERPROFILE%\.nanorc"

REM Vim
XCOPY /Y /Q vim\.vimrc "%USERPROFILE%\.vimrc"

REM bash
XCOPY /Y /Q bash\.bashrc "%USERPROFILE%\.bashrc"
XCOPY /Y /Q bash\.bash_aliases "%USERPROFILE%\.bash_aliases"

REM Sublime Text 3
MKDIR "%APPDATA%\Sublime Text 3\Packages\Custom Color Schemes\"
MKDIR "%APPDATA%\Sublime Text 3\Packages\User\"
XCOPY /Y /Q sublime\Preferences.sublime-settings "%APPDATA%\Sublime Text 3\Packages\User\"
XCOPY /Y /Q sublime\Default.sublime-keymap "%APPDATA%\Sublime Text 3\Packages\User\"
XCOPY /Y /Q sublime\jcd.tmTheme "%APPDATA%\Sublime Text 3\Packages\Custom Color Schemes\"

@echo off

REM Emacs
COPY /Y emacs\.emacs "%APPDATA%\.emacs"

REM nano
COPY /Y nano\.nanorc "%USERPROFILE%\.nanorc"

REM Vim
COPY /Y vim\.vimrc "%USERPROFILE%\.vimrc"

REM bash
COPY /Y bash\.bashrc "%USERPROFILE%\.bashrc"
COPY /Y bash\.bash_aliases "%USERPROFILE%\.bash_aliases"

REM Sublime Text 3
MKDIR "%APPDATA%\Sublime Text 3\Packages\Custom Color Schemes\"
MKDIR "%APPDATA%\Sublime Text 3\Packages\User\"
COPY /Y sublime\Preferences.sublime-settings "%APPDATA%\Sublime Text 3\Packages\User\"
COPY /Y sublime\Default.sublime-keymap "%APPDATA%\Sublime Text 3\Packages\User\"
COPY /Y sublime\jcd.tmTheme "%APPDATA%\Sublime Text 3\Packages\Custom Color Schemes\"

Replace XCOPY with COPY

Replace XCOPY with COPY


SETLOCAL

SET "K_APPBASE=%~dp0..\src\Omnisharp"
%USERPROFILE%\.k\packages\KRE-CLR-x86.1.0.0-beta3\bin\k run %*

SETLOCAL

SET "KRE_APPBASE=%~dp0..\src\Omnisharp"
%USERPROFILE%\.k\runtimes\kre-clr-win-x86.1.0.0-beta3\bin\k run %*

fix Omnisharp.cmd script for windows

fix Omnisharp.cmd script for windows


@ECHO OFF
call gradlew.bat clean build javadoc

@ECHO OFF
call gradlew clean build javadoc

Fix setupSE crashing on Unix machines

Fix setupSE crashing on Unix machines


@TITLE Building Mesa3D
@cd "%~dp0"
@cd ..\..\
@for %%I in ("%cd%") do @set mesa=%%~sI
@set mesa=%mesa%\
@where /q cmake.exe
@IF ERRORLEVEL 1 set PATH=%mesa%cmake\bin\;%PATH%
@set ERRORLEVEL=0
@where /q python.exe
@IF ERRORLEVEL 1 set PATH=%mesa%Python\;%mesa%Python\Scripts\;%PATH%
@set ERRORLEVEL=0
@set pyupd=y
@set pyfrstupd=1
@if EXIST pyupd.ini set /p pyfrstupd=<pyupd.ini
@if %pyfrstupd%==0 set pyupd=n
@if %pyfrstupd%==0 set /p pyupd=Install/update python modules (y/n):
@if "%pyupd%"=="y" (
@python -m pip install -U mako
@python -m pip freeze > requirements.txt
@python -m pip install -r requirements.txt --upgrade
@del requirements.txt
@echo.
@echo 0 > pyupd.ini
)
@set abi=x86
@set /p x64=Do you want to build for x64? (y/n) Otherwise build for x86:
@if /I "%x64%"=="y" set abi=x64
@set longabi=%abi%
@if %abi%==x64 set longabi=x86_64
@set altabi=i686
@if %abi%==x64 set altabi=%longabi%
@set minabi=32
@if %abi%==x64 set minabi=64
@set targetabi=x86
@if %abi%==x64 set targetabi=amd64
@set hostabi=x86
@set vsenv="%ProgramFiles%
@if NOT "%ProgramW6432%"=="" set hostabi=amd64
@set vsabi=%minabi%
@if NOT %targetabi%==%hostabi% set vsabi=%hostabi%_%targetabi%
@if NOT "%ProgramW6432%"=="" set vsenv=%vsenv% (x86)
@set vsenv15=%vsenv%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars%vsabi%.bat"
@if %vsabi%==32 set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\%vsabi%\vcvars%vsabi%.bat"
@if %vsabi%==64 set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\%targetabi%\vcvars%targetabi%.bat"
@if NOT %targetabi%==%hostabi% set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\%vsabi%\vcvars%vsabi%.bat"
@set gcc=%mesa%mingw-w64\%abi%\mingw%minabi%\bin
@set vsenvloaded=0
@set dxtnbuilt=0
@set toolset=14
@if EXIST %vsenv15% set toolset=15
@if EXIST toolset-%abi%.ini set /p toolset=<toolset-%abi%.ini
@set vsenv=%vsenv14%
@if %toolset%==15 set vsenv=%vsenv15%
@set PATH=%mesa%flexbison\;%PATH%
@TITLE Building Mesa3D %abi%

:build_llvm
@set /p buildllvm=Begin LLVM build. Only needs to run once for each ABI and version. Proceed (y/n):
@if /I NOT "%buildllvm%"=="y" GOTO build_dxtn
@echo.
@cd %mesa%llvm
@if EXIST %abi% RD /S /Q %abi%
@if EXIST cmake-%abi% RD /S /Q cmake-%abi%
@md cmake-%abi%
@cd cmake-%abi%
@set toolchain=Visual Studio 14
@set toolset=14
@if EXIST %vsenv15% set toolchain=Visual Studio 15 2017
@if EXIST %vsenv15% set toolset=15
@set ninja=n
@set oldtoolset=n
@set x64compiler= -Thost=x64
@if EXIST %mesa%ninja set ninja=1
@if EXIST %vsenv15% set ninja=%ninja%2
@if %ninja%==12 set /p oldtoolset=Build with MSVC 2015 backward compatibility toolset, alternative solution for LLVM 3.9.1 build with Visual Studio 2017 (y/n):
@if %ninja%==12 echo.
@if /I "%oldtoolset%"=="y" set ninja=y
@if /I "%oldtoolset%"=="y" set toolset=14
@if %ninja%==12 set ninja=2
@if %ninja%==1 set ninja=2
@if %ninja%==2 set /p ninja=Use Ninja build system instead of MsBuild, there is no requirement to do this with the primary toolset though (y/n):
@echo.
@if /I "%ninja%"=="y" set toolchain=Ninja
@if /I "%ninja%"=="y" set x64compiler=
@if "%toolchain%"=="Ninja" set PATH=%mesa%ninja\;%PATH%
@set vsenv=%vsenv14%
@if %toolset%==15 set vsenv=%vsenv15%
@set llvmbuildsys=%CD%
@call %vsenv%
@set vsenvloaded=1
@echo.
@set modtoolchainabi=0
@if NOT "%toolchain%"=="Ninja" set modtoolchainabi=1
@if %abi%==x64 set modtoolchainabi=%modtoolchainabi%2
@if %modtoolchainabi%==12 set toolchain=%toolchain% Win64
@cd %llvmbuildsys%
@if NOT %hostabi%==amd64 set x64compiler=
@cmake -G "%toolchain%"%x64compiler% -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../%abi% ..
@echo.
@pause
@echo.
@if NOT "%toolchain%"=="Ninja" cmake --build . --config Release --target install
@if "%toolchain%"=="Ninja" ninja install
@echo.
@echo %toolset% > %mesa%toolset-%abi%.ini

:build_dxtn
@if NOT EXIST %gcc% GOTO build_mesa
@if NOT EXIST %mesa%dxtn GOTO build_mesa
@set /p builddxtn=Do you want to build S3 texture compression library? (y/n):
@if /i NOT "%builddxtn%"=="y" GOTO build_mesa
@set PATH=%gcc%\;%PATH%
@cd %mesa%dxtn
@echo.
@if EXIST %abi% RD /S /Q %abi%
@MD %abi%
@set dxtn=gcc -shared -m%minabi% -v *.c *.h -I ..\mesa\include -Wl,--dll,--dynamicbase,--enable-auto-image-base,--nxcompat -o %abi%\dxtn.dll
@%dxtn%
@echo.
@set dxtnbuilt=1

:build_mesa
@set /p buildmesa=Begin mesa build. Proceed (y/n):
@if /i NOT "%buildmesa%"=="y" GOTO distcreate
@echo.
@set LLVM=%mesa%llvm\%abi%
@if NOT EXIST %LLVM% (
@echo Could not find LLVM, aborting mesa build.
@echo.
@pause
@GOTO exit
)
@cd %mesa%
@if NOT EXIST mesa echo Mesa3D source code not found. Attempting to download it using git as long as it is in PATH...
@if NOT EXIST mesa set /p branch=Enter Mesa source code branch name - defaults to master:
@if "%branch%"=="" set branch=master
@if NOT EXIST mesa echo.
@if NOT EXIST mesa git clone --depth=1 --branch=%branch% git://anongit.freedesktop.org/mesa/mesa mesa
@cd mesa
git apply -v ..\mesa-dist-win\patches\scons-llvm5.patch
git apply -v ..\mesa-dist-win\patches\s3tc.patch
@echo.
@set openswr=n
@set sconscmd=python %mesa%Python\Scripts\scons.py build=release platform=windows machine=%longabi% libgl-gdi
@set /p openswr=Do you want to build OpenSWR drivers? (y=yes):
@echo.
@if /I "%openswr%"=="y" set sconscmd=%sconscmd% swr=1
@set /p osmesa=Do you want to build off-screen rendering drivers (y/n):
@echo.
@if /I "%osmesa%"=="y" set sconscmd=%sconscmd% osmesa
@set /p graw=Do you want to build graw library (y/n):
@echo.
@if /I "%graw%"=="y" set sconscmd=%sconscmd% graw-gdi
@GOTO build_with_vs

:build_with_mingw
@set mingw=n
@set mingwtest=0
@if EXIST %gcc% set mingwtest=1
@set msys2=%mesa%msys64\msys2_shell.cmd
@if EXIST %msys2% set mingwtest=%mingwtest%2
@if %mingwtest%==12 set /p mingw=Do you want to build with MinGW-W64 instead of Visual Studio (y=yes):
@if %dxtnbuilt%==0 set PATH=%gcc%\;%PATH%
@if /I "%mingw%"=="y" set sconscmd=%sconscmd% toolchain=crossmingw
@if /I "%mingw%"=="y" copy %gcc%\%altabi%-w64-mingw32-gcc-ar.exe %gcc%\%altabi%-w64-mingw32-ar.exe
@if /I "%mingw%"=="y" copy %gcc%\%altabi%-w64-mingw32-gcc-ranlib.exe %gcc%\%altabi%-w64-mingw32-ranlib.exe
@if /I "%mingw%"=="y" call "%msys2%" -use-full-path
@if /I "%mingw%"=="y" (
pacman -Syu
pacman -S python2
wget https://bootstrap.pypa.io/get-pip.py
python2 get-pip.py
pip install -U mako
pip install -U scons
pip freeze > requirements.txt
pip install -r requirements.txt --upgrade
cd $mesa
cd mesa
GOTO build_mesa_exec
)

:build_with_vs
@set cleanbuild=n
@if EXIST build\windows-%longabi% set /p cleanbuild=Do you want to clean build (y/n):
@if EXIST build\windows-%longabi% echo.
@if /I "%cleanbuild%"=="y" RD /S /Q build\windows-%longabi%
@if %vsenvloaded%==0 (
@call %vsenv%
@cd %mesa%mesa
@echo.
)

:build_mesa_exec
@%sconscmd%
@echo.

:distcreate
@set /p dist=Create or update Mesa3D distribution package (y/n):
@echo.
@if /I NOT "%dist%"=="y" GOTO exit
@cd %mesa%
@if NOT EXIST mesa-dist-win MD mesa-dist-win
@cd mesa-dist-win
@if NOT EXIST bin MD bin
@cd bin
@if EXIST %abi% RD /S /Q %abi%
@MD %abi%
@cd %abi%
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\libgl-gdi\opengl32.dll opengl32.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\drivers\swr\swrAVX.dll swrAVX.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\drivers\swr\swrAVX2.dll swrAVX2.dll
@copy %mesa%mesa\build\windows-%longabi%\mesa\drivers\osmesa\osmesa.dll osmesa-swrast.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\osmesa\osmesa.dll osmesa-gallium.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\graw-gdi\graw.dll graw.dll
@copy %mesa%dxtn\%abi%\dxtn.dll dxtn.dll
@echo.
@pause

:exit
exit

@TITLE Building Mesa3D
@cd "%~dp0"
@cd ..\..\
@for %%I in ("%cd%") do @set mesa=%%~sI
@set mesa=%mesa%\
@where /q cmake.exe
@IF ERRORLEVEL 1 set PATH=%mesa%cmake\bin\;%PATH%
@set ERRORLEVEL=0
@where /q python.exe
@IF ERRORLEVEL 1 set PATH=%mesa%Python\;%mesa%Python\Scripts\;%PATH%
@set ERRORLEVEL=0
@set pyupd=y
@set pyfrstupd=1
@if EXIST pyupd.ini set /p pyfrstupd=<pyupd.ini
@if %pyfrstupd%==0 set pyupd=n
@if %pyfrstupd%==0 set /p pyupd=Install/update python modules (y/n):
@if "%pyupd%"=="y" (
@python -m pip install -U mako
@python -m pip freeze > requirements.txt
@python -m pip install -r requirements.txt --upgrade
@del requirements.txt
@echo.
@echo 0 > pyupd.ini
)
@set abi=x86
@set /p x64=Do you want to build for x64? (y/n) Otherwise build for x86:
@if /I "%x64%"=="y" set abi=x64
@set longabi=%abi%
@if %abi%==x64 set longabi=x86_64
@set altabi=i686
@if %abi%==x64 set altabi=%longabi%
@set minabi=32
@if %abi%==x64 set minabi=64
@set targetabi=x86
@if %abi%==x64 set targetabi=amd64
@set hostabi=x86
@set vsenv="%ProgramFiles%
@if NOT "%ProgramW6432%"=="" set hostabi=amd64
@set vsabi=%minabi%
@if NOT %targetabi%==%hostabi% set vsabi=%hostabi%_%targetabi%
@if NOT "%ProgramW6432%"=="" set vsenv=%vsenv% (x86)
@set vsenv15=%vsenv%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars%vsabi%.bat"
@if %vsabi%==32 set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\vcvars%vsabi%.bat"
@if %vsabi%==64 set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\%targetabi%\vcvars%vsabi%.bat"
@if NOT %targetabi%==%hostabi% set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\%vsabi%\vcvars%vsabi%.bat"
@set gcc=%mesa%mingw-w64\%abi%\mingw%minabi%\bin
@set vsenvloaded=0
@set dxtnbuilt=0
@set toolset=14
@if EXIST %vsenv15% set toolset=15
@if EXIST toolset-%abi%.ini set /p toolset=<toolset-%abi%.ini
@set vsenv=%vsenv14%
@if %toolset%==15 set vsenv=%vsenv15%
@set PATH=%mesa%flexbison\;%PATH%
@TITLE Building Mesa3D %abi%

:build_llvm
@set /p buildllvm=Begin LLVM build. Only needs to run once for each ABI and version. Proceed (y/n):
@if /I NOT "%buildllvm%"=="y" GOTO build_dxtn
@echo.
@cd %mesa%llvm
@if EXIST %abi% RD /S /Q %abi%
@if EXIST cmake-%abi% RD /S /Q cmake-%abi%
@md cmake-%abi%
@cd cmake-%abi%
@set toolchain=Visual Studio 14
@set toolset=14
@if EXIST %vsenv15% set toolchain=Visual Studio 15 2017
@if EXIST %vsenv15% set toolset=15
@set ninja=n
@set oldtoolset=n
@set x64compiler= -Thost=x64
@if EXIST %mesa%ninja set ninja=1
@if EXIST %vsenv15% set ninja=%ninja%2
@if %ninja%==12 set /p oldtoolset=Build with MSVC 2015 backward compatibility toolset, alternative solution for LLVM 3.9.1 build with Visual Studio 2017 (y/n):
@if %ninja%==12 echo.
@if /I "%oldtoolset%"=="y" set ninja=y
@if /I "%oldtoolset%"=="y" set toolset=14
@if %ninja%==12 set ninja=2
@if %ninja%==1 set ninja=2
@if %ninja%==2 set /p ninja=Use Ninja build system instead of MsBuild, there is no requirement to do this with the primary toolset though (y/n):
@echo.
@if /I "%ninja%"=="y" set toolchain=Ninja
@if /I "%ninja%"=="y" set x64compiler=
@if "%toolchain%"=="Ninja" set PATH=%mesa%ninja\;%PATH%
@set vsenv=%vsenv14%
@if %toolset%==15 set vsenv=%vsenv15%
@set llvmbuildsys=%CD%
@call %vsenv%
@set vsenvloaded=1
@echo.
@set modtoolchainabi=0
@if NOT "%toolchain%"=="Ninja" set modtoolchainabi=1
@if %abi%==x64 set modtoolchainabi=%modtoolchainabi%2
@if %modtoolchainabi%==12 set toolchain=%toolchain% Win64
@cd %llvmbuildsys%
@if NOT %hostabi%==amd64 set x64compiler=
@cmake -G "%toolchain%"%x64compiler% -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../%abi% ..
@echo.
@pause
@echo.
@if NOT "%toolchain%"=="Ninja" cmake --build . --config Release --target install
@if "%toolchain%"=="Ninja" ninja install
@echo.
@echo %toolset% > %mesa%toolset-%abi%.ini

:build_dxtn
@if NOT EXIST %gcc% GOTO build_mesa
@if NOT EXIST %mesa%dxtn GOTO build_mesa
@set /p builddxtn=Do you want to build S3 texture compression library? (y/n):
@if /i NOT "%builddxtn%"=="y" GOTO build_mesa
@set PATH=%gcc%\;%PATH%
@cd %mesa%dxtn
@echo.
@if EXIST %abi% RD /S /Q %abi%
@MD %abi%
@set dxtn=gcc -shared -m%minabi% -v *.c *.h -I ..\mesa\include -Wl,--dll,--dynamicbase,--enable-auto-image-base,--nxcompat -o %abi%\dxtn.dll
@%dxtn%
@echo.
@set dxtnbuilt=1

:build_mesa
@set /p buildmesa=Begin mesa build. Proceed (y/n):
@if /i NOT "%buildmesa%"=="y" GOTO distcreate
@echo.
@set LLVM=%mesa%llvm\%abi%
@if NOT EXIST %LLVM% (
@echo Could not find LLVM, aborting mesa build.
@echo.
@pause
@GOTO exit
)
@cd %mesa%
@if NOT EXIST mesa echo Mesa3D source code not found. Attempting to download it using git as long as it is in PATH...
@if NOT EXIST mesa set /p branch=Enter Mesa source code branch name - defaults to master:
@if "%branch%"=="" set branch=master
@if NOT EXIST mesa echo.
@if NOT EXIST mesa git clone --depth=1 --branch=%branch% git://anongit.freedesktop.org/mesa/mesa mesa
@cd mesa
git apply -v ..\mesa-dist-win\patches\scons-llvm5.patch
git apply -v ..\mesa-dist-win\patches\s3tc.patch
@echo.
@set openswr=n
@set sconscmd=python %mesa%Python\Scripts\scons.py build=release platform=windows machine=%longabi% libgl-gdi
@if %abi%==x64 set /p openswr=Do you want to build OpenSWR drivers? (y=yes):
@echo.
@if /I "%openswr%"=="y" set sconscmd=%sconscmd% swr=1
@set /p osmesa=Do you want to build off-screen rendering drivers (y/n):
@echo.
@if /I "%osmesa%"=="y" set sconscmd=%sconscmd% osmesa
@set /p graw=Do you want to build graw library (y/n):
@echo.
@if /I "%graw%"=="y" set sconscmd=%sconscmd% graw-gdi
@GOTO build_with_vs

:build_with_mingw
@set mingw=n
@set mingwtest=0
@if EXIST %gcc% set mingwtest=1
@set msys2=%mesa%msys64\msys2_shell.cmd
@if EXIST %msys2% set mingwtest=%mingwtest%2
@if %mingwtest%==12 set /p mingw=Do you want to build with MinGW-W64 instead of Visual Studio (y=yes):
@if %dxtnbuilt%==0 set PATH=%gcc%\;%PATH%
@if /I "%mingw%"=="y" set sconscmd=%sconscmd% toolchain=crossmingw
@if /I "%mingw%"=="y" copy %gcc%\%altabi%-w64-mingw32-gcc-ar.exe %gcc%\%altabi%-w64-mingw32-ar.exe
@if /I "%mingw%"=="y" copy %gcc%\%altabi%-w64-mingw32-gcc-ranlib.exe %gcc%\%altabi%-w64-mingw32-ranlib.exe
@if /I "%mingw%"=="y" call "%msys2%" -use-full-path
@if /I "%mingw%"=="y" (
pacman -Syu
pacman -S python2
wget https://bootstrap.pypa.io/get-pip.py
python2 get-pip.py
pip install -U mako
pip install -U scons
pip freeze > requirements.txt
pip install -r requirements.txt --upgrade
cd $mesa
cd mesa
GOTO build_mesa_exec
)

:build_with_vs
@set cleanbuild=n
@if EXIST build\windows-%longabi% set /p cleanbuild=Do you want to clean build (y/n):
@if EXIST build\windows-%longabi% echo.
@if /I "%cleanbuild%"=="y" RD /S /Q build\windows-%longabi%
@if %vsenvloaded%==0 (
@call %vsenv%
@cd %mesa%mesa
@echo.
)

:build_mesa_exec
@%sconscmd%
@echo.

:distcreate
@set /p dist=Create or update Mesa3D distribution package (y/n):
@echo.
@if /I NOT "%dist%"=="y" GOTO exit
@cd %mesa%
@if NOT EXIST mesa-dist-win MD mesa-dist-win
@cd mesa-dist-win
@if NOT EXIST bin MD bin
@cd bin
@if EXIST %abi% RD /S /Q %abi%
@MD %abi%
@cd %abi%
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\libgl-gdi\opengl32.dll opengl32.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\drivers\swr\swrAVX.dll swrAVX.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\drivers\swr\swrAVX2.dll swrAVX2.dll
@copy %mesa%mesa\build\windows-%longabi%\mesa\drivers\osmesa\osmesa.dll osmesa-swrast.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\osmesa\osmesa.dll osmesa-gallium.dll
@copy %mesa%mesa\build\windows-%longabi%\gallium\targets\graw-gdi\graw.dll graw.dll
@copy %mesa%dxtn\%abi%\dxtn.dll dxtn.dll
@echo.
@pause

:exit
exit

Build script: Drop unsupported 32-bit OpenSWR build More Visual Studio 2015 toolchain loading fixes


rem We need Java 6 for this plugin. If you have Java 6, installed, set an environment variable, JDK6, to its location.
if exist classes rmdir classes /s /q
mkdir classes
xcopy /E /y src classes\
java -cp src;classes;../../../3rdpartypublic/classext/*;../../mmstudio/MMJ_.jar;../../MMCoreJ_wrap/MMCoreJ.jar;../../acqEngine/MMAcqEngine.jar -Djava.library.path=../../bin_Win32 -Dclojure.compile.path=classes -server clojure.lang.Compile DeviceAdapterHelper.plugin
jar cf DLLAutoReloader.jar -C classes\ .
copy /Y DLLAutoReloader.jar ..\..\Install_AllPlatforms\micro-manager\mmplugins\

rem We need Java 6 for this plugin. If you have Java 6, installed, set an environment variable, JDK6, to its location.
if exist classes rmdir classes /s /q
mkdir classes
xcopy /E /y src classes\
java -cp src;classes;../../../3rdpartypublic/classext/*;../../mmstudio/MMJ_.jar;../../MMCoreJ_wrap/MMCoreJ.jar;../../acqEngine/MMAcqEngine.jar -Djava.library.path=../../bin_Win32 -Dclojure.compile.path=classes -server clojure.lang.Compile DLLAutoReloader.plugin
jar cf DLLAutoReloader.jar -C classes\ .
copy /Y DLLAutoReloader.jar ..\..\Install_AllPlatforms\micro-manager\mmplugins\

change name to DLLAutoReloader

change name to DLLAutoReloader

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@10216 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd


@ECHO OFF
SET RepoRoot=%~dp0..\..\
%RepoRoot%build.cmd -projects %~dp0**\*.*proj %*

@ECHO OFF
SET RepoRoot=%~dp0..\..\
%RepoRoot%build.cmd -buildJava -projects %~dp0**\*.*proj %*

Check for Java in local SignalR build (#10455)


@echo off
:: Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
:: reserved. Use of this source code is governed by a BSD-style license
:: that can be found in the LICENSE file.

:: Set up the environment for use with MSVS tools and then execute whatever
:: was specified on the command-line.

set RC=
setlocal

:: In case it's already provided via the environment.
set vcvars="%CEF_VCVARS%"
if exist %vcvars% goto found_vcvars

:: Hardcoded list of MSVS paths.
:: Alternatively we could 'reg query' this key:
:: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VS;ProductDir
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
:: VS 2008 vcvars isn't standalone, it needs this env var.
set VS90COMNTOOLS=%PROGRAMFILES(X86)%\Microsoft Visual Studio 9.0\Common7\Tools\
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set VS90COMNTOOLS=%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\Tools\
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars

set RC=1
echo Failed to find vcvars
goto end

:found_vcvars
echo vcvars:
echo %vcvars%
call %vcvars%

echo PATH:
echo %PATH%
%*

:end
endlocal & set RC=%ERRORLEVEL%
goto omega

:returncode
exit /B %RC%

:omega
call :returncode %RC%

@echo off
:: Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
:: reserved. Use of this source code is governed by a BSD-style license
:: that can be found in the LICENSE file.

:: Set up the environment for use with MSVS tools and then execute whatever
:: was specified on the command-line.

set RC=
setlocal

:: In case it's already provided via the environment.
set vcvars="%CEF_VCVARS%"
if exist %vcvars% goto found_vcvars

:: Hardcoded list of MSVS paths.
:: Alternatively we could 'reg query' this key:
:: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VS;ProductDir
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
:: VS 2008 vcvars isn't standalone, it needs this env var.
set VS90COMNTOOLS=%PROGRAMFILES(X86)%\Microsoft Visual Studio 9.0\Common7\Tools\
set vcvars="%PROGRAMFILES(X86)%\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars
set VS90COMNTOOLS=%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\Tools\
set vcvars="%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
if exist %vcvars% goto found_vcvars

set RC=1
echo Failed to find vcvars
goto end

:found_vcvars
echo vcvars:
echo %vcvars%
call %vcvars%

echo PATH:
echo %PATH%
%*

:end
endlocal & set RC=%ERRORLEVEL%
goto omega

:returncode
exit /B %RC%

:omega
call :returncode %RC%

Update msvs_env.bat to include VS2013 paths (issue #1304).

git-svn-id: 66addb63d0c46e75f185859367c4faf62af16cdd@1725 5089003a-bbd8-11dd-ad1f-f1f9622dbc98


: %1: guid
: %2: maintanancetool path
: %3: base_key
: %4: node
@echo off
reg add "%~3\SOFTWARE\%~4\Windows\CurrentVersion\Uninstall\%~1" /f /v "UninstallString" /t REG_SZ /d "%~2 uninstallOnly=1"

: %1: guid
: %2: maintanancetool path
: %3: base_key
: %4: node
: %5: 0: offline; 1: online
@echo off
IF "%5" == "0" (
	reg add "%~3\SOFTWARE\%~4\Windows\CurrentVersion\Uninstall\%~1" /f /v "NoModify" /t REG_DWORD /d 1
) ELSE (
	reg add "%~3\SOFTWARE\%~4\Windows\CurrentVersion\Uninstall\%~1" /f /v "UninstallString" /t REG_SZ /d "%~2 uninstallOnly=1"
)

Update regSetUninst.bat

Update regSetUninst.bat


cls

setlocal EnableDelayedExpansion

if not exist mapnik_c_api.cpp curl -LO https://raw.github.com/springmeyer/mapnik-c-api/master/mapnik_c_api.cpp
if not exist mapnik_c_api.h curl -LO https://raw.github.com/springmeyer/mapnik-c-api/master/mapnik_c_api.h

If DEFINED ProgramFiles(x86) Set BUILDTOOLS32BIT=%ProgramFiles(x86)%
If NOT DEFINED ProgramFiles(x86) Set BUILDTOOLS32BIT=%ProgramFiles%

call "%BUILDTOOLS32BIT%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

set MAPNIK_C_DEFINES=-DUNICODE -DWIN32

set PATH=%PATH%;c:\mapnik-v2.2.0\bin

for /f "delims=" %%i in ('mapnik-config --prefix') do set MAPNIK_PATH=%%i
for /f "delims=" %%i in ('mapnik-config --cxxflags') do set MAPNIK_CXXFLAGS=%%i
for /f "delims=" %%i in ('mapnik-config --ldflags') do set MAPNIK_LDFLAGS=%%i
for /f "delims=" %%i in ('mapnik-config --dep-libs') do set MAPNIK_DEPLIBS=%%i
for /f "delims=" %%i in ('mapnik-config --libs') do set MAPNIK_LIBS=%%i
for /f "delims=" %%i in ('mapnik-config --defines') do set MAPNIK_DEFINES_LIST=%%i
for /f "delims=" %%i in ('mapnik-config --fonts') do set MAPNIK_FONTS_DIRECTORY=%%i
for /f "delims=" %%i in ('mapnik-config --input-plugins') do set MAPNIK_INPUT_PLUGINS_DIRECTORY=%%i

call :constructDefines %MAPNIK_DEFINES_LIST%

echo.LDFLAGS=%MAPNIK_LDFLAGS%
echo.LIBS=%MAPNIK_LIBS%
echo.DEFINES=%MAPNIK_C_DEFINES%
echo.FONTS=%MAPNIK_FONTS_DIRECTORY%
echo.PLUGINS=%MAPNIK_INPUT_PLUGINS_DIRECTORY%

> gen_import_windows.go (
    echo.package mapnik
	echo.
    echo.// #cgo LDFLAGS: c:/mapnik-v2.2.0/lib/mapnik_c_api.dll
	echo.import"C"
	echo.
	echo.const (
	echo.    fontPath = "%MAPNIK_FONTS_DIRECTORY%"
	echo.    pluginPath = "%MAPNIK_INPUT_PLUGINS_DIRECTORY%"
	echo.^)
)

if not exist mapnik_c_api.obj cl -c -nologo -Zm200 -Zc:wchar_t- -O2 %MAPNIK_CXXFLAGS% -W3 -w34100 -w34189 %MAPNIK_C_DEFINES% -I"c:\mapnik-v2.2.0\include" -I"c:\mapnik-v2.2.0\include\mapnik\agg" -I"." mapnik_c_api.cpp
::link /LIBPATH:%MAPNIK_LDFLAGS% %MAPNIK_LIBS% %MAPNIK_DEPLIBS% mapnik_c_api.obj /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /OUT:mapnik_c_api.dll
link /LIBPATH:%MAPNIK_LDFLAGS% %MAPNIK_LIBS%  mapnik_c_api.obj /DLL /OUT:mapnik_c_api.dll

del mapnik_c_api.obj  mapnik_c_api.cpp  mapnik_c_api.lib  mapnik_c_api.exp
move /y mapnik_c_api.dll c:\mapnik-v2.2.0\lib

go install

goto :eof

:constructDefines
	if "%1"=="" exit /b
	set MAPNIK_C_DEFINES=%MAPNIK_C_DEFINES% -D%1
	shift
	goto :constructDefines

cls

@echo off
setlocal EnableDelayedExpansion

If NOT DEFINED MAPNIK_SDK_PATH set MAPNIK_SDK_PATH=c:\mapnik-sdk

echo.
echo.Using Mapnik SDK from here: %MAPNIK_SDK_PATH%
echo.

If NOT EXIST %MAPNIK_SDK_PATH%\bin\mapnik-config.bat (
    echo.ERROR: Cannot find mapnik-config bat in %MAPNIK_SDK_PATH%\bin. Aborting...
    goto :eof
)

echo.
echo.Downloading C API from github
echo.

if not exist mapnik_c_api.cpp curl -LO https://raw.github.com/springmeyer/mapnik-c-api/master/mapnik_c_api.cpp
if not exist mapnik_c_api.h curl -LO https://raw.github.com/springmeyer/mapnik-c-api/master/mapnik_c_api.h

If DEFINED ProgramFiles(x86) Set BUILDTOOLS32BIT=%ProgramFiles(x86)%
If NOT DEFINED ProgramFiles(x86) Set BUILDTOOLS32BIT=%ProgramFiles%

call "%BUILDTOOLS32BIT%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

echo.
echo.Compiling C API to shared library
echo.

set MAPNIK_C_DEFINES=-DUNICODE -DWIN32

set PATH=%PATH%;%MAPNIK_SDK_PATH%\bin

for /f "delims=" %%i in ('mapnik-config --prefix') do set MAPNIK_PATH=%%i
for /f "delims=" %%i in ('mapnik-config --cxxflags') do set MAPNIK_CXXFLAGS=%%i
for /f "delims=" %%i in ('mapnik-config --ldflags') do set MAPNIK_LDFLAGS=%%i
for /f "delims=" %%i in ('mapnik-config --dep-libs') do set MAPNIK_DEPLIBS=%%i
for /f "delims=" %%i in ('mapnik-config --libs') do set MAPNIK_LIBS=%%i
for /f "delims=" %%i in ('mapnik-config --defines') do set MAPNIK_DEFINES_LIST=%%i
for /f "delims=" %%i in ('mapnik-config --fonts') do set MAPNIK_FONTS_DIRECTORY=%%i
for /f "delims=" %%i in ('mapnik-config --input-plugins') do set MAPNIK_INPUT_PLUGINS_DIRECTORY=%%i

call :constructDefines %MAPNIK_DEFINES_LIST%

echo.LDFLAGS=%MAPNIK_LDFLAGS%
echo.LIBS=%MAPNIK_LIBS%
echo.DEFINES=%MAPNIK_C_DEFINES%
echo.FONTS=%MAPNIK_FONTS_DIRECTORY%
echo.PLUGINS=%MAPNIK_INPUT_PLUGINS_DIRECTORY%

> gen_import_windows.go (
    echo.package mapnik
	echo.
    echo.// #cgo LDFLAGS: %MAPNIK_SDK_PATH%/lib/mapnik_c_api.dll
	echo.import"C"
	echo.
	echo.const (
	echo.    fontPath = "%MAPNIK_FONTS_DIRECTORY%"
	echo.    pluginPath = "%MAPNIK_INPUT_PLUGINS_DIRECTORY%"
	echo.^)
)

echo.
echo.Compiling C API to shared library
echo.

if not exist mapnik_c_api.obj cl -c -nologo -Zm200 -Zc:wchar_t- -O2 %MAPNIK_CXXFLAGS% -W3 -w34100 -w34189 %MAPNIK_C_DEFINES% -I"%MAPNIK_SDK_PATH%\include" -I"%MAPNIK_SDK_PATH%\include\mapnik\agg" -I"." mapnik_c_api.cpp
::link /LIBPATH:%MAPNIK_LDFLAGS% %MAPNIK_LIBS% %MAPNIK_DEPLIBS% mapnik_c_api.obj /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /OUT:mapnik_c_api.dll
link /LIBPATH:%MAPNIK_LDFLAGS% %MAPNIK_LIBS%  mapnik_c_api.obj /DLL /OUT:mapnik_c_api.dll

IF NOT EXIST mapnik_c_api.dll (
    echo.
    echo.ERROR: Could not compile the DLL. Check for any error messages above.
    goto :eof
)

echo.
echo.Installing C API DLL to %MAPNIK_SDK_PATH%\lib
echo.

del mapnik_c_api.obj  mapnik_c_api.cpp  mapnik_c_api.lib  mapnik_c_api.exp
move /y mapnik_c_api.dll %MAPNIK_SDK_PATH%\lib

echo.
echo.Installing Go package
echo.

go install

goto :eof

:constructDefines
	if "%1"=="" exit /b
	set MAPNIK_C_DEFINES=%MAPNIK_C_DEFINES% -D%1
	shift
	goto :constructDefines

win: set SDK path with envvar MAPNIK_SDK_PATH

default is c:\mapnik-sdk

also: more verborsity and early exit on most typical errors


mkdir -p build
pushd build

cmake -G "Ninja" \
      -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% \
      -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% \
      ..

ninja
ninja install

mkdir -p build
pushd build

cmake -G "Ninja" ^
      -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
      -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
      ..

ninja
ninja install

Fix line scape

Fix line scape


REM nuget restore

if not exist SimpleInjector.snk copy fake.snk SimpleInjector.snk

msbuild "src\SimpleInjector.NET\SimpleInjector.NET.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Packaging\SimpleInjector.Packaging.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Extensions.LifetimeScoping\SimpleInjector.Extensions.LifetimeScoping.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Extensions.ExecutionContextScoping\SimpleInjector.Extensions.ExecutionContextScoping.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Integration.Web\SimpleInjector.Integration.Web.csproj" /nologo /p:Configuration=Debug
rem doesn't build on AppVeyor. msbuild "src\SimpleInjector.Integration.Web.Mvc\SimpleInjector.Integration.Web.Mvc.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Integration.Wcf\SimpleInjector.Integration.Wcf.csproj" /nologo /p:Configuration=Debug

msbuild "src\SimpleInjector.NET.Tests.Unit\SimpleInjector.NET.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Extensions.LifetimeScoping.Tests.Unit\SimpleInjector.Extensions.LifetimeScoping.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Integration.Web.Tests.Unit\SimpleInjector.Integration.Web.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "src\SimpleInjector.Extensions.ExecutionContextScoping.Tests.Unit\SimpleInjector.Extensions.ExecutionContextScoping.Tests.Unit.csproj" /nologo /p:Configuration=Debug

REM nuget restore

if not exist SimpleInjector.snk copy fake.snk SimpleInjector.snk

msbuild "SimpleInjector.NET\SimpleInjector.NET.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Packaging\SimpleInjector.Packaging.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Extensions.LifetimeScoping\SimpleInjector.Extensions.LifetimeScoping.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Extensions.ExecutionContextScoping\SimpleInjector.Extensions.ExecutionContextScoping.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Integration.Web\SimpleInjector.Integration.Web.csproj" /nologo /p:Configuration=Debug
rem doesn't build on AppVeyor. msbuild "SimpleInjector.Integration.Web.Mvc\SimpleInjector.Integration.Web.Mvc.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Integration.Wcf\SimpleInjector.Integration.Wcf.csproj" /nologo /p:Configuration=Debug

msbuild "SimpleInjector.NET.Tests.Unit\SimpleInjector.NET.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Extensions.LifetimeScoping.Tests.Unit\SimpleInjector.Extensions.LifetimeScoping.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Integration.Web.Tests.Unit\SimpleInjector.Integration.Web.Tests.Unit.csproj" /nologo /p:Configuration=Debug
msbuild "SimpleInjector.Extensions.ExecutionContextScoping.Tests.Unit\SimpleInjector.Extensions.ExecutionContextScoping.Tests.Unit.csproj" /nologo /p:Configuration=Debug

remove src folder

remove src folder


@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@set APP_DIR=%HOME%\.spf13-vim-3
IF NOT EXIST "%APP_DIR%" (
  call git clone --recursive -b 3.0 https://github.com/spf13/spf13-vim.git "%APP_DIR%"
) ELSE (
	@set ORIGINAL_DIR=%CD%
    echo updating spf13-vim
    chdir /d "%APP_DIR%"
	call git pull
    chdir /d "%ORIGINAL_DIR%"
	call cd "%APP_DIR%"
)

call mklink "%HOME%\.vimrc" "%APP_DIR%\.vimrc"
call mklink "%HOME%\_vimrc" "%APP_DIR%\.vimrc"
call mklink "%HOME%\.vimrc.fork" "%APP_DIR%\.vimrc.fork"
call mklink "%HOME%\.vimrc.bundles" "%APP_DIR%\.vimrc.bundles"
call mklink "%HOME%\.vimrc.bundles.fork" "%APP_DIR%\.vimrc.bundles.fork"
call mklink "%HOME%\.vimrc.before" "%APP_DIR%\.vimrc.before"
call mklink "%HOME%\.vimrc.before.fork" "%APP_DIR%\.vimrc.before.fork"
call mklink /J "%HOME%\.vim" "%APP_DIR%\.vim"

IF NOT EXIST "%APP_DIR%\.vim\bundle" (
	call mkdir "%APP_DIR%\.vim\bundle"
)

IF NOT EXIST "%HOME%/.vim/bundle/vundle" (
	call git clone https://github.com/gmarik/vundle.git "%HOME%/.vim/bundle/vundle"
)

call vim -u "%APP_DIR%/.vimrc.bundles" +BundleInstall! +BundleClean +qall

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@set APP_DIR=%HOME%\.spf13-vim-3
IF NOT EXIST "%APP_DIR%" (
  call git clone --recursive -b 3.0 https://github.com/spf13/spf13-vim.git "%APP_DIR%"
) ELSE (
	@set ORIGINAL_DIR=%CD%
    echo updating spf13-vim
    chdir /d "%APP_DIR%"
	call git pull
    chdir /d "%ORIGINAL_DIR%"
	call cd "%APP_DIR%"
)

call mklink "%HOME%\.vimrc" "%APP_DIR%\.vimrc"
call mklink "%HOME%\_vimrc" "%APP_DIR%\.vimrc"
call mklink "%HOME%\.vimrc.fork" "%APP_DIR%\.vimrc.fork"
call mklink "%HOME%\.vimrc.bundles" "%APP_DIR%\.vimrc.bundles"
call mklink "%HOME%\.vimrc.bundles.fork" "%APP_DIR%\.vimrc.bundles.fork"
call mklink "%HOME%\.vimrc.before" "%APP_DIR%\.vimrc.before"
call mklink "%HOME%\.vimrc.before.fork" "%APP_DIR%\.vimrc.before.fork"
call mklink /J "%HOME%\.vim" "%APP_DIR%\.vim"

IF NOT EXIST "%APP_DIR%\.vim\bundle" (
	call mkdir "%APP_DIR%\.vim\bundle"
)

IF NOT EXIST "%HOME%/.vim/bundle/vundle" (
	call git clone https://github.com/gmarik/vundle.git "%HOME%/.vim/bundle/vundle"
) ELSE (
  call cd "%HOME%/.vim/bundle/vundle"
  call git pull
  call cd %HOME%
)

call vim -u "%APP_DIR%/.vimrc.bundles" +BundleInstall! +BundleClean +qall

Update Vundle first

Update Vundle first