From 5c6a55b36f3b2c8b23e28a013d42980501f6f4e1 Mon Sep 17 00:00:00 2001 From: Frankly George <54015-franklygeorge@users.noreply.gitgud.io> Date: Thu, 8 Feb 2024 00:42:10 +0000 Subject: [PATCH] Legacy is legacy --- compile-legacy.bat | 127 ++++++++++++++++++++++++++++++++++++++++++++- compile.bat | 121 ++++-------------------------------------- sanityCheck.bat | 7 ++- 3 files changed, 140 insertions(+), 115 deletions(-) diff --git a/compile-legacy.bat b/compile-legacy.bat index a07be8664a8..448dc9c4eb4 100644 --- a/compile-legacy.bat +++ b/compile-legacy.bat @@ -1,2 +1,125 @@ -:: just a shortcut for compile.bat --legacy -call compile.bat --legacy \ No newline at end of file +@echo off +:: Free Cities Basic Compiler - Windows + +:: Set working directory +pushd %~dp0 +SET BASEDIR=%~dp0 +SETLOCAL EnableDelayedExpansion + +:: process arguments from command line +:processargs +SET ARG=%1 +IF DEFINED ARG ( + :: legacy arguments + IF "%ARG%"=="EXTRAMEMORY" SET SORT_MEM=65535 + IF "%ARG%"=="EMEMORY" SET SORT_MEM=65535 + IF "%ARG%"=="EXTRAMEM" SET SORT_MEM=65535 + IF "%ARG%"=="--extramem" SET SORT_MEM=65535 + :: create theme + if "%ARG%"=="--themes" SET "THEMES=True" + if "%ARG%"=="--help" GOTO :help + SHIFT + GOTO processargs +) + +:legacybuild + +:: if the bin directory doesn't exist, then create it +if NOT EXIST .\bin\ ( + MKDIR .\bin\ +) + +if DEFINED THEMES ( + CALL :compile_themes +) + +ECHO Compiling FC... +ECHO Press Ctrl+C at any time to cancel the build. + +:: See if we can find a git installation +set GITFOUND=no +for %%k in (HKCU HKLM) do ( + for %%w in (\ \Wow6432Node\) do ( + for /f "skip=2 delims=: tokens=1*" %%a in ('reg query "%%k\SOFTWARE%%wMicrosoft\Windows\CurrentVersion\Uninstall\Git_is1" /v InstallLocation 2^> nul') do ( + for /f "tokens=3" %%z in ("%%a") do ( + set GIT=%%z:%%b + set GITFOUND=yes + goto FOUND + ) + ) + ) +) +:FOUND +if %GITFOUND% == yes ( + set "PATH=%GIT%bin;%PATH%" + echo|set /p out="App.Version.commitHash = " > "%~dp0src\002-config\fc-version.js.commitHash.js" + git rev-parse --sq --short HEAD >> "%~dp0src\002-config\fc-version.js.commitHash.js" 2>NUL + if errorlevel 1 echo|set /p out="null" >> "%~dp0src\002-config\fc-version.js.commitHash.js" + echo|set /p out=";" >> "%~dp0src\002-config\fc-version.js.commitHash.js" +) + +if not exist "bin\resources" mkdir bin\resources +CALL devTools/concatFiles.bat js\ "*.js" bin\fc.js +CALL devTools/concatFiles.bat css\ "*.css" bin\fc.css +SET TWEEGO_PATH=%~dp0devTools\tweeGo\storyFormats +:: Run the appropriate compiler for the user's CPU architecture. +if %PROCESSOR_ARCHITECTURE% == AMD64 ( + CALL "%~dp0devTools\tweeGo\tweego_win64.exe" -o "%~dp0bin/FC_pregmod.html" --module=bin/fc.js --module=bin/fc.css --head resources/raster/favicon/arcologyVector.html "%~dp0src" +) else ( + CALL "%~dp0devTools\tweeGo\tweego_win86.exe" -o "%~dp0bin/FC_pregmod.html" --module=bin/fc.js --module=bin/fc.css --head resources/raster/favicon/arcologyVector.html "%~dp0src" +) +DEL bin\fc.js +DEL bin\fc.css +IF EXIST "%~dp0src\002-config\fc-version.js.commitHash.js" DEL "%~dp0src\002-config\fc-version.js.commitHash.js" + +ECHO Done + +:: keep window open instead of closing it +<nul set /p "=Press any key to exit" +pause >nul + +ENDLOCAL +popd +GOTO :eof + +:compile_themes +ECHO Compiling Themes... + +set back=%cd% +for /d %%i in (%~dp0\themes\*) do ( + CALL :compileDirectory %%i +) +cd %back% + +EXIT /B %ERRORLEVEL% + +:compileDirectory +REM ~1 is an absolute path, get name of directory here +REM https://stackoverflow.com/a/5480568 +set var1=%~1% +set var2=%var1% +set i=0 + +:loopprocess +for /F "tokens=1* delims=\" %%A in ( "%var1%" ) do ( + set /A i+=1 + set var1=%%B + goto loopprocess +) + +for /F "tokens=%i% delims=\" %%G in ( "%var2%" ) do set last=%%G + +REM compile +CALL devTools/concatFiles.bat "%%~1" "*.css" bin\"%last%".css +:: end loopprocess and compileDirectory +GOTO :eof + +:help +ECHO compile.bat [flags] +ECHO. +ECHO --themes: create themes +ECHO --extramem: passed to sort (as SORT_MEM) in devTools/concatFiles.bat +:: exit +ENDLOCAL +popd +exit /b 0 \ No newline at end of file diff --git a/compile.bat b/compile.bat index 1ec489dd0fe..5dbdc2df58b 100644 --- a/compile.bat +++ b/compile.bat @@ -1,5 +1,5 @@ @echo off -:: Free Cities Basic Compiler - Windows +:: Free Cities Compiler - Windows :: Set working directory pushd %~dp0 @@ -12,15 +12,8 @@ set "GULP=True" :processargs SET ARG=%1 IF DEFINED ARG ( - :: legacy arguments - IF "%ARG%"=="EXTRAMEMORY" SET SORT_MEM=65535 - IF "%ARG%"=="EMEMORY" SET SORT_MEM=65535 - IF "%ARG%"=="EXTRAMEM" SET SORT_MEM=65535 :: disable building with Gulp if "%ARG%"=="--legacy" SET "GULP=" - :: create themes using legacy compile - if "%ARG%"=="--themes" SET "THEMES=True" - if "%ARG%"=="--help" GOTO :help SHIFT GOTO processargs ) @@ -62,125 +55,29 @@ if DEFINED GULP ( ECHO Using Gulp to build FC. ECHO Pass the '--legacy' flag to use the legacy compiler or run 'compile-legacy.bat' instead. - if DEFINED THEMES ( - ECHO The '--themes' flag only needed for legacy compiler. Gulp always compiles themes. - ECHO Either remove it or add the '--legacy' flag to use the legacy compiler. - ) - :: execute gulp command CALL npx gulp all --color + :: keep window open instead of closing it + <nul set /p "=Press any key to exit" + pause >nul + :: exit ENDLOCAL popd exit /b 0 ) -) else ( - :: Using legacy compiler since the '--legacy' flag was set. - GOTO legacybuild ) -:gulpmessage ECHO. ECHO Development builds will be more debugable (will include source maps) if you enable Gulp. ECHO To enable Gulp make sure you have git and Node installed. ECHO To remove these messages, pass the '--legacy' flag or run 'compile-legacy.bat' instead. ECHO. -:legacybuild - -:: if the bin directory doesn't exist, then create it -if NOT EXIST .\bin\ ( - MKDIR .\bin\ -) - -if DEFINED THEMES ( - CALL :compile_themes -) - -ECHO Compiling FC... -ECHO Press Ctrl+C at any time to cancel the build. - -:: See if we can find a git installation -set GITFOUND=no -for %%k in (HKCU HKLM) do ( - for %%w in (\ \Wow6432Node\) do ( - for /f "skip=2 delims=: tokens=1*" %%a in ('reg query "%%k\SOFTWARE%%wMicrosoft\Windows\CurrentVersion\Uninstall\Git_is1" /v InstallLocation 2^> nul') do ( - for /f "tokens=3" %%z in ("%%a") do ( - set GIT=%%z:%%b - set GITFOUND=yes - goto FOUND - ) - ) - ) -) -:FOUND -if %GITFOUND% == yes ( - set "PATH=%GIT%bin;%PATH%" - echo|set /p out="App.Version.commitHash = " > "%~dp0src\002-config\fc-version.js.commitHash.js" - git rev-parse --sq --short HEAD >> "%~dp0src\002-config\fc-version.js.commitHash.js" 2>NUL - if errorlevel 1 echo|set /p out="null" >> "%~dp0src\002-config\fc-version.js.commitHash.js" - echo|set /p out=";" >> "%~dp0src\002-config\fc-version.js.commitHash.js" -) - -if not exist "bin\resources" mkdir bin\resources -CALL devTools/concatFiles.bat js\ "*.js" bin\fc.js -CALL devTools/concatFiles.bat css\ "*.css" bin\fc.css -SET TWEEGO_PATH=%~dp0devTools\tweeGo\storyFormats -:: Run the appropriate compiler for the user's CPU architecture. -if %PROCESSOR_ARCHITECTURE% == AMD64 ( - CALL "%~dp0devTools\tweeGo\tweego_win64.exe" -o "%~dp0bin/FC_pregmod.html" --module=bin/fc.js --module=bin/fc.css --head resources/raster/favicon/arcologyVector.html "%~dp0src" -) else ( - CALL "%~dp0devTools\tweeGo\tweego_win86.exe" -o "%~dp0bin/FC_pregmod.html" --module=bin/fc.js --module=bin/fc.css --head resources/raster/favicon/arcologyVector.html "%~dp0src" -) -DEL bin\fc.js -DEL bin\fc.css -IF EXIST "%~dp0src\002-config\fc-version.js.commitHash.js" DEL "%~dp0src\002-config\fc-version.js.commitHash.js" - +:: Using legacy compiler since the '--legacy' flag was set or depenencies were missing. +CALL compile-legacy.bat +:: exit ENDLOCAL popd -ECHO Done -GOTO :eof - -:compile_themes -ECHO Compiling Themes... - -set back=%cd% -for /d %%i in (%~dp0\themes\*) do ( - CALL :compileDirectory %%i -) -cd %back% - -EXIT /B %ERRORLEVEL% - -:compileDirectory -REM ~1 is an absolute path, get name of directory here -REM https://stackoverflow.com/a/5480568 -set var1=%~1% -set var2=%var1% -set i=0 - -:loopprocess -for /F "tokens=1* delims=\" %%A in ( "%var1%" ) do ( - set /A i+=1 - set var1=%%B - goto loopprocess -) - -for /F "tokens=%i% delims=\" %%G in ( "%var2%" ) do set last=%%G - -REM compile -CALL devTools/concatFiles.bat "%%~1" "*.css" bin\"%last%".css -:: end loopprocess and compileDirectory -GOTO :eof - -:: print help -:help -ECHO compile.bat [flags] -ECHO. -ECHO --legacy: build using legacy compiler (less features, but no extra depenencies) -ECHO --themes: create themes using legacy compiler (automatically created in new compiler) -ECHO EXTRAMEM: passed to the sort script when using legacy compiler -ECHO --npm: install npm modules automatically -:: exit -GOTO :eof \ No newline at end of file +exit /b 0 \ No newline at end of file diff --git a/sanityCheck.bat b/sanityCheck.bat index 66eb8252085..e867346942d 100644 --- a/sanityCheck.bat +++ b/sanityCheck.bat @@ -19,8 +19,13 @@ for %%k in (HKCU HKLM) do ( :FOUND if %GITFOUND% == yes ( set "PATH=%GIT%bin;%PATH%" - echo Running sanityCheck.sh using git bash + echo Running sanityCheck.sh using git bash... bash --login -c "./sanityCheck.sh" ) else ( echo Could not find git installation ) + +:: keep window open instead of closing it +<nul set /p "=Press any key to exit" +pause >nul +popd \ No newline at end of file -- GitLab