command line applications, supplying parameters, reading from stdout / stderr?

59 views
Skip to first unread message

Joel Longanecker

unread,
Nov 8, 2019, 1:20:43 PM11/8/19
to emscripten-discuss
Hello emscripten users!

I am planning on building a tool for doing homebrew gameboy development in the web browser. I am hoping to be able to get a compiler and an emulator working to do live reload when a user changes a file, and a bunch of other neat stuff.

Anyways, I feel like the first big thing I need to be able to do is port RGBDS or GBDK over to web assembly. 



This is mostly straight up C, nothing too tricky, no fancy libraries or flags. It might take me a bit to make these forks work nicely, but I am more concerned how to invoke them and use them from the browser.

* How do I invoke these tools so I can pass them command line arguments?

* How do I read from stderr / stdout?

Thanks

-Joel

Mehdi Sabwat

unread,
Nov 8, 2019, 1:30:03 PM11/8/19
to emscripte...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/c1bb797a-a874-4441-bdf7-bea0002a9308%40googlegroups.com.

Mehdi Sabwat

unread,
Nov 8, 2019, 1:47:35 PM11/8/19
to emscripte...@googlegroups.com
Sorry, I think I misunderstood your first point.


You could affect the programs execution with Module["arguments"].push() before. But now it was replaced by `arguments_` so basically in a --post-js or in your C/CPP source file, you could do something like :

EM_ASM({
arguments_.push("Insert argv[1] here")
})

Then you could access it in an array with `arguments_`

Hope it helps, 

Regards,

Joel Longanecker

unread,
Nov 8, 2019, 2:24:32 PM11/8/19
to emscripte...@googlegroups.com
Thanks, That definitely gets me in the right direction.

Floh

unread,
Nov 11, 2019, 5:35:09 AM11/11/19
to emscripten-discuss
For some of those problems you can check whether some of my sokol headers fit your needs:


One problem with the established POSIX / CRT APIs is that they don't map particularly well to how things work in the browser runtime, so I tried to create simple alternative C APIs which better map to the web world but still work on native platforms.

Joel Longanecker

unread,
Nov 11, 2019, 9:15:48 AM11/11/19
to emscripte...@googlegroups.com
@Floh

Thanks for introducing me to your wonderful library. I am hoping to be able to port these tools over without having to change the source too much. (I was able to get RGBDS to work as a node app this weekend) But if I do any new work with emscripten, I will definitely keep it in mind.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages