2

How can I add an Emscripten compilation target for my program using biicode. I would like to do a "bii cpp:configure" or a build with params, that would build my C/C++ source code using the downloaded Emscripten SDK (emsdk) or the installed Emscripten (from a package manager).

W1M0R
  • 3,367
  • 3
  • 30
  • 32

1 Answers1

1

So you want to #include a emscripten header in your code and get the library? I would suggest to write a block that acts as a proxy and manage to download and install the prebuilt packages, as they seem quite good. This can be done in a several ways:

  1. Write block with a hook, which is a script in python. You have for example the OpenCV one here: http://www.biicode.com/diego/opencv . That will install it to a biicode predefined location, which can be accessed in the CMakeLists.txt via a cmake variable ${BIICODE_ENV_DIR} . You can use that variable to define and link libraries. You should add the headers you want to include in your block, so you can actually #include things, and have biicode retrieve things. Do not forget to add the hook to the biicode.conf [hooks] section

  2. Write a block with a cmake script. In CMake it is also possible to retrieve and install files. In this case you can just write and INCLUDE(youruser/yourblock/yourcmakescript) in the CMakeLists.txt of the block that wants to "consume" and use emscripten. That file will be handle exactly the same as C/C++ files, they will appear initially as unresolved in "bii deps" and can be resolved with "bii find" or adding the block to the [requirements] section.

I initially recommend this as the library seems a bit complex to build, it does not have standard CMakeLists.txt, but custom configures.

EDIT: Now I see with your comments that this is not what you actually want, but to use a custom compilation (cross compilation to js) toolchain. This can be actually done using custom toolchains: http://docs.biicode.com/c++/building.html#using-a-custom-tool-chain This could require some mastery of both CMake and the emscripten toolchain. The integration of this toolchains is a little bit tricky now, it is being revamped and will be released in a few weeks. Note that the rest of the answer is still valid, you can easily write a block with a hook that manages to install the emscripten tool from binaries.

drodri
  • 5,157
  • 15
  • 21
  • Thanks for your answer @drodri. My question is a bit unclear. I have a small "hello world" program that I want to build with emscripten. The program does not #include an emscripten header. I can build it quite easily without biicode (using the emsdk), but I find it difficult to automate the build with biicode. – W1M0R Jan 22 '15 at 09:53
  • I see. Can you build it without biicode but with a CMake script? Can you share such script? We are just now refactoring the toolchains (i.e. CMake scripts that let the user to custom define the build), opening them so any user can define their own toolchain for their purposes. A second stage will be that those custom toolchains can also be shared with biicode. Your input of what you are trying to do can be very useful to tune this new feature. – drodri Jan 22 '15 at 11:06
  • I don't build it with CMake, but after some reading online it seems possible to do so. A Google/GitHub search for Emscripten.cmake reveals a few approaches. The way I build my program with emscripten, is using the terminal command em++ provided by the emsdk. – W1M0R Jan 22 '15 at 12:14
  • Perhaps this file can be added to a biicode/cmake or some other public block and then reused: https://github.com/kripken/emscripten/blob/master/cmake/Modules/Platform/Emscripten.cmake – W1M0R Jan 22 '15 at 15:51