From 74481023d8c9617004c842502101b52edb36be19 Mon Sep 17 00:00:00 2001 From: peizhe <472708703@qq.com> Date: Tue, 18 Apr 2023 09:34:35 +0800 Subject: [PATCH] Add GN Build Files and Custom Modifications Signed-off-by: peizhe <472708703@qq.com> --- README.OpenSource | 11 +++++++++ openssl-macros/BUILD.gn | 31 ++++++++++++++++++++++++ openssl-sys/BUILD.gn | 53 +++++++++++++++++++++++++++++++++++++++++ openssl/BUILD.gn | 53 +++++++++++++++++++++++++++++++++++++++++ openssl/src/lib.rs | 1 + 5 files changed, 149 insertions(+) create mode 100644 README.OpenSource create mode 100644 openssl-macros/BUILD.gn create mode 100644 openssl-sys/BUILD.gn create mode 100644 openssl/BUILD.gn diff --git a/README.OpenSource b/README.OpenSource new file mode 100644 index 0000000..5e6dd50 --- /dev/null +++ b/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "openssl", + "License": "Apache License V2.0, MIT", + "License File": "LICENSE-APACHE, LICENSE-MIT", + "Version Number": "0.10.47", + "Owner": "xuelei3@huawei.com", + "Upstream URL": "https://github.com/sfackler/rust-openssl", + "Description": "OpenSSL bindings." + } +] diff --git a/openssl-macros/BUILD.gn b/openssl-macros/BUILD.gn new file mode 100644 index 0000000..ec50550 --- /dev/null +++ b/openssl-macros/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# 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. + +import("//build/ohos.gni") + +ohos_cargo_crate("lib") { + crate_name = "openssl_macros" + crate_type = "proc-macro" + crate_root = "src/lib.rs" + + sources = [ "src/lib.rs" ] + edition = "2018" + cargo_pkg_version = "0.1.0" + cargo_pkg_name = "openssl-macros" + cargo_pkg_description = "Internal macros used by the openssl crate." + deps = [ + "//third_party/rust/crates/proc-macro2:lib", + "//third_party/rust/crates/quote:lib", + "//third_party/rust/crates/syn:lib", + ] +} diff --git a/openssl-sys/BUILD.gn b/openssl-sys/BUILD.gn new file mode 100644 index 0000000..8821bcf --- /dev/null +++ b/openssl-sys/BUILD.gn @@ -0,0 +1,53 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# 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. + +import("//build/ohos.gni") + +ohos_cargo_crate("lib") { + crate_name = "openssl_sys" + crate_type = "rlib" + crate_root = "src/lib.rs" + + sources = [ "src/lib.rs" ] + edition = "2018" + cargo_pkg_version = "0.9.82" + cargo_pkg_authors = "Alex Crichton , Steven Fackler " + cargo_pkg_name = "openssl-sys" + cargo_pkg_description = "FFI bindings to OpenSSL" + deps = [ + "//third_party/openssl:libcrypto_shared", + "//third_party/openssl:libssl_shared", + "//third_party/rust/crates/libc:lib", + ] + rustflags = [ + "--cfg=const_fn", + "--cfg=openssl", + "--cfg=osslconf=\"OPENSSL_NO_BF\"", + "--cfg=osslconf=\"OPENSSL_NO_IDEA\"", + "--cfg=osslconf=\"OPENSSL_NO_CAMELLIA\"", + "--cfg=osslconf=\"OPENSSL_NO_CAST\"", + "--cfg=osslconf=\"OPENSSL_NO_RMD160\"", + "--cfg=osslconf=\"OPENSSL_NO_SSL3_METHOD\"", + "--cfg=ossl101", + "--cfg=ossl102", + "--cfg=ossl102f", + "--cfg=ossl102h", + "--cfg=ossl110", + "--cfg=ossl110f", + "--cfg=ossl110g", + "--cfg=ossl110h", + "--cfg=ossl111", + "--cfg=ossl111b", + "--cfg=ossl111c", + ] +} diff --git a/openssl/BUILD.gn b/openssl/BUILD.gn new file mode 100644 index 0000000..70e33ee --- /dev/null +++ b/openssl/BUILD.gn @@ -0,0 +1,53 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# 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. + +import("//build/ohos.gni") + +ohos_cargo_crate("lib") { + crate_name = "openssl" + crate_type = "rlib" + crate_root = "src/lib.rs" + + sources = [ "src/lib.rs" ] + edition = "2018" + cargo_pkg_version = "0.10.47" + cargo_pkg_authors = "Steven Fackler " + cargo_pkg_name = "openssl" + cargo_pkg_description = "OpenSSL bindings" + deps = [ + "//third_party/rust/crates/bitflags:lib", + "//third_party/rust/crates/cfg-if:lib", + "//third_party/rust/crates/foreign-types/foreign-types/:lib", + "//third_party/rust/crates/libc:lib", + "//third_party/rust/crates/once_cell:lib", + "//third_party/rust/crates/rust-openssl/openssl-macros:lib(${host_toolchain})", + "//third_party/rust/crates/rust-openssl/openssl-sys:lib", + ] + features = [ "default" ] + rustflags = [ + "--cfg=osslconf=\"OPENSSL_NO_BF\"", + "--cfg=osslconf=\"OPENSSL_NO_IDEA\"", + "--cfg=osslconf=\"OPENSSL_NO_CAMELLIA\"", + "--cfg=osslconf=\"OPENSSL_NO_CAST\"", + "--cfg=osslconf=\"OPENSSL_NO_RMD160\"", + "--cfg=osslconf=\"OPENSSL_NO_SSL3_METHOD\"", + "--cfg=ossl101", + "--cfg=ossl102", + "--cfg=ossl110", + "--cfg=ossl110g", + "--cfg=ossl110h", + "--cfg=ossl111", + "-Copt-level=3", + "-Cprefer-dynamic", + ] +} diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 5678298..d1c97af 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -126,6 +126,7 @@ pub use ffi::init; use libc::c_int; +extern crate openssl_sys as ffi; use crate::error::ErrorStack; #[macro_use]