shamadee/wasm-init

emcmake support

Opened this issue · 5 comments

It would be nice to get this to work with cmake - more for the event insertion and nicer loading mechanism than the auto-recompile (given that even the linking step in some cmake projects takes multiple minutes).

First question: is that in line with what you, the maintainers, want to see this module do?
Second question: would a cmake build need to be fully configurable via the wasm.config.js file, or just whatever command line args can be supplied to cmake?

My thinking is that the former option would be a bit redundant and a lot of work, requiring a full AST parser for CMakeLists.txt files.

I'm not going to absolutely dismiss the possibility of adding an AST parser, but I'm currently not even sure how to go about it. Adding cmake support via cl arguments sounds reasonable and interesting, though I don't have much experience with emcmake, yet. Can you give some specific use cases? Thanks.

Mm, there's material around, though the benefit is pretty questionable, given that people inevitably have to hand-edit the CMakeLists.txt file anyway - little things like 'is there are an instance of ${WASM_INIT_FLAGS}? If not, warn' would be the most useful interaction with it, since the particulars vary wildly from project to project.

The usecases I have in mind usually revolve around the debugging phase of converting old, complicated codebases to wasm. At the moment, I'm converting the zxing library. Much like original projects, its useful to have wasm-init scaffolding when pinning down linking issues that only occur when using emscripten, particularly since you'll likely be working off a pre-existing cli .cpp file.

Basically, usecases are:

  • Building anything that uses cmake and depends on OpenCV.

I've forked the repo and added the relevant options to specify a build generator and run the build process with an appropriate level of parallelism wasm-init. I'll submit a PR once I've hooked up the relevant pieces for EXPORTED_FUNCTIONS and emcc flags to work.

Thanks, I merged your PR. I'll keep this issue open, for now, and might opt for tighter integration of emcmake support further down the road.

Im here just to say! MANY THANKS MAN! Its awesome! Keep up!

And Im got question. Why to export some func from C++ we need to use
extern "C" { void myFunc(){ cout << "bla bla bla" << endl; } }

I'm new to c++, so if its to hard to explain just say is this rule, or there is some other way, without this expression?)