shamadee / wasm-init

Build tool and template generator for WebAssembly Projects
MIT License
171 stars 25 forks source link

emcmake support #21

Open H-Plus-Time opened 7 years ago

H-Plus-Time commented 7 years ago

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.

matzewagner commented 7 years ago

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.

H-Plus-Time commented 7 years ago

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:

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.

matzewagner commented 7 years ago

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.

gonardfreeman commented 7 years ago

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

gonardfreeman commented 7 years ago

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?)