News:

Welcome to RetroCoders Community

Main Menu

emscripten + freebasic

Started by mysoft, May 26, 2025, 07:47 PM

Previous topic - Next topic

mysoft

ok, if anyone need a portable toolchain (just extract and run) there it is...
https://github.com/MyTDT-Mysoft/emsdk32/releases/tag/v3.1.71-release-0.1-alpha

some tests/code that i have that i compiled using it
https://mysoft.codeberg.page/FreebasicWebShowcase

later i will upload the fork repository of freebasic where i keep releases of this for windows, while fixing bugs and making it more direct usable
with ports of common used libraries, extra functions for specific but important things over the web (like mounting special file systems)

by default the fbc with the fbjs target is generating .js and .wasm files, but imo the default should be generating just a single .html file , and only generate .js/.wasm files when generating a library so that then dylibload can dynamically load those, which means extra .data files can be loaded when using single .html files as well (to avoid needing to have all games maps/assets/libraries/everything in memory)

one great advantage of "--single-file" is that it works just like an executable you just click and it runs on the browser... no server needed (does the same in mobile), so that's a good default

but some features like "Fetch" trigger cors when used to local local .html HOWEVER there's DOM ways to bypass that (i used them to load the background music in piranha... and to load an optional "skin" file, which can be easily modified for different environment (like the keypad mapping one), either way it's possible to use that same method to load wasm files and bypass cors... so i will go over this route for freebasic's sake (i think i can even extend that to generate blob links to create workers, which is another thing that ends blocked by cors with local files)... and last but not least, many important new javascript features seems to require a "secure" environment i.e. they dont work with HTTP only HTTPS (which is ridiculous, but they DO work with local .html files), and having a local server that is also a verifiable https server would be a crazy requirement for freebasic by default.

the huge sad thing is that the web environment does not allow sockets to be used without proxies... so it ends requiring some local server to bypass that for sockets or even http/https request that are bypassing cors... imo they screwed up that, and they should had used permissions (like they have to access local folders in chrome now), but... oh well i guess a generic shared server that will query for access (like when apps use web auth permissions), to prevent the local proxy to be abused is something that will be taken in account.

and later i will actually include the FBC with a minimal emscripten toolchain (similar as we have with the minimal GCC option). But first i will get rid of the python garbage requirement of emscripten (not sure what i can do about the NODE requirement to build tough, but node is just a single .exe anyway)

also yeah i should include the release with the freebasic part of it soon enough.... along with an android apk geneator.