From a51f9f685be4d4b0b8434547c1acc025925e01a5 Mon Sep 17 00:00:00 2001 From: wangmeng Date: Wed, 19 Nov 2025 16:10:04 +0800 Subject: [PATCH] =?UTF-8?q?link-cplusplus=E5=8D=87=E7=BA=A71.0.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangmeng --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++---- .gitignore | 2 +- BUILD.gn | 2 +- Cargo.toml | 14 +++++++---- LICENSE-APACHE | 25 -------------------- README.OpenSource | 2 +- README.md | 8 +++---- build.rs | 12 ++++++---- src/dummy.cc | 5 ++++ src/lib.rs | 8 +++---- 10 files changed, 80 insertions(+), 49 deletions(-) create mode 100644 src/dummy.cc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ad97eb..e060d9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: pull_request: + workflow_dispatch: schedule: [cron: "40 1 * * *"] permissions: @@ -12,21 +13,62 @@ env: RUSTFLAGS: -Dwarnings jobs: + pre_ci: + uses: dtolnay/.github/.github/workflows/pre_ci.yml@master + test: name: Rust ${{matrix.rust}} on ${{matrix.os}} + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ${{matrix.os}}-latest strategy: fail-fast: false matrix: - rust: [nightly, beta, stable, 1.34.0] + rust: [nightly, beta, stable, 1.68.0] os: [ubuntu, macos, windows] timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} + - name: Enable type layout randomization + run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV + if: matrix.rust == 'nightly' + shell: bash - run: cargo test + - uses: actions/upload-artifact@v4 + if: matrix.os == 'ubuntu' && matrix.rust == 'nightly' && always() + with: + name: Cargo.lock + path: Cargo.lock + continue-on-error: true + + minimal: + name: Minimal versions + needs: pre_ci + if: needs.pre_ci.outputs.continue + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@nightly + - run: cargo generate-lockfile -Z minimal-versions + - run: cargo check --locked + + doc: + name: Documentation + needs: pre_ci + if: needs.pre_ci.outputs.continue + runs-on: ubuntu-latest + timeout-minutes: 45 + env: + RUSTDOCFLAGS: -Dwarnings + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/install@cargo-docs-rs + - run: cargo docs-rs clippy: name: Clippy @@ -34,7 +76,7 @@ jobs: if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@clippy - run: cargo clippy -- -Dclippy::all -Dclippy::pedantic @@ -44,6 +86,7 @@ jobs: if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable - uses: dtolnay/install@cargo-outdated - run: cargo outdated --workspace --exit-code 1 diff --git a/.gitignore b/.gitignore index 1b72444..042776a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /Cargo.lock -/target +/target/ diff --git a/BUILD.gn b/BUILD.gn index e4f9124..7771f4e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,7 +21,7 @@ ohos_cargo_crate("lib") { sources = [ "src/lib.rs" ] edition = "2018" - cargo_pkg_version = "1.0.8" + cargo_pkg_version = "1.0.12" cargo_pkg_authors = "David Tolnay " cargo_pkg_name = "link-cplusplus" cargo_pkg_description = "Link libstdc++ or libc++ automatically or manually" diff --git a/Cargo.toml b/Cargo.toml index c09576e..ab8ae33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.12" authors = ["David Tolnay "] -categories = ["external-ffi-bindings", "development-tools::ffi", "compilers", "no-std"] +categories = ["external-ffi-bindings", "development-tools::ffi", "compilers", "no-std", "no-std::no-alloc"] description = "Link libstdc++ or libc++ automatically or manually" documentation = "https://docs.rs/link-cplusplus" edition = "2018" @@ -10,10 +10,10 @@ keywords = ["linkage", "c++"] license = "MIT OR Apache-2.0" links = "cplusplus" repository = "https://github.com/dtolnay/link-cplusplus" -rust-version = "1.34" +rust-version = "1.68" [build-dependencies] -cc = "1.0" +cc = "1" [features] default = [] # automatic @@ -27,3 +27,9 @@ libcxx = ["libc++"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = [ + "--generate-link-to-definition", + "--extern-html-root-url=core=https://doc.rust-lang.org", + "--extern-html-root-url=alloc=https://doc.rust-lang.org", + "--extern-html-root-url=std=https://doc.rust-lang.org", +] diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 16fe87b..1b5ec8b 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/README.OpenSource b/README.OpenSource index d18bffc..5d55a4d 100644 --- a/README.OpenSource +++ b/README.OpenSource @@ -3,7 +3,7 @@ "Name": "link-cplusplus", "License": "Apache License V2.0, MIT", "License File": "LICENSE-APACHE, LICENSE-MIT", - "Version Number": "1.0.8", + "Version Number": "1.0.12", "Owner": "fangting12@huawei.com", "Upstream URL": "https://github.com/dtolnay/link-cplusplus", "Description": "A Rust library that provides support for linking with C++ code." diff --git a/README.md b/README.md index 7743b4f..d45f24d 100644 --- a/README.md +++ b/README.md @@ -29,18 +29,18 @@ Cargo.toml: ```toml [dependencies] -link-cplusplus = "1.0" +link-cplusplus = "1" ``` An application that wants a particular one or the other linked should use: ```toml [dependencies] -link-cplusplus = { version = "1.0", features = ["libstdc++"] } +link-cplusplus = { version = "1", features = ["libstdc++"] } # or -link-cplusplus = { version = "1.0", features = ["libc++"] } +link-cplusplus = { version = "1", features = ["libc++"] } ``` An application that wants to handle its own more complicated logic for link @@ -48,7 +48,7 @@ flags from its build script can make this crate do nothing by using: ```toml [dependencies] -link-cplusplus = { version = "1.0", features = ["nothing"] } +link-cplusplus = { version = "1", features = ["nothing"] } ``` Lastly, make sure to add an explicit `extern crate` dependency to your crate diff --git a/build.rs b/build.rs index 1f67922..8315642 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,4 @@ use std::env; -use std::fs; use std::path::PathBuf; fn main() { @@ -25,10 +24,13 @@ fn main() { (false, true) => println!("cargo:rustc-link-lib=c++"), (false, false) | (true, true) => { // The platform's default. - let out_dir = env::var_os("OUT_DIR").expect("missing OUT_DIR"); - let path = PathBuf::from(out_dir).join("dummy.cc"); - fs::write(&path, "int rust_link_cplusplus;\n").unwrap(); - cc::Build::new().cpp(true).file(&path).compile("link-cplusplus"); + let manifest_dir = + env::var_os("CARGO_MANIFEST_DIR").expect("missing CARGO_MANIFEST_DIR"); + let path = PathBuf::from(manifest_dir).join("src").join("dummy.cc"); + cc::Build::new() + .cpp(true) + .file(&path) + .compile("link-cplusplus"); } } } diff --git a/src/dummy.cc b/src/dummy.cc new file mode 100644 index 0000000..ce29620 --- /dev/null +++ b/src/dummy.cc @@ -0,0 +1,5 @@ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wmissing-variable-declarations" +#endif + +int rust_link_cplusplus; diff --git a/src/lib.rs b/src/lib.rs index 7864d59..ca52af8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,18 +31,18 @@ //! //! ```toml //! [dependencies] -//! link-cplusplus = "1.0" +//! link-cplusplus = "1" //! ``` //! //! An application that wants a particular one or the other linked should use: //! //! ```toml //! [dependencies] -//! link-cplusplus = { version = "1.0", features = ["libstdc++"] } +//! link-cplusplus = { version = "1", features = ["libstdc++"] } //! //! # or //! -//! link-cplusplus = { version = "1.0", features = ["libc++"] } +//! link-cplusplus = { version = "1", features = ["libc++"] } //! ``` //! //! An application that wants to handle its own more complicated logic for link @@ -50,7 +50,7 @@ //! //! ```toml //! [dependencies] -//! link-cplusplus = { version = "1.0", features = ["nothing"] } +//! link-cplusplus = { version = "1", features = ["nothing"] } //! ``` //! //! Lastly, make sure to add an explicit `extern crate` dependency to your crate