Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Correct umbrella header compilation
It turns out that we cannot simply take all the headers and include them
from the umbrella header. OpenSSL has some intricate interdependencies
there so we have to resort to hacks.

Instead of using "find" to locate all the headers (which returns them
in some unspecified order), make sure to include the "ssl.h" header
first and then follow it with other headers in alphabetic order.
This seems to work for the current OpenSSL version (1.0.2o).

Take care to not include the umbrella header into itself to avoid
blowing up compiler's include stack.
  • Loading branch information
ilammy committed Mar 21, 2019
commit 9fbee23143cd0ed7f1e2ee631abff17de48f5b39
54 changes: 33 additions & 21 deletions create-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,40 @@ sed -i '' 's/include <openssl/include <OpenSSL/' Frameworks/macos/$FWNAME.framew

echo "Create module"

# Umbrella header

for entry in `find Frameworks/ios/OpenSSL.framework/Headers -mindepth 1 -maxdepth 1 -type f -exec basename {} \;`; do
echo "#include \"$entry\"" >> Frameworks/ios/$FWNAME.framework/Headers/OpenSSL.h
done

for entry in `find Frameworks/macos/OpenSSL.framework/Headers -mindepth 1 -maxdepth 1 -type f -exec basename {} \;`; do
echo "#include \"$entry\"" >> Frameworks/macos/$FWNAME.framework/Headers/OpenSSL.h
done

echo "framework module OpenSSL {
umbrella header \"OpenSSL.h\"
create_module() {
local fw_path=$1
local fw_name

fw_name=$(basename $fw_path)
fw_name=${fw_name%.framework}

# Special case because of OpenSSL reasons
if [ -f $fw_path/Headers/ssl.h ]
then
echo "#include \"ssl.h\"" >> $fw_path/Headers/$fw_name.h
fi

# Create umbrella header
for header in $fw_path/Headers/*
do
header=$(basename $header)
[ "$header" = "$fw_name.h" ] && continue
[ "$header" = "ssl.h" ] && continue
echo "#include \"$header\"" >> $fw_path/Headers/$fw_name.h
done

# Create module map
cat << EOF > $fw_path/Modules/module.modulemap
framework module $fw_name {
umbrella header "$fw_name.h"

export *
module * { export *}
}" > Frameworks/ios/$FWNAME.framework/Modules/module.modulemap
module * { export * }
}
EOF
}

echo "framework module OpenSSL {
umbrella header \"OpenSSL.h\"

export *
module * { export *}
}" > Frameworks/macos/$FWNAME.framework/Modules/module.modulemap
create_module Frameworks/ios/$FWNAME.framework
create_module Frameworks/macos/$FWNAME.framework

echo "Created $FWNAME.framework"
echo "Created $FWNAME.framework"