squirrel icon indicating copy to clipboard operation
squirrel copied to clipboard

A batch script for easy build (using GCC) on Windows

Open PNBRQK opened this issue 4 years ago • 0 comments

For People having only GCC, w/o advanced tools like cmake Edit: This is derived from the Makefiles in the source tree. because those Makefiles issue commands like mkdir -p which conflict the syntax of cmd.exe shell, and they call the make tool make rather than mingw32-make, one cannot simply type mingw32-make to build in a native cmd.exe shell.

:: build.bat
:: put this script in the top level directory of the SQ source tree
:: Usage: build.bat [sq64 | sqprof]

@echo off
pushd %~dp0
setlocal

if not exist lib\NUL mkdir lib
if not exist bin\NUL mkdir bin

set "lib_dir=%~dp0lib"
set "bin_dir=%~dp0bin"
 
set "includeflag=-I../include -I. -Iinclude"

if /i "%1"=="sq64" (
	set "gccflag_for_libs=-O2 -m64 -D_SQ64 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing"
	set "gccflag_for_sq=-O2 -m64 -D_SQ64 -fno-exceptions -fno-rtti"
	goto action
)

if /i "%1"=="sqprof" (
	set "gccflag_for_libs=-O2 -m32 -pg -fno-exceptions -fno-rtti -pie -gstabs -g3 -Wall -fno-strict-aliasing"
	set "gccflag_for_sq=-O2 -m32 -pg -fno-exceptions -fno-rtti -pie -gstabs -g3"
	goto action
)

set "gccflag_for_libs=-O2 -m32 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing"
set "gccflag_for_sq=-O2 -m32 -fno-exceptions -fno-rtti"

:action

chdir squirrel
for %%i in (*.cpp) do (g++ %gccflag_for_libs% -c %%~nxi %includeflag%)
ar rc "%lib_dir%\libsquirrel.a" *.o
del /q *.o

chdir ..\sqstdlib
for %%i in (*.cpp) do (g++ %gccflag_for_libs% -c %%~nxi %includeflag%)
ar rc "%lib_dir%\libsqstdlib.a" *.o
del /q *.o

chdir ..\sq
g++ %gccflag_for_sq% -o "%bin_dir%\sq" sq.c %includeflag% -I../sqlibs -L../lib -lsquirrel -lsqstdlib

chdir ..

endlocal
popd
echo on

PNBRQK avatar Apr 30 '20 12:04 PNBRQK