├── .gitignore ├── libfyaml-sys ├── LICENSE-MIT ├── README.md ├── Cargo.toml ├── src │ └── lib.rs └── build.rs ├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── Cargo.toml ├── .gitmodules ├── README.md └── LICENSE-MIT /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock 3 | -------------------------------------------------------------------------------- /libfyaml-sys/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /libfyaml-sys/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: dtolnay 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["libfyaml-sys"] 3 | resolver = "2" 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libfyaml-sys/libfyaml"] 2 | path = libfyaml-sys/libfyaml 3 | url = https://github.com/pantoniou/libfyaml 4 | -------------------------------------------------------------------------------- /libfyaml-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libfyaml-sys" 3 | version = "0.2.9+fy0.8.0" 4 | authors = ["David Tolnay "] 5 | categories = ["api-bindings", "encoding", "parser-implementations"] 6 | description = "Rust binding for libfyaml" 7 | documentation = "https://docs.rs/libfyaml-sys" 8 | edition = "2021" 9 | keywords = ["yaml"] 10 | license = "MIT" 11 | links = "libfyaml" 12 | repository = "https://github.com/dtolnay/libfyaml-rs" 13 | rust-version = "1.63" 14 | 15 | [dependencies] 16 | libc = "0.2" 17 | 18 | [build-dependencies] 19 | bindgen = "0.71" 20 | cc = "1" 21 | 22 | [lib] 23 | doc-scrape-examples = false 24 | 25 | [package.metadata.docs.rs] 26 | targets = ["x86_64-unknown-linux-gnu"] 27 | rustdoc-args = ["--generate-link-to-definition"] 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libfyaml-rs 2 | =========== 3 | 4 | [github](https://github.com/dtolnay/libfyaml-rs) 5 | [crates.io](https://crates.io/crates/libfyaml-sys) 6 | [docs.rs](https://docs.rs/libfyaml-sys) 7 | [build status](https://github.com/dtolnay/libfyaml-rs/actions?query=branch%3Amaster) 8 | 9 | Rust binding for the [libfyaml] C library. 10 | 11 | [libfyaml]: https://github.com/pantoniou/libfyaml 12 | 13 | ```toml 14 | [dependencies] 15 | libfyaml-sys = "0.2" 16 | ``` 17 | 18 | ## License 19 | 20 | MIT license, same as libfyaml. 21 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /libfyaml-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! [![github]](https://github.com/dtolnay/libfyaml-rs) [![crates-io]](https://crates.io/crates/libfyaml-sys) [![docs-rs]](https://docs.rs/libfyaml-sys) 2 | //! 3 | //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github 4 | //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust 5 | //! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs 6 | 7 | #![doc(html_root_url = "https://docs.rs/libfyaml-sys/0.2.9+fy0.8.0")] 8 | #![allow( 9 | improper_ctypes, 10 | non_camel_case_types, 11 | non_snake_case, 12 | non_upper_case_globals 13 | )] 14 | 15 | #[allow(clippy::all, clippy::pedantic)] 16 | mod bindings { 17 | use libc::FILE; 18 | 19 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 20 | } 21 | 22 | pub use crate::bindings::{fy_event__bindgen_ty_1 as fy_event_data, *}; 23 | 24 | // Exclude the following types from being exported out of the bindings module. 25 | #[allow(unknown_lints, dead_code, hidden_glob_reexports)] 26 | struct fy_event__bindgen_ty_1; 27 | #[allow(unknown_lints, dead_code, hidden_glob_reexports)] 28 | struct __BindgenBitfieldUnit; 29 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | schedule: [cron: "40 1 * * *"] 8 | 9 | permissions: 10 | contents: read 11 | 12 | env: 13 | RUSTFLAGS: -Dwarnings 14 | 15 | jobs: 16 | pre_ci: 17 | uses: dtolnay/.github/.github/workflows/pre_ci.yml@master 18 | 19 | test: 20 | name: ${{matrix.name || format('Rust {0}', matrix.rust)}} 21 | needs: pre_ci 22 | if: needs.pre_ci.outputs.continue 23 | runs-on: ${{matrix.os}}-latest 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | rust: [nightly, beta, stable, 1.82.0] 28 | os: [ubuntu] 29 | include: 30 | - name: macOS 31 | rust: nightly 32 | os: macos 33 | # TODO: windows (https://github.com/pantoniou/libfyaml/issues/10) 34 | timeout-minutes: 45 35 | steps: 36 | - uses: actions/checkout@v4 37 | - uses: dtolnay/rust-toolchain@master 38 | with: 39 | toolchain: ${{matrix.rust}} 40 | - name: Enable type layout randomization 41 | run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV 42 | if: matrix.rust == 'nightly' 43 | - run: cargo test 44 | - uses: actions/upload-artifact@v4 45 | if: matrix.os == 'ubuntu' && matrix.rust == 'nightly' && always() 46 | with: 47 | name: Cargo.lock 48 | path: Cargo.lock 49 | continue-on-error: true 50 | 51 | doc: 52 | name: Documentation 53 | needs: pre_ci 54 | if: needs.pre_ci.outputs.continue 55 | runs-on: ubuntu-latest 56 | timeout-minutes: 45 57 | env: 58 | RUSTDOCFLAGS: -Dwarnings 59 | steps: 60 | - uses: actions/checkout@v4 61 | - uses: dtolnay/rust-toolchain@nightly 62 | - uses: dtolnay/install@cargo-docs-rs 63 | - run: cargo docs-rs -p libfyaml-sys 64 | 65 | clippy: 66 | name: Clippy 67 | runs-on: ubuntu-latest 68 | if: github.event_name != 'pull_request' 69 | timeout-minutes: 45 70 | steps: 71 | - uses: actions/checkout@v4 72 | - uses: dtolnay/rust-toolchain@clippy 73 | - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic 74 | 75 | miri: 76 | name: Miri 77 | needs: pre_ci 78 | if: needs.pre_ci.outputs.continue 79 | runs-on: ubuntu-latest 80 | timeout-minutes: 45 81 | steps: 82 | - uses: actions/checkout@v4 83 | - uses: dtolnay/rust-toolchain@miri 84 | - run: cargo miri setup 85 | - run: cargo miri test 86 | env: 87 | MIRIFLAGS: -Zmiri-strict-provenance 88 | 89 | outdated: 90 | name: Outdated 91 | runs-on: ubuntu-latest 92 | if: github.event_name != 'pull_request' 93 | timeout-minutes: 45 94 | steps: 95 | - uses: actions/checkout@v4 96 | - uses: dtolnay/rust-toolchain@stable 97 | - uses: dtolnay/install@cargo-outdated 98 | - run: cargo outdated --workspace --exit-code 1 99 | -------------------------------------------------------------------------------- /libfyaml-sys/build.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::let_underscore_untyped, clippy::uninlined_format_args)] 2 | 3 | use std::env; 4 | use std::ffi::OsStr; 5 | use std::fs::DirEntry; 6 | use std::io; 7 | use std::path::Path; 8 | use std::process::{self, Command}; 9 | 10 | fn main() { 11 | let windows = env::var_os("CARGO_CFG_WINDOWS").is_some(); 12 | if windows { 13 | eprintln!("libfyaml is not supported on Windows."); 14 | eprintln!("See https://github.com/pantoniou/libfyaml/issues/10"); 15 | process::exit(1); 16 | } 17 | 18 | let header = "libfyaml/include/libfyaml.h"; 19 | println!("cargo:rerun-if-changed={}", header); 20 | 21 | if let Ok(false) = Path::new(header).try_exists() { 22 | let _ = Command::new("git") 23 | .args(["submodule", "update", "--init", "libfyaml"]) 24 | .status(); 25 | } 26 | 27 | let bindings = bindgen::builder() 28 | .header(header) 29 | .allowlist_recursively(false) 30 | .allowlist_function("fy_.*") 31 | .allowlist_type("fy_.*") 32 | .blocklist_function("fy_library_version") 33 | .blocklist_type("fy_node_mapping_sort_ctx") 34 | // Variadic functions that use `va_list`. 35 | // Blocked on https://github.com/rust-lang/rust/issues/44930. 36 | .blocklist_function("fy_diag_node_override_vreport") 37 | .blocklist_function("fy_diag_node_vreport") 38 | .blocklist_function("fy_diag_vprintf") 39 | .blocklist_function("fy_document_vbuildf") 40 | .blocklist_function("fy_document_vscanf") 41 | .blocklist_function("fy_emit_event_vcreate") 42 | .blocklist_function("fy_node_create_vscalarf") 43 | .blocklist_function("fy_node_override_vreport") 44 | .blocklist_function("fy_node_set_vanchorf") 45 | .blocklist_function("fy_node_vbuildf") 46 | .blocklist_function("fy_node_vreport") 47 | .blocklist_function("fy_node_vscanf") 48 | .blocklist_function("fy_parse_event_vcreate") 49 | .blocklist_function("fy_vdiag") 50 | .prepend_enum_name(false) 51 | .generate_comments(false) 52 | .formatter(bindgen::Formatter::Prettyplease) 53 | .generate() 54 | .unwrap(); 55 | 56 | let out_dir = env::var_os("OUT_DIR").unwrap(); 57 | let out_file = Path::new(&out_dir).join("bindings.rs"); 58 | bindings.write_to_file(out_file).unwrap(); 59 | 60 | let mut build = cc::Build::new(); 61 | add_c_files(&mut build, Path::new("libfyaml/src/lib")); 62 | add_c_files(&mut build, Path::new("libfyaml/src/xxhash")); 63 | build.include("libfyaml/include"); 64 | build.include("libfyaml/src/xxhash"); 65 | build.flag_if_supported("-Wno-type-limits"); 66 | build.flag_if_supported("-Wno-unused-but-set-parameter"); 67 | build.flag_if_supported("-Wno-unused-parameter"); 68 | build.define("VERSION", "NULL"); 69 | build.define("__STDC_WANT_LIB_EXT2__", "1"); 70 | build.compile("libfyaml"); 71 | } 72 | 73 | fn add_c_files(build: &mut cc::Build, dir: &Path) { 74 | // Sort the C files to ensure a deterministic build for reproducible builds. 75 | let iter = dir.read_dir().unwrap(); 76 | let mut paths = iter.collect::>>().unwrap(); 77 | paths.sort_by_key(DirEntry::path); 78 | 79 | for entry in paths { 80 | if entry.file_type().unwrap().is_file() { 81 | let path = entry.path(); 82 | if path.extension() == Some(OsStr::new("c")) { 83 | build.file(path); 84 | } 85 | } 86 | } 87 | } 88 | --------------------------------------------------------------------------------