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
|
2019-07-27 20:16:28 +00:00
|
|
|
@if "%1"=="install" goto INSTALL
|
2019-07-28 01:44:44 +00:00
|
|
|
@if "%1"=="test-install" goto TESTINSTALL
|
|
|
|
@if "%1"=="all" goto ALL
|
2018-08-06 01:13:14 +00:00
|
|
|
|
2019-03-24 19:04:47 +00:00
|
|
|
@rem Set compile and link options here
|
|
|
|
@setlocal
|
2019-11-09 21:05:07 +00:00
|
|
|
@set JANET_COMPILE=cl /nologo /Isrc\include /Isrc\conf /c /O2 /W3 /D_CRT_SECURE_NO_WARNINGS /MD
|
2019-03-24 19:04:47 +00:00
|
|
|
@set JANET_LINK=link /nologo
|
2019-07-27 20:16:28 +00:00
|
|
|
@set JANET_LINK_STATIC=lib /nologo
|
2019-03-24 19:04:47 +00:00
|
|
|
|
2019-08-19 01:01:47 +00:00
|
|
|
@rem Add janet build tag
|
|
|
|
if not "%JANET_BUILD%" == "" (
|
|
|
|
@set JANET_COMPILE=%JANET_COMPILE% /DJANET_BUILD="\"%JANET_BUILD%\""
|
|
|
|
)
|
|
|
|
|
2018-08-07 04:54:47 +00:00
|
|
|
mkdir build
|
|
|
|
mkdir build\core
|
|
|
|
mkdir build\mainclient
|
2019-02-08 18:37:14 +00:00
|
|
|
mkdir build\boot
|
2018-08-07 04:54:47 +00:00
|
|
|
|
2019-07-27 20:16:28 +00:00
|
|
|
@rem Build the bootstrap interpreter
|
2019-02-08 18:37:14 +00:00
|
|
|
for %%f in (src\core\*.c) do (
|
2019-08-19 01:01:47 +00:00
|
|
|
%JANET_COMPILE% /DJANET_BOOTSTRAP /Fobuild\boot\%%~nf.obj %%f
|
2019-02-08 18:37:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
)
|
|
|
|
for %%f in (src\boot\*.c) do (
|
2019-08-19 01:01:47 +00:00
|
|
|
%JANET_COMPILE% /DJANET_BOOTSTRAP /Fobuild\boot\%%~nf.obj %%f
|
2019-02-08 18:37:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
)
|
|
|
|
%JANET_LINK% /out:build\janet_boot.exe build\boot\*.obj
|
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
2020-01-29 05:38:52 +00:00
|
|
|
build\janet_boot . > build\janet.c
|
2018-08-06 01:13:14 +00:00
|
|
|
|
|
|
|
@rem Build the sources
|
2020-01-29 05:38:52 +00:00
|
|
|
%JANET_COMPILE% /Fobuild\janet.obj build\janet.c
|
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
%JANET_COMPILE% /Fobuild\shell.obj src\mainclient\shell.c
|
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
2018-08-06 01:13:14 +00:00
|
|
|
|
2019-05-29 00:45:39 +00:00
|
|
|
@rem Build the resources
|
|
|
|
rc /nologo /fobuild\janet_win.res janet_win.rc
|
|
|
|
|
2018-08-06 01:13:14 +00:00
|
|
|
@rem Link everything to main client
|
2020-01-29 05:38:52 +00:00
|
|
|
%JANET_LINK% /out:janet.exe build\janet.obj build\shell.obj build\janet_win.res
|
2018-08-06 01:13:14 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
|
|
|
|
2019-07-27 20:16:28 +00:00
|
|
|
@rem Build static library (libjanet.a)
|
2020-01-29 05:38:52 +00:00
|
|
|
%JANET_LINK_STATIC% /out:build\libjanet.lib build\janet.obj
|
2019-07-28 01:44:44 +00:00
|
|
|
@if errorlevel 1 goto :BUILDFAIL
|
2019-07-27 20:16:28 +00:00
|
|
|
|
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
|
2019-07-27 20:16:28 +00:00
|
|
|
del *.exe *.lib *.exp
|
2018-08-07 04:54:47 +00:00
|
|
|
rd /s /q build
|
2019-07-27 20:16:28 +00:00
|
|
|
rd /s /q dist
|
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
|
2019-07-28 01:44:44 +00:00
|
|
|
@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
|
2019-09-13 04:18:52 +00:00
|
|
|
janet.exe tools\removecr.janet dist\doc.html
|
2019-03-23 23:59:54 +00:00
|
|
|
|
2019-05-23 15:15:58 +00:00
|
|
|
copy build\janet.c dist\janet.c
|
2020-01-29 05:38:52 +00:00
|
|
|
copy src\mainclient\shell.c dist\shell.c
|
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
|
2019-06-01 14:38:28 +00:00
|
|
|
|
2018-12-08 22:10:46 +00:00
|
|
|
copy janet.lib dist\janet.lib
|
2018-12-08 22:26:07 +00:00
|
|
|
copy janet.exp dist\janet.exp
|
2019-07-27 20:16:28 +00:00
|
|
|
|
2019-02-19 01:13:35 +00:00
|
|
|
copy src\include\janet.h dist\janet.h
|
2019-06-20 21:28:22 +00:00
|
|
|
copy src\conf\janetconf.h dist\janetconf.h
|
2019-07-28 01:44:44 +00:00
|
|
|
copy build\libjanet.lib dist\libjanet.lib
|
2019-07-27 20:16:28 +00:00
|
|
|
|
2020-04-26 13:58:53 +00:00
|
|
|
copy .\jpm dist\jpm
|
2019-05-29 00:45:39 +00:00
|
|
|
copy tools\jpm.bat dist\jpm.bat
|
2019-07-27 20:16:28 +00:00
|
|
|
|
|
|
|
@rem Create installer
|
2019-12-19 18:45:38 +00:00
|
|
|
janet.exe -e "(->> janet/version (peg/match ''(* :d+ `.` :d+ `.` :d+)) first print)" > build\version.txt
|
2019-12-19 18:18:46 +00:00
|
|
|
janet.exe -e "(print (= (os/arch) :x64))" > build\64bit.txt
|
|
|
|
set /p JANET_VERSION= < build\version.txt
|
|
|
|
set /p SIXTYFOUR= < build\64bit.txt
|
2019-12-19 18:45:38 +00:00
|
|
|
echo "JANET_VERSION is %JANET_VERSION%"
|
2019-12-19 18:46:59 +00:00
|
|
|
"C:\Program Files (x86)\NSIS\makensis.exe" /DVERSION=%JANET_VERSION% /DSIXTYFOUR=%SIXTYFOUR% janet-installer.nsi
|
2019-07-27 20:16:28 +00:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
@rem Run the installer. (Installs to the local user with default settings)
|
2019-07-28 01:44:44 +00:00
|
|
|
:INSTALL
|
|
|
|
@echo Running Installer...
|
2020-04-01 14:26:20 +00:00
|
|
|
FOR %%a in (janet-*-windows-*-installer.exe) DO (
|
2019-07-28 05:05:15 +00:00
|
|
|
%%a /S /CurrentUser
|
2019-07-27 20:16:28 +00:00
|
|
|
)
|
2018-12-08 22:40:05 +00:00
|
|
|
exit /b 0
|
2018-12-08 22:10:46 +00:00
|
|
|
|
2019-07-28 01:44:44 +00:00
|
|
|
@rem Test the installation.
|
|
|
|
:TESTINSTALL
|
|
|
|
pushd test\install
|
|
|
|
call jpm clean
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-07-28 01:44:44 +00:00
|
|
|
call jpm test
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-08-29 02:05:34 +00:00
|
|
|
call jpm --verbose --modpath=. install https://github.com/janet-lang/json.git
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-08-29 02:05:34 +00:00
|
|
|
call build\testexec
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-10-30 01:40:09 +00:00
|
|
|
call jpm --verbose quickbin testexec.janet build\testexec2.exe
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-10-30 01:40:09 +00:00
|
|
|
call build\testexec2.exe
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-11-09 16:03:56 +00:00
|
|
|
call jpm --verbose --test --modpath=. install https://github.com/janet-lang/jhydro.git
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-11-09 16:03:56 +00:00
|
|
|
call jpm --verbose --test --modpath=. install https://github.com/janet-lang/path.git
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-11-09 16:03:56 +00:00
|
|
|
call jpm --verbose --test --modpath=. install https://github.com/janet-lang/argparse.git
|
2019-11-09 16:28:40 +00:00
|
|
|
@if errorlevel 1 goto :TESTINSTALLFAIL
|
2019-11-09 18:22:07 +00:00
|
|
|
popd
|
|
|
|
exit /b 0
|
|
|
|
|
2019-11-09 16:28:40 +00:00
|
|
|
:TESTINSTALLFAIL
|
2019-07-28 01:44:44 +00:00
|
|
|
popd
|
2019-11-09 16:28:40 +00:00
|
|
|
goto :TESTFAIL
|
2019-07-28 01:44:44 +00:00
|
|
|
|
|
|
|
@rem build, test, dist, install. Useful for local dev.
|
|
|
|
:ALL
|
|
|
|
call %0 build
|
|
|
|
@if errorlevel 1 exit /b 1
|
|
|
|
call %0 test
|
|
|
|
@if errorlevel 1 exit /b 1
|
|
|
|
call %0 dist
|
|
|
|
@if errorlevel 1 exit /b 1
|
|
|
|
call %0 install
|
|
|
|
@if errorlevel 1 exit /b 1
|
|
|
|
@echo Done!
|
|
|
|
exit /b 0
|
|
|
|
|
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
|