Skip to content

Commit dac42bc

Browse files
committed
Add support for SPM resources
This should fix issue #5. If SPM produces *.resources directories in the build dir, we copy them over.
1 parent b3deb8f commit dac42bc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

scripts/swift-lambda-build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@ copyProductResources() {
421421
done
422422
}
423423

424+
# This copies SwiftPM resource directories into the LAMBDA_BUILD_DIR (defaults
425+
# to `.build/lambda`).
426+
# SPM puts the resource directories into SPM_BUILD_PRODUCT_RESOURCES_DIR,
427+
# for example `PhoneNumberKit_PhoneNumberKit.resources`.
428+
copySwiftPMResources() {
429+
for dir in $(ls 2>/dev/null -d "${SPM_BUILD_PRODUCT_RESOURCES_DIR}/"*.resources); do
430+
echo " Embedding package resource dir: $(basename $dir)"
431+
cp -ac "${dir}" "${LAMBDA_BUILD_DIR}/"
432+
done
433+
}
434+
424435
# This zips the LAMBDA_BUILD_DIR (.build/lambda) into a zipfile for
425436
# distribution.
426437
zipBuildDir() {
@@ -447,6 +458,7 @@ prepareLambdaDir
447458
copySharedLibraryDependencies
448459
copyBuildProduct
449460
copyProductResources
461+
copySwiftPMResources
450462

451463
if [[ "x${verbose}" = "xyes" ]]; then
452464
echo -n "Zipping .."

scripts/swift-lambda-env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ else
237237
fi
238238
239239
SPM_EXECUTABLE_BUILD_PRODUCT="${SPM_BUILD_DIR}/${TARGET}/${SPM_BUILD_CONFIG}/${PRODUCT_NAME}"
240+
SPM_BUILD_PRODUCT_RESOURCES_DIR="${SPM_BUILD_DIR}/${TARGET}/${SPM_BUILD_CONFIG}"
240241
241242
LAMBDA_BUILD_DIR=${LAMBDA_BUILD_DIR:=${BUILD_DIR}/lambda}
242243
LAMBDA_EXECUTABLE_NAME=bootstrap

0 commit comments

Comments
 (0)