hammer/tools/windows/build_examples.bat
nicolas 69d3e70211 Port scons build files for Windows users
We disable:
- the tests (which require glib) although they can be
  reactivated with the `--tests` command line flag
- shared library (lack of export symbol declarations
  means that although it can be built, no symbol is
  exported and therefore it can't be used)

The `install` target installs the library and headers
under the `build` folder, because it's a traditional practice
to move libraries to a central location on Windows, unless
you are using cygwin. In which case pass `prefix` to the
command line.

We adapt tools\windows\build_examples.bat to take the library
that is built using scons or using tools\windows\build.bat
2016-05-22 13:29:12 +02:00

53 lines
1.5 KiB
Batchfile

@echo off
setlocal
REM This script must be run after vcvarsall.bat has been run,
REM so that cl.exe is in your path.
where cl.exe || goto vsmissing_err
REM HEREPATH is <drive_letter>:<script_directory>
set HEREPATH=%~d0%~p0
REM Set up SRC, BUILD and CLFLAGS
call %HEREPATH%\env.bat
call %HEREPATH%\clvars.bat
echo SRC=%SRC%, BUILD=%BUILD%
echo CLFLAGS=%CLFLAGS%
set HAMMERLIB=%BUILD%\lib\hammer_s.lib
REM Now let's build some example programs
cl.exe -nologo %CLFLAGS% examples\base64.c %HAMMERLIB% -Fo%BUILD%\ -Fe%BUILD%\
if %errorlevel% neq 0 goto err
echo PROGRAM build\base64.exe
cl.exe -nologo %CLFLAGS% examples\base64_sem1.c %HAMMERLIB% -Fo%BUILD%\ -Fe%BUILD%\
if %errorlevel% neq 0 goto err
echo PROGRAM build\base64_sem1.exe
cl.exe -nologo %CLFLAGS% examples\base64_sem2.c %HAMMERLIB% -Fo%BUILD%\ -Fe%BUILD%\
if %errorlevel% neq 0 goto err
echo PROGRAM build\base64_sem2.exe
REM FIXME(windows) TODO(uucidl): dns.c only works on posix
REM cl.exe -nologo %CLFLAGS% examples\dns.c %HAMMERLIB% -Fo%BUILD%\ -Fe%BUILD%\
REM if %errorlevel% neq 0 goto err
REM echo PROGRAM build\dns.exe
REM FIXME(windows) TODO(uucidl): grammar.c needs to be fixed
cl.exe -nologo %CLFLAGS% examples\ties.c examples\grammar.c %HAMMERLIB% -Fo%BUILD%\ -Fe%BUILD%\
if %errorlevel% neq 0 goto err
echo PROGRAM build\ties.exe
echo SUCCESS: Successfully built
endlocal
exit /b 0
:vsmissing_err
echo ERROR: CL.EXE missing. Have you run vcvarsall.bat?
exit /b 1
:err
echo ERROR: Failed to build
endlocal
exit /b %errorlevel%