wpilibsuite / frc-docs

Official FRC Documentation powered by Read the Docs
https://docs.wpilib.org
Other
145 stars 258 forks source link

Cross compile WPILib to Javascript for use in interactive docs tutorials #1831

Open calcmogul opened 2 years ago

calcmogul commented 2 years ago

Emscripten lets you cross compile C++ into Javascript. We could use this to run potentially any part of WPILib simulation in a browser.

Apparently Eigen works fine with this: https://eigen.tuxfamily.narkive.com/Yf7dM1wo/status-of-building-with-emscripten-running-code-in-a-web-browser. At the very least, we could cross compile our DARE solver so we can use it in the forthcoming PID tuning interactive tutorial.

If possible, I'd suggest writing a makefile that invokes em++ on each .cpp file and generates a .js file so the docs can just call JS functions.

Daltz333 commented 2 years ago

If anyone wants to take this on, go for it.

gerth2 commented 2 months ago

Double checking... any motion on this beyond the suggestion in the PR?

The biggest unknown I think I have is the release/distribution strategy - is there pattern on where the built files should end up to be useful for web?

The second biggest unknown I have is the build infrastructure. I saw makefile mentioned.... is there pattern on invoking that from the allwiplib gradle build process?

Am I thinking too complexly about this? Would a local "I built this on my machine and committed the files in docs" strategy work?

calcmogul commented 2 months ago

We could use the CMake build with the following:

emcmake cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF