Skip to content

Commit b3deb8f

Browse files
committed
Add comments
...
1 parent c1c7597 commit b3deb8f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/swift-lambda-build

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,22 @@ fi
326326

327327
# ********** Archive ****************************
328328

329+
# Drop and recreate the LAMBDA_BUILD_DIR (defaults to `.build/lambda`)
329330
prepareLambdaDir() {
330331
rm -rf "${LAMBDA_BUILD_DIR}"
331332
mkdir -p "${LAMBDA_BUILD_DIR}"
332333
}
333334

335+
# Clone copy the file passed in Argument $1 into the LAMBDA_BUILD_DIR (defaults
336+
# to `.build/lambda`)
334337
embedInZip() {
335338
# a - preserve attributes
336339
# c - clone
337340
# H - follow symbolic links
338341
cp -acH "$1" "${LAMBDA_BUILD_DIR}/"
339342
}
343+
# This embeds a subdirectory contains within the product directory in the
344+
# Zip directory. For example Sources/MacroApp/public.
340345
embedSourcesDirInZip() {
341346
if [[ -d "${SPM_PACKAGE_SOURCE_DIR}/Sources/${PRODUCT_NAME}/$1" ]]; then
342347
if [[ "x${verbose}" = "xyes" ]]; then
@@ -351,6 +356,9 @@ embedSourcesDirInZip() {
351356
fi
352357
}
353358

359+
# This copies dylibs required by the built product (in .build/x86_64.../release)
360+
# to the zip.
361+
# It uses `objdump` to discover the required libs.
354362
copySharedLibraryDependencies() {
355363
XTOOLCHAIN_SDK=$(jq -r ".sdk" ${SPM_DESTINATION_FILE})
356364
USED_LIBS=$(objdump -p ${SPM_BUILD_DIR}/${TARGET}/${SPM_BUILD_CONFIG}/${PRODUCT_NAME} \
@@ -396,18 +404,25 @@ copySharedLibraryDependencies() {
396404
done
397405
}
398406

407+
# This just copies the executable product into the LAMBDA_BUILD_DIR
399408
copyBuildProduct() {
400409
cp -ac "${SPM_EXECUTABLE_BUILD_PRODUCT}" \
401410
"${LAMBDA_BUILD_DIR}/${LAMBDA_EXECUTABLE_NAME}"
402411
}
403412

413+
# This copies Macro-like product resource directories into the zip. Those live
414+
# alongside the source files, for example Sources/MacroApp/public (and /view).
415+
# Note: do not mix up w/ SPM resource directories, which work differently.
404416
copyProductResources() {
405417
# make configurable somehow
418+
# defaults to: views public
406419
for dir in ${LAMBDA_SOURCE_RELATIVE_RESOURCEDIRS}; do
407420
embedSourcesDirInZip $dir
408421
done
409422
}
410423

424+
# This zips the LAMBDA_BUILD_DIR (.build/lambda) into a zipfile for
425+
# distribution.
411426
zipBuildDir() {
412427
# X - exclude extended attributes
413428
# 9 - higher compression

0 commit comments

Comments
 (0)