Skip to content

Commit 60209ac

Browse files
committed
Merge branch 'master' into fn-ptr
2 parents c500cff + 28422cc commit 60209ac

93 files changed

Lines changed: 1730 additions & 395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "CodeQL"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
analyze:
7+
name: Analyze ${{ matrix.language }}
8+
runs-on: ubuntu-latest
9+
permissions:
10+
actions: read
11+
contents: read
12+
security-events: write
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
language: [ 'actions', 'cpp', 'rust' ]
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v6
22+
23+
- name: Setup LLVM
24+
if: matrix.language == 'cpp'
25+
uses: ZhongRuoyu/setup-llvm@v0
26+
with:
27+
llvm-version: 22
28+
29+
- name: Setup Rust
30+
if: matrix.language == 'rust'
31+
uses: dtolnay/rust-toolchain@master
32+
with:
33+
toolchain: 1.94.0
34+
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v4
37+
with:
38+
languages: ${{ matrix.language }}
39+
trap-caching: false
40+
config: |
41+
paths-ignore:
42+
- 'tests/**'
43+
44+
- name: Build C++ code
45+
if: matrix.language == 'cpp'
46+
run: |
47+
mkdir build && cd build
48+
cmake -GNinja ..
49+
ninja
50+
51+
- name: Build Rust code
52+
if: matrix.language == 'rust'
53+
run: cargo build --verbose
54+
working-directory: libcc2rs
55+
56+
- name: Perform CodeQL Analysis
57+
uses: github/codeql-action/analyze@v4
58+
with:
59+
category: "/language:${{matrix.language}}"

.github/workflows/format.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on: [push, pull_request]
55
jobs:
66
format:
77
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
811
steps:
912
- name: Checkout code
1013
uses: actions/checkout@v6
@@ -14,13 +17,14 @@ jobs:
1417
with:
1518
llvm-version: 22
1619

17-
- name: Install Rust toolchain
18-
run: |
19-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.94.0
20-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
20+
- name: Setup Rust
21+
uses: dtolnay/rust-toolchain@master
22+
with:
23+
toolchain: 1.94.0
24+
components: rustfmt
2125

2226
- name: Check C++ formatting
23-
run: find cpp2rust tests -name '*.cpp' -o -name '*.h' | xargs clang-format --dry-run --Werror
27+
run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format --dry-run --Werror
2428

2529
- name: Check Rust formatting
2630
run: |

.github/workflows/run-tests.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run tests
1+
name: "Run tests"
22

33
on: [push, pull_request]
44

@@ -11,30 +11,33 @@ jobs:
1111
build_type: [Debug, Release]
1212

1313
runs-on: ${{ matrix.os }}
14-
name: ${{ matrix.test.name }} (${{ matrix.os }}, ${{ matrix.build_type }})
14+
name: Run Tests (${{ matrix.os }}, ${{ matrix.build_type }})
15+
16+
permissions:
17+
contents: read
1518

1619
steps:
1720
- name: Checkout code
1821
uses: actions/checkout@v6
1922

20-
- name: Setup LLVM 22
23+
- name: Setup LLVM
2124
uses: ZhongRuoyu/setup-llvm@v0
2225
with:
2326
llvm-version: 22
2427

25-
- name: Install dependencies (Linux)
26-
if: runner.os == 'Linux'
27-
run: sudo apt-get install -y python3-tomli
28+
- name: Setup Rust
29+
uses: dtolnay/rust-toolchain@master
30+
with:
31+
toolchain: 1.94.0
32+
components: rustfmt
2833

29-
- name: Install dependencies (macOS)
30-
if: runner.os == 'macOS'
31-
run: |
32-
pip3 install tomli --break-system-packages
34+
- name: Setup Python
35+
uses: actions/setup-python@v6
36+
with:
37+
python-version: '3.x'
3338

34-
- name: Install Rust toolchain
35-
run: |
36-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.94.0
37-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
39+
- name: Install Python dependencies
40+
run: pip install tomli
3841

3942
- name: Configure
4043
run: |

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ list(APPEND CMAKE_MODULE_PATH "${CLANG_CMAKE_DIR}")
3434
include(AddLLVM)
3535
include(AddClang)
3636

37-
if (NOT CMAKE_CXX_COMPILER MATCHES "clang")
37+
if (NOT CMAKE_CXX_COMPILER MATCHES "clang" AND NOT DEFINED ENV{CODEQL_EXTRACTOR_CPP_ROOT})
3838
set(CMAKE_CXX_COMPILER "${CLANG_CMAKE_DIR}/../../../bin/clang++")
3939
endif()
4040

@@ -93,7 +93,7 @@ add_subdirectory(tests)
9393
find_program(CLANG_FORMAT NAMES clang-format-22 clang-format)
9494

9595
file(GLOB_RECURSE ALL_CXX_SOURCES
96-
cpp2rust/*.cpp cpp2rust/*.h tests/*.cpp)
96+
cpp2rust/*.cpp cpp2rust/*.h tests/*.cpp tests/*.c)
9797

9898
add_custom_target("format"
9999
COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES}

cpp2rust/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ target_link_libraries(cpp2rust PRIVATE
1313
target_include_directories(cpp2rust PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1414
target_include_directories(cpp2rust PUBLIC SYSTEM ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
1515
target_compile_definitions(cpp2rust PUBLIC ${LLVM_DEFINITIONS})
16-
target_compile_definitions(cpp2rust PUBLIC "-DCLANG_EXECUTABLE=\"${CMAKE_CXX_COMPILER}\"")
16+
target_compile_definitions(cpp2rust PUBLIC "-DCLANG_C_COMPILER=\"${CMAKE_C_COMPILER}\"")
17+
target_compile_definitions(cpp2rust PUBLIC "-DCLANG_CXX_COMPILER=\"${CMAKE_CXX_COMPILER}\"")
1718
target_compile_definitions(cpp2rust PUBLIC "-DCLANG_RESOURCE_DIR=\"${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}\"")
1819
target_compile_definitions(cpp2rust PUBLIC "-DCOMPAT_INCLUDE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/compat\"")
1920

0 commit comments

Comments
 (0)