-
Notifications
You must be signed in to change notification settings - Fork 90
Add antlr4-runtime #5565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Alex-PLACET
wants to merge
2
commits into
emscripten-forge:main
Choose a base branch
from
Alex-PLACET:antlr4-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add antlr4-runtime #5565
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| set -exuo pipefail | ||
|
|
||
| # Set default values for potentially unset variables | ||
| EM_FORGE_SIDE_MODULE_CFLAGS="${EM_FORGE_SIDE_MODULE_CFLAGS:-}" | ||
| EM_FORGE_SIDE_MODULE_LDFLAGS="${EM_FORGE_SIDE_MODULE_LDFLAGS:-}" | ||
| CFLAGS="${CFLAGS:-}" | ||
| CXXFLAGS="${CXXFLAGS:-}" | ||
| LDFLAGS="${LDFLAGS:-}" | ||
|
|
||
| export CFLAGS="$CFLAGS $EM_FORGE_SIDE_MODULE_CFLAGS" | ||
| export CXXFLAGS="$CXXFLAGS $EM_FORGE_SIDE_MODULE_CFLAGS" | ||
| export LDFLAGS="$LDFLAGS $EM_FORGE_SIDE_MODULE_LDFLAGS" | ||
|
|
||
| # ANTLR4 C++ runtime lives in runtime/Cpp/ subdirectory | ||
| cd runtime/Cpp | ||
|
|
||
| mkdir -p build | ||
| cd build | ||
|
|
||
| emcmake cmake -GNinja \ | ||
| ${CMAKE_ARGS} \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_CXX_STANDARD=17 \ | ||
| -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ | ||
| -DCMAKE_INSTALL_LIBDIR=lib \ | ||
| -DCMAKE_PREFIX_PATH="${PREFIX}" \ | ||
| -DANTLR_BUILD_CPP_TESTS=OFF \ | ||
| -DANTLR_BUILD_SHARED=OFF \ | ||
| -DANTLR_BUILD_STATIC=ON \ | ||
| -DANTLR4_INSTALL=ON \ | ||
| -DWITH_DEMO=OFF \ | ||
| .. | ||
|
|
||
| ninja install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| export CFLAGS="${CFLAGS:-}" | ||
| export CXXFLAGS="${CXXFLAGS:-}" | ||
|
|
||
| emcmake cmake -S tests -B build_tests \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_PREFIX_PATH="${PREFIX}" \ | ||
| -DCMAKE_FIND_ROOT_PATH="${PREFIX}" \ | ||
| -DCMAKE_CXX_STANDARD=17 | ||
|
|
||
| emmake make -C build_tests -j"${CPU_COUNT:-1}" | ||
|
|
||
| echo "Running test..." | ||
| node build_tests/test_antlr4_runtime.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| context: | ||
| name: antlr-cpp-runtime | ||
| version: 4.13.2 | ||
|
|
||
| package: | ||
| name: ${{ name }} | ||
| version: ${{ version }} | ||
|
|
||
| source: | ||
| url: https://github.com/antlr/antlr4/archive/refs/tags/${{ version }}.tar.gz | ||
| sha256: 9f18272a9b32b622835a3365f850dd1063d60f5045fb1e12ce475ae6e18a35bb | ||
|
|
||
| build: | ||
| number: 0 | ||
| script: build.sh | ||
|
|
||
| requirements: | ||
| build: | ||
| - ${{ compiler('c') }} | ||
| - ${{ compiler('cxx') }} | ||
| - cmake | ||
| - ninja | ||
|
|
||
| tests: | ||
| - package_contents: | ||
| lib: | ||
| - libantlr4-runtime.a | ||
| include: | ||
| - antlr4-runtime/antlr4-runtime.h | ||
| - script: | ||
| - build_tests.sh | ||
| requirements: | ||
| build: | ||
| - ${{ compiler('cxx') }} | ||
| - cmake | ||
| - ninja | ||
| files: | ||
| recipe: | ||
| - build_tests.sh | ||
| - tests/ | ||
|
|
||
| about: | ||
| homepage: https://www.antlr.org/ | ||
| license: BSD-3-Clause | ||
| license_family: BSD | ||
| license_file: LICENSE.txt | ||
| summary: ANTLR (ANother Tool for Language Recognition) C++ runtime library | ||
| description: | | ||
| ANTLR is a powerful parser generator for reading, processing, executing, | ||
| or translating structured text or binary files. This package provides | ||
| the C++ runtime library required to run parsers generated by ANTLR 4. | ||
| documentation: https://github.com/antlr/antlr4/blob/master/doc/index.md | ||
| repository: https://github.com/antlr/antlr4 | ||
|
|
||
| extra: | ||
| recipe-maintainers: | ||
| - Alex-PLACET |
21 changes: 21 additions & 0 deletions
21
recipes/recipes_emscripten/antlr4-runtime/tests/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
| project(test_antlr4_runtime CXX) | ||
| set(CMAKE_CXX_STANDARD 17) | ||
|
|
||
| find_path(ANTLR4_INCLUDE_DIR antlr4-runtime.h | ||
| PATHS "${PREFIX}/include/antlr4-runtime" | ||
| NO_DEFAULT_PATH) | ||
|
|
||
| find_library(ANTLR4_LIBRARY antlr4-runtime | ||
| PATHS "${PREFIX}/lib" | ||
| NO_DEFAULT_PATH) | ||
|
|
||
| if(NOT ANTLR4_INCLUDE_DIR OR NOT ANTLR4_LIBRARY) | ||
| message(FATAL_ERROR "Could not find antlr4-runtime library or headers") | ||
| endif() | ||
|
|
||
| add_executable(test_antlr4_runtime test_antlr4.cpp) | ||
| target_include_directories(test_antlr4_runtime PRIVATE | ||
| "${PREFIX}/include" | ||
| "${ANTLR4_INCLUDE_DIR}") | ||
| target_link_libraries(test_antlr4_runtime PRIVATE ${ANTLR4_LIBRARY}) |
33 changes: 33 additions & 0 deletions
33
recipes/recipes_emscripten/antlr4-runtime/tests/test_antlr4.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include <antlr4-runtime.h> | ||
| #include <iostream> | ||
|
|
||
| int main() { | ||
| // Create an ANTLR input stream from a string | ||
| antlr4::ANTLRInputStream input("hello world"); | ||
|
|
||
| // Verify basic properties | ||
| if (input.size() != 11) { | ||
| std::cerr << "FAIL: expected size 11, got " << input.size() << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| // Check that we can read characters | ||
| std::string consumed; | ||
| for (size_t i = 0; i < input.size(); ++i) { | ||
| consumed += input.LA(static_cast<ssize_t>(i + 1)); | ||
| } | ||
| if (consumed != "hello world") { | ||
| std::cerr << "FAIL: expected 'hello world', got '" << consumed << "'" << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| // Test reset and index tracking | ||
| input.reset(); | ||
| if (input.index() != 0) { | ||
| std::cerr << "FAIL: expected index 0 after reset, got " << input.index() << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| std::cout << "ANTLR4 runtime test passed!" << std::endl; | ||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the directory as well, please.