Skip to content

Commit 273790e

Browse files
committed
rust: Initial yarp-sys
Still need to add more tests Update Cargo.toml; add README Switch yp_string_t_type variants to SNAKE_CASE Add unescape tests Add encoding callback tests Add pack_parse test Add diagnostic test Add comment test Add node tests Add string_list tests Add other string tests Add shared string test Add list tests Fixes for updated branch Run bundle install before running Rust tests Fix version test ci: Add proper config for rust-toolchain step for sanitizers ci: Fix tests, clippy Remove extra `bundle install`; run `bundle exec rake` Didn't realize `setup-ruby`'s `bundle-cache: true` runs `bundle install`. Remove `rake compile` from build.rs This is complicating CI for me; maybe we add it back later. Undo README formatting changes Fix UB in C callbacks Use slice+str instead of String for raw things Move bindings to bindings module Handle non-UTF-8 strings in paths rust ci: test with sanitizers; add -D warnings Update rust-bindings.yml Update Cargo.toml Don't need to compile extra crate_types PR changes Apply patch from @kddnewton Delete unescape_tests.rs Fix things after rebasing
1 parent 87e02c0 commit 273790e

File tree

15 files changed

+1243
-1
lines changed

15 files changed

+1243
-1
lines changed

.github/workflows/rust-bindings.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
name: Rust Bindings
3+
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/rust-bindings.yml"
8+
- "include/"
9+
- "src/"
10+
- "rust/"
11+
- "*akefile*"
12+
branches:
13+
- main
14+
pull_request:
15+
16+
env:
17+
RUSTFLAGS: "-D warnings"
18+
19+
jobs:
20+
cargo-test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set up Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: head
28+
bundler-cache: true
29+
- uses: actions/cache@v3
30+
with:
31+
path: |
32+
~/.cargo/registry
33+
~/.cargo/git
34+
target
35+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
36+
restore-keys: |
37+
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
38+
${{ runner.os }}-cargo
39+
- name: rake compile
40+
run: bundle exec rake compile
41+
- name: cargo test
42+
working-directory: rust/yarp-sys
43+
run: cargo test
44+
45+
cargo-clippy:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v3
49+
- name: Set up Ruby
50+
uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: head
53+
bundler-cache: true
54+
- uses: actions/cache@v3
55+
with:
56+
path: |
57+
~/.cargo/registry
58+
~/.cargo/git
59+
target
60+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
61+
restore-keys: |
62+
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
63+
${{ runner.os }}-cargo
64+
- name: rake compile
65+
run: bundle exec rake compile
66+
- name: cargo clippy
67+
working-directory: rust/yarp-sys
68+
run: cargo clippy --tests -- -W "clippy::pedantic"
69+
70+
sanitizer-test:
71+
name: Test with -Zsanitizer=${{ matrix.sanitizer }}
72+
runs-on: ubuntu-latest
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
sanitizer: [address, leak]
77+
steps:
78+
- uses: actions/checkout@v3
79+
- name: Set up Ruby
80+
uses: ruby/setup-ruby@v1
81+
with:
82+
ruby-version: head
83+
bundler-cache: true
84+
- name: rake compile
85+
run: bundle exec rake compile
86+
- uses: dtolnay/rust-toolchain@nightly
87+
with:
88+
target: "x86_64-unknown-linux-gnu"
89+
components: "rust-src"
90+
- name: Test with sanitizer
91+
env:
92+
RUSTFLAGS: -Zsanitizer=${{ matrix.sanitizer }}
93+
RUSTDOCFLAGS: -Zsanitizer=${{ matrix.sanitizer }}
94+
# only needed by asan
95+
ASAN_OPTIONS: detect_stack_use_after_return=1
96+
# Asan's leak detection occasionally complains
97+
# about some small leaks if backtraces are captured,
98+
# so ensure they're not
99+
RUST_BACKTRACE: 0
100+
working-directory: rust/yarp-sys
101+
run: cargo test -Zbuild-std --verbose --target=x86_64-unknown-linux-gnu

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ The repository contains the infrastructure for both a shared library (librubypar
2929
│   ├── yarp Ruby library files
3030
│   └── yarp.rb main entrypoint for the Ruby library
3131
├── rakelib various Rake tasks for the project
32+
├── rust
33+
│   └── yarp-sys FFI binding for Rust
3234
├── src
3335
│   ├── enc various encoding files
3436
│   ├── util various utility files
@@ -45,7 +47,7 @@ The repository contains the infrastructure for both a shared library (librubypar
4547
To compile the shared library, you will need:
4648

4749
* A C99 compiler
48-
* autotools (autoconf, automake, libtool)
50+
* autotools autoconf, automake, libtool)
4951
* make
5052
* Ruby 3.3.0-preview1 or later
5153

@@ -84,3 +86,4 @@ See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. We additio
8486
* [Ripper](docs/ripper.md)
8587
* [Serialization](docs/serialization.md)
8688
* [Testing](docs/testing.md)
89+

rakelib/check_manifest.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ task :check_manifest => [:templates] do
1616
java
1717
pkg
1818
rakelib
19+
rust
1920
templates
2021
test
2122
tmp

rust/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

rust/yarp-sys/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# will have compiled files and executables
2+
debug/
3+
target/
4+
5+
# These are backup files generated by rustfmt
6+
**/*.rs.bk
7+
8+
# MSVC Windows builds of rustc generate these, which store debugging information
9+
*.pdb

0 commit comments

Comments
 (0)