From 5b9699f330f6aa5846800337fad32554b3a7334e Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sat, 20 Feb 2021 00:06:20 -0500
Subject: [PATCH] Add extra memory settings to compile.bat

---
 compile.bat              | 8 ++++++++
 devTools/concatFiles.bat | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/compile.bat b/compile.bat
index 1009033f4f4..869fd26680f 100644
--- a/compile.bat
+++ b/compile.bat
@@ -5,6 +5,14 @@
 pushd %~dp0
 SETLOCAL
 
+:: If compile is invoked with "extramemory", set SORT_MEM (used by concatFiles.bat)
+
+SET CMD_OPTION=%~1
+IF DEFINED CMD_OPTION IF /I [%CMD_OPTION%]==[EXTRAMEMORY] SET CMD_OPTION=EXTRAMEM
+IF DEFINED CMD_OPTION IF /I [%CMD_OPTION%]==[EMEMORY] SET CMD_OPTION=EXTRAMEM
+IF DEFINED CMD_OPTION IF /I [%CMD_OPTION%]==[EXTRAMEM] SET SORT_MEM=65535
+
+
 :: See if we can find a git installation
 set GITFOUND=no
 for %%k in (HKCU HKLM) do (
diff --git a/devTools/concatFiles.bat b/devTools/concatFiles.bat
index 5bb64b35847..064696a0650 100644
--- a/devTools/concatFiles.bat
+++ b/devTools/concatFiles.bat
@@ -8,10 +8,14 @@ CHCP 65001 > NUL
 :: TODO Proper temp file instead of bin\list.txt
 IF EXIST %3 DEL %3
 SET _LISTFILE=bin\list.txt
+SET _SORT_CMD=sort
+
+:: If SORT_MEM is defined, use memory option for SORT
+IF DEFINED SORT_MEM SET _SORT_CMD=%_SORT_CMD% /m %SORT_MEM%
 
 :: Collect sorted list of files
 ECHO "Ignore the first line to skip the BOM" >%_LISTFILE%
-(FOR /R "%~1" %%F IN (%2) DO echo "%%F") | sort >>%_LISTFILE%
+(FOR /R "%~1" %%F IN (%2) DO echo "%%F") | %_SORT_CMD% >>%_LISTFILE%
 
 :: If we have powershell available, strip the absolute path information
 :: If not, fail silently (which is fine, but will leak path information into the built file)
-- 
GitLab