Commit 10663de7 authored by Axel Simon's avatar Axel Simon

add Windows build script

parent 2a5b509c
......@@ -134,11 +134,11 @@ GDSLFLAGS = --runtime=$(srcdir)/detail/codegen @EXTRA_GDSL_FLAGS@
if HAVE_MLTON
$(builddir)/gdslc: $(srcdir)/gdslc.mlb $(GDSLC_SML_FILES)
$(MLTON) -output $(builddir)/gdslc $(srcdir)/gdslc.mlb
$(builddir)/gdslc$(EXEEXT): $(srcdir)/gdslc.mlb $(GDSLC_SML_FILES)
$(MLTON) -output $(builddir)/gdslc$(EXEEXT) $(srcdir)/gdslc.mlb
GDSLC_DEP += $(builddir)/gdslc
GDSLC = $(builddir)/gdslc
GDSLC_DEP += $(builddir)/gdslc$(EXEEXT)
GDSLC = $(builddir)/gdslc$(EXEEXT)
else
......
@ECHO OFF
setlocal ENABLEEXTENSIONS
rem This file is to be run on the Windows command line and generates the specified decoders.
rem
set ARGS=
rem remove bogus quotes from the PATH variable, that every path is in quotes
set LOCALPATH=%PATH:"=%
set LOCALPATH="%LOCALPATH:;=" "%"
rem let the user specify an output directory
set OUTDIR=
if NOT "%1"=="/odir" goto NoDir
set ARGS=%ARGS% %1
shift
set OUTDIR=%1
set ARGS=%ARGS% %1
shift
:NoDir
rem check if we find the Visual Studio compiler
set MSVC=
for %%p in (%LOCALPATH%) do if exist "%%~p\cl.exe" set MSVC="%%~p\cl.exe"
rem let the user specify the path to the C compiler
if NOT "%1"=="/cl" goto NoComp
set ARGS=%ARGS% %1
shift
set CL=%1
set ARGS=%ARGS% %1
shift
if exist %CL% goto NoComp
echo The compiler %CL% does not exist!
goto Error
:NoComp
rem let the user specify the Windows SDK lib directory
set SDKLIBPATH=
if NOT "%1"=="/sdklib" goto NoSDKLIB
set ARGS=%ARGS% %1
shift
set SDKLIBPATH=%1
set ARGS=%ARGS% %1
shift
:NoSDKLIB
SET DECODERS=x86 x86-rreil avr avr-rreil mips mips-rreil arm7
echo on
if "%1"=="all" for %%d in (%DECODERS%) do build.bat %ARGS% %%d
echo off
for %%d IN (%DECODERS%) DO if "%1"=="%%d" set DECODER=%%d& goto Build
:Usage
echo Usage: build.bat [/odir "output-directory"] [/cl "cl-path"] [/sdklib "sdklib-path"] "decoder"
echo where "cl-path" is the path to the Visual C compiler (ending in cl.exe)
echo and"sdklib-path" is the path to the \lib directory of the Windows SDK
echo and "decoder" is either "all" or one of the following:
SET RREIL=NO
for %%d IN (%DECODERS%) DO (
if %RREIL%==NO (
echo %%d the %%d decoder and pretty printer
set RREIL=yes
) ELSE (
echo %%d the decoder, pretty printer and translation to RREIL
set RREIL=NO
)
)
goto End
:Build
echo off
rem keep these lists in sync with Makefile.am
set GDSL_BASIS=
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/prelude.ml
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/tree-set.ml
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/bbtree.ml
set GDSL_ASM=
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm-cif.ml
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm.ml
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm-pretty.ml
set GDSL_X86=
set GDSL_X86=%GDSL_X86% specifications/x86/x86.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-traverse.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-pretty.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-asm.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-semantics-mapping.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-semantics-mapping-pretty.ml
set GDSL_X86SEM=
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator-a-l.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator-m-z.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-liveness.ml
set GDSL_AVR=
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-asm.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-traverse.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-pretty.ml
set GDSL_AVRSEM=
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-translator.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-registermapping.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-pretty.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-liveness.ml
set GDSL_MIPS=
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-asm.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-traverse.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-pretty.ml
set GDSL_MIPSSEM=
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-translator.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-registermapping.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-pretty.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-liveness.ml
set GDSL_RREIL=
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/fmap.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-examples.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-cif.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-pretty.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-liveness.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-forward-subst.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-cleanup.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-opt.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-translator.ml
set GDSL_ARM7=
set GDSL_ARM7=%GDSL_ARM7% specifications/arm7/arm7.ml
set GDSL_ARM7=%GDSL_ARM7% specifications/arm7/arm7-pretty.ml
if NOT "%DECODER%"=="x86" goto NOT_x86
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_X86%
set OUT=gdsl-x86
:NOT_x86
if NOT "%DECODER%"=="x86-rreil" goto NOT_x86_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_X86% %GDSL_RREIL% %GDSL_X86SEM%
set OUT=gdsl-x86-rreil
:NOT_X86_rreil
if NOT "%DECODER%"=="avr" goto NOT_avr
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_AVR%
set OUT=gdsl-avr
:NOT_avr
if NOT "%DECODER%"=="avr-rreil" goto NOT_avr_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_AVR% %GDSL_RREIL% %GDSL_AVRSEM%
set OUT=gdsl-avr-rreil
:NOT_avr_rreil
if NOT "%DECODER%"=="mips" goto NOT_mips
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_MIPS%
set OUT=gdsl-mips
:NOT_mips
if NOT "%DECODER%"=="mips-rreil" goto NOT_mips_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_MIPS% %GDSL_RREIL% %GDSL_MIPSSEM%
set OUT=gdsl-mips-rreil
:NOT_mips_rreil
if NOT "%DECODER%"=="arm7" goto NOT_arm7
set SPEC=%GDSL_BASIS% %GDSL_ARM7%
set OUT=gdsl-arm7
:NOT_arm7
echo on
gdslc.exe --target=C89 -o %OUT% %SPEC%
rem @echo off
if x%MSVC%x==xx (
echo Unable to compiler the generated decoder since the compiler cannot be found.
goto End
)
rem Find out where to get kernel32.lib and friends. It's somewhere under "Windows Kits"
rem which resides in "Program Files (x86)". This will probably break occasionally, but
rem it works for my machine. I couldn't find a reliably registry key. Feedback welcome.
for /f "usebackq tokens=*" %%d in (`dir /ad /b /s "C:\Program Files (x86)\Windows Kits" ^| find "\x86" ^| find /i "lib"`) do set SDKLIBPATH=%%d
for /f "usebackq tokens=*" %%d in (`dir /ad /b /s "C:\Program Files (x86)\Windows Kits" ^| find "\x86" ^| find /i "include"`) do set SDKINCPATH=%%d
rem set SDKREGKEYS=
rem set SDKREGKEYS=%SDKREGKEYS% "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows"
rem set SDKREGKEYS=%SDKREGKEYS% "HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows"
rem if "%SDKPATH%"=="" for %%k in (%SDKREGKEYS%) do (
rem for /f "usebackq tokens=*" %%r in (`reg query %%k 2^>nul`) do (
rem for /f "usebackq tokens=2 delims=_" %%s in (`reg query "%%r" /v InstallationFolder 2^>nul`) do set SDKPATH=%%s
rem )
rem )
if NOT defined SDKLIBPATH (
echo Cannot find SDK library directory. Use /sdklib switch to specify.
goto Error
)
set MSVCBARE=%MSVC:.exe=%
set LIB=%MSVCBARE:\bin\cl=\lib%;"%SDKLIBPATH%"
set INCLUDE=%MSVCBARE:\bin\cl=\include%
set CL=
echo Compiling %OUT%.c
%MSVC% /Od /Gd /nologo /Za /D WITHMAIN /TC %OUT%.c /link /OUT:"%OUTDIR%%OUT%-demo.exe"
goto End
:Error
exit /b 1
:End
......@@ -18,8 +18,9 @@ AC_PROG_INSTALL()
dnl check if the compiler understand C99
AC_PROG_CC_C99()
AC_ARG_ENABLE(msvc,[AS_HELP_STRING([--enable-msvc], [emit code for Microsoft Visual C compiler])])
AC_ARG_VAR(EXTRA_GDSL_FLAGS)
if test [x$ac_cv_prog_cc_c99 == "xno"]; then
if test [x$ac_cv_prog_cc_c99 == "xno" -o x$enable_msvc == "xyes"]; then
EXTRA_GDSL_FLAGS="--target=C89";
fi
......@@ -70,7 +71,7 @@ FRONTENDS="x86 x86-rreil avr avr-rreil mips mips-rreil arm7";
AC_ARG_WITH([frontend],
[AS_HELP_STRING(
[--with-frontend=frontend],
[one of: ]$FRONTENDS)],
[one of: x86 x86-rreil avr avr-rreil mips mips-rreil arm7])],
[], [with_frontend=all])
case $with_frontend in
......
......@@ -74,7 +74,7 @@ typedef unsigned int field_tag_t;
#endif
static void NO_INLINE_ATTR alloc_heap(state_t s, char* prev_page, size_t size) {
static NO_INLINE_ATTR void alloc_heap(state_t s, char* prev_page, size_t size) {
if (size<CHUNK_SIZE) size = CHUNK_SIZE; else size = CHUNK_SIZE*((size/CHUNK_SIZE)+1);
s->heap_base = (char*) malloc(size);
if (s->heap_base==NULL) {
......@@ -121,7 +121,7 @@ size_t
return res;
};
static INLINE_ATTR void* MALLOC_ATTR alloc(state_t s, size_t bytes) {
static INLINE_ATTR MALLOC_ATTR void* alloc(state_t s, size_t bytes) {
bytes = ((bytes+7)>>3)<<3; /* align to multiple of 8 */
if (s->heap+bytes >= s->heap_limit) alloc_heap(s, s->heap_base, bytes);
char* res = s->heap;
......@@ -219,7 +219,9 @@ static obj_t del_fields(state_t s, field_tag_t tags[], int tags_size, obj_t rec)
#define slice(vec_data,ofs,sz) ((vec_data >> ofs) & ((1ul << sz)-1))
static INLINE_ATTR vec_t gen_vec(unsigned int vec_sz,vec_data_t vec_data) {
vec_t res = {vec_sz, vec_data};
vec_t res;
res.size=vec_sz;
res.data=vec_data;
return res;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment