diff --git a/.github/workflows/cpp-bindings.yml b/.github/workflows/cpp-bindings.yml new file mode 100644 index 00000000000..12176470a57 --- /dev/null +++ b/.github/workflows/cpp-bindings.yml @@ -0,0 +1,33 @@ +name: C++ bindings + +on: + push: + paths: + - ".github/workflows/cpp-bindings.yml" + - "include/" + - "src/" + - "cpp/" + - "*akefile*" + branches: + - main + pull_request: + +jobs: + test: + name: test + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: head + bundler-cache: true + - name: Compile prism + run: bundle exec rake compile + - name: Compile C++ + run: g++ -o ./cpp_test cpp/test.cpp build/static/*.o build/static/util/*.o -Iinclude + - name: Run C++ + run: ./cpp_test diff --git a/cpp/test.cpp b/cpp/test.cpp new file mode 100644 index 00000000000..af993c9fca9 --- /dev/null +++ b/cpp/test.cpp @@ -0,0 +1,24 @@ +extern "C" { + #include "prism.h" +} + +#include + +int main() { + pm_parser_t parser; + pm_parser_init(&parser, reinterpret_cast("1 + 2"), 5, NULL); + + pm_node_t *root = pm_parse(&parser); + pm_buffer_t buffer = { 0 }; + + pm_prettyprint(&buffer, &parser, root); + pm_buffer_append_byte(&buffer, '\0'); + + std::cout << buffer.value << std::endl; + + pm_buffer_free(&buffer); + pm_node_destroy(&parser, root); + pm_parser_free(&parser); + + return 0; +} diff --git a/rakelib/check_manifest.rake b/rakelib/check_manifest.rake index 50a88569e3f..b705763d6d4 100644 --- a/rakelib/check_manifest.rake +++ b/rakelib/check_manifest.rake @@ -13,6 +13,7 @@ task check_manifest: :templates do autom4te.cache bin build + cpp doc fuzz gemfiles