@@ -395,19 +395,13 @@ done
395
395
# Now generate the bundle
396
396
groupstart " Bundling SDK"
397
397
398
- sdk_name=swift-${swift_version} -android-${android_api} -${android_sdk_version}
399
- # sdk_base=android-27c-sysroot
400
- # sdk_base=swift-unknown-android
401
- # sdk_base=linux-android
402
398
sdk_base=swift-android
403
- # sdk_root="${sdk_base}-${android_sdk_version}.sdk"
404
- sdk_root=" ${sdk_base} .sdk"
399
+ sdk_staging=" sdk_staging"
405
400
406
401
bundle=" ${sdk_name} .artifactbundle"
407
402
408
- rm -rf " ${build_dir} /$bundle "
409
- mkdir -p " ${build_dir} /$bundle /$sdk_name /$sdk_base "
410
-
403
+ rm -rf ${build_dir} /$bundle
404
+ mkdir -p ${build_dir} /$bundle
411
405
quiet_pushd ${build_dir} /$bundle
412
406
413
407
# First the info.json, for SwiftPM
@@ -418,7 +412,7 @@ cat > info.json <<EOF
418
412
"$sdk_name ": {
419
413
"variants": [
420
414
{
421
- "path": "$sdk_name / $ sdk_base "
415
+ "path": "$sdk_base "
422
416
}
423
417
],
424
418
"version": "${android_sdk_version} ",
@@ -428,14 +422,15 @@ cat > info.json <<EOF
428
422
}
429
423
EOF
430
424
431
- quiet_pushd " $sdk_name /$sdk_base "
432
-
433
- # ndk_sysroot_path="ndk-sysroot"
434
- ndk_sysroot_path=" android-27c-sysroot"
425
+ mkdir -p $sdk_base
426
+ quiet_pushd $sdk_base
435
427
436
- cp -a ${ndk_toolchain} /sysroot ${ndk_sysroot_path}
428
+ # sysroot_path="ndk-sysroot"
429
+ # sysroot_path="android-27c-sysroot"
430
+ sysroot_path=" sysroot"
431
+ cp -a ${ndk_toolchain} /sysroot ${sysroot_path}
437
432
438
- cat > $ndk_sysroot_path /SDKSettings.json << EOF
433
+ cat > $sysroot_path /SDKSettings.json << EOF
439
434
{
440
435
"DisplayName": "Swift Android SDK",
441
436
"Version": "${android_sdk_version} ",
@@ -444,13 +439,13 @@ cat > $ndk_sysroot_path/SDKSettings.json <<EOF
444
439
}
445
440
EOF
446
441
447
- cp -a ${build_dir} /sdk_root sdk_root
442
+ cp -a ${build_dir} /sdk_root ${sdk_staging}
448
443
# Copy necessary headers and libraries from the toolchain and NDK clang resource directories
449
- mkdir -pv $ndk_sysroot_path /usr/lib/swift/clang/lib
450
- cp -rv $host_toolchain /lib/clang/* /include $ndk_sysroot_path /usr/lib/swift/clang
444
+ mkdir -p $sysroot_path /usr/lib/swift/clang/lib
445
+ cp -r $host_toolchain /lib/clang/* /include $sysroot_path /usr/lib/swift/clang
451
446
452
447
for arch in $archs ; do
453
- quiet_pushd sdk_root /${arch} /usr
448
+ quiet_pushd ${sdk_staging} /${arch} /usr
454
449
rm -r bin
455
450
rm -r include/*
456
451
cp -r ${source_dir} /swift-project/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/
@@ -473,16 +468,16 @@ for arch in $archs; do
473
468
ln -s ../swift/clang lib/swift_static-$arch /clang
474
469
quiet_popd
475
470
476
- # now sync the massaged sdk_root into the ndk_sysroot_path
477
- rsync -a sdk_root /${arch} /usr ${ndk_sysroot_path }
471
+ # now sync the massaged sdk_root into the sysroot_path
472
+ rsync -a ${sdk_staging} /${arch} /usr ${sysroot_path }
478
473
done
479
474
480
- rm -r ${ndk_sysroot_path } /usr/share/{doc,man}
481
- rm -r ${ndk_sysroot_path } /usr/{include,lib}/{i686,riscv64}-linux-android
482
- rm -r sdk_root
475
+ rm -r ${sysroot_path } /usr/share/{doc,man}
476
+ rm -r ${sysroot_path } /usr/{include,lib}/{i686,riscv64}-linux-android
477
+ rm -r ${sdk_staging}
483
478
484
479
# validate that some expected paths exist
485
- quiet_pushd ${ndk_sysroot_path } /usr
480
+ quiet_pushd ${sysroot_path } /usr
486
481
ls lib/swift/android
487
482
ls lib/swift/android/*
488
483
ls lib/swift/android/* /swiftrt.o
507
502
first=true
508
503
# create targets for the supported API and higher,
509
504
# as well as a blank API, which will be the NDK default
510
- for api in " " $( eval echo " {$android_api ..36}" ) ; do
505
+ # FIXME: building against blank API doesn't work: ld.lld: error: cannot open crtbegin_dynamic.o: No such file or directory
506
+ # for api in "" $(eval echo "{$android_api..36}"); do
507
+ for api in $( eval echo " {$android_api ..36}" ) ; do
511
508
for arch in $archs ; do
512
509
if [[ " $first " == " true" ]]; then
513
510
first=false
518
515
fi
519
516
cat >> swift-sdk.json << EOF
520
517
"${arch} -unknown-linux-android${api} ": {
521
- "sdkRootPath": "${ndk_sysroot_path } ",
522
- "swiftResourcesPath": "${ndk_sysroot_path } /usr/lib/swift",
523
- "swiftStaticResourcesPath": "${ndk_sysroot_path } /usr/lib/swift_static-${arch} ",
518
+ "sdkRootPath": "${sysroot_path } ",
519
+ "swiftResourcesPath": "${sysroot_path } /usr/lib/swift",
520
+ "swiftStaticResourcesPath": "${sysroot_path } /usr/lib/swift_static-${arch} ",
524
521
"toolsetPaths": [ "swift-toolset.json" ]
525
522
EOF
526
523
done
0 commit comments