d:/fb.git is assumed for latest fbc checked out from repository
d:
cd \fb.git
REM whatever you use to set-up your fbc build environment (sets PATH)
call c:\batch\setpath.bat fbgit32
REM add-in the emscripten build environment (also sets PATH)
call d:\emsdk.git\emsdk_env.bat
REM build the rtlib and gfxlib for emscripten
make rtlib gfxlib2 TARGET=asmjs-unknown-emscripten ENABLE_STANDALONE=1
Here's the issue: fbc expects the supporting tools to be executable and emscripten font-end on windows uses 'emcc.bat' (plus python in the background) and fbc can't directly call a .BAT file. Here's a cheap hack to make it work:
Compile the following source and copy 'emcc.exe' to 'd:/fb.git/bin/js-asmjs/emcc.exe'
'' emcc.exe to call emcc.bat and pass all arguments
''
'' tested, but not well tested...
''
function EscapeArg( byref arg as const string ) as string
dim ret as string = """"
for i as integer = 1 to len(arg)
select case mid( arg, i, 1 )
case """"
ret &= """"""
case else
ret &= mid( arg, i, 1 )
end select
next
ret &= """"
function = ret
end function
dim cmd as string = "emcc.bat"
dim i as integer = 1
while( command(i) > "" )
cmd += " " & EscapeArg( command(i) )
i += 1
wend
'' assumes 'emcc.bat' is on PATH
var result = shell( cmd )
end result
fbc emcc.bas
copy emcc.exe d:\fb.git\bin\js-asmjs\emcc.exe
The first time this runs, emcc takes a long time because emscripten needs to build it's own runtime library and store the result. After the first time, compile times should be much quicker.
REM whatever you use to set-up your fbc build environment (sets PATH)
call c:\batch\setpath.bat fbgit32
REM add-in the emscripten build environment (also sets PATH)
call d:\emsdk.git\emsdk_env.bat
REM build program.bas
fbc -target js-asmjs program.bas