:: build-windows.bat
::
:: This source file is part of the Swift.org open source project
::
:: Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
:: Licensed under Apache License v2.0 with Runtime Library Exception
::
:: See https://swift.org/LICENSE.txt for license information
:: See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

:: REQUIRED ENVIRONMENT VARIABLES
:: This script requires to be executed inside one Visual Studio command line,
:: in order for many of the tools and environment variables to be available.
:: Additionally, it needs the following variables:
:: - CMAKE_BUILD_TYPE: Kind of build: Release, RelWithDebInfo, Debug.
:: - PYTHON_HOME: The Python installation directory.

:: REQUIRED PERMISSIONS
:: Practically, it is easier to be in the Adminstrators group to run the
:: script, but it should be possible to execute as a normal user.
:: The user will need permission to write files into the Windows SDK and the
:: VisualC++ folder.

@echo off

setlocal enableextensions enabledelayedexpansion

set icu_version_major=64
set icu_version_minor=2
set icu_version=%icu_version_major%_%icu_version_minor%
set icu_version_dotted=%icu_version_major%.%icu_version_minor%

set "exitOnError=|| (exit /b)"
set current_directory=%~dp0
set current_directory=%current_directory:~0,-1%
set source_root=%current_directory%\..\..

:: Resetting source_root with %CD% removes the ..\.. from the paths, and makes
:: the output easier to read.
cd %source_root%
set source_root=%CD%

set full_build_root=%source_root%\build
set install_directory=%build_root%\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr

mkdir %full_build_root%
:: Use the shortest path we can for the build directory, to avoid Windows
:: path problems as much as we can.
subst S: /d
subst S: %full_build_root% %exitOnError%
set build_root=S:

call :clone_repositories %exitOnError%
call :download_icu %exitOnError%
:: TODO: Disabled until we need LLBuild/SwiftPM in this build script.
:: call :download_sqlite3

call :build_llvm %exitOnError%
path %PATH%;%install_directory%\bin

call :build_cmark %exitOnError%

call :prepare_platform_modules %exitOnError%
call :build_swift %exitOnError%

call :build_lldb %exitOnError%

path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
call :test_swift %exitOnError%

goto :end
endlocal

:clone_repositories
:: Clones the repositories used by the Windows build.
:: It supposes that the swift repository is already cloned by CI.
:: It supposes the %CD% is the source root.
setlocal enableextensions enabledelayedexpansion

git config --global core.autocrlf false
git clone --depth 1 --single-branch https://github.com/apple/swift-cmark cmark %exitOnError%
git clone --depth 1 --single-branch https://github.com/apple/swift-clang clang %exitOnError%
git clone --depth 1 --single-branch https://github.com/apple/swift-llvm llvm %exitOnError%
git clone --depth 1 --single-branch https://github.com/apple/swift-lldb lldb %exitOnError%
git clone --depth 1 --single-branch https://github.com/apple/swift-compiler-rt compiler-rt %exitOnError%
git clone --depth 1 --single-branch https://github.com/apple/swift-corelibs-libdispatch %exitOnError%

goto :eof
endlocal

:download_icu
:: Downloads ICU, which will be used as a dependency for the Swift Standard
:: Library and Foundation.
setlocal enableextensions enabledelayedexpansion

set file_name=icu4c-%icu_version%-Win64-MSVC2017.zip
curl -L -O -z %file_name% "http://download.icu-project.org/files/icu4c/%icu_version_dotted%/%file_name%" %exitOnError%
:: unzip warns about the paths in the zip using slashes, which raises the
:: errorLevel to 1. We cannot use exitOnError, and have to ignore errors.
unzip -o %file_name% -d "%source_root%\icu-%icu_version%"
exit /b 0

goto :eof
endlocal

:download_sqlite3
:: Downloads SQLite3, which will be used as a dependency for llbuild and
:: Swift Package Manager.
setlocal enableextensions enabledelayedexpansion

set file_name=sqlite-amalgamation-3270200.zip
curl -L -O "https://www.sqlite.org/2019/%file_name%" %exitOnError%
unzip -o %file_name% %exitOnError%

goto :eof
endlocal

:prepare_platform_modules
:: Create files into the right places of the Windows SDK to the files in the
:: swift repository, in order to consider the headers of the Windows SDK a
:: module to compile Swift code against them.
setlocal enableextensions enabledelayedexpansion

copy /y "%source_root%\swift\stdlib\public\Platform\ucrt.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\winsdk.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.modulemap" "%VCToolsInstallDir%\include\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.apinotes" "%VCToolsInstallDir%\include\visualc.apinotes" %exitOnError%

goto :eof
endlocal

:build_llvm
:: Configures, builds, and installs LLVM
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\llvm" %exitOnError%
pushd "%build_root%\llvm"

cmake "%source_root%\llvm"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
    -DLLVM_ENABLE_PDB:BOOL=YES^
    -DLLVM_ENABLE_ASSERTIONS:BOOL=YES^
    -DLLVM_ENABLE_PROJECTS:STRING=clang^
    -DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;X86"^
    -DLLVM_INCLUDE_BENCHMARKS:BOOL=NO^
    -DLLVM_INCLUDE_DOCS:BOOL=NO^
    -DLLVM_INCLUDE_EXAMPLES:BOOL=NO^
    -DLLVM_INCLUDE_GO_TESTS:BOOL=NO^
    -DLLVM_TOOL_GOLD_BUILD:BOOL=NO^
    -DLLVM_ENABLE_OCAMLDOC:BOOL=NO^
    -DLLVM_ENABLE_LIBXML2:BOOL=NO^
    -DLLVM_ENABLE_ZLIB:BOOL=NO^
    -DENABLE_X86_RELAX_RELOCATIONS:BOOL=YES^
    -DLLVM_INSTALL_BINUTILS_SYMLINKS:BOOL=YES^
    -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=YES^
    -DLLVM_TOOLCHAIN_TOOLS:STRING="addr2line;ar;c++filt;dsymutil;dwp;llvm-ar;llvm-cov;llvm-cvtres;llvm-cxxfilt;llvm-dlltool;llvm-dwp;llvm-ranlib;llvm-lib;llvm-mt;llvm-nm;llvm-objdump;llvm-pdbutil;llvm-profdata;llvm-rc;llvm-readelf;llvm-readobj;llvm-size;llvm-strip;llvm-symbolizer;llvm-undname;nm;objcopy;objdump;ranlib;readelf;size;strings"^
    -DCLANG_TOOLS="clang;clang-format;clang-headers;clang-tidy"^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\llvm" %exitOnError%
cmake --build "%build_root%\llvm" --target install %exitOnError%

goto :eof
endlocal

:build_cmark
:: Configures and builds CMark
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\cmark" %exitOnError%
pushd "%build_root%\cmark"

cmake "%source_root%\cmark"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\cmark" %exitOnError%

goto :eof
endlocal

:build_swift
:: Configures, builds, and installs Swift and the Swift Standard Library
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\swift" %exitOnError%
pushd "%build_root%\swift"

:: SWIFT_PARALLEL_LINK_JOBS=8 allows the build machine to use as many CPU as
:: possible, while not exhausting the RAM.
cmake "%source_root%\swift"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
    -DSWIFT_PATH_TO_CMARK_BUILD:PATH=%build_root%\cmark^
    -DSWIFT_PATH_TO_CMARK_SOURCE:PATH=%source_root%\cmark^
    -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH=%source_root%\swift-corelibs-libdispatch^
    -DLLVM_DIR:PATH=%build_root%\llvm\lib\cmake\llvm^
    -DSWIFT_INCLUDE_DOCS:BOOL=NO^
    -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE:PATH=%source_root%\icu-%icu_version%\include\unicode^
    -DSWIFT_WINDOWS_x86_64_ICU_UC:PATH=%source_root%\icu-%icu_version%\lib64\icuuc.lib^
    -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE:PATH=%source_root%\icu-%icu_version%\include^
    -DSWIFT_WINDOWS_x86_64_ICU_I18N:PATH=%source_root%\icu-%icu_version%\lib64\icuin.lib^
    -DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=YES^
    -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY:BOOL=YES^
    -DSWIFT_BUILD_STATIC_STDLIB:BOOL=NO^
    -DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=NO^
    -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=YES^
    -DSWIFT_BUILD_SOURCEKIT:BOOL=YES^
    -DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=NO^
    -DSWIFT_INSTALL_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;editor-integration;tools;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers"^
    -DSWIFT_PARALLEL_LINK_JOBS=8^
    -DPYTHON_EXECUTABLE:PATH=%PYTHON_HOME%\python.exe^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\swift" %exitOnError%
cmake --build "%build_root%\swift" --target install %exitOnError%

goto :eof
endlocal

:test_swift
:: Tests the Swift compiler and the Swift Standard Library
setlocal enableextensions enabledelayedexpansion

cmake --build "%build_root%\swift" --target check-swift %exitOnError%

goto :eof
endlocal

:build_lldb
:: Configures, builds, and installs LLDB
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\lldb" %exitOnError%
pushd "%build_root%\lldb"

cmake "%source_root%\lldb"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=clang-cl^
    -DCMAKE_CXX_COMPILER=clang-cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DLLVM_DIR:PATH=%build_root%\llvm\lib\cmake\llvm^
    -DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
    -DSwift_DIR:PATH=%build_root%\swift\lib\cmake\swift^
    -DLLVM_ENABLE_ASSERTIONS:BOOL=YES^
    -DLLDB_ALLOW_STATIC_BINDINGS:BOOL=YES^
    -DPYTHON_HOME:PATH=%PYTHON_HOME%^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DLLDB_INCLUDE_TESTS:BOOL=NO %exitOnError%

popd

cmake --build "%build_root%\lldb" %exitOnError%
cmake --build "%build_root%\lldb" --target install %exitOnError%

goto :eof
endlocal

:build_libdispatch
:: Configures, builds, and installs Dispatch
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\swift-corelibs-libdispatch" %exitOnError%
pushd "%build_root%\swift-corelibs-libdispatch"

cmake "%source_root%\swift-corelibs-libdispatch"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=clang-cl^
    -DCMAKE_CXX_COMPILER=clang-cl^
    -DCMAKE_SWIFT_COMPILER:PATH=%install_directory%\bin\swiftc.exe^
    -DSwift_DIR:PATH=%build_root%\swift\lib\cmake\swift^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DBUILD_SHARED_LIBS:BOOL=YES^
    -DENABLE_TESTING:BOOL=NO^
    -DCMAKE_C_COMPILER_TARGET=x86_64-unknown-windows-msvc^
    -DENABLE_SWIFT:BOOL=YES^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\swift-corelibs-libdispatch" %exitOnError%
cmake --build "%build_root%\swift-corelibs-libdispatch" --target install %exitOnError%

goto :eof
endlocal

:end

:: build-windows.bat
::
:: This source file is part of the Swift.org open source project
::
:: Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
:: Licensed under Apache License v2.0 with Runtime Library Exception
::
:: See https://swift.org/LICENSE.txt for license information
:: See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

:: REQUIRED ENVIRONMENT VARIABLES
:: This script requires to be executed inside one Visual Studio command line,
:: in order for many of the tools and environment variables to be available.
:: Additionally, it needs the following variables:
:: - CMAKE_BUILD_TYPE: Kind of build: Release, RelWithDebInfo, Debug.
:: - PYTHON_HOME: The Python installation directory.

:: REQUIRED PERMISSIONS
:: Practically, it is easier to be in the Adminstrators group to run the
:: script, but it should be possible to execute as a normal user.
:: The user will need permission to write files into the Windows SDK and the
:: VisualC++ folder.

@echo off

setlocal enableextensions enabledelayedexpansion

set icu_version_major=64
set icu_version_minor=2
set icu_version=%icu_version_major%_%icu_version_minor%
set icu_version_dotted=%icu_version_major%.%icu_version_minor%

set "exitOnError=|| (exit /b)"
set current_directory=%~dp0
set current_directory=%current_directory:~0,-1%
set source_root=%current_directory%\..\..

:: Resetting source_root with %CD% removes the ..\.. from the paths, and makes
:: the output easier to read.
cd %source_root%
set source_root=%CD%

set full_build_root=%source_root%\build
set install_directory=%build_root%\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr

mkdir %full_build_root%
:: Use the shortest path we can for the build directory, to avoid Windows
:: path problems as much as we can.
subst S: /d
subst S: %full_build_root% %exitOnError%
set build_root=S:

call :clone_repositories %exitOnError%
call :download_icu %exitOnError%
:: TODO: Disabled until we need LLBuild/SwiftPM in this build script.
:: call :download_sqlite3

call :build_llvm %exitOnError%
path %PATH%;%install_directory%\bin

call :build_cmark %exitOnError%

call :prepare_platform_modules %exitOnError%
call :build_swift %exitOnError%

call :build_lldb %exitOnError%

path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
call :test_swift %exitOnError%

goto :end
endlocal

:clone_repositories
:: Clones the repositories used by the Windows build.
:: It supposes that the swift repository is already cloned by CI.
:: It supposes the %CD% is the source root.
setlocal enableextensions enabledelayedexpansion

git config --global core.autocrlf false
git clone --depth 1 --single-branch https://github.com/apple/swift-cmark cmark %exitOnError%
git clone --depth 1 --single-branch --branch swift/master https://github.com/apple/llvm-project llvm-project %exitOnError%
mklink /D "%source_root%\clang" "%source_root%\llvm-project\clang"
mklink /D "%source_root%\llvm" "%source_root%\llvm-project\llvm"
mklink /D "%source_root%\lldb" "%source_root%\llvm-project\lldb"
mklink /D "%source_root%\compiler-rt" "%source_root%\llvm-project\compiler-rt"
mklink /D "%source_root%\libcxx" "%source_root%\llvm-project\libcxx"
mklink /D "%source_root%\clang-tools-extra" "%source_root%\llvm-project\clang-tools-extra"
git clone --depth 1 --single-branch https://github.com/apple/swift-corelibs-libdispatch %exitOnError%

goto :eof
endlocal

:download_icu
:: Downloads ICU, which will be used as a dependency for the Swift Standard
:: Library and Foundation.
setlocal enableextensions enabledelayedexpansion

set file_name=icu4c-%icu_version%-Win64-MSVC2017.zip
curl -L -O -z %file_name% "http://download.icu-project.org/files/icu4c/%icu_version_dotted%/%file_name%" %exitOnError%
:: unzip warns about the paths in the zip using slashes, which raises the
:: errorLevel to 1. We cannot use exitOnError, and have to ignore errors.
unzip -o %file_name% -d "%source_root%\icu-%icu_version%"
exit /b 0

goto :eof
endlocal

:download_sqlite3
:: Downloads SQLite3, which will be used as a dependency for llbuild and
:: Swift Package Manager.
setlocal enableextensions enabledelayedexpansion

set file_name=sqlite-amalgamation-3270200.zip
curl -L -O "https://www.sqlite.org/2019/%file_name%" %exitOnError%
unzip -o %file_name% %exitOnError%

goto :eof
endlocal

:prepare_platform_modules
:: Create files into the right places of the Windows SDK to the files in the
:: swift repository, in order to consider the headers of the Windows SDK a
:: module to compile Swift code against them.
setlocal enableextensions enabledelayedexpansion

copy /y "%source_root%\swift\stdlib\public\Platform\ucrt.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\winsdk.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.modulemap" "%VCToolsInstallDir%\include\module.modulemap" %exitOnError%
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.apinotes" "%VCToolsInstallDir%\include\visualc.apinotes" %exitOnError%

goto :eof
endlocal

:build_llvm
:: Configures, builds, and installs LLVM
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\llvm" %exitOnError%
pushd "%build_root%\llvm"

cmake "%source_root%\llvm"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
    -DLLVM_ENABLE_PDB:BOOL=YES^
    -DLLVM_ENABLE_ASSERTIONS:BOOL=YES^
    -DLLVM_ENABLE_PROJECTS:STRING=clang^
    -DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;X86"^
    -DLLVM_INCLUDE_BENCHMARKS:BOOL=NO^
    -DLLVM_INCLUDE_DOCS:BOOL=NO^
    -DLLVM_INCLUDE_EXAMPLES:BOOL=NO^
    -DLLVM_INCLUDE_GO_TESTS:BOOL=NO^
    -DLLVM_TOOL_GOLD_BUILD:BOOL=NO^
    -DLLVM_ENABLE_OCAMLDOC:BOOL=NO^
    -DLLVM_ENABLE_LIBXML2:BOOL=NO^
    -DLLVM_ENABLE_ZLIB:BOOL=NO^
    -DENABLE_X86_RELAX_RELOCATIONS:BOOL=YES^
    -DLLVM_INSTALL_BINUTILS_SYMLINKS:BOOL=YES^
    -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=YES^
    -DLLVM_TOOLCHAIN_TOOLS:STRING="addr2line;ar;c++filt;dsymutil;dwp;llvm-ar;llvm-cov;llvm-cvtres;llvm-cxxfilt;llvm-dlltool;llvm-dwp;llvm-ranlib;llvm-lib;llvm-mt;llvm-nm;llvm-objdump;llvm-pdbutil;llvm-profdata;llvm-rc;llvm-readelf;llvm-readobj;llvm-size;llvm-strip;llvm-symbolizer;llvm-undname;nm;objcopy;objdump;ranlib;readelf;size;strings"^
    -DCLANG_TOOLS="clang;clang-format;clang-headers;clang-tidy"^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\llvm" %exitOnError%
cmake --build "%build_root%\llvm" --target install %exitOnError%

goto :eof
endlocal

:build_cmark
:: Configures and builds CMark
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\cmark" %exitOnError%
pushd "%build_root%\cmark"

cmake "%source_root%\cmark"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\cmark" %exitOnError%

goto :eof
endlocal

:build_swift
:: Configures, builds, and installs Swift and the Swift Standard Library
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\swift" %exitOnError%
pushd "%build_root%\swift"

:: SWIFT_PARALLEL_LINK_JOBS=8 allows the build machine to use as many CPU as
:: possible, while not exhausting the RAM.
cmake "%source_root%\swift"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=cl^
    -DCMAKE_CXX_COMPILER=cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
    -DSWIFT_PATH_TO_CMARK_BUILD:PATH=%build_root%\cmark^
    -DSWIFT_PATH_TO_CMARK_SOURCE:PATH=%source_root%\cmark^
    -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH=%source_root%\swift-corelibs-libdispatch^
    -DLLVM_DIR:PATH=%build_root%\llvm\lib\cmake\llvm^
    -DSWIFT_INCLUDE_DOCS:BOOL=NO^
    -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE:PATH=%source_root%\icu-%icu_version%\include\unicode^
    -DSWIFT_WINDOWS_x86_64_ICU_UC:PATH=%source_root%\icu-%icu_version%\lib64\icuuc.lib^
    -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE:PATH=%source_root%\icu-%icu_version%\include^
    -DSWIFT_WINDOWS_x86_64_ICU_I18N:PATH=%source_root%\icu-%icu_version%\lib64\icuin.lib^
    -DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=YES^
    -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY:BOOL=YES^
    -DSWIFT_BUILD_STATIC_STDLIB:BOOL=NO^
    -DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=NO^
    -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=YES^
    -DSWIFT_BUILD_SOURCEKIT:BOOL=YES^
    -DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=NO^
    -DSWIFT_INSTALL_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;editor-integration;tools;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers"^
    -DSWIFT_PARALLEL_LINK_JOBS=8^
    -DPYTHON_EXECUTABLE:PATH=%PYTHON_HOME%\python.exe^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\swift" %exitOnError%
cmake --build "%build_root%\swift" --target install %exitOnError%

goto :eof
endlocal

:test_swift
:: Tests the Swift compiler and the Swift Standard Library
setlocal enableextensions enabledelayedexpansion

cmake --build "%build_root%\swift" --target check-swift %exitOnError%

goto :eof
endlocal

:build_lldb
:: Configures, builds, and installs LLDB
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\lldb" %exitOnError%
pushd "%build_root%\lldb"

cmake "%source_root%\lldb"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=clang-cl^
    -DCMAKE_CXX_COMPILER=clang-cl^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DLLVM_DIR:PATH=%build_root%\llvm\lib\cmake\llvm^
    -DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
    -DSwift_DIR:PATH=%build_root%\swift\lib\cmake\swift^
    -DLLVM_ENABLE_ASSERTIONS:BOOL=YES^
    -DLLDB_ALLOW_STATIC_BINDINGS:BOOL=YES^
    -DPYTHON_HOME:PATH=%PYTHON_HOME%^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DLLDB_INCLUDE_TESTS:BOOL=NO %exitOnError%

popd

cmake --build "%build_root%\lldb" %exitOnError%
cmake --build "%build_root%\lldb" --target install %exitOnError%

goto :eof
endlocal

:build_libdispatch
:: Configures, builds, and installs Dispatch
setlocal enableextensions enabledelayedexpansion

mkdir "%build_root%\swift-corelibs-libdispatch" %exitOnError%
pushd "%build_root%\swift-corelibs-libdispatch"

cmake "%source_root%\swift-corelibs-libdispatch"^
    -G Ninja^
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%^
    -DCMAKE_C_COMPILER=clang-cl^
    -DCMAKE_CXX_COMPILER=clang-cl^
    -DCMAKE_SWIFT_COMPILER:PATH=%install_directory%\bin\swiftc.exe^
    -DSwift_DIR:PATH=%build_root%\swift\lib\cmake\swift^
    -DCMAKE_INSTALL_PREFIX:PATH=%install_directory%^
    -DBUILD_SHARED_LIBS:BOOL=YES^
    -DENABLE_TESTING:BOOL=NO^
    -DCMAKE_C_COMPILER_TARGET=x86_64-unknown-windows-msvc^
    -DENABLE_SWIFT:BOOL=YES^
    -DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
    -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
    -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO %exitOnError%

popd

cmake --build "%build_root%\swift-corelibs-libdispatch" %exitOnError%
cmake --build "%build_root%\swift-corelibs-libdispatch" --target install %exitOnError%

goto :eof
endlocal

:end

[windows] Use the monorepo in the Windows build script for CI.

Clone the monorepo, in the swift/master branch (since that seems to be
the one used by swift master branch), and create links for the different
parts of the LLVM project in the first level.


@ECHO OFF
SETLOCAL EnableDelayedExpansion

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                                                ::
::  Node.js Portable                                                              ::
::                                                                                ::
::  A DOS Batch script to make Node.js portable on Windows systems.               ::
::                                                                                ::
::  Copyright (C) 2013 Cr@zy <webmaster@crazyws.fr>                               ::
::                                                                                ::
::  Node.js Portable is free software; you can redistribute it and/or modify      ::
::  it under the terms of the GNU Lesser General Public License as published by   ::
::  the Free Software Foundation, either version 3 of the License, or             ::
::  (at your option) any later version.                                           ::
::                                                                                ::
::  Node.js Portable is distributed in the hope that it will be useful,           ::
::  but WITHOUT ANY WARRANTY; without even the implied warranty of                ::
::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  ::
::  GNU Lesser General Public License for more details.                           ::
::                                                                                ::
::  You should have received a copy of the GNU Lesser General Public License      ::
::  along with this program. If not, see http://www.gnu.org/licenses/.            ::
::                                                                                ::
::  Related post: http://goo.gl/gavL4                                             ::
::  Usage: nodejs-portable.bat                                                    ::
::                                                                                ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

TITLE Node.js Portable v1.2

:: Settings
SET nodejsVersion=0.10.21

:: Batch vars (no edits necessary)
SET nodejsPath=%~dp0
SET nodejsWork=%nodejsPath%\work
SET npmPath=%nodejsPath%\node_modules\npm
SET npmGlobalConfigFilePath=%npmPath%\npmrc
SET nodejsInstallVbs=%TEMP%\nodejs_install.vbs
SET nodejsMsiPackage=node-v%nodejsVersion%-x86.msi
SET nodejsUrl=http://nodejs.org/dist/v%nodejsVersion%/%nodejsMsiPackage%

::::::::::::::::::::::::::::::::::::::::
:MENU
::::::::::::::::::::::::::::::::::::::::
CLS
ECHO.
ECHO # Node.js Portable v1.2
ECHO.

ECHO  1 - Launch
ECHO  2 - Install
ECHO  9 - Exit
ECHO.
SET /P nodejsTask=Choose a task:
ECHO.

IF %nodejsTask% == 1 GOTO LAUNCH
IF %nodejsTask% == 2 GOTO INSTALL
IF %nodejsTask% == 9 GOTO EXIT
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:INSTALL
::::::::::::::::::::::::::::::::::::::::

:: Check if node.js is installed
IF EXIST "%nodejsPath%\node.exe" ECHO node.js is already installed... && GOTO EOF

:: Reloacte and create temp dir (workaround for permission issue)
SET TEMP=%nodejsPath%\tmp
IF NOT EXIST "%TEMP%" MKDIR "%TEMP%"

:: Prepare cscript to download node.js
ECHO WScript.StdOut.Write "Download " ^& "%nodejsMsiPackage%" ^& " ">%nodejsInstallVbs%
:: Switched to 'WinHttp.WinHttpRequest.5.1'
ECHO dim http: set http = createobject("WinHttp.WinHttpRequest.5.1") >>%nodejsInstallVbs%
ECHO dim bStrm: set bStrm = createobject("Adodb.Stream") >>%nodejsInstallVbs%
:: Open in asynchronous mode.
ECHO http.Open "GET", "%nodejsUrl%", True >>%nodejsInstallVbs%
ECHO http.Send >>%nodejsInstallVbs%
:: Every second write a '.' until the download is complete
ECHO while http.WaitForResponse(0) = 0 >>%nodejsInstallVbs%
ECHO   WScript.StdOut.Write "." >>%nodejsInstallVbs%
ECHO   WScript.Sleep 1000 >>%nodejsInstallVbs%
ECHO wend >>%nodejsInstallVbs%
:: ECHO WScript.StdOut.Write vbCRLF >>%nodejsInstallVbs%
:: Write the HTTP status code onto console
ECHO WScript.StdOut.WriteLine " [HTTP " ^& http.Status ^& " " ^& http.StatusText ^& "]" >>%nodejsInstallVbs%
ECHO with bStrm >>%nodejsInstallVbs%
ECHO .type = 1 '//binary >>%nodejsInstallVbs%
ECHO .open >>%nodejsInstallVbs%
ECHO .write http.responseBody >>%nodejsInstallVbs%
ECHO .savetofile "%TEMP%\%nodejsMsiPackage%", 2 >>%nodejsInstallVbs%
ECHO end with >>%nodejsInstallVbs%

:: Download latest version in the current folder
cscript.exe /NoLogo %nodejsInstallVbs%

:: Extract the MSI package
ECHO Install node.js in %nodejsPath%...
msiexec /a "%TEMP%\%nodejsMsiPackage%" /qn TARGETDIR="%nodejsPath%"
XCOPY "%nodejsPath%\nodejs" "%nodejsPath%" /s /e /i /h /y

:: Clean folders
RMDIR /s /q "%nodejsPath%\nodejs"
RMDIR /s /q "%TEMP%"
IF EXIST "%nodejsPath%\%nodejsMsiPackage%" DEL "%nodejsPath%\%nodejsMsiPackage%"

:: Finish installation
ECHO.
IF EXIST "%nodejsPath%\node.exe" ECHO node.js successfully installed in '%nodejsPath%'
IF NOT EXIST "%nodejsPath%\node.exe" ECHO An error occurred during the installation.
GOTO PREPARE

::::::::::::::::::::::::::::::::::::::::
:LAUNCH
::::::::::::::::::::::::::::::::::::::::

:: Check if node.js is installed
IF NOT EXIST "%nodejsPath%\node.exe" ECHO node.js is not installed... Please install first... && GOTO EOF
IF NOT %nodejsTask% == 0 GOTO PREPARE

:: Init node vars
cmd.exe /k "cd "%nodejsWork%" && "%nodejsPath%\nodevars.bat" && "%nodejsPath%\npm" config set globalconfig "%npmGlobalConfigFilePath%" --global"
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:PREPARE
::::::::::::::::::::::::::::::::::::::::

:: Relocate and edit NPM global config file
ECHO prefix = %nodejsPath%\ >%npmGlobalConfigFilePath%
ECHO globalconfig = %npmPath%\npmrc >>%npmGlobalConfigFilePath%
ECHO globalignorefile = %npmPath%\npmignore >>%npmGlobalConfigFilePath%
ECHO init-module = %npmPath%\init.js >>%npmGlobalConfigFilePath%
ECHO cache = %npmPath%\cache >>%npmGlobalConfigFilePath%

IF NOT EXIST "%nodejsWork%" MKDIR "%nodejsWork%"
IF NOT EXIST "%npmPath%\npmignore" ECHO. 2>"%npmPath%\npmignore"
IF NOT EXIST "%npmPath%\init.js" ECHO. 2>"%npmPath%\init.js"
IF NOT EXIST "%npmPath%\cache" MKDIR "%npmPath%\cache"
IF %nodejsTask% == 1 SET nodejsTask=0 && GOTO LAUNCH
GOTO EOF

::::::::::::::::::::::::::::::::::::::::
:EOF
::::::::::::::::::::::::::::::::::::::::

ECHO.
PAUSE
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:EXIT
::::::::::::::::::::::::::::::::::::::::

ENDLOCAL

@ECHO OFF
SETLOCAL EnableDelayedExpansion

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                                                ::
::  Node.js Portable                                                              ::
::                                                                                ::
::  A DOS Batch script to make Node.js portable on Windows systems.               ::
::                                                                                ::
::  Copyright (C) 2013 Cr@zy <webmaster@crazyws.fr>                               ::
::                                                                                ::
::  Node.js Portable is free software; you can redistribute it and/or modify      ::
::  it under the terms of the GNU Lesser General Public License as published by   ::
::  the Free Software Foundation, either version 3 of the License, or             ::
::  (at your option) any later version.                                           ::
::                                                                                ::
::  Node.js Portable is distributed in the hope that it will be useful,           ::
::  but WITHOUT ANY WARRANTY; without even the implied warranty of                ::
::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  ::
::  GNU Lesser General Public License for more details.                           ::
::                                                                                ::
::  You should have received a copy of the GNU Lesser General Public License      ::
::  along with this program. If not, see http://www.gnu.org/licenses/.            ::
::                                                                                ::
::  Related post: http://goo.gl/gavL4                                             ::
::  Usage: nodejs-portable.bat                                                    ::
::                                                                                ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

TITLE Node.js Portable v1.2

:: Settings
SET nodejsVersion=0.10.21

:: Batch vars (no edits necessary)
SET nodejsPath=%~dp0
set nodejsPath=!nodejsPath:~0,-1!
SET nodejsWork=%nodejsPath%\work
SET npmPath=%nodejsPath%\node_modules\npm
SET npmGlobalConfigFilePath=%npmPath%\npmrc
SET nodejsInstallVbs=%TEMP%\nodejs_install.vbs
SET nodejsMsiPackage=node-v%nodejsVersion%-x86.msi
SET nodejsUrl=http://nodejs.org/dist/v%nodejsVersion%/%nodejsMsiPackage%

::::::::::::::::::::::::::::::::::::::::
:MENU
::::::::::::::::::::::::::::::::::::::::
CLS
ECHO.
ECHO # Node.js Portable v1.2
ECHO.

ECHO  1 - Launch
ECHO  2 - Install
ECHO  9 - Exit
ECHO.
SET /P nodejsTask=Choose a task:
ECHO.

IF %nodejsTask% == 1 GOTO LAUNCH
IF %nodejsTask% == 2 GOTO INSTALL
IF %nodejsTask% == 9 GOTO EXIT
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:INSTALL
::::::::::::::::::::::::::::::::::::::::

:: Check if node.js is installed
IF EXIST "%nodejsPath%\node.exe" ECHO node.js is already installed... && GOTO EOF

:: Reloacte and create temp dir (workaround for permission issue)
SET TEMP=%nodejsPath%\tmp
IF NOT EXIST "%TEMP%" MKDIR "%TEMP%"

:: Prepare cscript to download node.js
ECHO WScript.StdOut.Write "Download " ^& "%nodejsMsiPackage%" ^& " ">%nodejsInstallVbs%
:: Switched to 'WinHttp.WinHttpRequest.5.1'
ECHO dim http: set http = createobject("WinHttp.WinHttpRequest.5.1") >>%nodejsInstallVbs%
ECHO dim bStrm: set bStrm = createobject("Adodb.Stream") >>%nodejsInstallVbs%
:: Open in asynchronous mode.
ECHO http.Open "GET", "%nodejsUrl%", True >>%nodejsInstallVbs%
ECHO http.Send >>%nodejsInstallVbs%
:: Every second write a '.' until the download is complete
ECHO while http.WaitForResponse(0) = 0 >>%nodejsInstallVbs%
ECHO   WScript.StdOut.Write "." >>%nodejsInstallVbs%
ECHO   WScript.Sleep 1000 >>%nodejsInstallVbs%
ECHO wend >>%nodejsInstallVbs%
:: ECHO WScript.StdOut.Write vbCRLF >>%nodejsInstallVbs%
:: Write the HTTP status code onto console
ECHO WScript.StdOut.WriteLine " [HTTP " ^& http.Status ^& " " ^& http.StatusText ^& "]" >>%nodejsInstallVbs%
ECHO with bStrm >>%nodejsInstallVbs%
ECHO .type = 1 '//binary >>%nodejsInstallVbs%
ECHO .open >>%nodejsInstallVbs%
ECHO .write http.responseBody >>%nodejsInstallVbs%
ECHO .savetofile "%TEMP%\%nodejsMsiPackage%", 2 >>%nodejsInstallVbs%
ECHO end with >>%nodejsInstallVbs%

:: Download latest version in the current folder
cscript.exe /NoLogo %nodejsInstallVbs%

:: Extract the MSI package
ECHO Install node.js in %nodejsPath%...
msiexec /a "%TEMP%\%nodejsMsiPackage%" /qn TARGETDIR="%nodejsPath%"
XCOPY "%nodejsPath%\nodejs" "%nodejsPath%" /s /e /i /h /y

:: Clean folders
RMDIR /s /q "%nodejsPath%\nodejs"
RMDIR /s /q "%TEMP%"
IF EXIST "%nodejsPath%\%nodejsMsiPackage%" DEL "%nodejsPath%\%nodejsMsiPackage%"

:: Finish installation
ECHO.
IF EXIST "%nodejsPath%\node.exe" ECHO node.js successfully installed in '%nodejsPath%'
IF NOT EXIST "%nodejsPath%\node.exe" ECHO An error occurred during the installation.
GOTO PREPARE

::::::::::::::::::::::::::::::::::::::::
:LAUNCH
::::::::::::::::::::::::::::::::::::::::

:: Check if node.js is installed
IF NOT EXIST "%nodejsPath%\node.exe" ECHO node.js is not installed... Please install first... && GOTO EOF
IF NOT %nodejsTask% == 0 GOTO PREPARE

:: Init node vars
cmd.exe /k "cd "%nodejsWork%" && "%nodejsPath%\nodevars.bat" && "%nodejsPath%\npm" config set globalconfig "%npmGlobalConfigFilePath%" --global"
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:PREPARE
::::::::::::::::::::::::::::::::::::::::

:: Relocate and edit NPM global config file
ECHO prefix = %nodejsPath%\ >%npmGlobalConfigFilePath%
ECHO globalconfig = %npmPath%\npmrc >>%npmGlobalConfigFilePath%
ECHO globalignorefile = %npmPath%\npmignore >>%npmGlobalConfigFilePath%
ECHO init-module = %npmPath%\init.js >>%npmGlobalConfigFilePath%
ECHO cache = %npmPath%\cache >>%npmGlobalConfigFilePath%

IF NOT EXIST "%nodejsWork%" MKDIR "%nodejsWork%"
IF NOT EXIST "%npmPath%\npmignore" ECHO. 2>"%npmPath%\npmignore"
IF NOT EXIST "%npmPath%\init.js" ECHO. 2>"%npmPath%\init.js"
IF NOT EXIST "%npmPath%\cache" MKDIR "%npmPath%\cache"
IF %nodejsTask% == 1 SET nodejsTask=0 && GOTO LAUNCH
GOTO EOF

::::::::::::::::::::::::::::::::::::::::
:EOF
::::::::::::::::::::::::::::::::::::::::

ECHO.
PAUSE
GOTO MENU

::::::::::::::::::::::::::::::::::::::::
:EXIT
::::::::::::::::::::::::::::::::::::::::

ENDLOCAL

Remove trailing slash on nodejsPath

Remove trailing slash on nodejsPath


@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem 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, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat7 as service name.
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is considered
rem                        to be new service name
rem
rem $Id: service.bat 1000718 2010-09-24 06:00:00Z mturk $
rem ---------------------------------------------------------------------------

set "SELF=%~dp0%service.bat"
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%cd%"
if exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHome
rem CD to the upper dir
cd ..
set "CATALINA_HOME=%cd%"
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
:okHome
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo Service will try to guess them from the registry.
goto okJavaHome
:gotJreHome
if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome
goto okJavaHome
:gotJdkHome
if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
if not "%JRE_HOME%" == "" goto okJavaHome
set "JRE_HOME=%JAVA_HOME%\jre"
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK not a JRE
goto end
:okJavaHome
if not "%CATALINA_BASE%" == "" goto gotBase
set "CATALINA_BASE=%CATALINA_HOME%"
:gotBase

set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat7.exe"

rem Set default Service name
set SERVICE_NAME=Tomcat7
set PR_DISPLAYNAME=Apache Tomcat 7

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
:checkUser
if "x%1x" == "x/userx" goto runAsUser
if "x%1x" == "x--userx" goto runAsUser
set SERVICE_NAME=%1
set PR_DISPLAYNAME=Apache Tomcat %1
shift
if "x%1x" == "xx" goto checkServiceCmd
goto checkUser
:runAsUser
shift
if "x%1x" == "xx" goto displayUsage
set SERVICE_USER=%1
shift
runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
goto end
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name] [/user username]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
goto end
:removed
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    "%CATALINA_HOME%"
echo Using CATALINA_BASE:    "%CATALINA_BASE%"
echo Using JAVA_HOME:        "%JAVA_HOME%"
echo Using JRE_HOME:         "%JRE_HOME%"

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat 7.0.27 Server - http://tomcat.apache.org/
set "PR_INSTALL=%EXECUTABLE%"
set "PR_LOGPATH=%CATALINA_BASE%\logs"
set "PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar"
rem Set the server jvm from JAVA_HOME
set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll"
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll"
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:              "%PR_JVM%"
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set "PR_LOGPATH=%CATALINA_BASE%\logs"
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Dsolr.solr.home=%CATALINA_HOME%\solr;-Dsolr.data.dir=%CATALINA_HOME%\solr\core1\data;-Dfess.log.file=%CATALINA_HOME%\webapps\fess\WEB-INF\logs\fess.out;-Djava.awt.headless=true;-XX:+UseGCOverheadLimit;-XX:+UseConcMarkSweepGC;-XX:+CMSIncrementalMode;-XX:+UseTLAB;-XX:MaxPermSize=128m" --JvmMs 128 --JvmMx 512
echo The service '%SERVICE_NAME%' has been installed.

:end
cd "%CURRENT_DIR%"

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem 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, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat8 as service name.
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is considered
rem                        to be new service name
rem
rem $Id: service.bat 1000718 2010-09-24 06:00:00Z mturk $
rem ---------------------------------------------------------------------------

set "SELF=%~dp0%service.bat"
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%cd%"
if exist "%CATALINA_HOME%\bin\tomcat8.exe" goto okHome
rem CD to the upper dir
cd ..
set "CATALINA_HOME=%cd%"
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat8.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
:okHome
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo Service will try to guess them from the registry.
goto okJavaHome
:gotJreHome
if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome
goto okJavaHome
:gotJdkHome
if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
if not "%JRE_HOME%" == "" goto okJavaHome
set "JRE_HOME=%JAVA_HOME%\jre"
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK not a JRE
goto end
:okJavaHome
if not "%CATALINA_BASE%" == "" goto gotBase
set "CATALINA_BASE=%CATALINA_HOME%"
:gotBase

set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat8.exe"

rem Set default Service name
set SERVICE_NAME=Tomcat8
set PR_DISPLAYNAME=Apache Tomcat 8

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
:checkUser
if "x%1x" == "x/userx" goto runAsUser
if "x%1x" == "x--userx" goto runAsUser
set SERVICE_NAME=%1
set PR_DISPLAYNAME=Apache Tomcat %1
shift
if "x%1x" == "xx" goto checkServiceCmd
goto checkUser
:runAsUser
shift
if "x%1x" == "xx" goto displayUsage
set SERVICE_USER=%1
shift
runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
goto end
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name] [/user username]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
goto end
:removed
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    "%CATALINA_HOME%"
echo Using CATALINA_BASE:    "%CATALINA_BASE%"
echo Using JAVA_HOME:        "%JAVA_HOME%"
echo Using JRE_HOME:         "%JRE_HOME%"

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat 8 Server - http://tomcat.apache.org/
set "PR_INSTALL=%EXECUTABLE%"
set "PR_LOGPATH=%CATALINA_BASE%\logs"
set "PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar"
rem Set the server jvm from JAVA_HOME
set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll"
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll"
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:              "%PR_JVM%"
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set "PR_LOGPATH=%CATALINA_BASE%\logs"
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Dsolr.solr.home=%CATALINA_HOME%\solr;-Dsolr.data.dir=%CATALINA_HOME%\solr\core1\data;-Dfess.log.file=%CATALINA_HOME%\webapps\fess\WEB-INF\logs\fess.out;-Djava.awt.headless=true;-XX:+UseGCOverheadLimit;-XX:+UseConcMarkSweepGC;-XX:+CMSIncrementalMode;-XX:+UseTLAB;-XX:MaxPermSize=128m" --JvmMs 128 --JvmMx 512
echo The service '%SERVICE_NAME%' has been installed.

:end
cd "%CURRENT_DIR%"

Update service.bat

Update service.bat


add run.bat

add run.bat


ECHO OFF

ECHO.
ECHO ----------------------------------------
ECHO copy file to converter
ECHO ----------------------------------------

mkdir "%~dp0\App_Data"
mkdir "%~dp0\FileConverter\Bin"
mkdir "%~dp0\FileConverter\Bin\HtmlFileInternal"

cd /D "%~dp0\FileConverter\Bin" || goto ERROR
copy "..\..\..\core\build\bin\windows\icudt.dll" "."
copy "..\..\..\core\build\bin\icu\win_32\icudt55.dll" "."
copy "..\..\..\core\build\bin\icu\win_32\icuuc55.dll" "."
copy "..\..\..\core\build\lib\DoctRenderer.config" "."
copy "..\..\..\core\build\lib\win_32\doctrenderer.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlRenderer.dll" "."
copy "..\..\..\core\build\lib\win_32\DjVuFile.dll" "."
copy "..\..\..\core\build\lib\win_32\XpsFile.dll" "."
copy "..\..\..\core\build\lib\win_32\PdfReader.dll" "."
copy "..\..\..\core\build\lib\win_32\PdfWriter.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlFile.dll" "."
copy "..\..\..\core\build\lib\win_32\UnicodeConverter.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlFileInternal.exe" ".\HtmlFileInternal"
xcopy /s/h/e/k/c/y/q "..\..\..\core\build\cef\win32" ".\HtmlFileInternal"
copy "..\..\..\core\build\bin\windows\x2t32.exe" "."

powershell -Command "(gc ./DoctRenderer.config) -replace '../../OfficeWeb', '../../../sdkjs' | sc ./DoctRenderer.config"
"..\..\..\core\build\bin\AllFontsGen\windows_32.exe" "%windir%\Fonts" "%~dp0\..\sdkjs\common\AllFonts.js" "%~dp0\..\sdkjs\common\Images" "%~dp0\FileConverter\Bin\font_selection.bin"

ECHO.
ECHO ----------------------------------------
ECHO build skd-all.js
ECHO ----------------------------------------
CD /D %~dp0\..\sdkjs\build\deploy
SET GRUNT_OLD=grunt@0.3.17
SET GRUNT_CLI=grunt-cli

echo Check is there old grunt installed.
call npm list -g %GRUNT_OLD% && call npm uninstall -g grunt

echo Installation grunt-cli
call npm list -g %GRUNT_CLI% || call npm install -g %GRUNT_CLI%

call npm install
call grunt.cmd --src="./sdk_configs" --level=WHITESPACE_ONLY

ECHO.
ECHO ----------------------------------------
ECHO Install node.js modules
ECHO ----------------------------------------

CD /D %~dp0\DocService || goto ERROR
call npm install

cd /D ..\Common || goto ERROR
call npm install

cd /D ..\FileConverter || goto ERROR
call npm install

cd /D ..\SpellChecker || goto ERROR
call npm install

SET RUN_DIR=%~dp0
SET NODE_ENV=development-windows
SET NODE_CONFIG_DIR=%RUN_DIR%\Common\config

cd "%RUN_DIR%\DocService\sources"
start /min /b node server.js
start /min /b node gc.js

cd "%RUN_DIR%\FileConverter\sources"
start /min /b node convertermaster.js

:ERROR
:SUCCESS
pause

ECHO OFF

ECHO.
ECHO ----------------------------------------
ECHO copy file to converter
ECHO ----------------------------------------

mkdir "%~dp0\App_Data"
mkdir "%~dp0\FileConverter\Bin"
mkdir "%~dp0\FileConverter\Bin\HtmlFileInternal"

cd /D "%~dp0\FileConverter\Bin" || goto ERROR
copy "..\..\..\core\build\bin\windows\icudt.dll" "."
copy "..\..\..\core\build\bin\icu\win_32\icudt55.dll" "."
copy "..\..\..\core\build\bin\icu\win_32\icuuc55.dll" "."
copy "..\..\..\core\build\lib\DoctRenderer.config" "."
copy "..\..\..\core\build\lib\win_32\doctrenderer.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlRenderer.dll" "."
copy "..\..\..\core\build\lib\win_32\DjVuFile.dll" "."
copy "..\..\..\core\build\lib\win_32\XpsFile.dll" "."
copy "..\..\..\core\build\lib\win_32\PdfReader.dll" "."
copy "..\..\..\core\build\lib\win_32\PdfWriter.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlFile.dll" "."
copy "..\..\..\core\build\lib\win_32\UnicodeConverter.dll" "."
copy "..\..\..\core\build\lib\win_32\HtmlFileInternal.exe" ".\HtmlFileInternal"
xcopy /s/h/e/k/c/y/q "..\..\..\core\build\cef\win32" ".\HtmlFileInternal"
copy "..\..\..\core\build\bin\windows\x2t32.exe" "."

"..\..\..\core\build\bin\AllFontsGen\windows_32.exe" "%windir%\Fonts" "%~dp0\..\sdkjs\common\AllFonts.js" "%~dp0\..\sdkjs\common\Images" "%~dp0\FileConverter\Bin\font_selection.bin"

ECHO.
ECHO ----------------------------------------
ECHO build skd-all.js
ECHO ----------------------------------------
CD /D %~dp0\..\sdkjs\build\deploy
SET GRUNT_OLD=grunt@0.3.17
SET GRUNT_CLI=grunt-cli

echo Check is there old grunt installed.
call npm list -g %GRUNT_OLD% && call npm uninstall -g grunt

echo Installation grunt-cli
call npm list -g %GRUNT_CLI% || call npm install -g %GRUNT_CLI%

call npm install
call grunt.cmd --src="./sdk_configs" --level=WHITESPACE_ONLY --nomap=true --formatting=PRETTY_PRINT

ECHO.
ECHO ----------------------------------------
ECHO Install node.js modules
ECHO ----------------------------------------

CD /D %~dp0\DocService || goto ERROR
call npm install

cd /D ..\Common || goto ERROR
call npm install

cd /D ..\FileConverter || goto ERROR
call npm install

cd /D ..\SpellChecker || goto ERROR
call npm install

SET RUN_DIR=%~dp0
SET NODE_ENV=development-windows
SET NODE_CONFIG_DIR=%RUN_DIR%\Common\config

cd "%RUN_DIR%\DocService\sources"
start /min /b node server.js
start /min /b node gc.js

cd "%RUN_DIR%\FileConverter\sources"
start /min /b node convertermaster.js

:ERROR
:SUCCESS
pause

add PRETTY_PRINT and nomap options to run file


erl ^
 -sname webpackman ^
 -pa ebin ^
 -pa deps/cowboy/ebin ^
 -pa deps/gproc/ebin ^
 -pa /deps/cowlib/ebin ^
 -pa /deps/ranch/ebin ^
 -boot start_sasl ^
 -s boot

erl ^
 -sname webpackman ^
 -pa ebin ^
 -pa ./deps/gproc/ebin ^
 -pa ./deps/ranch/ebin ^
 -pa ./deps/cowlib/ebin ^
 -pa ./deps/cowboy/ebin ^
 -pa ./deps/jsx/ebin ^
 -boot start_sasl ^
 -s boot

update run.bat with the new dep (jsx)

update run.bat with the new dep (jsx)


@setlocal

@rem Define paths to necessary directories
set workingdir=%~dp0
set inputdir=%workingdir%nuget-unsigned
set outputdir=%workingdir%nuget-signed

@rem Define paths to necessary tools
set NUGET=c:\nuget\nuget.exe
set SEVENZIP="c:\Program Files\7-Zip\7z.exe"
set SIGNTOOL="C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe"

@rem Define signing options
set CERTHASH=9ccadd88b898155baef4c7b8ff7b17595275b1bb
set TSAURL=http://time.certum.pl/
set LIBNAME=Pkcs11Interop
set LIBURL=https://www.pkcs11interop.net/

@rem Clean output directory
rmdir /S /Q %outputdir%
mkdir %outputdir% || goto :error

@rem Copy unsigned package to output directory
copy %inputdir%\*.nupkg %outputdir% || goto :error

@rem Extract unsigned package contents into the output directory
cd %outputdir% || goto :error
%SEVENZIP% x *.nupkg || goto :error
rmdir /S /Q _rels || goto :error
rmdir /S /Q package || goto :error
del /Q *.xml || goto :error
del /Q *.nupkg || goto :error

@rem Sign all assemblies using SHA256withRSA algorithm
%SIGNTOOL% sign /sha1 %CERTHASH% /fd sha256 /tr %TSAURL% /td sha256 /d %LIBNAME% /du %LIBURL% ^
lib\net20\Pkcs11Interop.dll ^
lib\net40\Pkcs11Interop.dll ^
lib\net45\Pkcs11Interop.dll ^
lib\netstandard2.0\Pkcs11Interop.dll || goto :error

@rem Create signed package with signed assemblies
%NUGET% pack Pkcs11Interop.nuspec || goto :error
%NUGET% sign Pkcs11Interop*.nupkg -CertificateFingerprint %CERTHASH% -Timestamper %TSAURL% || goto :error
%NUGET% verify -Signature Pkcs11Interop*.nupkg || goto :error
copy %inputdir%\*.snupkg . || goto :error

@rem Clean up
rmdir /S /Q lib || goto :error
del /Q *.nuspec || goto :error
del /Q *.txt || goto :error

@echo *** SIGN SUCCESSFUL ***
@endlocal
@exit /b 0

:error
@echo *** SIGN FAILED ***
@endlocal
@exit /b 1

@setlocal

@rem Define paths to necessary directories
set workingdir=%~dp0
set inputdir=%workingdir%nuget-unsigned
set outputdir=%workingdir%nuget-signed

@rem Define paths to necessary tools
set NUGET=c:\nuget\nuget.exe
set SEVENZIP="c:\Program Files\7-Zip\7z.exe"
set SIGNTOOL="C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe"

@rem Define signing options
set CERTHASH=d4ba72939a46bac6dd31dad895a9901ace0d56f6
set TSAURL=http://time.certum.pl/
set LIBNAME=Pkcs11Interop
set LIBURL=https://www.pkcs11interop.net/

@rem Clean output directory
rmdir /S /Q %outputdir%
mkdir %outputdir% || goto :error

@rem Copy unsigned package to output directory
copy %inputdir%\*.nupkg %outputdir% || goto :error

@rem Extract unsigned package contents into the output directory
cd %outputdir% || goto :error
%SEVENZIP% x *.nupkg || goto :error
rmdir /S /Q _rels || goto :error
rmdir /S /Q package || goto :error
del /Q *.xml || goto :error
del /Q *.nupkg || goto :error

@rem Sign all assemblies using SHA256withRSA algorithm
%SIGNTOOL% sign /sha1 %CERTHASH% /fd sha256 /tr %TSAURL% /td sha256 /d %LIBNAME% /du %LIBURL% ^
lib\net20\Pkcs11Interop.dll ^
lib\net40\Pkcs11Interop.dll ^
lib\net45\Pkcs11Interop.dll ^
lib\netstandard2.0\Pkcs11Interop.dll || goto :error

@rem Create signed package with signed assemblies
%NUGET% pack Pkcs11Interop.nuspec || goto :error
%NUGET% sign Pkcs11Interop*.nupkg -CertificateFingerprint %CERTHASH% -Timestamper %TSAURL% || goto :error
%NUGET% verify -Signature Pkcs11Interop*.nupkg || goto :error
copy %inputdir%\*.snupkg . || goto :error

@rem Clean up
rmdir /S /Q lib || goto :error
del /Q *.nuspec || goto :error
del /Q *.txt || goto :error
del /Q *.png || goto :error

@echo *** SIGN SUCCESSFUL ***
@endlocal
@exit /b 0

:error
@echo *** SIGN FAILED ***
@endlocal
@exit /b 1

Use 2021-code-signing-jimrich.cer

Use 2021-code-signing-jimrich.cer


@echo off

for /f "delims=" %%i in ("%~dp0..\envs") do (
    set ANACONDA_ENVS=%%~fi
)

set CONDA_NEW_NAME=%~1

if "%~2" == "" goto skiptoomanyargs
    echo ERROR: Too many arguments provided
    goto usage
:skiptoomanyargs

if "%CONDA_NEW_NAME%" == "" set CONDA_NEW_NAME=%~dp0..\

if exist "%ANACONDA_ENVS%\%CONDA_NEW_NAME%\conda-meta" goto usenamedenv
    for /F %%i in ("%CONDA_NEW_NAME%") do set CONDA_NEW_PATH=%%~fi
    if exist "%CONDA_NEW_PATH%\conda-meta" goto usefullpath
        echo No environment named "%CONDA_NEW_NAME%" exists in %ANACONDA_ENVS%
        set CONDA_NEW_NAME=
        set CONDA_NEW_PATH=
        exit /b 1
:usenamedenv
    set CONDA_NEW_PATH=%ANACONDA_ENVS%\%CONDA_NEW_NAME%
    goto skipmissingenv
:usefullpath
    for /F %%i in ("%CONDA_NEW_PATH%") do set CONDA_NEW_NAME=%%~ni
:skipmissingenv

REM Deactivate a previous activation if it is live
if "%CONDA_DEFAULT_ENV%" == "" goto skipdeactivate
    REM This search/replace removes the previous env from the path
    echo Deactivating environment "%CONDA_DEFAULT_ENV%"...

    REM Run any deactivate scripts
    if not exist "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d" goto nodeactivate
        pushd "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d"
        for %%g in (*.bat) do call "%%g"
        popd
    :nodeactivate

    set CONDACTIVATE_PATH="%CONDA_DEFAULT_ENV%";"%CONDA_DEFAULT_ENV%\Scripts";"%CONDA_DEFAULT_ENV%\Library\bin"
    call set PATH=%%PATH:%CONDACTIVATE_PATH%=%%
    set CONDA_DEFAULT_ENV=
    set CONDACTIVATE_PATH=
    set PROMPT=%CONDA_OLD_PROMPT%
    set CONDA_OLD_PROMPT=
:skipdeactivate

set CONDA_DEFAULT_ENV=%CONDA_NEW_PATH%
echo Activating environment "%CONDA_DEFAULT_ENV%"...
set PATH="%CONDA_DEFAULT_ENV%";"%CONDA_DEFAULT_ENV%\Scripts";"%CONDA_DEFAULT_ENV%\Library\bin";%PATH%
IF "%CONDA_NEW_NAME%"=="" (
   set PROMPT=$P$G
   ) ELSE (
   set PROMPT=[%CONDA_NEW_NAME%] $P$G
)
set CONDA_NEW_NAME=
set CONDA_NEW_PATH=

REM Run any activate scripts
if not exist "%CONDA_DEFAULT_ENV%\etc\conda\activate.d" goto noactivate
    pushd "%CONDA_DEFAULT_ENV%\etc\conda\activate.d"
    for %%g in (*.bat) do call "%%g"
    popd
:noactivate

@echo off

for /f "delims=" %%i in ("%~dp0..\envs") do (
    set ANACONDA_ENVS=%%~fi
)

set CONDA_NEW_NAME=%~1

if "%~2" == "" goto skiptoomanyargs
    echo ERROR: Too many arguments provided
    goto usage
:skiptoomanyargs

if "%CONDA_NEW_NAME%" == "" set CONDA_NEW_NAME=%~dp0..\

if exist "%ANACONDA_ENVS%\%CONDA_NEW_NAME%\conda-meta" goto usenamedenv
    for /F %%i in ("%CONDA_NEW_NAME%") do set CONDA_NEW_PATH=%%~fi
    if exist "%CONDA_NEW_PATH%\conda-meta" goto usefullpath
        echo No environment named "%CONDA_NEW_NAME%" exists in %ANACONDA_ENVS%
        set CONDA_NEW_NAME=
        set CONDA_NEW_PATH=
        exit /b 1
:usenamedenv
    set CONDA_NEW_PATH=%ANACONDA_ENVS%\%CONDA_NEW_NAME%
    goto skipmissingenv
:usefullpath
    for /F %%i in ("%CONDA_NEW_PATH%") do set CONDA_NEW_NAME=%%~ni
:skipmissingenv

REM Deactivate a previous activation if it is live
if "%CONDA_DEFAULT_ENV%" == "" goto skipdeactivate
    REM This search/replace removes the previous env from the path
    echo Deactivating environment "%CONDA_DEFAULT_ENV%"...

    REM Run any deactivate scripts
    if not exist "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d" goto nodeactivate
        pushd "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d"
        for %%g in (*.bat) do call "%%g"
        popd
    :nodeactivate

    set CONDACTIVATE_PATH="%CONDA_DEFAULT_ENV%";"%CONDA_DEFAULT_ENV%\Scripts";"%CONDA_DEFAULT_ENV%\Library\bin"
    call set PATH=%%PATH:%CONDACTIVATE_PATH%=%%
    set CONDA_DEFAULT_ENV=
    set CONDACTIVATE_PATH=
    set PROMPT=%CONDA_OLD_PROMPT%
    set CONDA_OLD_PROMPT=
:skipdeactivate

set CONDA_DEFAULT_ENV=%CONDA_NEW_PATH%
echo Activating environment "%CONDA_DEFAULT_ENV%"...
set PATH="%CONDA_DEFAULT_ENV%";"%CONDA_DEFAULT_ENV%\Scripts";"%CONDA_DEFAULT_ENV%\Library\bin";%PATH%
IF "%CONDA_NEW_NAME%"=="" (
   set PROMPT=$P$G
   REM Clear CONDA_DEFAULT_ENV so that this is truly a "root" environment, not an environment pointed at root
   set CONDA_DEFAULT_ENV=
   ) ELSE (
   set PROMPT=[%CONDA_NEW_NAME%] $P$G
)
set CONDA_NEW_NAME=
set CONDA_NEW_PATH=

REM Run any activate scripts
if not exist "%CONDA_DEFAULT_ENV%\etc\conda\activate.d" goto noactivate
    pushd "%CONDA_DEFAULT_ENV%\etc\conda\activate.d"
    for %%g in (*.bat) do call "%%g"
    popd
:noactivate

clean CONDA_DEFAULT_ENV when activate root env


@REM ============================================================
@REM Copy music files from original KaM TPR game
@REM ============================================================
@REM take music from previous KMR version for now
@REM xcopy "%KaMOrigDir%"\data\sfx\songs\*.sng "%kam_folder%"\Music\*.mp2 /y /r /s

REM ============================================================
REM Copy data folders
REM ============================================================
@REM Copy all data files, except sfx, which should be copied from KMRPrevVersionDir
xcopy ..\data\defines "%kam_folder%"\data\defines\ /y /r /s
xcopy ..\data\gfx "%kam_folder%"\data\gfx\ /y /r /s
xcopy ..\data\Sprites "%kam_folder%"\data\Sprites\ /y /r /s
xcopy ..\data\text "%kam_folder%"\data\text\ /y /r /s
xcopy ..\data\locales.txt "%kam_folder%"\data\locales.txt* /y /r /i
xcopy ..\Campaigns "%kam_folder%"\Campaigns\ /y /r /s
xcopy ..\Maps "%kam_folder%"\Maps\ /y /r /s /exclude:excluded_test_maps.txt
xcopy ..\MapsMP "%kam_folder%"\MapsMP\ /y /r /s
xcopy ..\Tutorials "%kam_folder%"\Tutorials\ /y /r /s
xcopy ..\Docs\Readme "%kam_folder%"\ /y /r /s
xcopy ..\Sounds "%kam_folder%"\Sounds\ /y /r /s
xcopy ..\Music "%kam_folder%"\Music\ /y /r /s
xcopy ..\lib "%kam_folder%"\lib\ /y /r /s

REM ============================================================
REM Copy video files
REM ============================================================
xcopy "%KMRVideosDir%" "%kam_folder%" /y /r /s

REM ============================================================
REM Copy files from KMRPrevVersionDir
REM ============================================================
xcopy "%KMRPrevVersionDir%"\data\sfx "%kam_folder%"\data\sfx\ /y /r /s
xcopy "%KMRPrevVersionDir%"\Music "%kam_folder%"\Music\ /y /r /s
xcopy "%KMRPrevVersionDir%"\Campaigns\*.mp3 "%kam_folder%"\Campaigns\ /y /r /s

@REM ============================================================
@REM Erase source-code files from copied "data\"
@REM ============================================================
@REM erase /F /Q /S .\"%kam_folder%"\*.inc

REM ============================================================
REM Copy selected executable files
REM ============================================================
@REM Adding * to the file name supresses the "Is it a file or a folder" query
@REM xcopy ..\data.pack .\"%kam_folder%"\data.pack* /y /r /i
xcopy ..\KaM_Remake.exe "%kam_folder%"\KaM_Remake.exe* /y /r /i
xcopy ..\KM_TextIDs.inc "%kam_folder%"\KM_TextIDs.inc* /y /r /i
xcopy ..\libzplay.dll "%kam_folder%"\libzplay.dll* /y /r /i
xcopy ..\ogg.dll "%kam_folder%"\ogg.dll* /y /r /i
xcopy ..\vorbis.dll "%kam_folder%"\vorbis.dll* /y /r /i
xcopy ..\vorbisfile.dll "%kam_folder%"\vorbisfile.dll* /y /r /i
xcopy "%KMRPrevVersionDir%"\oalinst.exe "%kam_folder%"\oalinst.exe* /y /r /i

mkdir "%kam_folder%"\Utils

@REM copy ScriptingEditor
if %IncludeScriptingEditor%==True (
xcopy "%ScriptingEditorDir%"\bin\ScriptingEditor.exe* "%kam_folder%"\Utils\ScriptingEditor /y /r /i
xcopy "%ScriptingEditorDir%"\bin\SE_Data_KMR "%kam_folder%"\Utils\ScriptingEditor\SE_Data\ /y /r /s
xcopy "%ScriptingEditorDir%"\bin\SE_Data\Examples "%kam_folder%"\Utils\ScriptingEditor\SE_Data\Examples\ /y /r /s
xcopy "..\Utils\ScriptValidator\ScriptValidator.exe" "%kam_folder%"\Utils\ScriptingEditor\SE_Data\ScriptValidator.exe* /y /r /i
@REM no need for OLD folder there
rmdir /S /Q "%kam_folder%"\bin\SE_Data\OLD
rmdir /S /Q "%kam_folder%"\bin\SE_Data\Logs
)

@REM copy utility applications exe files
xcopy "..\Utils\Campaign builder\KaM_Remake_Settings_ini_readme.txt" "%kam_folder%"\Utils\KaM_Remake_Settings_ini_readme.txt* /y /r /i
xcopy "..\Utils\Campaign builder\CampaignBuilder.exe" "%kam_folder%"\Utils\CampaignBuilder.exe* /y /r /i
xcopy "..\Utils\DedicatedServer\KaM_DedicatedServer.exe" "%kam_folder%"\Utils\KaM_Remake_Server_win32.exe* /y /r /i
xcopy "..\Utils\DedicatedServerGUI\KaM_DedicatedServerGUI.exe" "%kam_folder%"\Utils\KaM_Remake_ServerGUI_win32.exe* /y /r /i
xcopy "..\Utils\ScriptValidator\ScriptValidator.exe" "%kam_folder%"\Utils\ScriptValidator.exe* /y /r /i
xcopy "..\Utils\TranslationManager\TranslationManager.exe" "%kam_folder%"\Utils\TranslationManager.exe* /y /r /i
@REM copy linux dedicated servers
xcopy "..\Utils\DedicatedServer\KaM_Remake_Server_linux_x86" "%kam_folder%"\Utils\KaM_Remake_Server_linux_x86* /y /r /i
xcopy "..\Utils\DedicatedServer\KaM_Remake_Server_linux_x86_64" "%kam_folder%"\Utils\KaM_Remake_Server_linux_x86_64* /y /r /i

@REM ============================================================
@REM Copy music files from original KaM TPR game
@REM ============================================================
@REM take music from previous KMR version for now
@REM xcopy "%KaMOrigDir%"\data\sfx\songs\*.sng "%kam_folder%"\Music\*.mp2 /y /r /s

REM ============================================================
REM Copy data folders
REM ============================================================
@REM Copy all data files, except sfx, which should be copied from KMRPrevVersionDir
xcopy ..\data\defines "%kam_folder%"\data\defines\ /y /r /s
xcopy ..\data\gfx "%kam_folder%"\data\gfx\ /y /r /s
xcopy ..\data\Sprites "%kam_folder%"\data\Sprites\ /y /r /s
xcopy ..\data\text "%kam_folder%"\data\text\ /y /r /s
xcopy ..\data\locales.txt "%kam_folder%"\data\locales.txt* /y /r /i
xcopy ..\Campaigns "%kam_folder%"\Campaigns\ /y /r /s
xcopy ..\Maps "%kam_folder%"\Maps\ /y /r /s /exclude:excluded_test_maps.txt
xcopy ..\MapsMP "%kam_folder%"\MapsMP\ /y /r /s
xcopy ..\Tutorials "%kam_folder%"\Tutorials\ /y /r /s
xcopy ..\Docs\Readme "%kam_folder%"\ /y /r /s
xcopy ..\Sounds "%kam_folder%"\Sounds\ /y /r /s
xcopy ..\Music "%kam_folder%"\Music\ /y /r /s
xcopy ..\lib "%kam_folder%"\lib\ /y /r /s

REM ============================================================
REM Copy video files
REM ============================================================
xcopy "%KMRVideosDir%" "%kam_folder%" /y /r /s

REM ============================================================
REM Copy files from KMRPrevVersionDir
REM ============================================================
xcopy "%KMRPrevVersionDir%"\data\sfx "%kam_folder%"\data\sfx\ /y /r /s
xcopy "%KMRPrevVersionDir%"\Music "%kam_folder%"\Music\ /y /r /s
xcopy "%KMRPrevVersionDir%"\Campaigns\*.mp3 "%kam_folder%"\Campaigns\ /y /r /s

@REM ============================================================
@REM Erase source-code files from copied "data\"
@REM ============================================================
@REM erase /F /Q /S .\"%kam_folder%"\*.inc

REM ============================================================
REM Copy selected executable files
REM ============================================================
@REM Adding * to the file name supresses the "Is it a file or a folder" query
@REM xcopy ..\data.pack .\"%kam_folder%"\data.pack* /y /r /i
xcopy ..\KaM_Remake.exe "%kam_folder%"\KaM_Remake.exe* /y /r /i
xcopy ..\libzplay.dll "%kam_folder%"\libzplay.dll* /y /r /i
xcopy ..\ogg.dll "%kam_folder%"\ogg.dll* /y /r /i
xcopy ..\vorbis.dll "%kam_folder%"\vorbis.dll* /y /r /i
xcopy ..\vorbisfile.dll "%kam_folder%"\vorbisfile.dll* /y /r /i
xcopy "%KMRPrevVersionDir%"\oalinst.exe "%kam_folder%"\oalinst.exe* /y /r /i

mkdir "%kam_folder%"\Utils

@REM copy ScriptingEditor
if %IncludeScriptingEditor%==True (
xcopy "%ScriptingEditorDir%"\bin\ScriptingEditor.exe* "%kam_folder%"\Utils\ScriptingEditor /y /r /i
xcopy "%ScriptingEditorDir%"\bin\SE_Data_KMR "%kam_folder%"\Utils\ScriptingEditor\SE_Data\ /y /r /s
xcopy "%ScriptingEditorDir%"\bin\SE_Data\Examples "%kam_folder%"\Utils\ScriptingEditor\SE_Data\Examples\ /y /r /s
xcopy "..\Utils\ScriptValidator\ScriptValidator.exe" "%kam_folder%"\Utils\ScriptingEditor\SE_Data\ScriptValidator.exe* /y /r /i
@REM no need for OLD and Logs folders there
rmdir /S /Q "%kam_folder%"\Utils\ScriptingEditor\SE_Data\OLD
rmdir /S /Q "%kam_folder%"\Utils\ScriptingEditor\SE_Data\Logs
)

@REM copy utility applications exe files
xcopy ..\KM_TextIDs.inc "%kam_folder%"\Utils\KM_TextIDs.inc* /y /r /i
xcopy "..\Utils\Campaign builder\KaM_Remake_Settings_ini_readme.txt" "%kam_folder%"\Utils\KaM_Remake_Settings_ini_readme.txt* /y /r /i
xcopy "..\Utils\Campaign builder\CampaignBuilder.exe" "%kam_folder%"\Utils\CampaignBuilder.exe* /y /r /i
xcopy "..\Utils\DedicatedServer\KaM_DedicatedServer.exe" "%kam_folder%"\Utils\KaM_Remake_Server_win32.exe* /y /r /i
xcopy "..\Utils\DedicatedServerGUI\KaM_DedicatedServerGUI.exe" "%kam_folder%"\Utils\KaM_Remake_ServerGUI_win32.exe* /y /r /i
xcopy "..\Utils\ScriptValidator\ScriptValidator.exe" "%kam_folder%"\Utils\ScriptValidator.exe* /y /r /i
xcopy "..\Utils\TranslationManager\TranslationManager.exe" "%kam_folder%"\Utils\TranslationManager.exe* /y /r /i
@REM copy linux dedicated servers
xcopy "..\Utils\DedicatedServer\KaM_Remake_Server_linux_x86" "%kam_folder%"\Utils\KaM_Remake_Server_linux_x86* /y /r /i
xcopy "..\Utils\DedicatedServer\KaM_Remake_Server_linux_x86_64" "%kam_folder%"\Utils\KaM_Remake_Server_linux_x86_64* /y /r /i

update bat_build script

update bat_build script


@echo off
REM # Copyright 2015 The Android Open Source Project
REM # Copyright (C) 2015 Valve Corporation
REM
REM # Licensed under the Apache License, Version 2.0 (the "License");
REM # you may not use this file except in compliance with the License.
REM # 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, software
REM # distributed under the License is distributed on an "AS IS" BASIS,
REM # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM # See the License for the specific language governing permissions and
REM # limitations under the License.

if exist generated (
  rmdir /s /q generated
)
mkdir generated\include generated\common

python ../vk-generate.py Android dispatch-table-ops layer > generated/include/vk_dispatch_table_helper.h

python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated/include
python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated/include

python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/include/object_tracker.cpp
python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/include/unique_objects.cpp

cd generated/include
python ../../../genvk.py threading -registry ../../../vk.xml thread_check.h
python ../../../genvk.py paramchecker -registry ../../../vk.xml parameter_validation.h
cd ../..

copy /Y ..\layers\vk_layer_config.cpp   generated\common\
copy /Y ..\layers\vk_layer_extension_utils.cpp  generated\common\
copy /Y ..\layers\vk_layer_utils.cpp    generated\common\
copy /Y ..\layers\vk_layer_table.cpp    generated\common\

REM create build-script root directory
mkdir generated\gradle-build
cd generated\gradle-build
mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects
cd ..\..
mkdir generated\layer-src
cd generated\layer-src
mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects
cd ..\..
xcopy /s gradle-templates\*   generated\gradle-build\
for %%G in (core_validation device_limits image parameter_validation swapchain threading) Do (
    copy ..\layers\%%G.cpp   generated\layer-src\%%G
    echo apply from: "../common.gradle"  > generated\gradle-build\%%G\build.gradle
)
copy generated\include\object_tracker.cpp   generated\layer-src\object_tracker
echo apply from: "../common.gradle"  > generated\gradle-build\object_tracker\build.gradle
copy generated\include\unique_objects.cpp   generated\layer-src\unique_objects
copy generated\include\vk_safe_struct.cpp generated\layer-src\core_validation\vk_safe_struct.cpp
move generated\include\vk_safe_struct.cpp generated\layer-src\unique_objects\vk_safe_struct.cpp
echo apply from: "../common.gradle"  > generated\gradle-build\unique_objects\build.gradle

del  /f /q generated\include\object_tracker.cpp
del  /f /q generated\include\unique_objects.cpp

@echo off
REM # Copyright 2015 The Android Open Source Project
REM # Copyright (C) 2015 Valve Corporation
REM
REM # Licensed under the Apache License, Version 2.0 (the "License");
REM # you may not use this file except in compliance with the License.
REM # 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, software
REM # distributed under the License is distributed on an "AS IS" BASIS,
REM # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM # See the License for the specific language governing permissions and
REM # limitations under the License.

if exist generated (
  rmdir /s /q generated
)
mkdir generated\include generated\common

python ../vk-generate.py Android dispatch-table-ops layer > generated/include/vk_dispatch_table_helper.h

python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated/include
python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated/include

python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/include/object_tracker.cpp
python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/include/unique_objects.cpp

cd generated/include
python ../../../genvk.py threading -registry ../../../vk.xml thread_check.h
python ../../../genvk.py paramchecker -registry ../../../vk.xml parameter_validation.h
cd ../..

copy /Y ..\layers\vk_layer_config.cpp   generated\common\
copy /Y ..\layers\vk_layer_extension_utils.cpp  generated\common\
copy /Y ..\layers\vk_layer_utils.cpp    generated\common\
copy /Y ..\layers\vk_layer_table.cpp    generated\common\
copy /Y ..\layers\descriptor_sets.cpp   generated\common\

REM create build-script root directory
mkdir generated\gradle-build
cd generated\gradle-build
mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects
cd ..\..
mkdir generated\layer-src
cd generated\layer-src
mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects
cd ..\..
xcopy /s gradle-templates\*   generated\gradle-build\
for %%G in (core_validation device_limits image parameter_validation swapchain threading) Do (
    copy ..\layers\%%G.cpp   generated\layer-src\%%G
    echo apply from: "../common.gradle"  > generated\gradle-build\%%G\build.gradle
)
copy generated\include\object_tracker.cpp   generated\layer-src\object_tracker
echo apply from: "../common.gradle"  > generated\gradle-build\object_tracker\build.gradle
copy generated\include\unique_objects.cpp   generated\layer-src\unique_objects
copy generated\common\descriptor_sets.cpp generated\layer-src\core_validation\descriptor_sets.cpp
copy generated\include\vk_safe_struct.cpp generated\layer-src\core_validation\vk_safe_struct.cpp
move generated\include\vk_safe_struct.cpp generated\layer-src\unique_objects\vk_safe_struct.cpp
echo apply from: "../common.gradle"  > generated\gradle-build\unique_objects\build.gradle

del  /f /q generated\include\object_tracker.cpp
del  /f /q generated\include\unique_objects.cpp

Fix android-generate.bat

windows: Fix android-generate.bat

Mirror changes made to android-generate.sh in cb9ce9e0


::npm-install.bat
@echo off
::install web server dependencies && game server dependencies
cd web-server && npm install -d && cd .. && cd game-server && npm install -d

add windows install .bat

add windows install .bat

Change-Id: If451d2202d9223a5e42e79aba9bbae7688336d9b


@echo off
echo 'Will change the versions in pom.xml files based on git branch name when doing Jenkins CI build...'

::
:: get git branch_name
::

:: get current git branch name
:: Jenkins will set GIT_BRANCH environment variable if this batch is running in a Jenkins job
goto getbranch_name-2

:getbranch_name-1
if %GIT_BRANCH%==""  (
	echo GIT_BRANCH is NOT defined
	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
) else (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
)

:getbranch_name-2
if defined GIT_BRANCH (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
) else (
 	echo GIT_BRANCH is NOT defined
 	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
)

echo branch_name is %branch_name%

if %branch_name%==dev (
	echo It is dev branch build. Do nothing
	goto end
)

::
:: get current_version in parent pom
::

:: get the pathname of the batch script itself with %0
REM echo %0
:: parameter extensions can be applied to this so %~dp0 will return the Drive and Path to the batch script
REM echo %~dp0
:: %~f0 will return the full pathname
REM echo %~f0
:: You can refer to other files in the same folder as the batch script by using this syntax
:: echo %0\..\SecondBatch.cmd
REM echo %~dp0\access-control-service
:: set the working directory of a command in windows batch file
REM pushd %~dp0\access-control-service

:: WORKSPACE  The absolute path of the workspace if running in a Jenkins job.
:: set the working directory of a command in windows batch file
pushd %WORKSPACE%\DS4P

:: get current version of the top level pom
:: call mvn help:evaluate -Dexpression=project.version
:: for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i
:: run the following line first to have downloading done before next line
call mvn help:evaluate -Dexpression=project.version
:: The following link couldn't excluding Downloading: line
for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i

echo current_version is %current_version%

::
:: get Jenkins BUILD_NUMBER
::

:: Jenkins will set BUILD_NUMBER environment variable if this batch is running in a Jenkins job
if defined BUILD_NUMBER (
 	echo BUILD_NUMBER is defined
) else (
 	set BUILD_NUMBER=0
)

::
:: build new version
::

if %branch_name%==dev (
	echo It is dev branch build
	goto end
) else if %branch_name%==master (
	echo It is master branch build
	:: replace .0-SNAPSHOT with empty and append build number
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%
) else (
	echo It is not master/dev branch
	echo Put the branch name in the qualifier
	:: replace .0-SNAPSHOT with empty, append build number and add branch name as quilifier
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%-%branch_name%
)

echo new_version is %new_version%

:: Sets the current projects version, updating the details of any child modules as necessary.
call mvn versions:set -DgenerateBackupPoms=false -DnewVersion=%new_version%

:: Scans the current projects child modules, updating the versions of any which use the current project to the version of the current project.
::call mvn versions:update-child-modules -DgenerateBackupPoms=false -DnewVersion=%new_version%

:: reset the working directory
popd

:end

@echo off
echo 'Will change the versions in pom.xml files based on git branch name when doing Jenkins CI build...'

::
:: get git branch_name
::

:: get current git branch name
:: Jenkins will set GIT_BRANCH environment variable if this batch is running in a Jenkins job
goto getbranch_name-2

:getbranch_name-1
if %GIT_BRANCH%==""  (
	echo GIT_BRANCH is NOT defined
	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
) else (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
)

:getbranch_name-2
if defined GIT_BRANCH (
 	echo GIT_BRANCH is defined
 	set branch_name=%GIT_BRANCH%
) else (
 	echo GIT_BRANCH is NOT defined
 	for /f %%i in ('"git rev-parse --abbrev-ref HEAD"') do set branch_name=%%i
)

echo branch_name is %branch_name%

if %branch_name%==dev (
	echo It is dev branch build. Do nothing
	goto end
)

::
:: get current_version in parent pom
::

:: get the pathname of the batch script itself with %0
REM echo %0
:: parameter extensions can be applied to this so %~dp0 will return the Drive and Path to the batch script
REM echo %~dp0
:: %~f0 will return the full pathname
REM echo %~f0
:: You can refer to other files in the same folder as the batch script by using this syntax
:: echo %0\..\SecondBatch.cmd
REM echo %~dp0\access-control-service
:: set the working directory of a command in windows batch file
REM pushd %~dp0\access-control-service

:: WORKSPACE  The absolute path of the workspace if running in a Jenkins job.
:: set the working directory of a command in windows batch file
pushd %WORKSPACE%\DS4P

:: get current version of the top level pom
:: call mvn help:evaluate -Dexpression=project.version
:: for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i
:: run the following line first to have downloading done before next line
call mvn help:evaluate -Dexpression=project.version
:: The following link couldn't excluding Downloading: line
for /f %%i in ('"mvn help:evaluate -Dexpression=project.version | grep -v '\[.*'"') do set current_version=%%i

echo current_version is %current_version%

::
:: get Jenkins BUILD_NUMBER
::

:: Jenkins will set BUILD_NUMBER environment variable if this batch is running in a Jenkins job
if defined BUILD_NUMBER (
 	echo BUILD_NUMBER is defined
) else (
 	set BUILD_NUMBER=0
)

::
:: build new version
::

if %branch_name%==dev (
	echo It is dev branch build
	goto end
) else if %branch_name%==master (
	echo It is master branch build
	:: replace .0-SNAPSHOT with empty and append build number
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%
) else (
	echo It is not master/dev branch
	echo Put the branch name in the qualifier
	:: replace .0-SNAPSHOT with empty, append build number and add branch name as quilifier
	set new_version=%current_version:.0-SNAPSHOT=%.%BUILD_NUMBER%-%branch_name%
)

echo new_version is %new_version%

:: Sets the current projects version, updating the details of any child modules as necessary.
call mvn versions:set -DgenerateBackupPoms=false -DnewVersion=%new_version%

:: Scans the current projects child modules, updating the versions of any which use the current project to the version of the current project.
::call mvn versions:update-child-modules -DgenerateBackupPoms=false -DnewVersion=%new_version%

::
:: generate a version properties file to be used by Jenkins Enviorenment Injector Plugin to generate a Jenkins PROJECT_VERSION environment variable
::

echo PROJECT_VERSION=%new_version% > version.properties

:: reset the working directory
popd

:end

Update updatePomVesions.bat to create version.properties file


@echo off

set SYS_FILE_NAME=vioscsi

if "%1_%2" neq "_" goto %1_%2
for %%A in (Win8 Win7 Wlh) do for %%B in (32 64) do call :%%A_%%B
set SYS_FILE_NAME=
goto :eof

:buildsys
call buildOne.bat %1 %2
goto :eof

:packsys
call packOne.bat %1 %2 %SYS_FILE_NAME%
goto :eof

:buildpack
call :buildsys %1 %2
call :packsys %1 %2
set BUILD_OS=
set BUILD_ARC=
goto :eof

:create2012H
echo #define _NT_TARGET_MAJ %_NT_TARGET_MAJ%
echo #define _NT_TARGET_MIN %_NT_TARGET_MIN%
echo #define _MAJORVERSION_ %_MAJORVERSION_%
echo #define _MINORVERSION_ %_MINORVERSION_%
goto :eof

:BuildUsing2012
if exist vioscsi-2012.h del vioscsi-2012.h
setlocal
if "%_NT_TARGET_VERSION%"=="" set _NT_TARGET_VERSION=0x602
if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101
if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000
if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61

set _MAJORVERSION_=%_BUILD_MAJOR_VERSION_%
set _MINORVERSION_=%_BUILD_MINOR_VERSION_%
set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)"
set _NT_TARGET_MIN=%_RHEL_RELEASE_VERSION_%
call :create2012H  > vioscsi-2012.h
set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_%
call ..\tools\callVisualStudio.bat 12 vioscsi.vcxproj /Rebuild "%~1" /Out %2
endlocal
goto :eof

:StaticDriverVerifier2012
setlocal
if "%_NT_TARGET_VERSION%"=="" set _NT_TARGET_VERSION=0x602
if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101
if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000
if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61

set _MAJORVERSION_=%_BUILD_MAJOR_VERSION_%
set _MINORVERSION_=%_BUILD_MINOR_VERSION_%
set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)"
set _NT_TARGET_MIN=%_RHEL_RELEASE_VERSION_%

set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_%
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %2
msbuild.exe vioscsi.vcxproj /t:clean /p:Configuration="%~1" /P:Platform=%2
msbuild.exe vioscsi.vcxproj /t:sdv /p:inputs="/clean" /p:Configuration="%~1" /P:platform=%2
msbuild.exe vioscsi.vcxproj /p:Configuration="%~1" /P:Platform=%2 /P:RunCodeAnalysisOnce=True
msbuild.exe vioscsi.vcxproj /t:sdv /p:inputs="/devenv /check" /p:Configuration="%~1" /P:platform=%2
msbuild.exe vioscsi.vcxproj /t:dvl /p:Configuration="%~1" /P:platform=%2
endlocal
goto :eof

:WIN8_32
setlocal
set BUILD_OS=Win8
set BUILD_ARC=x86
rem set INF2CAT_PATH=

if exist Install\win8\x86 rmdir Install\win8\x86 /s /q
call :BuildUsing2012 "Win8 Release|Win32" buildfre_win8_x86.log
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
endlocal
goto :eof

:WIN8_64
setlocal
set BUILD_OS=Win8
set BUILD_ARC=x64
rem set INF2CAT_PATH=

if exist Install\win8\amd64 rmdir Install\win8\amd64 /s /q
call :BuildUsing2012 "Win8 Release|x64" buildfre_win8_amd64.log
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
if "%_BUILD_DISABLE_SDV%"=="" goto :DO_SDV
endlocal
goto :eof

:DO_SDV
call :StaticDriverVerifier2012 "Win8 Release" %BUILD_ARC%
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
rmdir /S /Q .\sdv
endlocal
goto :eof

:WLH_64
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x64
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WLH_32
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x86
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WIN7_64
setlocal
set BUILD_OS=Win7
set BUILD_ARC=x64
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WIN7_32
setlocal
set BUILD_OS=Win7
set BUILD_ARC=x86
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:eof

@echo off

set SYS_FILE_NAME=vioscsi

if "%1_%2" neq "_" goto %1_%2
for %%A in (Wlh Win7 Win8 Win10) do for %%B in (32 64) do call :%%A_%%B
set SYS_FILE_NAME=
goto :eof

:buildsys
call buildOne.bat %1 %2
goto :eof

:packsys
call packOne.bat %1 %2 %SYS_FILE_NAME%
goto :eof

:buildpack
call :buildsys %1 %2
call :packsys %1 %2
set BUILD_OS=
set BUILD_ARC=
goto :eof

:create2012H
echo #define _NT_TARGET_MAJ %_NT_TARGET_MAJ%
echo #define _NT_TARGET_MIN %_NT_TARGET_MIN%
echo #define _MAJORVERSION_ %_MAJORVERSION_%
echo #define _MINORVERSION_ %_MINORVERSION_%
goto :eof

:BuildUsing2012
if exist vioscsi-2012.h del vioscsi-2012.h
setlocal
if "%_NT_TARGET_VERSION%"=="" set _NT_TARGET_VERSION=0x602
if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101
if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000
if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61

set _MAJORVERSION_=%_BUILD_MAJOR_VERSION_%
set _MINORVERSION_=%_BUILD_MINOR_VERSION_%
set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)"
set _NT_TARGET_MIN=%_RHEL_RELEASE_VERSION_%
call :create2012H  > vioscsi-2012.h
set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_%
call ..\tools\callVisualStudio.bat 12 vioscsi.vcxproj /Rebuild "%~1" /Out %2
endlocal
goto :eof

:StaticDriverVerifier2012
setlocal
if "%_NT_TARGET_VERSION%"=="" set _NT_TARGET_VERSION=0x602
if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101
if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000
if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61

set _MAJORVERSION_=%_BUILD_MAJOR_VERSION_%
set _MINORVERSION_=%_BUILD_MINOR_VERSION_%
set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)"
set _NT_TARGET_MIN=%_RHEL_RELEASE_VERSION_%

set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_%
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %2
msbuild.exe vioscsi.vcxproj /t:clean /p:Configuration="%~1" /P:Platform=%2
msbuild.exe vioscsi.vcxproj /t:sdv /p:inputs="/clean" /p:Configuration="%~1" /P:platform=%2
msbuild.exe vioscsi.vcxproj /p:Configuration="%~1" /P:Platform=%2 /P:RunCodeAnalysisOnce=True
msbuild.exe vioscsi.vcxproj /t:sdv /p:inputs="/devenv /check" /p:Configuration="%~1" /P:platform=%2
msbuild.exe vioscsi.vcxproj /t:dvl /p:Configuration="%~1" /P:platform=%2
endlocal
goto :eof

:WIN8_32
setlocal
set BUILD_OS=Win8
set BUILD_ARC=x86
rem set INF2CAT_PATH=

if exist Install\win8\x86 rmdir Install\win8\x86 /s /q
call :BuildUsing2012 "Win8 Release|Win32" buildfre_win8_x86.log
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
endlocal
goto :eof

:WIN8_64
setlocal
set BUILD_OS=Win8
set BUILD_ARC=x64
rem set INF2CAT_PATH=

if exist Install\win8\amd64 rmdir Install\win8\amd64 /s /q
call :BuildUsing2012 "Win8 Release|x64" buildfre_win8_amd64.log
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
if "%_BUILD_DISABLE_SDV%"=="" goto :DO_SDV
endlocal
goto :eof

:DO_SDV
call :StaticDriverVerifier2012 "Win8 Release" %BUILD_ARC%
call packOne.bat %BUILD_OS% %BUILD_ARC% %SYS_FILE_NAME%
rmdir /S /Q .\sdv
endlocal
goto :eof

:WLH_64
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x64
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WLH_32
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x86
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WIN7_64
setlocal
set BUILD_OS=Win7
set BUILD_ARC=x64
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WLH_64
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x64
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:WLH_32
setlocal
set BUILD_OS=Wlh
set BUILD_ARC=x86
call :buildpack %BUILD_OS% %BUILD_ARC%
endlocal
goto :eof

:eof

add legacy build targets

add legacy build targets


Include collecting Newtonsoft.Json package


@echo off
setlocal

pushd %~dp0\..

if not "%APPVEYOR%" == "" (
	set ELECTRON_RUN_AS_NODE=
)
set VSCODEUSERDATADIR=%TMP%\vscodeuserfolder-%RANDOM%-%TIME:~6,5%

:: Tests in the extension host
.\scripts\code.bat %~dp0\..\extensions\vscode-api-tests\testWorkspace --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out --disableExtensions --user-data-dir=%VSCODEUSERDATADIR%
.\scripts\code.bat %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --user-data-dir=%VSCODEUSERDATADIR%
.\scripts\code.bat $%~dp0\..\extensions\emmet\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disableExtensions --user-data-dir=%VSCODEUSERDATADIR%

:: Integration & performance tests in AMD
.\scripts\test.bat --runGlob **\*.integrationTest.js %*

:: Tests in commonJS (language servers tests...)
.\scripts\mocha-electron.bat .\extensions\html\server\out\test\

rmdir /s /q %VSCODEUSERDATADIR%

popd

endlocal

@echo off
setlocal

pushd %~dp0\..

if not "%APPVEYOR%" == "" (
	set ELECTRON_RUN_AS_NODE=
)
set VSCODEUSERDATADIR=%TMP%\vscodeuserfolder-%RANDOM%-%TIME:~6,5%

:: Tests in the extension host
call .\scripts\code.bat %~dp0\..\extensions\vscode-api-tests\testWorkspace --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out --disableExtensions --user-data-dir=%VSCODEUSERDATADIR%
call .\scripts\code.bat %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --disableExtensions --user-data-dir=%VSCODEUSERDATADIR%
call .\scripts\code.bat $%~dp0\..\extensions\emmet\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disableExtensions --user-data-dir=%VSCODEUSERDATADIR%

:: Integration & performance tests in AMD
call .\scripts\test.bat --runGlob **\*.integrationTest.js %*

:: Tests in commonJS (language servers tests...)
call .\scripts\node-electron.bat .\node_modules\mocha\bin\_mocha .\extensions\html\server\out\test\

rmdir /s /q %VSCODEUSERDATADIR%

popd

endlocal

Improve test-integration.bat

Improve test-integration.bat


emcc -c -o blog_code.bc blog_code.c
emcc -c -o ../fake_lib/fake_os.bc ../fake_lib/fake_os.c
emcc -o ../current_build.js ../fake_lib/fake_os.bc blog_code.bc

Create build.bat

Create build.bat