Skip to content

Commit 706565c

Browse files
authored
Include Go source in aws-lc-sys crate (#754)
* Include Go source in crate * Support a AWS_LC_SYS_NO_PREGENERATED_SRC env var * Narrow which Go files included * Also include prebuilt-nasm.sh
1 parent 344a56f commit 706565c

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

.github/workflows/tests.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -553,19 +553,25 @@ jobs:
553553
cmake-source-path-has-spaces:
554554
if: github.repository_owner == 'aws'
555555
name:
556-
"Spaces in path (CMake) - ${{ matrix.os }}"
556+
"Spaces in path (CMake) - ${{ matrix.os }} - pregen-src: ${{ matrix.pregen_src }}"
557557
runs-on: ${{ matrix.os }}
558558
env:
559559
AWS_LC_SYS_CMAKE_BUILDER: 1
560+
AWS_LC_SYS_NO_PREGENERATED_SRC: ${{ matrix.pregen_src }}
560561
strategy:
561562
fail-fast: false
562563
matrix:
563564
os: [ ubuntu-latest, macos-13, macos-14-xlarge ]
565+
pregen_src: [ 0, 1 ]
564566
steps:
565567
- uses: actions/checkout@v4
566568
with:
567569
submodules: 'recursive'
568570
path: "path has spaces/aws-lc-rs"
571+
- if: ${{ matrix.pregen_src == 1 }}
572+
shell: bash
573+
run: |
574+
rm -rf ./aws-lc-sys/aws-lc/generated-src/*
569575
- if: ${{ matrix.os == 'windows-latest' }}
570576
uses: ilammy/setup-nasm@v1
571577
- uses: dtolnay/rust-toolchain@stable

aws-lc-sys/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include = [
1919
"/aws-lc/**/CMakeLists.txt",
2020
"/aws-lc/**/*.cmake",
2121
"/aws-lc/**/*.errordata",
22+
"/aws-lc/**/err_data_generate.go",
2223
"/aws-lc/**/*.lds",
2324
"!/aws-lc/bindings/**",
2425
"!/aws-lc/docs/**",
@@ -39,6 +40,7 @@ include = [
3940
"/CMakeLists.txt",
4041
"/builder/**/*.rs",
4142
"/builder/**/*.bat",
43+
"/builder/**/*.sh",
4244
"/builder/**/*.obj",
4345
"/Cargo.toml",
4446
"/generated-include/**",

aws-lc-sys/builder/cmake_builder.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use crate::cc_builder::CcBuilder;
55
use crate::OutputLib::{Crypto, RustWrapper, Ssl};
66
use crate::{
77
allow_prebuilt_nasm, cargo_env, effective_target, emit_warning, execute_command,
8-
get_crate_cflags, is_crt_static, is_no_asm, option_env, target_arch, target_env, target_os,
9-
target_underscored, target_vendor, test_nasm_command, use_prebuilt_nasm, OutputLibType,
8+
get_crate_cflags, is_crt_static, is_no_asm, is_no_pregenerated_src, option_env, target_arch,
9+
target_env, target_os, target_underscored, target_vendor, test_nasm_command, use_prebuilt_nasm,
10+
OutputLibType,
1011
};
1112
use std::env;
1213
use std::ffi::OsString;
@@ -111,9 +112,15 @@ impl CmakeBuilder {
111112
} else {
112113
cmake_cfg.define("BUILD_LIBSSL", "OFF");
113114
}
114-
// Build flags that minimize our dependencies.
115-
cmake_cfg.define("DISABLE_PERL", "ON");
116-
cmake_cfg.define("DISABLE_GO", "ON");
115+
if is_no_pregenerated_src() {
116+
// Go and Perl will be required.
117+
cmake_cfg.define("DISABLE_PERL", "OFF");
118+
cmake_cfg.define("DISABLE_GO", "OFF");
119+
} else {
120+
// Build flags that minimize our dependencies.
121+
cmake_cfg.define("DISABLE_PERL", "ON");
122+
cmake_cfg.define("DISABLE_GO", "ON");
123+
}
117124

118125
if is_no_asm() {
119126
let opt_level = cargo_env("OPT_LEVEL");

aws-lc-sys/builder/main.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn get_builder(prefix: &Option<String>, manifest_dir: &Path, out_dir: &Path) ->
360360
))
361361
};
362362

363-
if let Some(val) = env_var_to_bool("AWS_LC_SYS_CMAKE_BUILDER") {
363+
if let Some(val) = is_cmake_builder() {
364364
let builder: Box<dyn Builder> = if val {
365365
cmake_builder_builder()
366366
} else {
@@ -420,6 +420,8 @@ static mut AWS_LC_SYS_EXTERNAL_BINDGEN: bool = false;
420420
static mut AWS_LC_SYS_NO_ASM: bool = false;
421421
static mut AWS_LC_SYS_CFLAGS: String = String::new();
422422
static mut AWS_LC_SYS_PREBUILT_NASM: Option<bool> = None;
423+
static mut AWS_LC_SYS_CMAKE_BUILDER: Option<bool> = None;
424+
static mut AWS_LC_SYS_NO_PREGENERATED_SRC: bool = false;
423425

424426
static mut AWS_LC_SYS_C_STD: CStdRequested = CStdRequested::None;
425427

@@ -434,6 +436,9 @@ fn initialize() {
434436
AWS_LC_SYS_CFLAGS = option_env("AWS_LC_SYS_CFLAGS").unwrap_or_default();
435437
AWS_LC_SYS_PREBUILT_NASM = env_var_to_bool("AWS_LC_SYS_PREBUILT_NASM");
436438
AWS_LC_SYS_C_STD = CStdRequested::from_env();
439+
AWS_LC_SYS_CMAKE_BUILDER = env_var_to_bool("AWS_LC_SYS_CMAKE_BUILDER");
440+
AWS_LC_SYS_NO_PREGENERATED_SRC =
441+
env_var_to_bool("AWS_LC_SYS_NO_PREGENERATED_SRC").unwrap_or(false);
437442
}
438443

439444
if !is_external_bindgen() && (is_pregenerating_bindings() || !has_bindgen_feature()) {
@@ -495,6 +500,18 @@ fn is_no_asm() -> bool {
495500
unsafe { AWS_LC_SYS_NO_ASM }
496501
}
497502

503+
fn is_cmake_builder() -> Option<bool> {
504+
if is_no_pregenerated_src() {
505+
Some(true)
506+
} else {
507+
unsafe { AWS_LC_SYS_CMAKE_BUILDER }
508+
}
509+
}
510+
511+
fn is_no_pregenerated_src() -> bool {
512+
unsafe { AWS_LC_SYS_NO_PREGENERATED_SRC }
513+
}
514+
498515
#[allow(unknown_lints)]
499516
#[allow(static_mut_refs)]
500517
fn get_crate_cflags() -> &'static str {

0 commit comments

Comments
 (0)