-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add links to aws-lc-fips-sys Cargo.toml (#279)
- Loading branch information
Showing
10 changed files
with
147 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "sys-testing" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[features] | ||
default = ["aws-lc-sys"] | ||
aws-lc-sys = ["dep:aws-lc-sys"] | ||
aws-lc-fips-sys = ["dep:aws-lc-fips-sys"] | ||
|
||
[dependencies] | ||
aws-lc-sys = { path = "../aws-lc-sys", optional = true } | ||
aws-lc-fips-sys = { path = "../aws-lc-fips-sys", optional = true } | ||
|
||
[build-dependencies] | ||
cc = "1" | ||
toml_edit = "0.21" | ||
|
||
[package.metadata.cargo-udeps.ignore] | ||
normal = [ "aws-lc-sys", "aws-lc-fips-sys" ] # the sys crate is only used through a C library build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
use toml_edit::Document; | ||
|
||
fn main() { | ||
if cfg!(all(feature = "aws-lc-sys", feature = "aws-lc-fips-sys")) { | ||
panic!("only one sys crate can be built at a time") | ||
} else if cfg!(feature = "aws-lc-sys") { | ||
let aws_lc_sys_links = get_package_links_property("../aws-lc-sys/Cargo.toml"); | ||
build_and_link(aws_lc_sys_links.as_ref(), "aws_lc_sys"); | ||
return; | ||
} else if cfg!(feature = "aws-lc-fips-sys") { | ||
let aws_lc_fips_sys_links = get_package_links_property("../aws-lc-fips-sys/Cargo.toml"); | ||
build_and_link(aws_lc_fips_sys_links.as_ref(), "aws_lc_fips"); | ||
return; | ||
} | ||
panic!( | ||
"select a sys crate for testing using --features aws-lc-sys or --features aws-lc-fips-sys" | ||
) | ||
} | ||
|
||
fn build_and_link(links: &str, target_name: &str) { | ||
// ensure that the include path is exported and set up correctly | ||
cc::Build::new() | ||
.include(env(format!("DEP_{}_INCLUDE", links.to_uppercase()))) | ||
.file("src/testing.c") | ||
.compile(target_name); | ||
|
||
// ensure the libcrypto artifact is linked | ||
println!("cargo:rustc-link-lib={links}_crypto"); | ||
} | ||
|
||
fn get_package_links_property(cargo_toml_path: &str) -> String { | ||
let cargo_toml = std::fs::read_to_string(cargo_toml_path).unwrap(); | ||
let cargo_toml = cargo_toml.parse::<Document>().unwrap(); | ||
|
||
let links = cargo_toml["package"]["links"].as_str().unwrap(); | ||
|
||
String::from(links) | ||
} | ||
|
||
fn env<S: AsRef<str>>(s: S) -> String { | ||
let s = s.as_ref(); | ||
println!("cargo:rerun-if-env-changed={s}"); | ||
std::env::var(s).unwrap_or_else(|_| panic!("missing env var {s}")) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include <openssl/is_awslc.h> | ||
#include <openssl/evp.h> | ||
|
||
int testing_evp_key_type(int nid) | ||
{ | ||
int testing_evp_key_type(int nid) { | ||
return EVP_PKEY_type(nid); | ||
} |