Skip to content

Commit e842820

Browse files
authored
Merge pull request #4 from skiptools/resource-root
Copy libraries from swiftResourcesPath for Swift 6.2 artifactbundles
2 parents 22c9420 + 685caf3 commit e842820

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

action.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ runs:
295295
SWIFT_SDK_TARGET="${{ inputs.installed-sdk }}"
296296
echo "SWIFT_SDK_TARGET=${SWIFT_SDK_TARGET}" >> $GITHUB_ENV
297297
# for the bundle, we just grab the most recently installed one
298-
SWIFT_SDK_BUNDLE=$(ls -1drt ${SWIFT_SDK_ROOT}/*.artifactbundle | tail -n 1)
298+
SWIFT_SDK_ARTIFACTBUNDLE=$(ls -1drt ${SWIFT_SDK_ROOT}/*.artifactbundle | tail -n 1)
299299
else
300300
SWIFT_SDK_ANROID_API="24"
301301
echo "SWIFT_SDK_ANROID_API=${SWIFT_SDK_ANROID_API}" >> $GITHUB_ENV
@@ -317,18 +317,24 @@ runs:
317317
318318
${SWIFT_INSTALLATION}/bin/swift sdk configure --show-configuration ${SWIFT_SDK_ID} ${SWIFT_SDK_TARGET}
319319
320-
SWIFT_SDK_BUNDLE="${SWIFT_SDK_ROOT}/${SWIFT_SDK_ID}.artifactbundle"
320+
SWIFT_SDK_ARTIFACTBUNDLE="${SWIFT_SDK_ROOT}/${SWIFT_SDK_ID}.artifactbundle"
321321
fi
322322
323323
# extract the artifact ID from the info.plist in the SDK root
324-
SWIFT_SDK_ARTIFACT_ID=$(cat ${SWIFT_SDK_BUNDLE}/info.json | jq -r '.artifacts[] | .variants[0].path')
325-
SWIFT_SDK_BUNDLE="${SWIFT_SDK_BUNDLE}/${SWIFT_SDK_ARTIFACT_ID}"
324+
SWIFT_SDK_ARTIFACT_ID=$(cat ${SWIFT_SDK_ARTIFACTBUNDLE}/info.json | jq -r '.artifacts[] | .variants[0].path')
325+
SWIFT_ARTIFACTBUNDLE_ROOT="${SWIFT_SDK_ARTIFACTBUNDLE}/${SWIFT_SDK_ARTIFACT_ID}"
326326
327327
# extract the sdkRootPath from the swift-sdk.json
328-
SWIFT_SDK_ROOT_PATH=$(cat ${SWIFT_SDK_BUNDLE}/swift-sdk.json | jq -r '.targetTriples[] | .sdkRootPath' | head -n 1)
329-
SWIFT_SDK_BUNDLE="${SWIFT_SDK_BUNDLE}/${SWIFT_SDK_ROOT_PATH}"
328+
SWIFT_SDK_ROOT_PATH=$(cat ${SWIFT_ARTIFACTBUNDLE_ROOT}/swift-sdk.json | jq -r '.targetTriples[] | .sdkRootPath' | head -n 1)
329+
SWIFT_ARTIFACTBUNDLE_SDK_ROOT_PATH="${SWIFT_ARTIFACTBUNDLE_ROOT}/${SWIFT_SDK_ROOT_PATH}"
330330
331-
echo "SWIFT_SDK_BUNDLE=${SWIFT_SDK_BUNDLE}" >> $GITHUB_ENV
331+
echo "SWIFT_ARTIFACTBUNDLE_SDK_ROOT_PATH=${SWIFT_ARTIFACTBUNDLE_SDK_ROOT_PATH}" >> $GITHUB_ENV
332+
333+
# extract the swiftResourcesPath from the swift-sdk.json
334+
SWIFT_RESOURCES_ROOT_PATH=$(cat ${SWIFT_ARTIFACTBUNDLE_ROOT}/swift-sdk.json | jq -r '.targetTriples[] | .swiftResourcesPath' | head -n 1)
335+
SWIFT_ARTIFACTBUNDLE_RESOURCES_ROOT_PATH="${SWIFT_SDK_ROOT_PATH}/${SWIFT_RESOURCES_ROOT_PATH}"
336+
337+
echo "SWIFT_ARTIFACTBUNDLE_RESOURCES_ROOT_PATH=${SWIFT_ARTIFACTBUNDLE_RESOURCES_ROOT_PATH}" >> $GITHUB_ENV
332338
333339
# plugin-path is a workaround for https://github.com/swiftlang/swift-package-manager/issues/8362
334340
echo "swiftcmd=TARGET_OS_ANDROID=1 SKIP_BRIDGE=1 ${SWIFT_INSTALLATION}/bin/swift build --swift-sdk ${SWIFT_SDK_TARGET} -Xswiftc -plugin-path -Xswiftc ${SWIFT_INSTALLATION}/lib/swift/host/plugins/testing -Xswiftc -DTARGET_OS_ANDROID -Xswiftc -DSKIP_BRIDGE ${{ inputs.swift-build-flags }}" >> $GITHUB_OUTPUT
@@ -378,10 +384,13 @@ runs:
378384
# copy any optional resource bundles
379385
cp -vaf ${BUILD_DIR}/${SWIFT_SDK_TARGET}/${{ inputs.swift-configuration }}/*.resources ${PACK_DIR} || true
380386
# 6.0.2 keeps libraries in per-API folders
381-
cp -vaf ${SWIFT_SDK_BUNDLE}/usr/lib/${{ steps.setup.outputs.android-sdk-arch }}-linux-android/${SWIFT_SDK_ANROID_API}/lib*.so ${PACK_DIR} || true
387+
cp -vaf ${SWIFT_ARTIFACTBUNDLE_SDK_ROOT_PATH}/usr/lib/${{ steps.setup.outputs.android-sdk-arch }}-linux-android/${SWIFT_SDK_ANROID_API}/lib*.so ${PACK_DIR} || true
382388
383389
# 6.0.3 keeps libraries in the parent folder
384-
cp -vaf ${SWIFT_SDK_BUNDLE}/usr/lib/${{ steps.setup.outputs.android-sdk-arch }}-linux-android/lib*.so ${PACK_DIR} || true
390+
cp -vaf ${SWIFT_ARTIFACTBUNDLE_SDK_ROOT_PATH}/usr/lib/${{ steps.setup.outputs.android-sdk-arch }}-linux-android/lib*.so ${PACK_DIR} || true
391+
392+
# 6.2 keeps libraries in the resources root folder
393+
cp -vaf ${SWIFT_ARTIFACTBUNDLE_RESOURCES_ROOT_PATH}/usr/lib/swift-${{ steps.setup.outputs.android-sdk-arch }}/android/lib*.so ${PACK_DIR} || true
385394
386395
# clear out libraries that are already provided by Android
387396
rm -v ${PACK_DIR}/lib{c,dl,log,m,z}.so || true

0 commit comments

Comments
 (0)