diff --git a/.github/workflows/repository-hygiene.yml b/.github/workflows/repository-hygiene.yml index c75c69f3c..bfd4dc684 100644 --- a/.github/workflows/repository-hygiene.yml +++ b/.github/workflows/repository-hygiene.yml @@ -384,8 +384,9 @@ jobs: "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" 'platforms;android-35' 'build-tools;35.0.0' 'ndk;30.0.16248370' echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/30.0.16248370" >> "$GITHUB_ENV" echo "GRADLE_HOME=$(dirname "$(dirname "$(readlink -f "$(command -v gradle)")")")" >> "$GITHUB_ENV" - go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20261011034528-197770444867 - go install golang.org/x/mobile/cmd/gobind@v0.0.0-20261011034528-197770444867 + rustup toolchain install 1.91.0 --profile minimal --target aarch64-linux-android,x86_64-linux-android,wasm32-unknown-unknown + cargo +1.91.0 install wasm-bindgen-cli --version 0.2.129 --locked + cargo +1.91.0 install cargo-about --version 0.9.3 --locked --features cli - name: Prepare Android signing if: matrix.target == 'android-universal' env: diff --git a/licenses/jetbrains-annotations-13.0.txt b/licenses/jetbrains-annotations-13.0.txt new file mode 100644 index 000000000..6893a378f --- /dev/null +++ b/licenses/jetbrains-annotations-13.0.txt @@ -0,0 +1,218 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/licenses/kotlin-stdlib-2.2.10.txt b/licenses/kotlin-stdlib-2.2.10.txt new file mode 100644 index 000000000..0ac9c595b --- /dev/null +++ b/licenses/kotlin-stdlib-2.2.10.txt @@ -0,0 +1,211 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Kotlin Compiler distribution. == + ========================================================================= + + Kotlin Compiler + Copyright 2010-2024 JetBrains s.r.o and respective authors and developers diff --git a/licenses/rust-about.hbs b/licenses/rust-about.hbs new file mode 100644 index 000000000..08c3bcd09 --- /dev/null +++ b/licenses/rust-about.hbs @@ -0,0 +1,9 @@ +{{#each licenses}} +===== {{name}} ({{id}}) ===== +{{#each used_by}} +{{crate.name}} {{crate.version}} — {{crate.repository}} +{{/each}} + +{{{text}}} + +{{/each}} diff --git a/licenses/rust-about.toml b/licenses/rust-about.toml new file mode 100644 index 000000000..065b76d2d --- /dev/null +++ b/licenses/rust-about.toml @@ -0,0 +1,44 @@ +# Licenses in the shipped Rust dependency graph; new terms require review. +accepted = ["Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause", "ISC", "Zlib", "Unicode-3.0"] +ignore-dev-dependencies = true +ignore-build-dependencies = true +private = { ignore = true } + +[attohttpc] +accepted = ["MPL-2.0"] + +[option-ext] +accepted = ["MPL-2.0"] + +# These packaged files contain combined or extended notices that the scanner +# cannot identify. Preserve the complete upstream text rather than synthesize it. +[curve25519-dalek.clarify] +license = "BSD-3-Clause" +[[curve25519-dalek.clarify.files]] +path = "LICENSE" +checksum = "cca0bd3c4fcdba74145ef9d49c62337e2c9fbf9368288f11d0547f1b0273219f" + +[netlink-packet-core.clarify] +license = "MIT" +[[netlink-packet-core.clarify.files]] +path = "LICENSE-MIT" +checksum = "964a53330f9cd970c1790311024281a994644f9b554ff6d37e233672287bf767" + +[netlink-proto.clarify] +license = "MIT" +[[netlink-proto.clarify.files]] +path = "LICENSE-MIT" +checksum = "964a53330f9cd970c1790311024281a994644f9b554ff6d37e233672287bf767" + +[netlink-sys.clarify] +license = "MIT" +[[netlink-sys.clarify.files]] +path = "LICENSE-MIT" +checksum = "964a53330f9cd970c1790311024281a994644f9b554ff6d37e233672287bf767" + +# dlopen2 omits its workspace's license from the published crate. +[dlopen2.clarify] +license = "MIT" +[[dlopen2.clarify.git]] +path = "LICENSE" +checksum = "39fa265207450e77c62e90c5594a06c085b655d8374c7ced4bf7894b6bd95dd2" diff --git a/licenses/upstream.json b/licenses/upstream.json index b62ae9dda..416bebe83 100644 --- a/licenses/upstream.json +++ b/licenses/upstream.json @@ -18,5 +18,15 @@ "file": "cloudflared-2026.10.3.txt", "source": "https://github.com/cloudflare/cloudflared/tree/de6376c5af4a67cbc65258682e5a01781827643d", "sha256": "86d91fce84e045818cd3e4e95aba68d32274ed42b9eb1fe88612e12d9e7e1ce1" + }, + "kotlin-stdlib@2.2.10": { + "file": "kotlin-stdlib-2.2.10.txt", + "source": "https://github.com/JetBrains/kotlin/tree/v2.2.10/license", + "sha256": "b89c81530d06246b446c48697e25c3e0d664b48662cbc6d384f75a40e95cfdc2" + }, + "jetbrains-annotations@13.0": { + "file": "jetbrains-annotations-13.0.txt", + "source": "https://repo.maven.apache.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar", + "sha256": "87d9969aec44fb1ae09b0cca9586ceec329ff12a99342de28037cb648f792881" } } diff --git a/mobile/android/app/build.gradle b/mobile/android/app/build.gradle index 2b99d7ad6..271c75526 100644 --- a/mobile/android/app/build.gradle +++ b/mobile/android/app/build.gradle @@ -6,7 +6,7 @@ android { applicationId 'tv.piik.android.channel3'; minSdk 29; targetSdk 35 versionCode providers.gradleProperty('piikVersionCode').getOrElse('1').toInteger() versionName providers.gradleProperty('piikVersion').getOrElse('development') - ndk { abiFilters 'arm64-v8a' } + ndk { abiFilters 'arm64-v8a', 'x86_64' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 } packaging { jniLibs { useLegacyPackaging = true } } diff --git a/scripts/build-android.mjs b/scripts/build-android.mjs index 93c3ebfd2..faa50bb24 100644 --- a/scripts/build-android.mjs +++ b/scripts/build-android.mjs @@ -1,10 +1,10 @@ #!/usr/bin/env node import { spawnSync, execFileSync } from 'node:child_process'; import { createHash } from 'node:crypto'; -import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'; +import { chmodSync, copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { writeAndroidLicenseNotices } from './package-licenses.mjs'; +import { writeAndroidLicenseNotices, writeWebLicenseNotices } from './package-licenses.mjs'; import { writeAndroidAppIcon } from './app-icons.mjs'; import { CLOUDFLARED_VERSION, CLOUDFLARED_SOURCE_SHA256, ANDROID_APP_PACKAGE_TARGET, androidVersionCode } from './app-package-targets.mjs'; import { buildVersion } from './release-version.mjs'; @@ -13,6 +13,10 @@ import { assertCleanRevision } from './build-workspace.mjs'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const android = join(root, 'mobile', 'android'); const gradleHome = process.env.GRADLE_HOME; +const targets = [ + { abi: 'arm64-v8a', goarch: 'arm64', rust: 'aarch64-linux-android', machine: 'AArch64' }, + { abi: 'x86_64', goarch: 'amd64', rust: 'x86_64-linux-android', machine: 'Advanced Micro Devices X86-64' }, +]; const tunnelOnly = process.argv.includes('--tunnel-only'); const release = process.argv.includes('--release'); let output; @@ -83,14 +87,11 @@ if (!host) throw new Error('Unsupported NDK build host.'); const tools = join(process.env.ANDROID_NDK_HOME, 'toolchains', 'llvm', 'prebuilt', host, 'bin'); const exe = process.platform === 'win32' ? '.exe' : ''; const clang = join(tools, `clang${exe}`); -for (const [abi, arch, target, machine] of [ - ['arm64-v8a', 'arm64', 'aarch64-linux-android29', 'AArch64'], - ['x86_64', 'amd64', 'x86_64-linux-android29', 'Advanced Micro Devices X86-64'], -]) { +for (const { abi, goarch, rust, machine } of targets) { const output = join(android, 'app', 'src', 'main', 'jniLibs', abi, 'libcloudflared.so'); mkdirSync(dirname(output), { recursive: true }); - const env = { ...process.env, GOOS: 'android', GOARCH: arch, CGO_ENABLED: '1', - CC: `"${clang}" --target=${target}`, GOWORK: 'off' }; + const env = { ...process.env, GOOS: 'android', GOARCH: goarch, CGO_ENABLED: '1', + CC: `"${clang}" --target=${rust}29`, GOWORK: 'off' }; run('go', ['build', '-mod=readonly', `-overlay=${overlay}`, '-tags=piik_cloudflared', '-trimpath', '-buildvcs=false', '-buildmode=pie', `-ldflags=-s -w -X main.Version=${CLOUDFLARED_VERSION} -X main.BuildTime=source-pinned -linkmode=external -extldflags=-Wl,-z,max-page-size=16384`, '-o', output, './cmd/cloudflared'], { cwd: source, env }); @@ -117,35 +118,40 @@ if (!tunnelOnly) { const versionName = version === 'development' ? `${version}-${revision.slice(0, 7)}` : version; const launcher = readdirSync(join(gradleHome, 'lib')).find(name => /^gradle-launcher-.*\.jar$/.test(name)); if (!launcher) throw new Error('GRADLE_HOME does not contain a Gradle launcher.'); - const frameDropper = join(root, 'native', 'third_party', 'webrtc-frame-dropper'); - for (const [abi, target] of [['arm64-v8a', 'aarch64-linux-android29'], ['x86_64', 'x86_64-linux-android29']]) { - const output = join(android, 'app', 'src', 'main', 'jniLibs', abi, 'libpiik_frame_dropper.so'); - mkdirSync(dirname(output), { recursive: true }); - run(join(tools, `clang++${exe}`), [`--target=${target}`, '-std=c++17', '-O2', '-fPIC', '-shared', - '-static-libstdc++', '-fno-exceptions', '-fno-rtti', '-fvisibility=hidden', - '-ffunction-sections', '-fdata-sections', '-Wl,--gc-sections', '-Wl,--exclude-libs,ALL', - '-Wl,-z,defs', '-Wl,-z,max-page-size=16384', '-Wl,-soname,libpiik_frame_dropper.so', - '-I', frameDropper, join(android, 'frame_dropper.cc'), - join(frameDropper, 'modules', 'video_coding', 'utility', 'frame_dropper.cc'), - join(frameDropper, 'rtc_base', 'numerics', 'exp_filter.cc'), '-o', output]); + const cargoTarget = resolve(process.env.CARGO_TARGET_DIR ?? join(root, 'build', 'android-rust-target')); + for (const { abi, rust, machine } of targets) { + const output = join(android, 'app', 'src', 'main', 'jniLibs', abi, 'libpiik_channel_android.so'); + const key = rust.replaceAll('-', '_'); + const env = { ...process.env, CARGO_TARGET_DIR: cargoTarget, + PIIK_BUILD_VERSION: version, PIIK_BUILD_REVISION: revision, + [`CARGO_TARGET_${key.toUpperCase()}_LINKER`]: clang, + [`CARGO_TARGET_${key.toUpperCase()}_RUSTFLAGS`]: `-C link-arg=--target=${rust}29 -C link-arg=-Wl,-z,max-page-size=16384`, + [`CC_${key}`]: clang, [`CXX_${key}`]: join(tools, `clang++${exe}`), + [`AR_${key}`]: join(tools, `llvm-ar${exe}`), + [`CFLAGS_${key}`]: `--target=${rust}29`, [`CXXFLAGS_${key}`]: `--target=${rust}29` }; + run('cargo', ['+1.91.0', 'build', '--locked', '--manifest-path', join(root, 'prototype', 'channel-android', 'Cargo.toml'), + '--target', rust, '--lib', ...(release ? ['--release'] : [])], { env }); + copyFileSync(join(cargoTarget, rust, release ? 'release' : 'debug', 'libpiik_channel_android.so'), output); + run(join(tools, `llvm-strip${exe}`), ['--strip-debug', output]); + rmSync(join(dirname(output), 'libpiik_frame_dropper.so'), { force: true }); const elf = execFileSync(join(tools, `llvm-readelf${exe}`), ['-h', '-l', '-d', output], { encoding: 'utf8', windowsHide: true }); const loads = [...elf.matchAll(/^\s*LOAD\s+.*$/gm)]; - if (!/Type:\s+DYN/.test(elf) || !loads.length || loads.some(([line]) => !/0x4000\s*$/.test(line))) - throw new Error(`FrameDropper ${abi} must have 16KB LOAD alignment.`); + if (!elf.includes(machine) || !/Type:\s+DYN/.test(elf) || !loads.length || loads.some(([line]) => !/0x4000\s*$/.test(line))) + throw new Error(`Rust JNI ${abi} must have 16KB LOAD alignment.`); for (const [, library] of elf.matchAll(/Shared library: \[([^\]]+)\]/g)) - if (!['libc.so', 'libdl.so', 'libm.so'].includes(library)) - throw new Error(`Unexpected FrameDropper Android dependency: ${library}`); - console.log(`Android WebRTC FrameDropper: ${abi} (static C++ runtime, 16KB)`); + if (!['libc.so', 'libdl.so', 'libm.so', 'liblog.so', 'libandroid.so', 'libmediandk.so', 'libEGL.so', 'libGLESv2.so'].includes(library)) + throw new Error(`Unexpected Rust JNI Android dependency: ${library}`); + console.log(`Android Rust runtime: ${abi} (16KB)`); } - const webEnv = { ...process.env, VITE_PIIK_VERSION: version, VITE_PIIK_REVISION: revision }; - if (process.platform === 'win32') run(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', 'npm run build:web'], { env: webEnv }); - else run('npm', ['run', 'build:web'], { env: webEnv }); - writeAndroidLicenseNotices(root, join(android, 'app', 'src', 'main', 'assets', 'THIRD-PARTY-NOTICES.txt'), 'go'); + const webEnv = { ...process.env, CARGO_TARGET_DIR: cargoTarget, RUSTUP_TOOLCHAIN: '1.91.0', VITE_PIIK_VERSION: version, VITE_PIIK_REVISION: revision }; + writeWebLicenseNotices(root, join(root, 'public', 'third-party-licenses.txt')); + run(process.execPath, [join(root, 'prototype', 'channel-browser', 'build.mjs')], { env: webEnv }); + run(process.execPath, [join(root, 'node_modules', 'vite', 'bin', 'vite.js'), 'build', '--config', 'prototype/channel-browser/web.vite.config.ts'], { env: webEnv }); + const webAssets = join(android, 'app', 'src', 'main', 'assets', 'web'); + rmSync(webAssets, { recursive: true, force: true }); + cpSync(join(root, 'build', 'channel-web'), webAssets, { recursive: true }); + writeAndroidLicenseNotices(root, join(android, 'app', 'src', 'main', 'assets', 'THIRD-PARTY-NOTICES.txt')); writeAndroidAppIcon(join(root, 'cmd', 'piik-app', 'piik.ico'), join(android, 'app', 'src', 'main', 'res', 'drawable-nodpi', 'piik.png')); - mkdirSync(join(android, 'app', 'libs'), { recursive: true }); - run(process.env.PIIK_GOMOBILE || 'gomobile', ['bind', '-trimpath', '-target=android/arm64,android/amd64', '-androidapi', '29', - `-ldflags=-s -w -checklinkname=0 -X github.com/TNTcraftHIM/Piik/internal/app/buildinfo.Release=${version} -X github.com/TNTcraftHIM/Piik/internal/app/buildinfo.Revision=${revision}`, - '-javapkg', 'tv.piik', '-o', join(android, 'app', 'libs', 'piik.aar'), './mobile/bridge']); // Recreate the final ZIP so replaced native libraries leave no free blocks. run('java', ['-classpath', join(gradleHome, 'lib', launcher), 'org.gradle.launcher.GradleMain', '-Dorg.gradle.jvmargs=-Xmx2g', '-p', android, '--no-daemon', @@ -161,7 +167,7 @@ if (!tunnelOnly) { 'verify', '--verbose', '--print-certs', apk], { encoding: 'utf8', windowsHide: true }); if (/CN=Android Debug\b/i.test(signing)) throw new Error('A release APK cannot use an Android debug signing key.'); const badging = execFileSync(join(sdkTools, `aapt${exe}`), ['dump', 'badging', apk], { encoding: 'utf8', windowsHide: true }); - if (!badging.includes(`package: name='tv.piik.android' versionCode='${versionCode}' versionName='${versionName}'`) || + if (!badging.includes(`package: name='tv.piik.android.channel3' versionCode='${versionCode}' versionName='${versionName}'`) || /application-debuggable/.test(badging) || !badging.includes("native-code: 'arm64-v8a' 'x86_64'")) throw new Error('Android release identity, ABIs or debuggable flag differs from the package contract.'); const { id: target, artifact } = ANDROID_APP_PACKAGE_TARGET; diff --git a/scripts/package-licenses.mjs b/scripts/package-licenses.mjs index c38e58446..829d3e4f5 100644 --- a/scripts/package-licenses.mjs +++ b/scripts/package-licenses.mjs @@ -116,26 +116,36 @@ export function writeServerLicenseNotices(repositoryRoot, outputFile, goCommand, WEB_NOTICE_LINE + notices.toolchain + moduleSections(notices.modules)); } -export function writeAndroidLicenseNotices(repositoryRoot, outputFile, goCommand) { - const mobileRoot = join(repositoryRoot, "mobile"); - const target = { goos: "android", goarch: "arm64", cgo: false }; - const notices = goNotices(mobileRoot, goCommand, target, "./bridge"); - // gomobile adds the JNI binding runtime when generating the AAR. It is not - // imported by the bridge package before generation, and has its own notice. - const runtime = JSON.parse(execFileSync(goCommand, ["list", "-m", "-json", "golang.org/x/mobile"], { - cwd: mobileRoot, encoding: "utf8", windowsHide: true, - })); - const files = new Map(noticesIn(runtime.Dir).map((file) => [file, readFileSync(join(runtime.Dir, file), "utf8")])); - if (!files.size) throw new Error("Missing Go mobile runtime license"); - notices.modules.set(`${runtime.Path}@${runtime.Version}`, files); +function rustNotices(repositoryRoot, manifest, targets) { + const command = process.env.CARGO_ABOUT ?? "cargo-about"; + const options = { cwd: repositoryRoot, encoding: "utf8", windowsHide: true, + maxBuffer: 16 * 1024 * 1024, env: { ...process.env, RUSTUP_TOOLCHAIN: "1.91.0" } }; + if (execFileSync(command, ["--version"], options).trim() !== "cargo-about 0.9.3") + throw new Error("Rust notices require cargo-about 0.9.3."); + const output = join(repositoryRoot, "build", "licenses", `${manifest.split("/").at(-2)}.txt`); + mkdirSync(dirname(output), { recursive: true }); + execFileSync(command, ["generate", "--locked", "--fail", "--output-file", output, + "--manifest-path", join(repositoryRoot, manifest), + ...targets.flatMap(target => ["--target", target]), + "--config", join(repositoryRoot, "licenses", "rust-about.toml"), + join(repositoryRoot, "licenses", "rust-about.hbs")], options); + return readFileSync(output, "utf8"); +} + +export function writeAndroidLicenseNotices(repositoryRoot, outputFile) { + const runtime = rustNotices(repositoryRoot, "prototype/channel-android/Cargo.toml", + ["aarch64-linux-android", "x86_64-linux-android"]); + const browser = rustNotices(repositoryRoot, "prototype/channel-browser/Cargo.toml", ["wasm32-unknown-unknown"]); mkdirSync(dirname(outputFile), { recursive: true }); writeFileSync(outputFile, "Piik Android third-party software notices\n" + section("Piik (MIT)", readFileSync(join(repositoryRoot, "LICENSE"), "utf8")) + - WEB_NOTICE_LINE + notices.toolchain + moduleSections(notices.modules) + + WEB_NOTICE_LINE + section("Rust runtime and paired Android platform verifier", runtime) + + section("Browser Rust/WASM adapter", browser) + + section("Kotlin standard library (Apache-2.0)", pinnedNotice("kotlin-stdlib@2.2.10")) + + section("JetBrains annotations (Apache-2.0)", pinnedNotice("jetbrains-annotations@13.0")) + section("WebRTC FrameDropper (BSD-3-Clause)", ["LICENSE", "PATENTS"].map(file => readFileSync(join(repositoryRoot, "native", "third_party", "webrtc-frame-dropper", file), "utf8")).join("\n")) + - section("Android NDK libc++ (Apache-2.0 WITH LLVM-exception)", pinnedNotice("libc++@ndk-30.0.16248370")) + section(`cloudflared@${CLOUDFLARED_VERSION}`, pinnedNotice(`cloudflared@${CLOUDFLARED_VERSION}`)) + section("Piik Android cloudflared changes (MIT)", "Android system DNS adapter and exhausted-QUIC-dial fallback. Source and provenance: mobile/cloudflared/."));