[Cpp] Don't define ANTLR4CPP_EXPORTS in *consumers* of ANTLR runtime. #919
Workflow file for this run
This file contains 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
name: antlr4 | |
concurrency: | |
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [ master, dev, hostedci ] | |
pull_request: | |
branches: [ master, dev ] | |
permissions: | |
contents: read | |
jobs: | |
cpp-lib-build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ | |
macos-11, | |
ubuntu-20.04, | |
windows-2022 | |
] | |
compiler: [ clang, gcc ] | |
unity_build: [ ON, OFF ] | |
exclude: | |
- os: windows-2022 | |
compiler: gcc | |
include: | |
- os: windows-2022 | |
compiler: cl | |
steps: | |
- name: Install dependencies (Ubuntu) | |
if: startswith(matrix.os, 'ubuntu') | |
run: | | |
sudo apt-get update -qq | |
sudo apt install -y ninja-build | |
- name: Install dependencies (MacOS) | |
if: startswith(matrix.os, 'macos') | |
run: brew install ninja | |
- name: Setup Clang | |
if: (matrix.compiler == 'clang') && !startswith(matrix.os, 'macos') | |
uses: egor-tensin/setup-clang@v1 | |
with: | |
version: 13 | |
platform: x64 | |
cygwin: 0 | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Use ccache | |
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu') | |
uses: hendrikmuhs/[email protected] | |
with: | |
key: ${{ matrix.os }}-${{ matrix.compiler }} | |
- name: Configure shell (Ubuntu) | |
if: startswith(matrix.os, 'ubuntu') | |
run: echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV | |
- name: Configure shell (MacOS) | |
if: startswith(matrix.os, 'macos') | |
run: echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV | |
- name: Build (Windows) | |
if: startswith(matrix.os, 'windows') | |
shell: cmd | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
if "${{ matrix.compiler }}" EQU "cl" ( | |
set CC=cl | |
set CXX=cl | |
echo 'CC=cl' >> $GITHUB_ENV | |
echo 'CXX=cl' >> $GITHUB_ENV | |
) else ( | |
set CC=clang | |
set CXX=clang++ | |
echo 'CC=clang' >> $GITHUB_ENV | |
echo 'CXX=clang++' >> $GITHUB_ENV | |
) | |
set | |
where cmake && cmake --version | |
where ninja && ninja --version | |
where %CC% && %CC% -version | |
where %CXX% && %CXX% -version | |
cd runtime/Cpp | |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
cmake --build out/Debug -j %NUMBER_OF_PROCESSORS% | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
cmake --build out/Release -j %NUMBER_OF_PROCESSORS% | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
- name: Build (non-Windows) | |
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu') | |
run: | | |
if [ "${{matrix.compiler}}" == "clang" ]; then | |
export CC=clang | |
export CXX=clang++ | |
echo 'CC=clang' >> $GITHUB_ENV | |
echo 'CXX=clang++' >> $GITHUB_ENV | |
else | |
export CC=gcc | |
export CXX=g++ | |
echo 'CC=gcc' >> $GITHUB_ENV | |
echo 'CXX=g++' >> $GITHUB_ENV | |
fi | |
env | |
which cmake && cmake --version | |
which ninja && ninja --version | |
which $CC && $CC --version | |
which $CXX && $CXX --version | |
cd runtime/Cpp | |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug | |
cmake --build out/Debug --parallel | |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release | |
cmake --build out/Release --parallel | |
- name: Prepare artifacts | |
if: always() | |
run: | | |
cd ${{ github.workspace }}/.. | |
tar czfp antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz --exclude='.git' antlr4 | |
mv antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz ${{ github.workspace }}/. | |
- name: Archive artifacts | |
if: always() | |
continue-on-error: true | |
uses: actions/upload-artifact@v3 | |
with: | |
name: antlr_${{ matrix.os }}_${{ matrix.compiler }} | |
path: antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ | |
macos-11, | |
ubuntu-20.04, | |
windows-2022 | |
] | |
target: [ | |
tool, | |
cpp, | |
csharp, | |
dart, | |
go, | |
java, | |
javascript, | |
typescript, | |
php, | |
python3, | |
# swift, | |
] | |
exclude: | |
- os: windows-2022 | |
target: swift | |
steps: | |
# Check out the code before setting the environment since some | |
# of the actions actually parse the files to figure out the | |
# dependencies, for instance, the setup-java actually parses | |
# **/pom.xml files to decide what to cache. | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Checkout antlr PHP runtime | |
if: matrix.target == 'php' | |
uses: actions/checkout@v3 | |
with: | |
repository: antlr/antlr-php-runtime | |
path: runtime/PHP | |
- name: Install dependencies | |
env: | |
COMPOSER_CACHE_DIR: ${{ github.workspace }}/.cache | |
if: matrix.target == 'php' | |
run: |- | |
cd runtime/PHP | |
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader | |
- name: Install dependencies (Ubuntu) | |
if: startswith(matrix.os, 'ubuntu') | |
run: | | |
sudo apt-get update -qq | |
sudo apt install -y ninja-build | |
- name: Install dependencies (MacOS) | |
if: startswith(matrix.os, 'macos') | |
run: brew install ninja | |
- name: Set up JDK 11 | |
id: setup-java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 11 | |
cache: 'maven' | |
- name: Set up Maven | |
if: steps.setup-java.outputs.cache-hit != 'true' | |
uses: stCarolas/[email protected] | |
with: | |
maven-version: 3.8.5 | |
- name: Add msbuild to PATH | |
if: startswith(matrix.os, 'windows') && (matrix.target == 'cpp') | |
uses: microsoft/[email protected] | |
- name: Set up Python 3 | |
if: matrix.target == 'python3' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
architecture: 'x64' | |
- name: Set up Node 16 | |
if: (matrix.target == 'javascript') || (matrix.target == 'typescript') | |
uses: actions/[email protected] | |
with: | |
node-version: '16' | |
- name: Setup Dotnet | |
if: matrix.target == 'csharp' | |
uses: actions/[email protected] | |
with: | |
dotnet-version: '7.0.x' | |
- name: Setup Dart 2.12.1 | |
if: matrix.target == 'dart' | |
uses: dart-lang/[email protected] | |
with: | |
sdk: 2.12.1 | |
- name: Setup Go 1.19 | |
if: matrix.target == 'go' | |
uses: actions/[email protected] | |
with: | |
go-version: '^1.19' | |
- name: Setup PHP 8.2 | |
if: matrix.target == 'php' | |
uses: shivammathur/[email protected] | |
with: | |
php-version: '8.2' | |
extensions: mbstring | |
tools: composer | |
- name: Setup Swift | |
if: matrix.target == 'swift' | |
uses: swift-actions/[email protected] | |
with: | |
swift-version: '5.2' | |
- name: Use ccache | |
if: (startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')) && (matrix.target == 'cpp') | |
uses: hendrikmuhs/[email protected] | |
with: | |
key: ${{ matrix.os }}-${{ matrix.target }} | |
- name: Configure shell (Ubuntu) | |
if: startswith(matrix.os, 'ubuntu') && (matrix.target == 'cpp') | |
run: echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV | |
- name: Configure shell (MacOS) | |
if: startswith(matrix.os, 'macos') && (matrix.target == 'cpp') | |
run: echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV | |
- name: Build ANTLR with Maven | |
run: mvn install -DskipTests=true -Darguments="-Dmaven.javadoc.skip=true" -B -V | |
- name: Test tool | |
if: matrix.target == 'tool' | |
run: | | |
cd tool-testsuite | |
mvn test | |
- name: Test runtime (Windows) | |
if: startsWith(matrix.os, 'windows') && (matrix.target != 'tool') | |
run: | | |
gci env:* | sort-object name | |
cd runtime-testsuite | |
switch ("${{ matrix.target }}") | |
{ | |
python3 { mvn -X '-Dantlr-python3-exec="${{ env.pythonLocation }}\python.exe"' '-Dtest=python3.**' test } | |
default { mvn -X '-Dtest=${{ matrix.target }}.**' test } | |
} | |
env: | |
CMAKE_GENERATOR: Ninja | |
- name: Test runtime (non-Windows) | |
if: (startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')) && (matrix.target != 'tool') | |
run: | | |
env | |
cd runtime-testsuite | |
case ${{ matrix.target }} in | |
python3) mvn -X '-Dantlr-python3-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python3.**' test ;; | |
*) mvn -X '-Dtest=${{ matrix.target }}.**' test ;; | |
esac | |
- name: Prepare artifacts | |
if: always() | |
run: | | |
cd ${{ github.workspace }}/.. | |
tar czfp antlr_${{ matrix.os }}_${{ matrix.target }}.tgz --exclude='.git' antlr4 | |
mv antlr_${{ matrix.os }}_${{ matrix.target }}.tgz ${{ github.workspace }}/. | |
- name: Archive artifacts | |
if: always() | |
continue-on-error: true | |
uses: actions/upload-artifact@v3 | |
with: | |
name: antlr_${{ matrix.os }}_${{ matrix.target }} | |
path: antlr_${{ matrix.os }}_${{ matrix.target }}.tgz |