Code Monkey home page Code Monkey logo

Comments (2)

donalffons avatar donalffons commented on June 8, 2024 1

I've been thinking about this problem for a while and what I've come up with is implemented in another project called libclangjs, here. Libclangjs adds JavaScript / WASM bindings to llvm's libclang (similar to how OCJS adds JavaScript / WASM bindings to OCCT - but much simpler). There is a fairly minimal test and some docs that explain how it works. In summary:

  • The bindings and relevant headers are published as a CMake package, that can be added via CMake's find_package call to your custom CMake project (which builds an "executable", i.e. the .js and .wasm files, you want to use in your JS project).
  • This CMake package is published via NPM. That might be a bit unusual, but I think it's an easy way of publishing that package, which should integrate nicely with commonly used JS development tools. This should also work nicely with a monorepo layout, where the "custom build" of OCJS is just another package that can be installed by other packages inside that repo.
  • C/C++ code can then be written "like usual" in any other CMake-based project.

I believe this is much cleaner and lightweight than the current solution of adding c++ code to a yaml file and starting a huge Docker container for each compilation. If you have any thoughts / opinions on this, please let me know.

PS: This ignores the fact that the custom build yaml-files also specify which bindings should be included. This would be a separate issue under this proposal.

from opencascade.js.

frank-pian avatar frank-pian commented on June 8, 2024

I've been thinking about this problem for a while and what I've come up with is implemented in another project called libclangjs, here. Libclangjs adds JavaScript / WASM bindings to llvm's libclang (similar to how OCJS adds JavaScript / WASM bindings to OCCT - but much simpler). There is a fairly minimal test and some docs that explain how it works. In summary:

* The bindings and relevant headers are published as a CMake package, that can be added via CMake's [`find_package`](https://github.com/donalffons/libclangjs/blob/5af1087a3dd29f05b03ca38360d7a07d17c73277/tests/test-cmake/CMakeLists.txt#L7) call to your custom CMake project (which builds an "executable", i.e. the `.js` and `.wasm` files, you want to use in your JS project).

* This CMake package is published via NPM. That might be a bit unusual, but I think it's an easy way of publishing that package, which should integrate nicely with commonly used JS development tools. This should also work nicely with a monorepo layout, where the "custom build" of OCJS is just another package that can be installed by other packages inside that repo.

* C/C++ code can then be written "like usual" in any other CMake-based project.

I believe this is much cleaner and lightweight than the current solution of adding c++ code to a yaml file and starting a huge Docker container for each compilation. If you have any thoughts / opinions on this, please let me know.

PS: This ignores the fact that the custom build yaml-files also specify which bindings should be included. This would be a separate issue under this proposal.

It looks great ! If there are any examples, I would be happy to test.

from opencascade.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.