-
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.
fix(aws-lc-sys): add
links
attribute to Cargo.toml (#277)
* fix(aws-lc-sys): add `links` attribute to Cargo.toml * fix failing ci tasks * use toml_edit to read expected links value
- Loading branch information
Showing
7 changed files
with
121 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "aws-lc-sys-testing" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
aws-lc-sys = { path = "../aws-lc-sys" } | ||
|
||
[build-dependencies] | ||
cc = "1" | ||
toml_edit = "0.21" | ||
|
||
[package.metadata.cargo-udeps.ignore] | ||
normal = [ "aws-lc-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,26 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
use toml_edit::Document; | ||
|
||
fn main() { | ||
let cargo_toml = std::fs::read_to_string("../aws-lc-sys/Cargo.toml").unwrap(); | ||
let cargo_toml = cargo_toml.parse::<Document>().unwrap(); | ||
|
||
let links = cargo_toml["package"]["links"].as_str().unwrap(); | ||
|
||
// 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("aws_ls_sys_testing"); | ||
|
||
// ensure the libcrypto artifact is linked | ||
println!("cargo:rustc-link-lib={}_crypto", 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}")) | ||
} |
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,18 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
use std::ffi::c_int; | ||
|
||
extern "C" { | ||
fn testing_evp_key_type(nid: c_int) -> c_int; | ||
} | ||
|
||
fn main() { | ||
let v = unsafe { testing_evp_key_type(123) }; | ||
println!("Hello EVP {v}!"); | ||
} | ||
|
||
#[test] | ||
fn link_test() { | ||
let _ = unsafe { testing_evp_key_type(123) }; | ||
} |
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,7 @@ | ||
#include <openssl/is_awslc.h> | ||
#include <openssl/evp.h> | ||
|
||
int testing_evp_key_type(int nid) | ||
{ | ||
return EVP_PKEY_type(nid); | ||
} |
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 should be
fs_extra = "1.3"
because, for example,CopyOptions::skip_exist
does not exist in version 1.Ideally the aws-lc-rs would have a
-Z minimal-versions
job to validate these versions do select usable versions.