Superbelko / ohmygentool

LLVM/Clang based bindings generator for D language
The Unlicense
39 stars 6 forks source link

Add ability to develop ohmygentool in a web browser VS Code (using Gitpod, with all dependencies set-up) #17

Closed GavinRay97 closed 3 years ago

GavinRay97 commented 3 years ago

Adds support for developing and building/running Ohmygentool from within your browser. Lets put a link on the repo README and let anyone who is interested in contributing do so with a click? 😃

I have put this up at: https://gitpod.io/#https://github.com/GavinRay97/Ohmygentool

If you visit that link and sign in with Github, it should pop you into a browser shell that has everything you need to develop + build OMG, except for Rapidjson (which isn't added as a submodule for some reason). You get 50 free dev hours per account per month.

To build:

git clone https://github.com/Tencent/rapidjson.git deps/rapidjson
cp -r deps/rapidjson/include/rapidjson include
mkdir build
cd build
cmake .. -G Ninja
cmake ./-config Release
./gentool # Should show helptext

One note about the Dockerfile -- I download and unpack a static distribution of LLVM12, and then immediately afterwards I install clang and lld with apt.

This is because trying to build with CMake (even if passing -DLLVM_DIR and -DClang_DIR) always gave me this:

CMake Error at /usr/lib/llvm-13/lib/cmake/clang/ClangTargets.cmake:699 (message):
  The imported target "clangBasic" references the file
     "/usr/lib/llvm-13/lib/libclangBasic.a"

Call Stack (most recent call first):
  /usr/lib/cmake/clang-13/ClangConfig.cmake:20 (include)
  CMakeLists.txt:7 (find_package)

Couldn't find a way around it trying to use this version 13.

And then the prebuilt LLVM binaries have some bug with libc, but they fix the CMake problem by adding a directory to /usr/lib/cmake/clang:

gitpod /workspace/ohmygentool $ clang --version
clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by clang)
clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by clang)

So you wind up with the mess I have, but it works. Would be awesome if someone knew a fix to this.

See bottom of screen output for OMG being compiled and then invoked:

image

Superbelko commented 3 years ago

Could be useful. Can you make a plain dockerfile as well for those who prefer to do this locally?

LLVM/Clang 13 is in development, they often out of sync with each other and/or in "broken" state, don't bother with it until it enter stabilization for RC builds. (glibc error: IIRC it comes with gcc install)

And then there is some issues with static linking on Linux after changes in clang 12 and/or build script, needs to be resolved anyway but I can't give any estimate, need to set up VM and all...

Rapidjson will be removed after v0.4 (coming next week). Having both C++ main() and D main() is confusing, and without C++ main() rapidjson no longer needed.

GavinRay97 commented 3 years ago

Sure, I have local Dockerfile already so that one will be easier.

I just need to remove some stuff because I also have Cling + cppyy in there for being able to interpret C++ as scripting lang for interactive dev.

Edit: Here it is: https://github.com/GavinRay97/ohmygentool/blob/master/Dockerfile.local-dev

I will build this and push it to my personal Dockerhub, as well as try to compress the image with: https://github.com/docker-slim/docker-slim

Then we can add instructions to README + people won't need to build the image again. They can just pull it and it's ready to go 👍

It works with both VS Code devcontainer and CLion (the SSH stage at the end is needed for CLion).

I have to write the VSCode devcontainer config still, will PR that to the .vscode folder later, along with extensions configured in the devcontainer like clangd, CMake Tools, etc that you need to be productive.

Superbelko commented 3 years ago

Thanks!