Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Update BUILD documentation for 2.0.0 (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Dec 21, 2023
1 parent eaad1d7 commit 02a1b0f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 52 deletions.
108 changes: 59 additions & 49 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,66 @@
# BUILD

For those who wish to verify reproducibility of the binaries being distributed
via MavenCentral, you can do so by following along below.
For those who wish to verify reproducibility of the binaries being distributed,
you can do so by following along below.

- What you will need:
- `Linux` or `macOS`
- A `Linux x86_64` machine
- Git
- Gradle
- Java 11 or higher

- Clone the repository
```shell
git clone https://github.com/05nelsonm/kmp-tor-binary.git
cd kmp-tor-binary
```

- Build `tor` binaries:
- This step will:
- Build all platforms supported by `kmp-tor-binary`
- Archive desktop binaries to the `binary-build/built` directory
- Move android binaries to `kmp-tor-binary-android` module
`src/androidMain/jniLibs` directory.
- Initialize the `tor-browser-build` submodule
```shell
git submodule update --init
```
- Open up the `tor-browser-build` submodule's `README` and install
packages needed to build `tor`
```shell
cat library/binary-build/tor-browser-build/README
```
- Run the build script
```shell
./library/binary-build/scripts/build_tor.sh all
```
- Running `git diff` at this point should show **no** changes to the project.
- Resource creation:
- This step will:
- Apply detached signatures to `macOS`/`Windows` binaries
- Reproducibly built binaries for `macOS` and `Windows` are codesigned
before being packaged as resources. The [diff-cli](tools/diff-cli/README.md) tool
is used to create and apply detached signatures.
- `gzip` all files
- Move them to their respective `kmp-tor-binary-<os><arch>` module resource directory
- Update `kmp-tor-binary-extract` constants (sha256 & manifest values)
- Run the resource creation script
```shell
./library/binary-build/scripts/resources_create.sh all
```
- Running `git diff` at this point should show **no** changes to the project.
- Docker
- Java 17+


1) Clone the repository
```shell
git clone -b master --single-branch https://github.com/05nelsonm/kmp-tor-binary.git
cd kmp-tor-binary
```

<!-- TODO: uncomment once release has been made for 2.0.0
2) Checkout the tag for whatver version you wish to verify
```shell
git checkout
```
-->

3) Build `tor` binaries (go touch grass for a little bit):
```shell
./external/task.sh build:all
```

4) Package them:
```shell
./external/task.sh package
```

5) Clean:
```shell
./gradlew clean -PKMP_TARGETS="JVM,LINUX_ARM64,LINUX_X64,MACOS_ARM64,MACOS_X64,MINGW_X64,IOS_ARM64,IOS_SIMULATOR_ARM64,IOS_X64,TVOS_ARM64,TVOS_SIMULATOR_ARM64,TVOS_X64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_SIMULATOR_ARM64,WATCHOS_X64"
```

6) Sync the project:
```shell
./gradlew prepareKotlinBuildScriptModel -PKMP_TARGETS="JVM,LINUX_ARM64,LINUX_X64,MACOS_ARM64,MACOS_X64,MINGW_X64,IOS_ARM64,IOS_SIMULATOR_ARM64,IOS_X64,TVOS_ARM64,TVOS_SIMULATOR_ARM64,TVOS_X64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_SIMULATOR_ARM64,WATCHOS_X64"
```

7) Check the generated reports for any errors:
```shell
(
set +e
ERRS=$(ls library/binary/build/reports/resource-validation/binary | grep ".err")
echo ""
for file_err in $ERRS; do
echo "$file_err:"
cat "library/binary/build/reports/resource-validation/binary/$file_err"
done
echo ""
)
```

If the output is blank, all built/packaged resources matched the expected sha256 hash values
defined in `build-logic/src/main/kotlin/resources/TorResources.kt`.

Any error output is pretty self-explanatory (either the file didn't exist or hashes did not
match what was expected for the given platform/architecture).

That's it.
10 changes: 7 additions & 3 deletions tooling
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ TOOL="$1"; shift 1

readonly DIR_SCRIPT=$( cd "$( dirname "$0" )" >/dev/null && pwd )

if [ -z "${TOOL}" ] || [ "${TOOL}" = "cli-core" ] || [ ! -d "$DIR_SCRIPT/tools/${TOOL}" ]; then
if [ -z "${TOOL}" ] ||
[ "${TOOL}" = "cli-core" ] ||
[ "${TOOL}" = "check-publication" ] ||
[ ! -d "$DIR_SCRIPT/tools/${TOOL}" ]; then

echo "Unknown tool: '${TOOL}'"
exit 1
fi
Expand All @@ -27,7 +31,7 @@ args="${args%"${args##*[![:space:]]}"}"
cd "$DIR_SCRIPT" || exit 3

if [ -z "$args" ]; then
./gradlew --quiet ":tools:${TOOL}:jvmRun"
./gradlew --quiet ":tools:${TOOL}:jvmRun" -PKMP_TARGETS="JVM"
else
./gradlew --quiet ":tools:${TOOL}:jvmRun" --args="$args"
./gradlew --quiet ":tools:${TOOL}:jvmRun" --args="$args" -PKMP_TARGETS="JVM"
fi

0 comments on commit 02a1b0f

Please sign in to comment.