Skip to content

Commit 2444836

Browse files
committed
Update CI to use CMake
1 parent 45b05dc commit 2444836

File tree

6 files changed

+33
-83
lines changed

6 files changed

+33
-83
lines changed

.github/workflows/bindings.yml

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,44 @@ jobs:
1212
include:
1313
- os: macOS-latest
1414
target: aarch64-apple-darwin
15+
cmake-options: -DCMAKE_OSX_ARCHITECTURES=arm64
1516
path: macos/arm64
16-
shared-ext: dylib
17-
static-ext: a
1817
- os: macOS-latest
1918
target: x86_64-apple-darwin
2019
path: macos/x86_64
21-
shared-ext: dylib
22-
static-ext: a
2320
- os: windows-2019
2421
target: aarch64-pc-windows-msvc
22+
setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsamd64_x86.bat" `& powershell'
23+
cmake-options: -A ARM64
2524
path: windows/arm64/msvc
26-
shared-ext: dll
27-
static-ext: lib
2825
- os: windows-2019
2926
target: i686-pc-windows-msvc
27+
setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" `& powershell'
28+
cmake-options: -A Win32
3029
path: windows/x86/msvc
31-
shared-ext: dll
32-
static-ext: lib
3330
- os: windows-2019
3431
target: x86_64-pc-windows-msvc
32+
setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" `& powershell'
3533
path: windows/x86_64/msvc
36-
shared-ext: dll
37-
static-ext: lib
3834
- os: ubuntu-latest
3935
target: i686-pc-windows-gnu
40-
use-cross: true
36+
setup-step: sudo apt update && sudo apt install -y mingw-w64
37+
cmake-options: -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86 -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++
4138
path: windows/x86/mingw
42-
shared-ext: dll
43-
static-ext: a
4439
- os: ubuntu-latest
4540
target: x86_64-pc-windows-gnu
46-
use-cross: true
41+
setup-step: sudo apt update && sudo apt install -y mingw-w64
42+
cmake-options: -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++
4743
path: windows/x86_64/mingw
48-
shared-ext: dll
49-
static-ext: a
5044
- os: ubuntu-latest
5145
target: i686-unknown-linux-gnu
52-
use-cross: true
46+
setup-step: sudo apt update && sudo apt install -y gcc-multilib g++-multilib
47+
cmake-options: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86
5348
path: linux/x86
54-
shared-ext: so
55-
static-ext: a
5649
- os: ubuntu-latest
5750
target: x86_64-unknown-linux-gnu
5851
path: linux/x86_64
59-
shared-ext: so
60-
static-ext: a
61-
name: cargo build
52+
name: Build
6253
steps:
6354
- uses: actions/checkout@v3
6455

@@ -70,34 +61,18 @@ jobs:
7061
profile: minimal
7162
override: true
7263

73-
- name: cargo build
74-
uses: actions-rs/cargo@v1
75-
with:
76-
command: build
77-
use-cross: ${{ matrix.use-cross || false }}
78-
args: --package accesskit_c --release --target ${{ matrix.target }}
79-
80-
- shell: bash
81-
run: |
82-
mkdir -p artifacts/${{ matrix.path }}/shared
83-
mkdir -p artifacts/${{ matrix.path }}/static
84-
85-
- if: startsWith(matrix.os, 'windows')
64+
- name: build libraries
8665
run: |
87-
mv target/${{ matrix.target }}/release/accesskit.dll.lib artifacts/${{ matrix.path }}/shared/accesskit.lib
88-
mv target/${{ matrix.target }}/release/*.pdb artifacts/${{ matrix.path }}/shared
89-
- if: contains(matrix.path, 'mingw')
90-
run: mv target/${{ matrix.target }}/release/libaccesskit.dll.a artifacts/${{ matrix.path }}/shared/libaccesskit.a
91-
92-
- run: |
93-
mv target/${{ matrix.target }}/release/*.${{ matrix.shared-ext }} artifacts/${{ matrix.path }}/shared
94-
mv target/${{ matrix.target }}/release/*.${{ matrix.static-ext }} artifacts/${{ matrix.path }}/static
66+
${{ matrix.setup-step || '' }}
67+
cmake -S bindings/c -B build -DACCESSKIT_BUILD_HEADERS=OFF -DRust_CARGO_TARGET=${{ matrix.target }} ${{ matrix.cmake-options || '' }} ${{ !contains(matrix.target, 'msvc') && '-DCMAKE_BUILD_TYPE=Release' || '' }}
68+
cmake --build build ${{ contains(matrix.target, 'msvc') && '--config Release' || '' }}
69+
cmake --install build ${{ contains(matrix.target, 'msvc') && '--config Release' || '' }}
9570
9671
- name: Upload binaries
9772
uses: actions/upload-artifact@v3
9873
with:
9974
name: ${{ matrix.target }}
100-
path: artifacts
75+
path: bindings/c/lib
10176

10277
generate-headers:
10378
if: startsWith(github.ref_name, 'accesskit_c-v')

.github/workflows/generate-headers.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ jobs:
1818
- uses: dtolnay/install@master
1919
with:
2020
crate: cbindgen
21-
- run: make -C bindings/c include/accesskit.h
21+
- run: cmake -S bindings/c -B build -DACCESSKIT_BUILD_LIBRARIES=OFF
22+
- run: cmake --build build
23+
- run: cmake --install build
2224

2325
- name: Upload header file
2426
uses: actions/upload-artifact@v3

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ default-members = [
1212
"common",
1313
"consumer",
1414
"platforms/winit",
15+
"bindings/c",
1516
]
1617

1718
[profile.release]

bindings/c/Makefile

Lines changed: 0 additions & 36 deletions
This file was deleted.

bindings/c/accesskit-config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (_accesskit_os STREQUAL "macos")
1616
elseif (_accesskit_os STREQUAL "windows")
1717
set_property(
1818
TARGET accesskit-static
19-
PROPERTY INTERFACE_LINK_LIBRARIES bcrypt uiautomationcore userenv ws2_32
19+
PROPERTY INTERFACE_LINK_LIBRARIES bcrypt ntdll uiautomationcore userenv ws2_32
2020
)
2121
endif()
2222

bindings/c/src/macos.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
action_handler, box_from_ptr, ref_from_ptr, tree_update, tree_update_factory, BoxCastPtr,
88
CastPtr,
99
};
10-
use accesskit_macos::{Adapter, NSObject, NSPoint, QueuedEvents, SubclassingAdapter};
10+
use accesskit_macos::{Adapter, NSPoint, QueuedEvents, SubclassingAdapter};
1111
use std::{os::raw::c_void, ptr};
1212

1313
pub struct macos_queued_events {
@@ -41,6 +41,10 @@ impl BoxCastPtr for macos_adapter {}
4141

4242
impl macos_adapter {
4343
/// This function takes ownership of `initial_state` and `handler`.
44+
///
45+
/// # Safety
46+
///
47+
/// `view` must be a valid, unreleased pointer to an `NSView`.
4448
#[no_mangle]
4549
pub unsafe extern "C" fn accesskit_macos_adapter_new(
4650
view: *mut c_void,
@@ -111,6 +115,10 @@ impl BoxCastPtr for macos_subclassing_adapter {}
111115

112116
impl macos_subclassing_adapter {
113117
/// This function takes ownership of `handler`.
118+
///
119+
/// # Safety
120+
///
121+
/// `view` must be a valid, unreleased pointer to an `NSView`.
114122
#[no_mangle]
115123
pub unsafe extern "C" fn accesskit_macos_subclassing_adapter_new(
116124
view: *mut c_void,

0 commit comments

Comments
 (0)