2018-09-06 02:18:42 +00:00
|
|
|
@rem Build janet on windows
|
2018-08-06 01:13:14 +00:00
|
|
|
@rem
|
2018-09-06 02:18:42 +00:00
|
|
|
@rem Open a "Windows SDK Command Shell" and cd to the janet directory
|
2018-08-07 04:54:47 +00:00
|
|
|
@rem Then run this script with no arguments to build the executable
|
2018-08-06 01:13:14 +00:00
|
|
|
|
|
|
|
@echo off
|
|
|
|
|
|
|
|
@rem Ensure correct command prompt
|
|
|
|
@if not defined INCLUDE goto :BADCMD
|
|
|
|
|
|
|
|
@rem Sub commands
|
|
|
|
@if "%1"=="help" goto HELP
|
|
|
|
@if "%1"=="clean" goto CLEAN
|
|
|
|
@if "%1"=="test" goto TEST
|
2018-12-08 22:10:46 +00:00
|
|
|
@if "%1"=="dist" goto DIST
|
2018-08-06 01:13:14 +00:00
|
|
|
|
|
|
|
@rem Set compile and link options here
|
|
|
|
@setlocal
|
2018-09-06 02:18:42 +00:00
|
|
|
@set JANET_COMPILE=cl /nologo /Isrc\include /c /O2 /W3 /LD /D_CRT_SECURE_NO_WARNINGS
|
|
|
|
@set JANET_LINK=link /nologo
|
2018-08-06 01:13:14 +00:00
|
|
|
|
2018-08-07 04:54:47 +00:00
|
|
|
mkdir build
|
|
|
|
mkdir build\core
|
|
|
|
mkdir build\mainclient
|
|
|
|
|
2018-08-06 01:13:14 +00:00
|
|
|
@rem Build the xxd tool for generating sources
|
2018-12-09 22:49:00 +00:00
|
|
|
@cl /nologo /c tools/xxd.c /Fobuild\xxd.obj
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
2018-08-07 04:54:47 +00:00
|
|
|
@link /nologo /out:build\xxd.exe build\xxd.obj
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
|
2018-12-06 19:30:11 +00:00
|
|
|
@rem Generate the embedded sources
|
|
|
|
@build\xxd.exe src\core\core.janet build\core\core.gen.c janet_gen_core
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
2018-12-06 19:30:11 +00:00
|
|
|
@build\xxd.exe src\mainclient\init.janet build\mainclient\init.gen.c janet_gen_init
|
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
|
|
|
|
@rem Build the generated sources
|
|
|
|
@%JANET_COMPILE% /Fobuild\core\core.gen.obj build\core\core.gen.c
|
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
@%JANET_COMPILE% /Fobuild\mainclient\init.gen.obj build\mainclient\init.gen.c
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
|
|
|
|
@rem Build the sources
|
2018-08-07 04:54:47 +00:00
|
|
|
for %%f in (src\core\*.c) do (
|
2018-12-15 18:52:07 +00:00
|
|
|
@%JANET_COMPILE% /Fobuild\core\%%~nf.obj %%f
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
)
|
|
|
|
|
|
|
|
@rem Build the main client
|
2018-08-07 04:54:47 +00:00
|
|
|
for %%f in (src\mainclient\*.c) do (
|
2018-12-15 18:52:07 +00:00
|
|
|
@%JANET_COMPILE% /Fobuild\mainclient\%%~nf.obj %%f
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
)
|
|
|
|
|
|
|
|
@rem Link everything to main client
|
2018-09-06 02:18:42 +00:00
|
|
|
%JANET_LINK% /out:janet.exe build\core\*.obj build\mainclient\*.obj
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
|
2018-09-06 02:18:42 +00:00
|
|
|
echo === Successfully built janet.exe for Windows ===
|
2018-08-07 04:54:47 +00:00
|
|
|
echo === Run 'build_win test' to run tests. ==
|
|
|
|
echo === Run 'build_win clean' to delete build artifacts. ===
|
2018-08-06 01:13:14 +00:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
@rem Not using correct command line
|
|
|
|
:BADCMD
|
|
|
|
@echo You must open a "Visual Studio .NET Command Prompt" to run this script
|
|
|
|
exit /b 1
|
|
|
|
|
|
|
|
@rem Show help
|
|
|
|
:HELP
|
|
|
|
@echo.
|
2018-12-15 20:42:27 +00:00
|
|
|
@echo Usage: build_windows [subcommand=clean,help,test,dist]
|
2018-08-06 01:13:14 +00:00
|
|
|
@echo.
|
2018-09-06 02:18:42 +00:00
|
|
|
@echo Script to build janet on windows. Must be run from the Visual Studio
|
2018-08-06 01:13:14 +00:00
|
|
|
@echo command prompt.
|
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
@rem Clean build artifacts
|
|
|
|
:CLEAN
|
2018-09-06 02:18:42 +00:00
|
|
|
del janet.exe janet.exp janet.lib
|
2018-08-07 04:54:47 +00:00
|
|
|
rd /s /q build
|
2018-08-06 01:13:14 +00:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
@rem Run tests
|
|
|
|
:TEST
|
2018-09-06 02:18:42 +00:00
|
|
|
for %%f in (test/suite*.janet) do (
|
2018-12-15 18:52:07 +00:00
|
|
|
janet.exe test\%%f
|
|
|
|
@if errorlevel 1 goto :TESTFAIL
|
2018-08-06 01:13:14 +00:00
|
|
|
)
|
|
|
|
exit /b 0
|
2018-12-08 22:10:46 +00:00
|
|
|
|
|
|
|
@rem Build a dist directory
|
|
|
|
:DIST
|
|
|
|
mkdir dist
|
2018-12-25 22:37:52 +00:00
|
|
|
janet.exe tools\gendoc.janet > dist\doc.html
|
2018-12-08 22:10:46 +00:00
|
|
|
copy janet.exe dist\janet.exe
|
2018-12-08 22:26:07 +00:00
|
|
|
copy LICENSE dist\LICENSE
|
2018-12-08 22:10:46 +00:00
|
|
|
copy README.md dist\README.md
|
|
|
|
copy janet.lib dist\janet.lib
|
2018-12-08 22:26:07 +00:00
|
|
|
copy janet.exp dist\janet.exp
|
2018-12-08 22:10:46 +00:00
|
|
|
copy src\include\janet\janet.h dist\janet.h
|
2018-12-08 22:40:05 +00:00
|
|
|
exit /b 0
|
2018-12-08 22:10:46 +00:00
|
|
|
|
2018-08-06 01:13:14 +00:00
|
|
|
:TESTFAIL
|
|
|
|
@echo.
|
|
|
|
@echo *******************************************************
|
|
|
|
@echo *** Tests FAILED -- Please check the error messages ***
|
|
|
|
@echo *******************************************************
|
|
|
|
exit /b 1
|
|
|
|
|
|
|
|
@rem Build failed
|
|
|
|
:BUILDFAIL
|
|
|
|
@echo.
|
|
|
|
@echo *******************************************************
|
|
|
|
@echo *** Build FAILED -- Please check the error messages ***
|
|
|
|
@echo *******************************************************
|
|
|
|
exit /b 1
|