Skip to content

Commit f555f48

Browse files
authored
SBOM and nits (#14)
* Address nits * Eliminate unnecessaryt pushds and use run cmake install instead of ninja * Generate SBOM with SDK dependencies * Add example of command for building locally
1 parent 1221544 commit f555f48

File tree

4 files changed

+97
-7
lines changed

4 files changed

+97
-7
lines changed

swift-ci/sdks/android/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@ perform the build locally on an Ubuntu 24.04 machine with all the
8181
build prerequisites already installed. This will generate
8282
the same artifacts in approximately half the time, and
8383
may be suitable to an already containerized envrionment (such as
84-
a GitHub runner).
84+
a GitHub runner). A local build can be run with the
85+
`build-local` script, such as:
8586

87+
```
88+
./build-local swift-6.2-branch /tmp/android-sdk-devel
89+
```

swift-ci/sdks/android/scripts/build.sh

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function declare_package
101101
packages+=(${name})
102102
}
103103

104-
declare_package android_sdk \
104+
declare_package swift_android_sdk \
105105
"Swift SDK for Android" \
106106
"Apache-2.0" "https://swift.org/install"
107107
declare_package swift "swift" "Apache-2.0" "https://swift.org"
@@ -359,7 +359,6 @@ for arch in $archs; do
359359
groupend
360360

361361
groupstart "Building libcurl for ${compiler_target_host}"
362-
quiet_pushd ${swift_source_dir}/curl
363362
run cmake \
364363
-G Ninja \
365364
-S ${swift_source_dir}/curl \
@@ -393,9 +392,8 @@ for arch in $archs; do
393392

394393
header "Installing libcurl for $arch"
395394
quiet_pushd ${build_dir}/$arch/curl
396-
run ninja -j$parallel_jobs install
395+
run cmake --install ${build_dir}/${arch}/curl
397396
quiet_popd
398-
quiet_popd
399397
groupend
400398

401399
groupstart "Building Android SDK for ${compiler_target_host}"
@@ -505,6 +503,96 @@ cat > info.json <<EOF
505503
}
506504
EOF
507505

506+
spdx_uuid=$(uuidgen)
507+
spdx_doc_uuid=$(uuidgen)
508+
spdx_timestamp=$(date -Iseconds)
509+
510+
# Now generate SPDX data
511+
cat > sbom.spdx.json <<EOF
512+
{
513+
"SPDXID": "SPDXRef-DOCUMENT",
514+
"name": "SBOM-SPDX-${spdx_uuid}",
515+
"spdxVersion": "SPDX-2.3",
516+
"creationInfo": {
517+
"created": "${spdx_timestamp}",
518+
"creators": [
519+
"Organization: Apple, Inc."
520+
]
521+
},
522+
"dataLicense": "Apache-2.0",
523+
"documentNamespace": "urn:uuid:${spdx_doc_uuid}",
524+
"documentDescribes": [
525+
"SPDXRef-Package-swift-android-sdk"
526+
],
527+
"packages": [
528+
EOF
529+
530+
first=true
531+
for package in ${packages[@]}; do
532+
if [[ "$first" == "true" ]]; then
533+
first=false
534+
else
535+
cat >> sbom.spdx.json <<EOF
536+
},
537+
EOF
538+
fi
539+
540+
snake=${package}_snake; snake=${!snake}
541+
version=${package}_version; version=${!version}
542+
name=${package}_name; name=${!name}
543+
license=${package}_license; license=${!license}
544+
url=${package}_url; url=${!url}
545+
546+
cat >> sbom.spdx.json <<EOF
547+
{
548+
"SPDXID": "SPDXRef-Package-${snake}",
549+
"name": "${name}",
550+
"versionInfo": "${version}",
551+
"filesAnalyzed": false,
552+
"licenseDeclared": "${license}",
553+
"licenseConcluded": "${license}",
554+
"downloadLocation": "${url}",
555+
"copyrightText": "NOASSERTION",
556+
"checksums": []
557+
EOF
558+
done
559+
560+
cat >> sbom.spdx.json <<EOF
561+
}
562+
],
563+
"relationships": [
564+
EOF
565+
566+
first=true
567+
for package in ${packages[@]}; do
568+
if [[ "$package" == "swift_android_sdk" ]]; then
569+
continue
570+
fi
571+
572+
if [[ "$first" == "true" ]]; then
573+
first=false
574+
else
575+
cat >> sbom.spdx.json <<EOF
576+
},
577+
EOF
578+
fi
579+
580+
snake=${package}_snake; snake=${!snake}
581+
582+
cat >> sbom.spdx.json <<EOF
583+
{
584+
"spdxElementId": "SPDXRef-Package-swift-android-sdk",
585+
"relationshipType": "GENERATED_FROM",
586+
"relatedSpdxElement": "SPDXRef-Package-${snake}"
587+
EOF
588+
done
589+
590+
cat >> sbom.spdx.json <<EOF
591+
}
592+
]
593+
}
594+
EOF
595+
508596
mkdir -p $sdk_base
509597
quiet_pushd $sdk_base
510598

swift-ci/sdks/android/scripts/fetch-source.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,3 @@ pushd boringssl >/dev/null 2>&1
149149
git checkout ${BORINGSSL_VERSION}
150150
popd >/dev/null 2>&1
151151
groupend
152-

swift-ci/sdks/android/scripts/install-swift.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,3 @@ tar -xzf toolchain.tar.gz --directory ${destination} --strip-components=2
5151
chmod -R o+r ${destination}/lib/swift
5252

5353
popd >/dev/null
54-

0 commit comments

Comments
 (0)