Advertisement
alaestor

how NOT to compile C++

Aug 15th, 2017 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.65 KB | None | 0 0
  1. @ECHO off
  2. :: Output Formatting Glitter
  3. SET NLM=^
  4.  
  5.  
  6. SET NL=^^^%NLM%%NLM%^%NLM%%NLM%
  7. SET NL3=^^^%NLM%%NLM%^%NLM%%NLM%^^^%NLM%%NLM%^%NLM%%NLM%^^^%NLM%%NLM%^%NLM%%NLM%
  8. SET NS=^^^%NLM%%NLM%^%NLM%%NLM%*****************************************************************************^^^%NLM%%NLM%^%NLM%%NLM%
  9. :: warning. Lines 4 and 5 are required to be empty for the formatting to work properly
  10. :: idea: > to temp file, read temp file to stdout, >> temp file to log file, delete temp file.
  11.  
  12.  
  13.  
  14.  
  15. :OPTIONS
  16. SET Flags=-std=c++14 -Wall -Wextra -pedantic
  17. SET LogName=compile.log
  18.  
  19.  
  20.  
  21.  
  22. :START
  23.     SET msg=Running compile script
  24.         ECHO %msg% > %LogName% 2>&1
  25.         ECHO %NL%%msg%
  26.     GOTO:COMMONOBJECTS
  27. ::START
  28.  
  29.  
  30.  
  31.  
  32. :COMMONOBJECTS
  33.     SET msg=compiling common objects...
  34.         ECHO %msg% >> %LogName% 2>&1
  35.         ECHO %NL3%%NS%        %msg%%NS%
  36.  
  37.     SET compile_objects=(Utility Manifest)
  38.     SET dir=xCommon
  39.         @ECHO on
  40.         @FOR %%i IN %compile_objects% DO (
  41.             CALL g++ %Flags% -c -o "./obj/%%i.o" "./%dir%/%%i.cpp" >> %LogName% 2>&1
  42.             @IF ERRORLEVEL 1 (GOTO:ERR)
  43.         )
  44.         @ECHO off
  45.         SET proj_objects=
  46. ::COMMONOBJECTS
  47.  
  48.  
  49.  
  50.  
  51. :XCHILD
  52.     SET msg=compiling child objects...
  53.         ECHO %msg% >> %LogName% 2>&1
  54.         ECHO %NL3%%NS%        %msg%%NS%
  55.  
  56.     SET compile_objects=(xchild ManifestChild SyncroChild)
  57.     SET dir=xChild
  58.         @ECHO on
  59.         @FOR %%i IN %compile_objects% DO (
  60.             CALL g++ %Flags% -c -o "./obj/%%i.o" "./%dir%/%%i.cpp" >> %LogName% 2>&1
  61.             @IF ERRORLEVEL 1 (GOTO:ERR)
  62.         )
  63.         @ECHO off
  64.  
  65.     SET msg=compiling child executible...
  66.         ECHO %msg% >> %LogName% 2>&1
  67.         ECHO %NL3%%NS%        %msg%%NS%
  68.  
  69.     SET filename=xfile_writer.exe
  70.     SET used_objects=(xchild Manifest Utility ManifestChild SyncroChild)
  71.         FOR %%i IN %used_objects% DO CALL SET "proj_objects=%%proj_objects%% "./obj/%%i.o""
  72.         @ECHO on
  73.         g++ -mconsole -s -o "./release/%filename%" %proj_objects% >> %LogName% 2>&1
  74.         @IF ERRORLEVEL 1 (GOTO:ERR)
  75.         @ECHO off
  76.         SET proj_objects=
  77. ::XCHILD
  78.  
  79.  
  80.  
  81.  
  82. :XPARENT
  83.     SET msg=compiling xfile objects...
  84.         ECHO %msg% >> %LogName% 2>&1
  85.         ECHO %NL3%%NS%        %msg%%NS%
  86.  
  87.     SET compile_objects=(xfile xfile_internal ManifestParent SyncroParent)
  88.     SET dir=xParent
  89.         @ECHO on
  90.         @FOR %%i IN %compile_objects% DO (
  91.             CALL g++ %Flags% -c -o "./obj/%%i.o" "./%dir%/%%i.cpp" >> %LogName% 2>&1
  92.             @IF ERRORLEVEL 1 (GOTO:ERR)
  93.         )
  94.         @ECHO off
  95.  
  96.     SET msg=compiling xfile windres resources...
  97.         ECHO %msg% >> %LogName% 2>&1
  98.         ECHO %NL3%%NS%        %msg%%NS%
  99.  
  100.     @ECHO on
  101.     windres "./%dir%/xfile.rc" -O coff -o "./obj/xfile.res" >> %LogName% 2>&1
  102.     @IF ERRORLEVEL 1 (GOTO:ERR)
  103.     @ECHO off
  104.     SET proj_objects=
  105. ::XPARENT
  106.  
  107.  
  108.  
  109.  
  110. :UNITTEST
  111.     SET msg=compiling unit test objects...
  112.         ECHO %msg% >> %LogName% 2>&1
  113.         ECHO %NL3%%NS%%msg%
  114.  
  115.     SET compile_objects=(tester)
  116.     SET dir=tester
  117.         @ECHO on
  118.         @FOR %%i IN %compile_objects% DO (
  119.             CALL g++ %Flags% -c -o "./obj/%%i.o" "./%dir%/%%i.cpp" >> %LogName% 2>&1
  120.             @IF ERRORLEVEL 1 (GOTO:ERR)
  121.         )
  122.         @ECHO off
  123.  
  124.     SET msg=compiling unit test executible...
  125.         ECHO %msg% >> %LogName% 2>&1
  126.         ECHO %NL3%%NS%        %msg%%NS%
  127.  
  128.     SET filename=xfile_unit_test
  129.     SET used_objects=(tester xfile xfile_internal Utility Manifest ManifestParent SyncroParent)
  130.         FOR %%i IN %used_objects% DO CALL SET "proj_objects=%%proj_objects%% "./obj/%%i.o""
  131.         @ECHO on
  132.         g++ -mconsole -o "./release/%filename%.exe" %proj_objects% "./obj/xfile.res" >> %LogName% 2>&1
  133.         @IF ERRORLEVEL 1 (GOTO:ERR)
  134.         @ECHO off
  135.         SET proj_objects=
  136. ::UNITTEST
  137.  
  138.  
  139.  
  140.  
  141. :END
  142.     SET msg=compile script finished successfully.
  143.         ECHO %msg% >> %LogName% 2>&1
  144.         ECHO %NL3%%NS%        %msg%%NS%
  145.     PAUSE
  146.     GOTO:EOF
  147. :ERR
  148.     @ECHO off
  149.     SET msg=!!! Error Detected !!!
  150.         ECHO %msg% >> %LogName% 2>&1
  151.         ECHO %NL3%%msg%
  152. :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement