Skip to content

Commit

Permalink
Fix for s2n_prelude.h Changes (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 authored Nov 18, 2024
1 parent 93ac601 commit 2253531
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 16 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/s2n-prelude-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Detect changes to s2n_prelude.h to update our `Package.swift` and stay in sync with it.
# See: https://github.com/awslabs/aws-crt-swift/pull/299 for updating the Package.swift.

name: s2n_prelude.h Change Detector

on: [push]

jobs:
check-for-changes:

runs-on: ubuntu-24.04 # latest

steps:
- name: Checkout Sources
uses: actions/checkout@v4
with:
submodules: true

- name: Check s2n_prelude.h
run: |
TMPFILE=$(mktemp)
echo "116f1525acbc94c91b0ee2ea2af9fdef aws-common-runtime/s2n/utils/s2n_prelude.h" > $TMPFILE
md5sum --check $TMPFILE
# No further steps if successful

- name: Echo fail
if: failure()
run: |
echo "The aws-crt-swift has a hack to manually define macros which are defined in s2n_prelude.h in Package.Swift.
This check will fail whenever s2n_prelude.h is updated by the S2N team. You should make sure that Package.Swift is updated accordingly
with the s2n_prelude.h changes and then run `md5sum aws-common-runtime/s2n/utils/s2n_prelude.h` and update the value above."
16 changes: 11 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,17 @@ packageTargets.append(.target(
publicHeadersPath: "api",
cSettings: [
.headerSearchPath("./"),
.define("POSIX_C_SOURCE=200809L"),
.define("S2N_NO_PQ")
.define("S2N_NO_PQ"),
// This is a hack to get around the fact that S2N uses the compiler option `-include`
// to include `s2n_prelude.h` in all .c files. Since SwiftPM doesn't support compiler flags,
// we manually define the macros from `s2n_prelude.h`. When SwiftPM supports compiler flags
// or building packages using CMake, this hack should be removed.
// We are not defining `S2N_API` because we don't need to expose any symbols from S2N in crt-swift.
.define("_S2N_PRELUDE_INCLUDED"),
.define("S2N_BUILD_RELEASE"),
.define("_FORTIFY_SOURCE", to: "2"),
.define("POSIX_C_SOURCE", to: "200809L"),

]
))
#endif
Expand Down Expand Up @@ -146,9 +155,6 @@ var awsCChecksumsExcludes = [
"cmake",
"tests"]

// swift never uses Microsoft Visual C++ compiler
awsCChecksumsExcludes.append("source/intel/visualc")

// Hardware accelerated checksums are disabled because SwiftPM doesn't like the necessary compiler flags.
// We can add it once SwiftPM has the necessary support for CPU flags or builds C libraries
// using CMake.
Expand Down
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-auth
Submodule aws-c-auth updated 2 files
+1 −5 CMakeLists.txt
+2 −2 README.md
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-cal
Submodule aws-c-cal updated 2 files
+2 −6 CMakeLists.txt
+1 −1 README.md
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-compression
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-event-stream
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-io
3 changes: 2 additions & 1 deletion aws-common-runtime/config/aws/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#ifndef AWS_COMMON_CONFIG_H
#define AWS_COMMON_CONFIG_H

/*
* This header exposes compiler feature test results determined during cmake
* configure time to inline function implementations. The macros defined here
Expand All @@ -13,7 +14,7 @@
*/
#ifdef __APPLE__
/* This is a trick to skip OpenSSL header on Apple platforms since Swift Package Manager is not smart enough to exclude
* some headers.
* some headers.
*/
# define AWS_C_CAL_OPENSSLCRYPTO_COMMON_H
#endif
Expand Down
2 changes: 1 addition & 1 deletion aws-common-runtime/s2n
Submodule s2n updated 151 files

0 comments on commit 2253531

Please sign in to comment.