@ECHO OFF & SETLOCAL EnableDelayedExpansion
TITLE arkenfox user.js updater

REM ## arkenfox user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 4.14
REM ## instructions: https://github.com/arkenfox/user.js/wiki/3.3-Updater-Scripts

SET v=4.14

VERIFY ON
CD /D "%~dp0"
SET _myname=%~n0
SET _myparams=%*

:parse
IF "%~1"=="" (GOTO endparse)
IF /I "%~1"=="-unattended" (SET _ua=1)
IF /I "%~1"=="-log" (SET _log=1)
IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1)
IF /I "%~1"=="-multioverrides" (SET _multi=1)
IF /I "%~1"=="-merge" (SET _merge=1)
IF /I "%~1"=="-updatebatch" (SET _updateb=1)
IF /I "%~1"=="-singlebackup" (SET _singlebackup=1)
IF /I "%~1"=="-esr" (SET _esr=1)
IF /I "%~1"=="-rfpalts" (SET _rfpalts=1)
SHIFT
GOTO parse
:endparse

FOR /F %%i IN ('PowerShell -Command "[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'"') DO (
	IF "%%i" == "False" (
		CALL :message "Your PowerShell version doesn't support TLS1.2 ^!"
		ECHO:  Instructions to update PowerShell are on the arkenfox wiki
		PAUSE
		EXIT
	)
)

IF DEFINED _updateb (
	REM The normal flow here goes from phase 1 to phase 2 and then phase 3.
	IF NOT "!_myname:~0,9!"=="[updated]" (
		IF EXIST "[updated]!_myname!.bat" (
			REM ## Phase 3 ##: The new script, with the original name, will:
			REM 	* Delete the [updated]*.bat and *.bat.old scripts
			REM 	* Begin the normal routine
			FC "[updated]!_myname!.bat" "!_myname!.bat.old" >nul
			IF NOT "!errorlevel!"=="0" (
				CALL :message "Script updated to version !v!"
				TIMEOUT 3 >nul
			)
			REN "[updated]!_myname!.bat" "[updated]!_myname!.bat.old"
			DEL /F "!_myname!.bat.old" "[updated]!_myname!.bat.old"
			GOTO begin
		)
		REM ## Phase 1 ##
		REM 	* Download new batch and name it [updated]*.bat
		REM 	* Start that script in a new CMD window
		REM 	* Exit
		CALL :message "Updating script..."
		REM Uncomment the next line and comment out the PowerShell call for testing.
		REM COPY /B /Y "!_myname!.bat" "[updated]!_myname!.bat" >nul
		CALL :psdownload https://raw.githubusercontent.com/arkenfox/user.js/master/updater.bat "[updated]!_myname!.bat"
		IF EXIST "[updated]!_myname!.bat" (
			START /min CMD /C "[updated]!_myname!.bat" !_myparams!
		) ELSE (
			CALL :message "Failed. Make sure PowerShell is allowed internet access."
			TIMEOUT 120 >nul
		)
	) ELSE (
		IF "!_myname!"=="[updated]" (
			CALL :message "The [updated] label is reserved. Rename this script and try again."
			TIMEOUT 300 >nul
		) ELSE (
			REM ## Phase 2 ##: The [updated]*.bat script will:
			REM 	* Rename the old script and make a copy of itself with the original name.
			REM 	* Run that copy in a new CMD instance
			REM 	* Exit
			IF EXIST "!_myname:~9!.bat" ( REN "!_myname:~9!.bat" "!_myname:~9!.bat.old" )
			COPY /B /Y "!_myname!.bat" "!_myname:~9!.bat"
			START CMD /C "!_myname:~9!.bat" !_myparams!
		)
	)
	EXIT /B
)

:begin
CLS
ECHO:
ECHO:
ECHO:                ########################################
ECHO:                ####  user.js Updater for Windows   ####
ECHO:                ####       by claustromaniac        ####
ECHO:                ####             v!v!              ####
ECHO:                ########################################
ECHO:
SET /A "_line=0"
IF NOT EXIST user.js (
	CALL :message "user.js not detected in the current directory."
) ELSE (
	FOR /F "skip=1 tokens=1,* delims=:" %%G IN (user.js) DO (
		SET /A "_line+=1"
		IF !_line! GEQ 4 (GOTO exitloop)
		IF !_line! EQU 1 (SET _name=%%H)
		IF !_line! EQU 2 (SET _date=%%H)
		IF !_line! EQU 3 (SET _version=%%G)
	)
	:exitloop
	IF NOT "!_name!"=="" (
		SET "_tempvar="
		IF /I NOT "!_name!"=="!_name:ghacks=!" SET _tempvar=1
		IF /I NOT "!_name!"=="!_name:arkenfox=!" SET _tempvar=1
		IF !_tempvar! EQU 1 (
			CALL :message "!_name! !_version:~2!,!_date!"
		) ELSE (CALL :message "Current user.js version not recognised.")
	) ELSE (CALL :message "Current user.js version not recognised.")
)
ECHO:
IF NOT DEFINED _ua (
	CALL :message "This batch should be run from your Firefox profile directory."
	ECHO:  It will download the latest version of arkenfox user.js from github and then
	CALL :message "append any of your own changes from user-overrides.js to it."
	CALL :message "Visit the wiki for more detailed information."
	ECHO:
	TIMEOUT 1 /nobreak >nul
	CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]"
	CLS
	IF ERRORLEVEL 3 (EXIT /B)
	IF ERRORLEVEL 2 (GOTO :showhelp)
)
IF DEFINED _log (
	CALL :log >>user.js-update-log.txt 2>&1
	IF DEFINED _logp (START user.js-update-log.txt)
	EXIT /B
	:log
	SET _log=2
	ECHO:##################################################################
	ECHO:  %date%, %time%
)
IF EXIST user.js.new (DEL /F "user.js.new")
CALL :message "Retrieving latest user.js file from github repository..."
CALL :psdownload https://raw.githubusercontent.com/arkenfox/user.js/master/user.js "user.js.new"
IF EXIST user.js.new (
	IF DEFINED _rfpalts (
		CALL :message "Activating RFP Alternatives section..."
		CALL :activate user.js.new "[SETUP-non-RFP]"
	)
	IF DEFINED _esr (
		CALL :message "Activating ESR section..."
		CALL :activate user.js.new ".x still uses all the following prefs"
	)
	IF DEFINED _multi (
		FORFILES /P user.js-overrides /M *.js >nul 2>&1
		IF NOT ERRORLEVEL 1 (
			IF DEFINED _merge (
				CALL :message "Merging..."
				COPY /B /Y user.js-overrides\*.js user-overrides-merged.js
				CALL :merge user-overrides-merged.js
				COPY /B /Y user.js.new+user-overrides-merged.js user.js.new
				CALL :merge user.js.new
			) ELSE (
				CALL :message "Appending..."
				COPY /B /Y user.js.new+"user.js-overrides\*.js" user.js.new
			)
		) ELSE (CALL :message "No override files found.")
	) ELSE (
		IF EXIST "user-overrides.js" (
			COPY /B /Y user.js.new+"user-overrides.js" "user.js.new"
			IF DEFINED _merge (
				CALL :message "Merging user-overrides.js..."
				CALL :merge user.js.new
			) ELSE (
				CALL :message "user-overrides.js appended."
			)
		) ELSE (CALL :message "user-overrides.js not found.")
	)
	IF EXIST user.js (
		FC user.js.new user.js >nul && SET "_changed=false" || SET "_changed=true"
	)
	IF "!_changed!"=="true" (
		CALL :message "Backing up..."
		IF DEFINED _singlebackup (
			MOVE /Y user.js user.js.bak >nul
		) ELSE (
			SET "_time=!time: =0!"
			MOVE /Y user.js "user-backup-!date:/=-!_!_time::=.!.js" >nul
		)
		REN user.js.new user.js
		CALL :message "Update complete."
	) ELSE (
		IF "!_changed!"=="false" (
			DEL /F user.js.new >nul
			CALL :message "Update completed without changes."
		) ELSE (
			REN user.js.new user.js
			CALL :message "Update complete."
			SET "_changed=true"
		)
	)
) ELSE (
	CALL :message "Update failed. Make sure PowerShell is allowed internet access."
	ECHO:  No changes were made.
)
IF NOT DEFINED _log (
	IF NOT DEFINED _ua (
		IF EXIST prefsCleaner.bat (
			IF "!_changed!"=="true" (
				CALL :message "Would you like to run the prefsCleaner now?"
				CHOICE /C YN /N /M "(Y/N) "
				IF "1"=="!errorlevel!" ( START "" cmd.exe /C "prefsCleaner.bat" )
			) ELSE (PAUSE)
		) ELSE (PAUSE)
	)
)
EXIT /B

::::::::::::::: Message :::::::::::::::
:message
SETLOCAL DisableDelayedExpansion
IF NOT "2"=="%_log%" (ECHO:)
ECHO:  %~1
IF NOT "2"=="%_log%" (ECHO:)
ENDLOCAL
GOTO :EOF

::::::::::::::: Download :::::::::::::::
:psdownload
(
	PowerShell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('%~1', '%~2')"
) >nul 2>&1
GOTO :EOF

::::::::::::::: Activate Section :::::::::::::::
:activate
:: arg1 = file
:: arg2 = line substring
SETLOCAL DisableDelayedExpansion
(
	FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" "%~1"') DO (
		SET "_temp=%%H"
		SETLOCAL EnableDelayedExpansion
		IF "!_temp:%~2=!"=="!_temp!" (
			ENDLOCAL & ECHO:%%H
		) ELSE (
			ECHO://!_temp:~2!
			ENDLOCAL
		)
	)
)>updatertempfile
MOVE /Y updatertempfile "%~1" >nul
ENDLOCAL
GOTO :EOF

::::::::::::::: Merge :::::::::::::::
:merge
SETLOCAL DisableDelayedExpansion
FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^user_pref[ 	]*\([ 	]*[\"'].*[\"'][ 	]*,.*\)[ 	]*;" "%~1"') DO (SET "[%%G]=%%H")
FOR /F tokens^=2^,^*^ delims^=^' %%G IN ('FINDSTR /R /C:"^//// --- comment-out --- '[^'][^']*'.*" "%~1"') DO (SET "__unset__%%G=1")
(
	FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO (
		SET "_temp=%%J"
		SETLOCAL EnableDelayedExpansion
		IF NOT "!_temp:~0,9!"=="user_pref" (
			ENDLOCAL & ECHO:%%J
		) ELSE (
			IF "!_temp:;=!"=="!_temp!" (
				ENDLOCAL & ECHO:%%J
			) ELSE (
				ENDLOCAL
				FOR /F tokens^=2^ delims^=^'^" %%K IN ("%%J") DO (
					IF NOT "_user.js.parrot"=="%%K" (
						IF DEFINED __unset__%%K (
							ECHO://%%J
						) ELSE (
							IF DEFINED [%%K] (
								SETLOCAL EnableDelayedExpansion
								FOR /F "delims=" %%L IN ("![%%K]!") DO (
									ENDLOCAL & ECHO:user_pref("%%K"%%L
									SET "[%%K]="
								)
							)
						)
					) ELSE (ECHO:%%J)
				)
			)
		)
	)
)>updatertempfile
MOVE /Y updatertempfile "%~1" >nul
ENDLOCAL
GOTO :EOF

::::::::::::::: Help :::::::::::::::
:showhelp
MODE 80,54
CLS
CALL :message "Available arguments (case-insensitive):"
CALL :message "  -esr"
ECHO:     Activate ESR related preferences
CALL :message "  -log"
ECHO:     Write the console output to a logfile (user.js-update-log.txt)
CALL :message "  -logP"
ECHO:     Like -log, but also open the logfile after updating.
CALL :message "  -merge"
ECHO:     Merge overrides instead of appending them. Single-line comments and
ECHO:     _user.js.parrot lines are appended normally. Overrides for inactive
ECHO:     user.js prefs will be appended. When -Merge and -MultiOverrides are used
ECHO:     together, a user-overrides-merged.js file is also generated in the root
ECHO:     directory for quick reference. It contains only the merged data from
ECHO:     override files and can be safely discarded after updating, or used as the
ECHO:     new user-overrides.js. When there are conflicting records for the same
ECHO:     pref, the value of the last one declared will be used. Visit the wiki
ECHO:     for usage examples and more detailed information.
CALL :message "  -multiOverrides"
ECHO:     Use any and all .js files in a user.js-overrides sub-folder as overrides
ECHO:     instead of the default user-overrides.js file. Files are appended in
ECHO:     alphabetical order.
CALL :message "  -unattended"
ECHO:     Run without user input.
CALL :message "  -singleBackup"
ECHO:     Use a single backup file and overwrite it on new updates, instead of
ECHO:     cumulative backups. This was the default behaviour before v4.3.
CALL :message "  -rfpAlts"
ECHO:     Activate RFP Alternatives section
CALL :message "  -updateBatch"
ECHO:     Update the script itself on execution, before the normal routine.
CALL :message ""
PAUSE
MODE 80,25
GOTO :begin

@ECHO OFF & SETLOCAL EnableDelayedExpansion
TITLE arkenfox user.js updater

REM ## arkenfox user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 4.15
REM ## instructions: https://github.com/arkenfox/user.js/wiki/3.3-Updater-Scripts

SET v=4.15

VERIFY ON
CD /D "%~dp0"
SET _myname=%~n0
SET _myparams=%*

:parse
IF "%~1"=="" (GOTO endparse)
IF /I "%~1"=="-unattended" (SET _ua=1)
IF /I "%~1"=="-log" (SET _log=1)
IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1)
IF /I "%~1"=="-multioverrides" (SET _multi=1)
IF /I "%~1"=="-merge" (SET _merge=1)
IF /I "%~1"=="-updatebatch" (SET _updateb=1)
IF /I "%~1"=="-singlebackup" (SET _singlebackup=1)
IF /I "%~1"=="-esr" (SET _esr=1)
SHIFT
GOTO parse
:endparse

FOR /F %%i IN ('PowerShell -Command "[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'"') DO (
	IF "%%i" == "False" (
		CALL :message "Your PowerShell version doesn't support TLS1.2 ^!"
		ECHO:  Instructions to update PowerShell are on the arkenfox wiki
		PAUSE
		EXIT
	)
)

IF DEFINED _updateb (
	REM The normal flow here goes from phase 1 to phase 2 and then phase 3.
	IF NOT "!_myname:~0,9!"=="[updated]" (
		IF EXIST "[updated]!_myname!.bat" (
			REM ## Phase 3 ##: The new script, with the original name, will:
			REM 	* Delete the [updated]*.bat and *.bat.old scripts
			REM 	* Begin the normal routine
			FC "[updated]!_myname!.bat" "!_myname!.bat.old" >nul
			IF NOT "!errorlevel!"=="0" (
				CALL :message "Script updated to version !v!"
				TIMEOUT 3 >nul
			)
			REN "[updated]!_myname!.bat" "[updated]!_myname!.bat.old"
			DEL /F "!_myname!.bat.old" "[updated]!_myname!.bat.old"
			GOTO begin
		)
		REM ## Phase 1 ##
		REM 	* Download new batch and name it [updated]*.bat
		REM 	* Start that script in a new CMD window
		REM 	* Exit
		CALL :message "Updating script..."
		REM Uncomment the next line and comment out the PowerShell call for testing.
		REM COPY /B /Y "!_myname!.bat" "[updated]!_myname!.bat" >nul
		CALL :psdownload https://raw.githubusercontent.com/arkenfox/user.js/master/updater.bat "[updated]!_myname!.bat"
		IF EXIST "[updated]!_myname!.bat" (
			START /min CMD /C "[updated]!_myname!.bat" !_myparams!
		) ELSE (
			CALL :message "Failed. Make sure PowerShell is allowed internet access."
			TIMEOUT 120 >nul
		)
	) ELSE (
		IF "!_myname!"=="[updated]" (
			CALL :message "The [updated] label is reserved. Rename this script and try again."
			TIMEOUT 300 >nul
		) ELSE (
			REM ## Phase 2 ##: The [updated]*.bat script will:
			REM 	* Rename the old script and make a copy of itself with the original name.
			REM 	* Run that copy in a new CMD instance
			REM 	* Exit
			IF EXIST "!_myname:~9!.bat" ( REN "!_myname:~9!.bat" "!_myname:~9!.bat.old" )
			COPY /B /Y "!_myname!.bat" "!_myname:~9!.bat"
			START CMD /C "!_myname:~9!.bat" !_myparams!
		)
	)
	EXIT /B
)

:begin
CLS
ECHO:
ECHO:
ECHO:                ########################################
ECHO:                ####  user.js Updater for Windows   ####
ECHO:                ####       by claustromaniac        ####
ECHO:                ####             v!v!              ####
ECHO:                ########################################
ECHO:
SET /A "_line=0"
IF NOT EXIST user.js (
	CALL :message "user.js not detected in the current directory."
) ELSE (
	FOR /F "skip=1 tokens=1,* delims=:" %%G IN (user.js) DO (
		SET /A "_line+=1"
		IF !_line! GEQ 4 (GOTO exitloop)
		IF !_line! EQU 1 (SET _name=%%H)
		IF !_line! EQU 2 (SET _date=%%H)
		IF !_line! EQU 3 (SET _version=%%G)
	)
	:exitloop
	IF NOT "!_name!"=="" (
		SET "_tempvar="
		IF /I NOT "!_name!"=="!_name:ghacks=!" SET _tempvar=1
		IF /I NOT "!_name!"=="!_name:arkenfox=!" SET _tempvar=1
		IF !_tempvar! EQU 1 (
			CALL :message "!_name! !_version:~2!,!_date!"
		) ELSE (CALL :message "Current user.js version not recognised.")
	) ELSE (CALL :message "Current user.js version not recognised.")
)
ECHO:
IF NOT DEFINED _ua (
	CALL :message "This batch should be run from your Firefox profile directory."
	ECHO:  It will download the latest version of arkenfox user.js from github and then
	CALL :message "append any of your own changes from user-overrides.js to it."
	CALL :message "Visit the wiki for more detailed information."
	ECHO:
	TIMEOUT 1 /nobreak >nul
	CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]"
	CLS
	IF ERRORLEVEL 3 (EXIT /B)
	IF ERRORLEVEL 2 (GOTO :showhelp)
)
IF DEFINED _log (
	CALL :log >>user.js-update-log.txt 2>&1
	IF DEFINED _logp (START user.js-update-log.txt)
	EXIT /B
	:log
	SET _log=2
	ECHO:##################################################################
	ECHO:  %date%, %time%
)
IF EXIST user.js.new (DEL /F "user.js.new")
CALL :message "Retrieving latest user.js file from github repository..."
CALL :psdownload https://raw.githubusercontent.com/arkenfox/user.js/master/user.js "user.js.new"
IF EXIST user.js.new (
	IF DEFINED _esr (
		CALL :message "Activating ESR section..."
		CALL :activate user.js.new ".x still uses all the following prefs"
	)
	IF DEFINED _multi (
		FORFILES /P user.js-overrides /M *.js >nul 2>&1
		IF NOT ERRORLEVEL 1 (
			IF DEFINED _merge (
				CALL :message "Merging..."
				COPY /B /Y user.js-overrides\*.js user-overrides-merged.js
				CALL :merge user-overrides-merged.js
				COPY /B /Y user.js.new+user-overrides-merged.js user.js.new
				CALL :merge user.js.new
			) ELSE (
				CALL :message "Appending..."
				COPY /B /Y user.js.new+"user.js-overrides\*.js" user.js.new
			)
		) ELSE (CALL :message "No override files found.")
	) ELSE (
		IF EXIST "user-overrides.js" (
			COPY /B /Y user.js.new+"user-overrides.js" "user.js.new"
			IF DEFINED _merge (
				CALL :message "Merging user-overrides.js..."
				CALL :merge user.js.new
			) ELSE (
				CALL :message "user-overrides.js appended."
			)
		) ELSE (CALL :message "user-overrides.js not found.")
	)
	IF EXIST user.js (
		FC user.js.new user.js >nul && SET "_changed=false" || SET "_changed=true"
	)
	IF "!_changed!"=="true" (
		CALL :message "Backing up..."
		IF DEFINED _singlebackup (
			MOVE /Y user.js user.js.bak >nul
		) ELSE (
			SET "_time=!time: =0!"
			MOVE /Y user.js "user-backup-!date:/=-!_!_time::=.!.js" >nul
		)
		REN user.js.new user.js
		CALL :message "Update complete."
	) ELSE (
		IF "!_changed!"=="false" (
			DEL /F user.js.new >nul
			CALL :message "Update completed without changes."
		) ELSE (
			REN user.js.new user.js
			CALL :message "Update complete."
			SET "_changed=true"
		)
	)
) ELSE (
	CALL :message "Update failed. Make sure PowerShell is allowed internet access."
	ECHO:  No changes were made.
)
IF NOT DEFINED _log (
	IF NOT DEFINED _ua (
		IF EXIST prefsCleaner.bat (
			IF "!_changed!"=="true" (
				CALL :message "Would you like to run the prefsCleaner now?"
				CHOICE /C YN /N /M "(Y/N) "
				IF "1"=="!errorlevel!" ( START "" cmd.exe /C "prefsCleaner.bat" )
			) ELSE (PAUSE)
		) ELSE (PAUSE)
	)
)
EXIT /B

::::::::::::::: Message :::::::::::::::
:message
SETLOCAL DisableDelayedExpansion
IF NOT "2"=="%_log%" (ECHO:)
ECHO:  %~1
IF NOT "2"=="%_log%" (ECHO:)
ENDLOCAL
GOTO :EOF

::::::::::::::: Download :::::::::::::::
:psdownload
(
	PowerShell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('%~1', '%~2')"
) >nul 2>&1
GOTO :EOF

::::::::::::::: Activate Section :::::::::::::::
:activate
:: arg1 = file
:: arg2 = line substring
SETLOCAL DisableDelayedExpansion
(
	FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" "%~1"') DO (
		SET "_temp=%%H"
		SETLOCAL EnableDelayedExpansion
		IF "!_temp:%~2=!"=="!_temp!" (
			ENDLOCAL & ECHO:%%H
		) ELSE (
			ECHO://!_temp:~2!
			ENDLOCAL
		)
	)
)>updatertempfile
MOVE /Y updatertempfile "%~1" >nul
ENDLOCAL
GOTO :EOF

::::::::::::::: Merge :::::::::::::::
:merge
SETLOCAL DisableDelayedExpansion
FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^user_pref[ 	]*\([ 	]*[\"'].*[\"'][ 	]*,.*\)[ 	]*;" "%~1"') DO (SET "[%%G]=%%H")
FOR /F tokens^=2^,^*^ delims^=^' %%G IN ('FINDSTR /R /C:"^//// --- comment-out --- '[^'][^']*'.*" "%~1"') DO (SET "__unset__%%G=1")
(
	FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO (
		SET "_temp=%%J"
		SETLOCAL EnableDelayedExpansion
		IF NOT "!_temp:~0,9!"=="user_pref" (
			ENDLOCAL & ECHO:%%J
		) ELSE (
			IF "!_temp:;=!"=="!_temp!" (
				ENDLOCAL & ECHO:%%J
			) ELSE (
				ENDLOCAL
				FOR /F tokens^=2^ delims^=^'^" %%K IN ("%%J") DO (
					IF NOT "_user.js.parrot"=="%%K" (
						IF DEFINED __unset__%%K (
							ECHO://%%J
						) ELSE (
							IF DEFINED [%%K] (
								SETLOCAL EnableDelayedExpansion
								FOR /F "delims=" %%L IN ("![%%K]!") DO (
									ENDLOCAL & ECHO:user_pref("%%K"%%L
									SET "[%%K]="
								)
							)
						)
					) ELSE (ECHO:%%J)
				)
			)
		)
	)
)>updatertempfile
MOVE /Y updatertempfile "%~1" >nul
ENDLOCAL
GOTO :EOF

::::::::::::::: Help :::::::::::::::
:showhelp
MODE 80,54
CLS
CALL :message "Available arguments (case-insensitive):"
CALL :message "  -esr"
ECHO:     Activate ESR related preferences
CALL :message "  -log"
ECHO:     Write the console output to a logfile (user.js-update-log.txt)
CALL :message "  -logP"
ECHO:     Like -log, but also open the logfile after updating.
CALL :message "  -merge"
ECHO:     Merge overrides instead of appending them. Single-line comments and
ECHO:     _user.js.parrot lines are appended normally. Overrides for inactive
ECHO:     user.js prefs will be appended. When -Merge and -MultiOverrides are used
ECHO:     together, a user-overrides-merged.js file is also generated in the root
ECHO:     directory for quick reference. It contains only the merged data from
ECHO:     override files and can be safely discarded after updating, or used as the
ECHO:     new user-overrides.js. When there are conflicting records for the same
ECHO:     pref, the value of the last one declared will be used. Visit the wiki
ECHO:     for usage examples and more detailed information.
CALL :message "  -multiOverrides"
ECHO:     Use any and all .js files in a user.js-overrides sub-folder as overrides
ECHO:     instead of the default user-overrides.js file. Files are appended in
ECHO:     alphabetical order.
CALL :message "  -unattended"
ECHO:     Run without user input.
CALL :message "  -singleBackup"
ECHO:     Use a single backup file and overwrite it on new updates, instead of
ECHO:     cumulative backups. This was the default behaviour before v4.3.
CALL :message "  -updateBatch"
ECHO:     Update the script itself on execution, before the normal routine.
CALL :message ""
PAUSE
MODE 80,25
GOTO :begin

remove rfpalts (#1288)

remove rfpalts (#1288)


create success.bat

create success.bat

It serves to suppress command errors in appveyor.yml.


:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
SET PATH="%PATH%;C:\Anaconda\bin"

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
    SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
    SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
    ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
    EXIT 1
)

IF "%PYTHON_ARCH%"=="64" (
    ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO Using default MSVC build environment for 32 bit architecture
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
)

:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
SET PATH=%PATH%;C:\Anaconda\bin

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
    SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
    SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
    ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
    EXIT 1
)

IF "%PYTHON_ARCH%"=="64" (
    ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO Using default MSVC build environment for 32 bit architecture
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
)

fix path on windows

fix path on windows


@echo off

setlocal

REM Build 'dotnet' using a version of itself hosted on the DNX
REM The output of this is independent of DNX

REM This trick gets the absolute path from a relative path
pushd %~dp0..
set REPOROOT=%CD%
popd

set RID=win7-x64
set TFM=dnxcore50
set DNX_DIR=%REPOROOT%\artifacts\%RID%\dnx
set STAGE0_DIR=%REPOROOT%\artifacts\%RID%\stage0
set STAGE1_DIR=%REPOROOT%\artifacts\%RID%\stage1
set STAGE2_DIR=%REPOROOT%\artifacts\%RID%\stage2
set START_PATH=%PATH%

where dnvm >nul 2>nul
if %errorlevel% == 0 goto have_dnvm
echo DNVM must be installed to bootstrap dotnet
exit /B 1

:have_dnvm
if not exist %DNX_DIR% mkdir %DNX_DIR%
set DNX_HOME=%DNX_DIR%
set DNX_USER_HOME=%DNX_DIR%
set DNX_GLOBAL_HOME=%DNX_DIR%

echo Installing and use-ing the latest CoreCLR x64 DNX ...
call dnvm install -nonative -u latest -r coreclr -arch x64 -alias dotnet_bootstrap
pushd "%DNX_DIR%"
cd "runtimes\dnx-*"
set DNX_ROOT=%CD%\bin
popd
if errorlevel 1 goto fail

call dnvm use dotnet_bootstrap -r coreclr -arch x64
if errorlevel 1 goto fail

if exist %STAGE1_DIR% rd /s /q %STAGE1_DIR%

echo Running 'dnu restore' to restore packages for DNX-hosted projects
call dnu restore "%REPOROOT%"
if errorlevel 1 goto fail

echo Building basic dotnet tools using older dotnet SDK version

set DOTNET_HOME=%STAGE0_DIR%
set DOTNET_USER_HOME=%STAGE0_DIR%
set DOTNET_GLOBAL_HOME=%STAGE0_DIR%

call %~dp0dnvm2 upgrade
if errorlevel 1 goto fail

echo Building stage1 dotnet.exe ...
dotnet-publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
if errorlevel 1 goto fail

echo Building stage1 dotnet-compile.exe ...
dotnet-publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
if errorlevel 1 goto fail

echo Building stage1 dotnet-compile-csc.exe ...
dotnet-publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
if errorlevel 1 goto fail

echo Building stage1 dotnet-publish.exe ...
dotnet-publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
if errorlevel 1 goto fail

echo Building stage1 dotnet-publish.exe ...
dotnet-publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
if errorlevel 1 goto fail

echo Re-building dotnet tools with the bootstrapped version
REM This should move into a proper build script of some kind once we are bootstrapped
set PATH=%STAGE1_DIR%;%START_PATH%

if exist %STAGE2_DIR% rd /s /q %STAGE2_DIR%

echo Building stage2 dotnet.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
if errorlevel 1 goto fail

echo Building stage2 dotnet-compile.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
if errorlevel 1 goto fail

echo Building stage2 dotnet-compile-csc.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
if errorlevel 1 goto fail

echo Building stage2 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
if errorlevel 1 goto fail

echo Building stage2 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
if errorlevel 1 goto fail

echo Crossgening Roslyn compiler ...
call %~dp0crossgen/crossgen_roslyn.cmd %STAGE2_DIR%
if errorlevel 1 goto fail

REM Copy DNX in to stage2
xcopy /s /q %DNX_ROOT% %STAGE2_DIR%\dnx\

REM Clean up some things we don't need
rd /s /q %STAGE2_DIR%\dnx\lib\Microsoft.Dnx.DesignTimeHost
rd /s /q %STAGE2_DIR%\dnx\lib\Microsoft.Dnx.Project
del %STAGE2_DIR%\dnx\dnu.cmd

REM Copy and CHMOD the dotnet-restore script
copy %~dp0dotnet-restore.cmd %STAGE2_DIR%\dotnet-restore.cmd

# Smoke-test the output
set PATH=%STAGE2_DIR%;%START_PATH%

del "%REPOROOT%\test\TestApp\project.lock.json"
dotnet restore "%REPOROOT%\test\TestApp" --runtime "%RID%"
dotnet publish "%REPOROOT%\test\TestApp" --framework "%TFM%" --runtime "%RID%" --output "%REPOROOT%\artifacts\%RID%\smoketest"

"%REPOROOT%/artifacts/%RID%/smoketest/TestApp"
if errorlevel 1 goto fail

REM Check that a compiler error is reported
dotnet compile "%REPOROOT%\test\compile\failing\SimpleCompilerError" --framework "%TFM%"
if %errorlevel% == 0 goto fail

echo Bootstrapped dotnet to %STAGE2_DIR%

goto end

:fail
echo Bootstrapping failed
exit /B 1

:end
exit /B 0

@echo off

setlocal

REM Build 'dotnet' using a version of itself hosted on the DNX
REM The output of this is independent of DNX

REM This trick gets the absolute path from a relative path
pushd %~dp0..
set REPOROOT=%CD%
popd

set RID=win7-x64
set TFM=dnxcore50
set DNX_DIR=%REPOROOT%\artifacts\%RID%\dnx
set STAGE1_DIR=%REPOROOT%\artifacts\%RID%\stage1
set STAGE2_DIR=%REPOROOT%\artifacts\%RID%\stage2
set START_PATH=%PATH%

call %~dp0dnvm2.cmd upgrade -a dotnet_stage0
if errorlevel 1 goto fail

REM Gross! But CMD has no other way to do this :(
where dotnet > %temp%\dotnet-cli-build-temp.tmp
set /P DOTNET_PATH=<%temp%\dotnet-cli-build-temp.tmp
pushd %DOTNET_PATH%\..
set STAGE0_DIR=%CD%
set DNX_ROOT=%STAGE0_DIR%\dnx
popd

if exist %STAGE1_DIR% rd /s /q %STAGE1_DIR%

echo Running 'dotnet restore' to restore packages
call dotnet restore "%REPOROOT%"
if errorlevel 1 goto fail

echo Building basic dotnet tools using older dotnet SDK version

echo Building stage1 dotnet.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
if errorlevel 1 goto fail

echo Building stage1 dotnet-compile.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
if errorlevel 1 goto fail

echo Building stage1 dotnet-compile-csc.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
if errorlevel 1 goto fail

echo Building stage1 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
if errorlevel 1 goto fail

echo Building stage1 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE1_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
if errorlevel 1 goto fail

echo Re-building dotnet tools with the bootstrapped version
REM This should move into a proper build script of some kind once we are bootstrapped
set PATH=%STAGE1_DIR%;%START_PATH%

if exist %STAGE2_DIR% rd /s /q %STAGE2_DIR%

echo Building stage2 dotnet.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
if errorlevel 1 goto fail

echo Building stage2 dotnet-compile.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
if errorlevel 1 goto fail

echo Building stage2 dotnet-compile-csc.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
if errorlevel 1 goto fail

echo Building stage2 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
if errorlevel 1 goto fail

echo Building stage2 dotnet-publish.exe ...
dotnet publish --framework %TFM% --runtime %RID% --output "%STAGE2_DIR%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
if errorlevel 1 goto fail

echo Crossgening Roslyn compiler ...
call %~dp0crossgen/crossgen_roslyn.cmd %STAGE2_DIR%
if errorlevel 1 goto fail

REM Copy DNX in to stage2
xcopy /s /q %DNX_ROOT% %STAGE2_DIR%\dnx\

REM Copy the dotnet-restore script
copy %~dp0dotnet-restore.cmd %STAGE2_DIR%\dotnet-restore.cmd

REM Smoke-test the output
set PATH=%STAGE2_DIR%;%START_PATH%

del "%REPOROOT%\test\TestApp\project.lock.json"
dotnet restore "%REPOROOT%\test\TestApp" --runtime "%RID%" --quiet
dotnet publish "%REPOROOT%\test\TestApp" --framework "%TFM%" --runtime "%RID%" --output "%REPOROOT%\artifacts\%RID%\smoketest"

"%REPOROOT%/artifacts/%RID%/smoketest/TestApp"
if errorlevel 1 goto fail

REM Check that a compiler error is reported
dotnet compile "%REPOROOT%\test\compile\failing\SimpleCompilerError" --framework "%TFM%" >nul
if %errorlevel% == 0 goto fail

echo Bootstrapped dotnet to %STAGE2_DIR%

goto end

:fail
echo Bootstrapping failed
exit /B 1

:end
exit /B 0

update windows bootstrap script

update windows bootstrap script


:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.

:: Environment variables that control make.bat:
::
:: GOROOT_FINAL: The expected final Go root, baked into binaries.
:: The default is the location of the Go tree during the build.
::
:: GOHOSTARCH: The architecture for host tools (compilers and
:: binaries).  Binaries of this type must be executable on the current
:: system, so the only common reason to set this is to set
:: GOHOSTARCH=386 on an amd64 machine.
::
:: GOARCH: The target architecture for installed packages and tools.
::
:: GOOS: The target operating system for installed packages and tools.
::
:: GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
:: building the packages and commands.
::
:: GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
:: building the commands.
::
:: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
:: to include all cgo related files, .c and .go file with "cgo"
:: build directive, in the build. Set it to 0 to ignore them.

@echo off

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

if exist make.bat goto ok
echo Must run make.bat from Go src directory.
goto fail
:ok

:: Clean old generated file that will cause problems in the build.
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL

:: Grab default GOROOT_FINAL and set GOROOT for build.
:: The expression %VAR:\=\\% means to take %VAR%
:: and apply the substitution \ = \\, escaping the
:: backslashes.  Then we wrap that in quotes to create
:: a C string.
cd ..
set GOROOT=%CD%
cd src
if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""

echo # Building C bootstrap tool.
echo cmd/dist
if not exist ..\bin\tool mkdir ..\bin\tool
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c cmd/dist/arm.c
if errorlevel 1 goto fail
.\cmd\dist\dist env -wp >env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.

if x%1==x--dist-tool goto copydist
if x%2==x--dist-tool goto copydist

echo # Building compilers and Go bootstrap tool.
set buildall=-a
if x%1==x--no-clean set buildall=
.\cmd\dist\dist bootstrap %buildall% -v
if errorlevel 1 goto fail
:: Delay move of dist tool to now, because bootstrap cleared tool directory.
move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
"%GOTOOLDIR%\go_bootstrap" clean -i std
echo.

if not %GOHOSTARCH% == %GOARCH% goto localbuild
if not %GOHOSTOS% == %GOOS% goto localbuild
goto mainbuild

:localbuild
echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
setlocal
set GOOS=%GOHOSTOS%
set GOARCH=%GOHOSTARCH%
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std
endlocal
if errorlevel 1 goto fail
echo.

:mainbuild
echo # Building packages and commands.
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std
if errorlevel 1 goto fail
del "%GOTOOLDIR%\go_bootstrap.exe"
echo.

if x%1==x--no-banner goto nobanner
"%GOTOOLDIR%\dist" banner
:nobanner

goto end

:copydist
mkdir "%GOTOOLDIR%" 2>NUL
copy cmd\dist\dist.exe "%GOTOOLDIR%\"
goto end

:fail
set GOBUILDFAIL=1

:end

:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.

:: Environment variables that control make.bat:
::
:: GOROOT_FINAL: The expected final Go root, baked into binaries.
:: The default is the location of the Go tree during the build.
::
:: GOHOSTARCH: The architecture for host tools (compilers and
:: binaries).  Binaries of this type must be executable on the current
:: system, so the only common reason to set this is to set
:: GOHOSTARCH=386 on an amd64 machine.
::
:: GOARCH: The target architecture for installed packages and tools.
::
:: GOOS: The target operating system for installed packages and tools.
::
:: GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
:: building the packages and commands.
::
:: GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
:: building the commands.
::
:: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
:: to include all cgo related files, .c and .go file with "cgo"
:: build directive, in the build. Set it to 0 to ignore them.

@echo off

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

if exist make.bat goto ok
echo Must run make.bat from Go src directory.
goto fail
:ok

:: Clean old generated file that will cause problems in the build.
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL

:: Grab default GOROOT_FINAL and set GOROOT for build.
:: The expression %VAR:\=\\% means to take %VAR%
:: and apply the substitution \ = \\, escaping the
:: backslashes.  Then we wrap that in quotes to create
:: a C string.
cd ..
set GOROOT=%CD%
cd src
if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""

echo # Building C bootstrap tool.
echo cmd/dist
if not exist ..\bin\tool mkdir ..\bin\tool
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildgo.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c cmd/dist/arm.c
if errorlevel 1 goto fail
.\cmd\dist\dist env -wp >env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.

if x%1==x--dist-tool goto copydist
if x%2==x--dist-tool goto copydist

echo # Building compilers and Go bootstrap tool.
set buildall=-a
if x%1==x--no-clean set buildall=
.\cmd\dist\dist bootstrap %buildall% -v
if errorlevel 1 goto fail
:: Delay move of dist tool to now, because bootstrap cleared tool directory.
move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
"%GOTOOLDIR%\go_bootstrap" clean -i std
echo.

if not %GOHOSTARCH% == %GOARCH% goto localbuild
if not %GOHOSTOS% == %GOOS% goto localbuild
goto mainbuild

:localbuild
echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
setlocal
set GOOS=%GOHOSTOS%
set GOARCH=%GOHOSTARCH%
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std
endlocal
if errorlevel 1 goto fail
echo.

:mainbuild
echo # Building packages and commands.
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std
if errorlevel 1 goto fail
del "%GOTOOLDIR%\go_bootstrap.exe"
echo.

if x%1==x--no-banner goto nobanner
"%GOTOOLDIR%\dist" banner
:nobanner

goto end

:copydist
mkdir "%GOTOOLDIR%" 2>NUL
copy cmd\dist\dist.exe "%GOTOOLDIR%\"
goto end

:fail
set GOBUILDFAIL=1

:end

fix windows build.

cmd/dist: fix windows build.

R=golang-dev, bradfitz
CC=golang-dev
https://codereview.appspot.com/12351045

Committer: Brad Fitzpatrick <ae9783c0b0efc69cd85ab025ddd17aa44cdc4aa5@golang.org>


:: setup paths of all tools used in plugin build process.

rem call "c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
call "c:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"

:: java runtime is used by yui_compressor and google closure compiler in MINIMIZE_CLIENT_SRC task.
set JAVA_HOME=%JAVA_HOME%

set SUBWCREV_TOOL_DIR=c:\Program Files\TortoiseSVN\bin
set INNO_SETUP_HOME=c:\Program Files\Inno Setup 5
set PATH=%SUBWCREV_TOOL_DIR%;%INNO_SETUP_HOME%;%PATH%

:: following variables are used for source indexing and storing debug symbols to symbol server.
set PERL_DIR=c:\perl
set DEBUG_TOOL_DIR=c:\Program Files\Debugging Tools for Windows (x86)
set SRCSRV_HOME=%DEBUG_TOOL_DIR%\srcsrv
set SVN_CLIENT_DIR=c:\Program Files\Subversion\bin
set PATH=%DEBUG_TOOL_DIR%;%SRCSRV_HOME%;%PERL_DIR%\bin;%SVN_CLIENT_DIR%\bin;%PATH%
set SYMBOL_STORE=C:\Symbols

:: following variables are used for documentation generation.
set DOXYGEN_PATH=c:\Program Files\doxygen\bin
set PATH=%DOXYGEN_PATH%;%PATH%

add doxygen into PATH env var.

add doxygen into PATH env var.


@IF NOT DEFINED _ECHO ECHO OFF
:::::::::::::::::::::::
:: Consuming the parser grammar, generate the compiled tables, the skeleton program, and the test
:::::::::::::::::::::::

set PATH=%PATH%;..\..\..\..\GoldBuilder

GOLDBuild.exe -verbose PashGrammar.grm PashGrammar.cgt
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt PashParser.pgt PashParser.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt PashParserContext.pgt PashParserContext.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt ParserTemplate.pgt RuleConstants.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt ParserTemplate.pgt SymbolConstants.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

@IF NOT DEFINED _ECHO ECHO OFF
:::::::::::::::::::::::
:: Consuming the parser grammar, generate the compiled tables, the skeleton program, and the test
:::::::::::::::::::::::

set PATH=%PATH%;..\..\..\..\GoldBuilder

GOLDBuild.exe -verbose PashGrammar.grm PashGrammar.cgt
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt PashParserContext.pgt PashParserContext.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt RuleConstants.pgt RuleConstants.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

GOLDProg.exe PashGrammar.cgt SymbolConstants.pgt SymbolConstants.Generated.cs
IF ERRORLEVEL 1 GOTO :EOF

Fix generate-parser script

Fix generate-parser script

Couldn't test it without overwriting the files, right? Hmm, maybe if I
was better with the Git Index.


"C:\Program Files\Wireshark\tshark.exe" -i Ethernet -l -f "udp port 53" -T fields -e dns.qry.name >> "C:\Users\....\dns.txt"

Create tshark.bat

Create tshark.bat


:: Sign keybase.exe and generate a signed installer, with an embedded signed uninsaller
:: $1 is full path to keybase.exe
:: todo: specify output?
::
:: For Jenkins:
if DEFINED WORKSPACE set GOPATH=%WORKSPACE%
set GOARCH=386
::
:: get the target build folder. Assume winresource.exe has been built.
:: If not, go there and do "go generate"
set Folder=%GOPATH%\src\github.com\keybase\client\go\keybase\
set PathName=%Folder%keybase.exe

pushd %GOPATH%\src\github.com\keybase\client\packaging\windows

:: Capture the windows style version - this is the only way to store it in a .cmd variable
for /f %%i in ('%Folder%winresource.exe -w') do set BUILDVER=%%i
echo %BUILDVER%

:: Capture keybase's semantic version - this is the only way to store it in a .cmd variable
for /f "tokens=3" %%i in ('%PathName% -version') do set SEMVER=%%i
echo %SEMVER%

:: dokan source binaries.
:: There are 8 (4 windows versions times 32/64 bit) but they all seem to have the same version.
for /f %%i in ('PowerShell "(Get-Item %GOPATH%\bin\dokan-dev\dokan-v1.0.0-RC2\Win32\Win10Release\dokan1.sys).VersionInfo.FileVersion"') do set DOKANVER=%%i
echo %DOKANVER%
IF %DOKANVER%=="" (
  EXIT /B 1
)

:: Other alternate time servers:
::   http://timestamp.verisign.com/scripts/timstamp.dll
::   http://timestamp.globalsign.com/scripts/timestamp.dll
::   http://tsa.starfieldtech.com
::   http://timestamp.comodoca.com/authenticode
::   http://timestamp.digicert.com
SignTool.exe sign /a /tr http://timestamp.digicert.com %PathName%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)
SignTool.exe sign /a /tr http://timestamp.digicert.com %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan\kbfsdokan.exe
IF %ERRORLEVEL% NEQ 0 (k
  EXIT /B 1
)
SignTool.exe sign /a /tr http://timestamp.digicert.com %GOPATH%\src\github.com\keybase\client\desktop\release\win32-ia32\Keybase-win32-ia32\Keybase.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that keybase is codesigned
signtool verify /pa %PathName%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that kbfs is codesigned
signtool verify /pa %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan\kbfsdokan.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that Keybase.exe gui is codesigned
signtool verify /pa %GOPATH%\src\github.com\keybase\client\desktop\release\win32-ia32\Keybase-win32-ia32\Keybase.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

if NOT DEFINED BUILD_TAG set BUILD_TAG=%SEMVER%

"%ProgramFiles(x86)%\Inno Setup 5\iscc.exe" /O%BUILD_TAG% /DMyExePathName=%PathName% /DMyAppVersion=%BUILDVER% /DMySemVersion=%SEMVER% /DNewDokanVersion=%DOKANVER% "/sSignCommand=signtool.exe sign /tr http://timestamp.digicert.com $f" %GOPATH%\src\github.com\keybase\client\packaging\windows\setup_windows_gui.iss
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

echo off

go get github.com/keybase/release
go install github.com/keybase/release
set release_bin=%GOPATH%\bin\windows_386\release.exe

pushd %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%

for /f %%i in ('dir /od /b') do set KEYBASE_INSTALLER_NAME=%%i
echo %KEYBASE_INSTALLER_NAME%

:: Double check that the installer is codesigned
signtool verify /pa %KEYBASE_INSTALLER_NAME%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

%GOPATH%\bin\windows_386\release update-json --version=%SEMVER% --src=%KEYBASE_INSTALLER_NAME% --uri=https://prerelease.keybase.io/windows > update-windows-prod.json
::"%ProgramFiles%\S3 Browser\s3browser-con.exe" upload keybase %KEYBASE_INSTALLER_NAME% prerelease.keybase.io/windows
:: After sanity checking, do:
::"%ProgramFiles%\S3 Browser\s3browser-con.exe" upload keybase update-windows-prod.json prerelease.keybase.io
:: popd
::%GOPATH%\bin\windows_386\release index-html --bucket-name=prerelease.keybase.io --prefixes="windows/" --upload="windows/index.html"

:: Sign keybase.exe and generate a signed installer, with an embedded signed uninsaller
:: $1 is full path to keybase.exe
:: todo: specify output?
::
:: For Jenkins:
if DEFINED WORKSPACE set GOPATH=%WORKSPACE%
set GOARCH=386
::
:: get the target build folder. Assume winresource.exe has been built.
:: If not, go there and do "go generate"
set Folder=%GOPATH%\src\github.com\keybase\client\go\keybase\
set PathName=%Folder%keybase.exe

pushd %GOPATH%\src\github.com\keybase\client\packaging\windows

:: Capture the windows style version - this is the only way to store it in a .cmd variable
for /f %%i in ('%Folder%winresource.exe -w') do set BUILDVER=%%i
echo %BUILDVER%

:: Capture keybase's semantic version - this is the only way to store it in a .cmd variable
for /f "tokens=3" %%i in ('%PathName% -version') do set SEMVER=%%i
echo %SEMVER%

:: dokan source binaries.
:: There are 8 (4 windows versions times 32/64 bit) but they all seem to have the same version.
for /f %%i in ('PowerShell "(Get-Item %GOPATH%\bin\dokan-dev\dokan-v1.0.0-RC2\Win32\Win10Release\dokan1.sys).VersionInfo.FileVersion"') do set DOKANVER=%%i
echo %DOKANVER%
IF %DOKANVER%=="" (
  EXIT /B 1
)

:: Other alternate time servers:
::   http://timestamp.verisign.com/scripts/timstamp.dll
::   http://timestamp.globalsign.com/scripts/timestamp.dll
::   http://tsa.starfieldtech.com
::   http://timestamp.comodoca.com/authenticode
::   http://timestamp.digicert.com
SignTool.exe sign /a /tr http://timestamp.digicert.com %PathName%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)
SignTool.exe sign /a /tr http://timestamp.digicert.com %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan\kbfsdokan.exe
IF %ERRORLEVEL% NEQ 0 (k
  EXIT /B 1
)
SignTool.exe sign /a /tr http://timestamp.digicert.com %GOPATH%\src\github.com\keybase\client\desktop\release\win32-ia32\Keybase-win32-ia32\Keybase.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that keybase is codesigned
signtool verify /pa %PathName%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that kbfs is codesigned
signtool verify /pa %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan\kbfsdokan.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

:: Double check that Keybase.exe gui is codesigned
signtool verify /pa %GOPATH%\src\github.com\keybase\client\desktop\release\win32-ia32\Keybase-win32-ia32\Keybase.exe
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

if NOT DEFINED BUILD_TAG set BUILD_TAG=%SEMVER%

"%ProgramFiles(x86)%\Inno Setup 5\iscc.exe" /O%BUILD_TAG% /DMyExePathName=%PathName% /DMyAppVersion=%BUILDVER% /DMySemVersion=%SEMVER% /DNewDokanVersion=%DOKANVER% "/sSignCommand=signtool.exe sign /tr http://timestamp.digicert.com $f" %GOPATH%\src\github.com\keybase\client\packaging\windows\setup_windows_gui.iss
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

echo off

go get github.com/keybase/release
go install github.com/keybase/release
set release_bin=%GOPATH%\bin\windows_386\release.exe

pushd %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%

for /f %%i in ('dir /od /b') do set KEYBASE_INSTALLER_NAME=%%i
echo %KEYBASE_INSTALLER_NAME%

:: Double check that the installer is codesigned
signtool verify /pa %KEYBASE_INSTALLER_NAME%
IF %ERRORLEVEL% NEQ 0 (
  EXIT /B 1
)

if NOT DEFINED JSON_UPDATE_FILENAME set JSON_UPDATE_FILENAME=update-windows-prod.json

%GOPATH%\bin\windows_386\release update-json --version=%SEMVER% --src=%KEYBASE_INSTALLER_NAME% --uri=https://prerelease.keybase.io/windows > %JSON_UPDATE_FILENAME%
::"%ProgramFiles%\S3 Browser\s3browser-con.exe" upload keybase %KEYBASE_INSTALLER_NAME% prerelease.keybase.io/windows
:: After sanity checking, do:
::"%ProgramFiles%\S3 Browser\s3browser-con.exe" upload keybase update-windows-prod.json prerelease.keybase.io
:: popd
::%GOPATH%\bin\windows_386\release index-html --bucket-name=prerelease.keybase.io --prefixes="windows/" --upload="windows/index.html"

Add json update filename build parameter


:<<"::CMDLITERAL"
@echo off
goto :CMDSCRIPT
::CMDLITERAL
#!/bin/bash
set -euo pipefail
IFS=$$'\n\t'

script_dir=$$(cd $$(dirname $$0); pwd -P)
python_path=$$script_dir/bin/python
pip_path=$$script_dir/bin/pip

if [ ! -e $$python_path ]; then
    virtualenv $$script_dir
fi

$$pip_path install -q -r $$script_dir/requirements.txt
$$python_path $$*

exit $$?

:CMDSCRIPT
@echo off
setlocal

set python_path=%~dp0Scripts\python.exe
set pip_path=%~dp0Scripts\pip.exe

if not exist "%python_path%" (
    cd /d "%~dp0"
    python -m virtualenv .
    if errorlevel 1 (
        echo virtualenv failed
        exit /b 1
    )
)

"%pip_path%" install -q -r "%~dp0requirements.txt"
if errorlevel 1 (
    echo pip failed
    exit /b 1
)

"%python_path%" %*
if errorlevel 1 (
    echo script failed
    exit /b 1
)

:<<"::CMDLITERAL"
@echo off
goto :CMDSCRIPT
::CMDLITERAL
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

script_dir=$(cd $(dirname $0); pwd -P)
python_path=$script_dir/bin/python
pip_path=$script_dir/bin/pip

if [ ! -e $python_path ]; then
    virtualenv $script_dir
fi

$pip_path install -q -r $script_dir/requirements.txt
$python_path $*

exit $?

:CMDSCRIPT
@echo off
setlocal

set python_path=%~dp0Scripts\python.exe
set pip_path=%~dp0Scripts\pip.exe

if not exist "%python_path%" (
    cd /d "%~dp0"
    python -m virtualenv .
    if errorlevel 1 (
        echo virtualenv failed
        exit /b 1
    )
)

"%pip_path%" install -q -r "%~dp0requirements.txt"
if errorlevel 1 (
    echo pip failed
    exit /b 1
)

"%python_path%" %*
if errorlevel 1 (
    echo script failed
    exit /b 1
)

Fix script

Fix script


:: Tron's log function with embedded date and time group (DTG)

:: When the whole argument (%1) string is wrapped in double quotes, it is sent as an argument.
:: The tilde syntax (%~1) removes the double quotes around the argument.
@echo off
echo:%CUR_DATE% %TIME% %~1>> "%LOGPATH%\%LOGFILE%"
echo:%CUR_DATE% %TIME% %~1

Create log_with_date.bat

Create log_with_date.bat


@echo off

mkdir public\compiled

set ts_apps=common chess ceval game tree chat

yarn install --non-interactive

for %%t in (%ts_apps%) do @(
    call echo Building TypeScript: %%t
    call cd ui\%%t
    call yarn run compile --non-interactive
    call cd ..\..
)

set apps=site challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul perfStat dasher

for %%a in (%apps%) do @(
  call echo Building: %%a
  call cd ui\%%a
  call gulp dev
  call cd ..\..
)

@echo off

mkdir public\compiled

set ts_apps=common chess ceval game tree chat

call yarn install --non-interactive

for %%t in (%ts_apps%) do @(
    call echo Building TypeScript: %%t
    call cd ui\%%t
    call yarn run --non-interactive compile
    call cd ..\..
)

set apps=site challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul perfStat dasher

for %%a in (%apps%) do @(
  call echo Building: %%a
  call cd ui\%%a
  call gulp dev
  call cd ..\..
)

fix windows ui build script

fix windows ui build script

1. preceed yarn command with call to avoid it exiting the script
2. pass the non-interactive flag to yarn instead of the compiler


rem run the trace-inputlocator for as many tools as possible, collecting the data

cea-config copy-default-databases --scenario c:\reference-case-WTP-reduced\WTP_MIX_m\
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts copy-default-databases, data-helper
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts radiation-daysim, demand
if %errorlevel% neq 0 exit /b %errorlevel%

rem make sure to run the quicker version (type-scpanel=FP)
cea-config solar-collector --type-scpanel FP
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts solar-collector
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts photovoltaic, photovoltaic-thermal
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts sewage-potential, lake-potential
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts operation-costs
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts network-layout
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts thermal-network-matrix
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts decentralized
if %errorlevel% neq 0 exit /b %errorlevel%

cea-config optimization --initialind 2 --ngen 2
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts optimization
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts plots
if %errorlevel% neq 0 exit /b %errorlevel%

rem run the trace-inputlocator for as many tools as possible, collecting the data

rem set up the case study
cea extract-reference-case --destination %temp% --case cooling
cea-config demand --scenario %temp%\reference-case-cooling\baseline --weather Singapore

rem data-helper
cea-config data-helper --region SG
cea trace-inputlocator --scripts data-helper
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts radiation-daysim, demand
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts emissions, operation-costs
if %errorlevel% neq 0 exit /b %errorlevel%

cea-config network-layout --network-type DC
cea trace-inputlocator --scripts network-layout
if %errorlevel% neq 0 exit /b %errorlevel%

rem make sure to run the quicker version (type-scpanel=FP)
cea-config solar-collector --type-scpanel FP
cea trace-inputlocator --scripts solar-collector
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts photovoltaic, photovoltaic-thermal
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts sewage-potential, lake-potential
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts operation-costs
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts network-layout
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts thermal-network
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts decentralized
if %errorlevel% neq 0 exit /b %errorlevel%

cea-config optimization --initialind 2 --ngen 2 --halloffame 2 --random-seed 1234
cea trace-inputlocator --scripts optimization
if %errorlevel% neq 0 exit /b %errorlevel%

cea trace-inputlocator --scripts multi-criteria-analysis
if %errorlevel% neq 0 exit /b %errorlevel%

Update trace-inputlocator.bat

Update trace-inputlocator.bat


DEL /Q .\Assets\Editor\Dummy\X_*
DEL /Q .\Assets\Editor\Plugins\X_*
DEL /Q .\Assets\Editor\Scripts\X_*
PAUSE.

DEL /Q .\Assets\Editor\Dummy\X_*
DEL /Q .\Assets\Plugins\Dummy\X_*
DEL /Q .\Assets\Scripts\Dummy\X_*
PAUSE.

Fix typo

Fix typo


@echo off
rem ======================================================================== rem
rem Copyright 2015-2018 Intel Corporation                                    rem
rem                                                                          rem
rem Licensed under the Apache License, Version 2.0 (the "License");          rem
rem you may not use this file except in compliance with the License.         rem
rem You may obtain a copy of the License at                                  rem
rem                                                                          rem
rem     http://www.apache.org/licenses/LICENSE-2.0                           rem
rem                                                                          rem
rem Unless required by applicable law or agreed to in writing, software      rem
rem distributed under the License is distributed on an "AS IS" BASIS,        rem
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. rem
rem See the License for the specific language governing permissions and      rem
rem limitations under the License.                                           rem
rem ======================================================================== rem

setlocal

echo Running tests
md failed

cd build
del CMakeCache.txt
cmake -G "Visual Studio 15 2017 Win64" ..
cmake --build . --config Release --target ospray_test_data -- /m /nologo
cd ..

set OSP_LIBS=build\Release
set EMBREE_DIR=C:\Program Files\Intel\Embree v2.16.1 x64
set BASELINE_DIR=build\regression_tests\baseline\

set PATH=%PATH%;%OSP_LIBS%;%embree_DIR%\bin

call build\regression_tests\Release\ospray_test_suite.exe --gtest_output=xml:tests.xml --baseline-dir=%BASELINE_DIR%

exit /B %ERRORLEBEL%

endlocal

@echo off
rem ======================================================================== rem
rem Copyright 2015-2018 Intel Corporation                                    rem
rem                                                                          rem
rem Licensed under the Apache License, Version 2.0 (the "License");          rem
rem you may not use this file except in compliance with the License.         rem
rem You may obtain a copy of the License at                                  rem
rem                                                                          rem
rem     http://www.apache.org/licenses/LICENSE-2.0                           rem
rem                                                                          rem
rem Unless required by applicable law or agreed to in writing, software      rem
rem distributed under the License is distributed on an "AS IS" BASIS,        rem
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. rem
rem See the License for the specific language governing permissions and      rem
rem limitations under the License.                                           rem
rem ======================================================================== rem

setlocal

echo Running tests
md failed

cd build
del CMakeCache.txt
cmake -G "Visual Studio 15 2017 Win64" -DOSPRAY_ENABLE_TESTING=ON ..
cmake --build . --config Release --target ospray_test_data -- /m /nologo
cd ..

set OSP_LIBS=build\Release
set EMBREE_DIR=C:\Program Files\Intel\Embree v2.16.1 x64
set BASELINE_DIR=build\regression_tests\baseline\

set PATH=%PATH%;%OSP_LIBS%;%embree_DIR%\bin

call build\regression_tests\Release\ospray_test_suite.exe --gtest_output=xml:tests.xml --baseline-dir=%BASELINE_DIR%

exit /B %ERRORLEBEL%

endlocal

enable testing for regression tests on Windows


start /B code .
start /B code ../csWeb
start tsc -p ../csWeb
start tsc -w
start nodemon server
cd ../csWeb/
gulp watch

start /B code .
start /B code ../csWeb
start tsc -w
start nodemon server
cd ../csWeb
start tsc -w
gulp watch

fix for starting editWithCode

fix for starting editWithCode


rem ################################
rem step2: f[^Rs[
rem ################################

if "%ORIGINAL%" == "" goto TERMINATE
if "%PUBLISH%" == "" goto TERMINATE

@echo %ORIGINAL%  %PUBLISH%\pub\db ɃRs[܂B

robocopy "%ORIGINAL%" %PUBLISH%\pub\db /mir /xa:SHT

rem # step2I. ###
exit /B

:TERMINATE
pause G[: step1ĂȂ̂ŁA~܂B
exit 1

make bat safer

make bat safer


@echo off

echo Building dependencies...

if exist lib (rd lib /q /s)
md lib
cd lib
md Debug
md Release
cd ../
REM ######################################################################################################
echo Building protobuf...

if exist protobuf (rd protobuf /q /s)
git clone -b 2.7.0 https://github.com/google/protobuf.git

cd protobuf/cmake
md build
cd build
cmake -G "Visual Studio 14 Win64" -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF ..
"%VS140COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Debug|x64"
"%VS140COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Release|x64"
copy Debug\*.dll ..\..\..\lib\Debug /Y
copy Debug\*.lib ..\..\..\lib\Debug /Y
copy Release\*.dll ..\..\..\lib\Release /Y
copy Release\*.lib ..\..\..\lib\Release /Y
cd ..\..\..\
REM ######################################################################################################
echo Building libevent...

if exist libevent (rd libevent /q /s)
git clone -b master https://github.com/libevent/libevent.git

cd libevent
md build
cd build
cmake -G "Visual Studio 14 Win64" -DEVENT__DISABLE_OPENSSL=ON ..
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_core_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_core_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_extra_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_extra_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building glog...
if exist glog (rd glog /q /s)
git clone -b v035 https://github.com/google/glog.git

cd glog
md build
cd build
cmake -G "Visual Studio 14 Win64" ..
"%VS140COMNTOOLS%..\IDE\Devenv" google-glog.sln /build "Debug|x64"
"%VS140COMNTOOLS%..\IDE\Devenv" google-glog.sln /build "Release|x64"
copy Debug\*.lib ..\..\lib\Debug /Y
copy Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building evpp...

if exist evpp (rd evpp /q /s)
git clone -b master https://github.com/ArkGame/evpp.git

cd evpp
cd vsprojects
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Debug|x64" /project evpp_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Release|x64" /project evpp_static.vcxproj
cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ../

@echo off

echo Building dependencies...

echo Building evpp...

cd evpp
cd vsprojects
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Debug|x64" /project libevpp.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Release|x64" /project libevpp.vcxproj
cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ../

modify evpp build bat

modify evpp build bat

Former-commit-id: 4f3fa236e18f00a3d85e31b0410a7e561f371153 [formerly 65d7d3bf078d96dcba516528460182db56373722] [formerly c7f78811efc4cb8355da04864170e579e975b16c] [formerly 9ec454225ae5023c63697a7ec92c85b128b8c8dd]
Former-commit-id: d53d8b34d3e33b131f0c3e6d92760b7bbee1fe55
Former-commit-id: e5c97dca72235539c29b64b901d62edc6aae4ec4
Former-commit-id: 522f15bf3a3f81e56e6cee99c952b4eb491d100d


modify evpp build bat

modify evpp build bat

Former-commit-id: fcbce83330c2cb95fbb185eb569283b5cebab6b8 [formerly 8979a339de6b529475b3ecbdfc7356a35402494e] [formerly c7b820ff842845ee8da7d9ddc04b01aa72ead784] [formerly 485b2899ff0a7263894bd821a3cd98a7c5287cd6 [formerly 241a82653b328331364f77275fec0081f13b16f3]] [formerly 8963a691856e5fac602c548770a653eff0087dcb [formerly 634badd744043316ef1f7276507512d50c0cfc3f] [formerly 027db863fdcf6a203b8f7b8b4ed48fdaa1a1ede2 [formerly 29f0b9ada565178e70414890ef08bcbf7a219d3f]]] [formerly 9ec454225ae5023c63697a7ec92c85b128b8c8dd]
Former-commit-id: d53d8b34d3e33b131f0c3e6d92760b7bbee1fe55
Former-commit-id: 31edc761d07dda7455d38256f1a9e34693d50269 [formerly 02462f3c7d5d2497b174d5b87bfebede1eb77c44] [formerly 40f911ce836d8b53fba9f4833e2cca7c4db3e3f3 [formerly 6b442709e27c4b595f49a6ad7f862daba8bb9f5a]]
Former-commit-id: 67cfcf7efd14d31c821d9d848c3085dd8d3696e2 [formerly ac5e3bc9da1248835f6ec47861a0a081da02bfbc]
Former-commit-id: 81fc11a67e3c7c9334473b7a1c8be806793f3b34
Former-commit-id: 3e71fa380b0f757532008559c8b4feb95bfa2f90


@echo off

SET RELEASE_VERSION=0.3rc2
SET WORKDIR=libfreespace-examples
SET ZIPNAME=libfreespace-examples-%RELEASE_VERSION%-win32

REM This must be run from the Visual Studio 2005 Command Prompt
devenv src\examples.sln /clean release
devenv src\examples.sln /build release

rd /S /Q %WORKDIR%
mkdir %WORKDIR%
copy src\release\libfreespace.dll %WORKDIR%
copy src\release\*.exe %WORKDIR%

REM Create ZIP file using Info-ZIP
REM http://www.info-zip.org/Zip.html
.\tools\zip -r %ZIPNAME%.zip %WORKDIR%

@echo off

SET RELEASE_VERSION=0.3rc2
SET WORKDIR=libfreespace-examples
SET ZIPNAME=libfreespace-examples-%RELEASE_VERSION%-win32

REM This must be run from the Visual Studio 2005 Command Prompt
devenv src\examples.sln /clean release
devenv src\examples.sln /build release

echo Cleanup any previous work directories
rd /S /Q %WORKDIR%
echo Creating work directory
mkdir %WORKDIR%
echo Copying build products
copy src\release\libfreespace.dll %WORKDIR%
copy src\release\*.exe %WORKDIR%

REM Create ZIP file using Info-ZIP
REM http://www.info-zip.org/Zip.html
echo Zipping - be sure to have zip.exe in your path or you will get an error below
zip -r %ZIPNAME%.zip %WORKDIR%
echo Done.

Update winbuild.bat to look in path for zip.exe and added some print messages to script.


@echo off

set VCPKG_PANIC=on
set VCPKG_ROOT=c:\Users\jim\src\vcpkg

rem
for %%i in (x86_64-pc-windows-msvc i686-pc-windows-msvc x86_64-pc-windows-gnu i686-pc-windows-gnu) DO (
    set VCPKG_ALL_STATIC=on
    set VCPKG_ALL_DYNAMIC=
    echo %%i static
    cargo run --target %%i
    cargo clean
    set VCPKG_ALL_STATIC=
    set VCPKG_ALL_DYNAMIC=on
    echo %%i dynamic
    cargo run --target %%i
    cargo clean
)

echo linux
bash -l -c "cargo run"

@echo off

set VCPKG_PANIC=on
set VCPKG_ROOT=c:\Users\jim\src\vcpkg

rem for %%i in (x64-windows x64-windows-static x86-windows x86-windows-static) DO (
rem     %VCPKG_ROOT%\vcpkg install --triplet=%i% openssl curl
rem )

rem x86_64-pc-windows-gnu i686-pc-windows-gnu
for %%i in (x86_64-pc-windows-msvc i686-pc-windows-msvc) DO (
    set RUSTFLAGS=-Ctarget-feature=+crt-static
    set VCPKGRS_DYNAMIC=
    echo %%i static
    cargo run --target %%i
    cargo clean
    set RUSTFLAGS=
    set VCPKGRS_DYNAMIC=1
    echo %%i dynamic
    cargo run --target %%i
    cargo clean
)

echo linux
bash -l -c "cargo run"

update test.cmd to use current environment variables


@echo off
@rem Run from the root of master to deploy the currently built contents
@rem of the out\ directory to PPE.

@echo =================================================================
@echo PPE Deployment
@echo Checking out DeployPPE branch which is configured in
@echo Azure App Service to automatically deploy to the PPE
@echo ZombAttack site.
@echo =================================================================
call git checkout DeployPPE
if ERRORLEVEL 1 echo ERROR: Git checkout failed && exit /b 1

@echo =================================================================
@echo Copying build in the out\ directory to the PPE deployment
@echo directory.
@echo =================================================================
robocopy.exe out\. Deployed\PPE\. /s /mir
if ERRORLEVEL 8 echo ERROR: Robocopy failed with errorlevel %ERRORLEVEL%. && exit /b 1

@echo =================================================================
@echo Committing and pushing copied deployment.
@echo =================================================================
robocopy.exe out\. DeployPPE\. /s /mir
if ERRORLEVEL 8 echo ERROR: Robocopy failed with errorlevel %ERRORLEVEL%. && exit /b 1

exit /b 0

@echo off
@rem Run from the root of master to deploy the currently built contents
@rem of the out\ directory to PPE.

@echo =================================================================
@echo PPE Deployment
@echo Checking out DeployPPE branch which is configured in
@echo Azure App Service to automatically deploy to the PPE
@echo ZombAttack site.
@echo =================================================================
call git checkout DeployPPE
if ERRORLEVEL 1 echo ERROR: Git checkout failed && exit /b 1

@echo =================================================================
@echo Copying build in the out\ directory to the PPE deployment
@echo directory.
@echo =================================================================
robocopy.exe out\. Deployed\PPE\. /s /mir
if ERRORLEVEL 8 echo ERROR: Robocopy failed with errorlevel %ERRORLEVEL%. && exit /b 1

@echo =================================================================
@echo Committing and pushing copied deployment.
@echo =================================================================
call git add Deployed/*
call git commit -am "Deploy PPE"
call git push --set-upstream origin DeployPPE

exit /b 0

Update PPE script

Update PPE script


@echo off
pushd %~dp0

set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe"
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe"

:main-menu
echo ========================= NHIBERNATE BUILD MENU ==========================
echo --- TESTING ---
echo B. (Step 1) Set up a new test configuration for a particular database.
echo C. (Step 2) Activate a test configuration.
echo D. (Step 3) Run tests using active configuration.
echo.
echo --- BUILD ---
echo E. Build NHibernate (Debug)
echo F. Build NHibernate (Release)
echo G. Build Release Package (Also runs tests and creates documentation)
echo.
echo --- Code generation ---
echo H. Generate async code (Generates files in Async sub-folders)
echo.
echo --- TeamCity (CI) build options
echo I. TeamCity build menu
echo.
echo --- Exit ---
echo X. Make the beautiful build menu go away.
echo.

%BUILDTOOL% prompt BCDEFGHIX
if errorlevel 8 goto end
if errorlevel 7 goto teamcity-menu
if errorlevel 6 goto build-async
if errorlevel 5 goto build-release-package
if errorlevel 4 goto build-release
if errorlevel 3 goto build-debug
if errorlevel 2 goto test-run
if errorlevel 1 goto test-activate
if errorlevel 0 goto test-setup-menu

:test-setup-menu
echo A. Add a test configuration for SQL Server.
echo B. Add a test configuration for Firebird (x86).
echo C. Add a test configuration for Firebird (x64). [not recommended]
echo D. Add a test configuration for SQLite (x86).
echo E. Add a test configuration for SQLite (x64). [not recommended]
echo F. Add a test configuration for PostgreSQL.
echo G. Add a test configuration for Oracle.
echo H. Add a test configuration for SQL Server Compact (x86).
echo I. Add a test configuration for SQL Server Compact (x64).
echo J. Add a test configuration for MySql.
echo.
echo X.  Exit to main menu.
echo.

%BUILDTOOL% prompt ABCDEFGHIJX
if errorlevel 10 goto main-menu
if errorlevel 9 goto test-setup-mysql
if errorlevel 8 goto test-setup-sqlservercex64
if errorlevel 7 goto test-setup-sqlservercex86
if errorlevel 6 goto test-setup-oracle
if errorlevel 5 goto test-setup-postgresql
if errorlevel 4 goto test-setup-sqlitex64
if errorlevel 3 goto test-setup-sqlitex86
if errorlevel 2 goto test-setup-firebirdx64
if errorlevel 1 goto test-setup-firebirdx86
if errorlevel 0 goto test-setup-sqlserver

:test-setup-sqlserver
set CONFIG_NAME=MSSQL
set PLATFORM=AnyCPU
set LIB_FILES=
set LIB_FILES2=
goto test-setup-generic

:test-setup-sqlservercex86
set CONFIG_NAME=SqlServerCe32
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\SqlServerCe\*.dll
set LIB_FILES2=lib\teamcity\SqlServerCe\X86\*.dll
goto test-setup-generic

:test-setup-sqlservercex64
set CONFIG_NAME=SqlServerCe64
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\sqlServerCe\*.dll
set LIB_FILES2=lib\teamcity\sqlServerCe\AMD64\*.dll
goto test-setup-generic

:test-setup-firebirdx86
set CONFIG_NAME=FireBird
set PLATFORM=x86
set LIB_FILES=lib\teamcity\firebird\*.dll
goto test-setup-generic

:test-setup-firebirdx64
set CONFIG_NAME=FireBird
set PLATFORM=x64
set LIB_FILES=lib\teamcity\firebird\*.dll
goto test-setup-generic

:test-setup-sqlitex86
set CONFIG_NAME=SQLite
set PLATFORM=x86
set LIB_FILES=lib\teamcity\sqlite\x86\*
set LIB_FILES2=
goto test-setup-generic

:test-setup-sqlitex64
set CONFIG_NAME=SQLite
set PLATFORM=x64
set LIB_FILES=lib\teamcity\sqlite\x64\*
set LIB_FILES2=
goto test-setup-generic

:test-setup-postgresql
set CONFIG_NAME=PostgreSQL
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\postgresql\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-mysql
set CONFIG_NAME=MySql
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\mysql\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-oracle
set CONFIG_NAME=Oracle
set PLATFORM=x86
set LIB_FILES=lib\teamcity\oracle\x86\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-generic
set CFGNAME=
set /p CFGNAME=Enter a name for your test configuration or press enter to use default name:
if /I "%CFGNAME%"=="" set CFGNAME=%CONFIG_NAME%-%PLATFORM%
mkdir "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
if /I "%LIB_FILES%"=="" goto test-setup-generic-skip-copy
copy %LIB_FILES% "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
if /I "%LIB_FILES2%"=="" goto test-setup-generic-skip-copy
copy %LIB_FILES2% "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
:test-setup-generic-skip-copy
copy src\NHibernate.Config.Templates\%CONFIG_NAME%.cfg.xml "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml"
echo Done setting up files.  Starting notepad to edit connection string in file:
echo %AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml
start notepad "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml"
echo When you're done, don't forget to activate the configuration through the menu.
goto main-menu

:test-activate
%BUILDTOOL% pick-folder "%AVAILABLE_CONFIGURATIONS%" folder.tmp "Which test configuration should be activated?"
set /p FOLDER=<folder.tmp
del folder.tmp
mkdir "%CURRENT_CONFIGURATION%" 2> nul
del /q "%CURRENT_CONFIGURATION%\*"
copy "%FOLDER%\*" "%CURRENT_CONFIGURATION%"
echo Configuration activated.
goto main-menu

:test-run
start "nunit3-console" cmd /K %NUNIT% --x86 --agents=1 --process=separate NHibernate.nunit
goto main-menu

rem :build-test
rem %NANT% test
rem goto main-menu

:build-async
%NANT% generate-async
goto main-menu

:build-debug
%NANT% clean build
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto main-menu

:build-release
%NANT% -D:project.config=release clean release
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto main-menu

:build-release-package
%NANT% -D:project.config=release clean package nugetpushbat
echo.
echo Assuming the build succeeded, your results will be in the build folder,
echo including NuGet packages and tools to push them.
echo.
goto main-menu

:teamcity-menu
echo.
echo --- TeamCity (CI) build options
echo A. NHibernate Trunk (default SQL Server)
echo B. NHibernate Trunk - Firebird (32-bit)
echo C. NHibernate Trunk - Firebird (64-bit)
echo D. NHibernate Trunk - SQLite (32-bit)
echo E. NHibernate Trunk - SQLite (64-bit)
echo F. NHibernate Trunk - PostgreSQL
echo G. NHibernate Trunk - Oracle (32-bit)
echo H. NHibernate Trunk - Oracle Managed (32-bit)
echo I. NHibernate Trunk - Oracle Managed (64-bit)
echo J. NHibernate Trunk - SQL Server Compact (32-bit)
echo K. NHibernate Trunk - SQL Server Compact (64-bit)
echo L. NHibernate Trunk - SQL Server ODBC (32-bit)
echo.
echo X.  Exit to main menu.
echo.

%BUILDTOOL% prompt ABCDEFGHIJKLX
if errorlevel 12 goto main-menu
if errorlevel 11 goto teamcity-sqlServerOdbc
if errorlevel 10 goto teamcity-sqlServerCe64
if errorlevel 9 goto teamcity-sqlServerCe32
if errorlevel 8 goto teamcity-oraclemanaged-64
if errorlevel 7 goto teamcity-oraclemanaged-32
if errorlevel 6 goto teamcity-oracle32
if errorlevel 5 goto teamcity-postgresql
if errorlevel 4 goto teamcity-sqlite64
if errorlevel 3 goto teamcity-sqlite32
if errorlevel 2 goto teamcity-firebird64
if errorlevel 1 goto teamcity-firebird32
if errorlevel 0 goto teamcity-trunk

:teamcity-trunk
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-firebird32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=firebird32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-firebird64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=firebird64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlite32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlite32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlite64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlite64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-postgresql
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=postgresql
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oracle32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oraclemanaged-32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle-managed32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oraclemanaged-64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle-managed64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerOdbc
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerOdbc
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerCe32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerCe32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerCe64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerCe64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:end
popd

@echo off
pushd %~dp0

set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe"
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe"

:main-menu
echo ========================= NHIBERNATE BUILD MENU ==========================
echo --- TESTING ---
echo B. (Step 1) Set up a new test configuration for a particular database.
echo C. (Step 2) Activate a test configuration.
echo D. (Step 3) Run tests using active configuration (Needs built in Visual Studio).
echo.
echo --- BUILD ---
echo E. Build NHibernate (Debug)
echo F. Build NHibernate (Release)
echo G. Build Release Package (Also runs tests and creates documentation)
echo.
echo --- Code generation ---
echo H. Generate async code (Generates files in Async sub-folders)
echo.
echo --- TeamCity (CI) build options
echo I. TeamCity build menu
echo.
echo --- Exit ---
echo X. Make the beautiful build menu go away.
echo.

%BUILDTOOL% prompt BCDEFGHIX
if errorlevel 8 goto end
if errorlevel 7 goto teamcity-menu
if errorlevel 6 goto build-async
if errorlevel 5 goto build-release-package
if errorlevel 4 goto build-release
if errorlevel 3 goto build-debug
if errorlevel 2 goto test-run
if errorlevel 1 goto test-activate
if errorlevel 0 goto test-setup-menu

:test-setup-menu
echo A. Add a test configuration for SQL Server.
echo B. Add a test configuration for Firebird (x86).
echo C. Add a test configuration for Firebird (x64). [not recommended]
echo D. Add a test configuration for SQLite (x86).
echo E. Add a test configuration for SQLite (x64). [not recommended]
echo F. Add a test configuration for PostgreSQL.
echo G. Add a test configuration for Oracle.
echo H. Add a test configuration for SQL Server Compact (x86).
echo I. Add a test configuration for SQL Server Compact (x64).
echo J. Add a test configuration for MySql.
echo.
echo X.  Exit to main menu.
echo.

%BUILDTOOL% prompt ABCDEFGHIJX
if errorlevel 10 goto main-menu
if errorlevel 9 goto test-setup-mysql
if errorlevel 8 goto test-setup-sqlservercex64
if errorlevel 7 goto test-setup-sqlservercex86
if errorlevel 6 goto test-setup-oracle
if errorlevel 5 goto test-setup-postgresql
if errorlevel 4 goto test-setup-sqlitex64
if errorlevel 3 goto test-setup-sqlitex86
if errorlevel 2 goto test-setup-firebirdx64
if errorlevel 1 goto test-setup-firebirdx86
if errorlevel 0 goto test-setup-sqlserver

:test-setup-sqlserver
set CONFIG_NAME=MSSQL
set PLATFORM=AnyCPU
set LIB_FILES=
set LIB_FILES2=
goto test-setup-generic

:test-setup-sqlservercex86
set CONFIG_NAME=SqlServerCe32
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\SqlServerCe\*.dll
set LIB_FILES2=lib\teamcity\SqlServerCe\X86\*.dll
goto test-setup-generic

:test-setup-sqlservercex64
set CONFIG_NAME=SqlServerCe64
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\sqlServerCe\*.dll
set LIB_FILES2=lib\teamcity\sqlServerCe\AMD64\*.dll
goto test-setup-generic

:test-setup-firebirdx86
set CONFIG_NAME=FireBird
set PLATFORM=x86
set LIB_FILES=lib\teamcity\firebird\*.dll
goto test-setup-generic

:test-setup-firebirdx64
set CONFIG_NAME=FireBird
set PLATFORM=x64
set LIB_FILES=lib\teamcity\firebird\*.dll
goto test-setup-generic

:test-setup-sqlitex86
set CONFIG_NAME=SQLite
set PLATFORM=x86
set LIB_FILES=lib\teamcity\sqlite\x86\*
set LIB_FILES2=
goto test-setup-generic

:test-setup-sqlitex64
set CONFIG_NAME=SQLite
set PLATFORM=x64
set LIB_FILES=lib\teamcity\sqlite\x64\*
set LIB_FILES2=
goto test-setup-generic

:test-setup-postgresql
set CONFIG_NAME=PostgreSQL
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\postgresql\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-mysql
set CONFIG_NAME=MySql
set PLATFORM=AnyCPU
set LIB_FILES=lib\teamcity\mysql\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-oracle
set CONFIG_NAME=Oracle
set PLATFORM=x86
set LIB_FILES=lib\teamcity\oracle\x86\*.dll
set LIB_FILES2=
goto test-setup-generic

:test-setup-generic
set CFGNAME=
set /p CFGNAME=Enter a name for your test configuration or press enter to use default name:
if /I "%CFGNAME%"=="" set CFGNAME=%CONFIG_NAME%-%PLATFORM%
mkdir "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
if /I "%LIB_FILES%"=="" goto test-setup-generic-skip-copy
copy %LIB_FILES% "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
if /I "%LIB_FILES2%"=="" goto test-setup-generic-skip-copy
copy %LIB_FILES2% "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%"
:test-setup-generic-skip-copy
copy src\NHibernate.Config.Templates\%CONFIG_NAME%.cfg.xml "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml"
echo Done setting up files.  Starting notepad to edit connection string in file:
echo %AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml
start notepad "%AVAILABLE_CONFIGURATIONS%\%CFGNAME%\hibernate.cfg.xml"
echo When you're done, don't forget to activate the configuration through the menu.
goto main-menu

:test-activate
%BUILDTOOL% pick-folder "%AVAILABLE_CONFIGURATIONS%" folder.tmp "Which test configuration should be activated?"
set /p FOLDER=<folder.tmp
del folder.tmp
mkdir "%CURRENT_CONFIGURATION%" 2> nul
del /q "%CURRENT_CONFIGURATION%\*"
copy "%FOLDER%\*" "%CURRENT_CONFIGURATION%"
echo Configuration activated.
goto main-menu

:test-run
SET NUNITPLATFORM=
IF /I "%PLATFORM%" NEQ "x64" set NUNITPLATFORM=--x86
start "nunit3-console" cmd /K %NUNIT% %NUNITPLATFORM% --agents=1 --process=separate NHibernate.nunit
goto main-menu

rem :build-test
rem %NANT% test
rem goto main-menu

:build-async
%NANT% generate-async
goto main-menu

:build-debug
%NANT% clean build
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto main-menu

:build-release
%NANT% -D:project.config=release clean release
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto main-menu

:build-release-package
%NANT% -D:project.config=release clean package nugetpushbat
echo.
echo Assuming the build succeeded, your results will be in the build folder,
echo including NuGet packages and tools to push them.
echo.
goto main-menu

:teamcity-menu
echo.
echo --- TeamCity (CI) build options
echo A. NHibernate Trunk (default SQL Server)
echo B. NHibernate Trunk - Firebird (32-bit)
echo C. NHibernate Trunk - Firebird (64-bit)
echo D. NHibernate Trunk - SQLite (32-bit)
echo E. NHibernate Trunk - SQLite (64-bit)
echo F. NHibernate Trunk - PostgreSQL
echo G. NHibernate Trunk - Oracle (32-bit)
echo H. NHibernate Trunk - Oracle Managed (32-bit)
echo I. NHibernate Trunk - Oracle Managed (64-bit)
echo J. NHibernate Trunk - SQL Server Compact (32-bit)
echo K. NHibernate Trunk - SQL Server Compact (64-bit)
echo L. NHibernate Trunk - SQL Server ODBC (32-bit)
echo.
echo X.  Exit to main menu.
echo.

%BUILDTOOL% prompt ABCDEFGHIJKLX
if errorlevel 12 goto main-menu
if errorlevel 11 goto teamcity-sqlServerOdbc
if errorlevel 10 goto teamcity-sqlServerCe64
if errorlevel 9 goto teamcity-sqlServerCe32
if errorlevel 8 goto teamcity-oraclemanaged-64
if errorlevel 7 goto teamcity-oraclemanaged-32
if errorlevel 6 goto teamcity-oracle32
if errorlevel 5 goto teamcity-postgresql
if errorlevel 4 goto teamcity-sqlite64
if errorlevel 3 goto teamcity-sqlite32
if errorlevel 2 goto teamcity-firebird64
if errorlevel 1 goto teamcity-firebird32
if errorlevel 0 goto teamcity-trunk

:teamcity-trunk
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-firebird32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=firebird32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-firebird64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=firebird64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlite32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlite32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlite64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlite64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-postgresql
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=postgresql
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oracle32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oraclemanaged-32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle-managed32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-oraclemanaged-64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=oracle-managed64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerOdbc
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerOdbc
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerCe32
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerCe32
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:teamcity-sqlServerCe64
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlServerCe64
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
goto main-menu

:end
popd

Update wording in ShowBuildMenu and allow NUnit tests to be ran with --x64


@echo off

::: clean, APK
call gradlew clean ^
 :app:assembleQuad5Release

pause

Add build batch file

Add build batch file