Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new CURRENT_ONLY build/test performance option assumes x86-64 / likely fails on M1 mac #211

Closed
mikehardy opened this issue Jun 27, 2022 · 1 comment · Fixed by #246
Closed

Comments

@mikehardy
Copy link
Member

shouldn't this determine the correct platform? Seems like cargoBuildX86_64 is an assumption as what the opposite of wantAllPlatforms is. David has an M1 now, for instance. That may be fancy so perhaps a middle-ground would be to failfast if CURRENT_ONLY == true and arch != x86-64 (or linux/x86-64 if it's that specific)

Originally posted by @mikehardy in #202 (comment)

@mikehardy
Copy link
Member Author

mikehardy commented Jun 27, 2022

Got a timeslice on the M1 we have in the house and for ./test-current.sh the appropriate thing is preBuildMac apparently:

Execution failed for task ':rsdroid-testing:preBuildMac'.

because of


  |
  = note: the `x86_64-apple-darwin` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-apple-darwin`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name cfg_if --edition=2018 /Users/mike/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=581f1a16a94707a6 -C extra-filename=-581f1a16a94707a6 --out-dir /Users/mike/work/Ankidroid/Anki-Android-Backend/rslib-bridge/target/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/mike/work/Ankidroid/Anki-Android-Backend/rslib-bridge/target/x86_64-apple-darwin/release/deps -L dependency=/Users/mike/work/Ankidroid/Anki-Android-Backend/rslib-bridge/target/release/deps --cap-lints allow` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

Here's the diff to PR after merging #202 and after making the rsdroid/build.gradle else dependent on OS version with regard to which one it does, this "cargoBuildArm64" gradle target is just the known-good / tested-locally target that works on M1 macs

diff --git a/rsdroid/build.gradle b/rsdroid/build.gradle
index fd7bb40..d6236b9 100644
--- a/rsdroid/build.gradle
+++ b/rsdroid/build.gradle
@@ -103,7 +103,7 @@ Boolean wantAllPlatforms = System.getenv("CURRENT_ONLY") != "true"
 if (wantAllPlatforms) {
     preBuild.dependsOn "cargoBuild"
 } else {
-    preBuild.dependsOn "cargoBuildX86_64"
+    preBuild.dependsOn "cargoBuildArm64"
 }
 
 signing {
diff --git a/test-current.sh b/test-current.sh
index b8a4960..424bc87 100755
--- a/test-current.sh
+++ b/test-current.sh
@@ -2,5 +2,5 @@
 
 set -e
 
-NO_CROSS=true CURRENT_ONLY=true ./gradlew rsdroid:test rsdroid-instrumented:connectedAndroidTest
+NO_CROSS=true CURRENT_ONLY=true ./gradlew rsdroid:testDebugUnitTest rsdroid-instrumented:connectedDebugAndroidTest
 
diff --git a/tools/doctor.sh b/tools/doctor.sh
index e763124..f650ca0 100755
--- a/tools/doctor.sh
+++ b/tools/doctor.sh
@@ -73,6 +73,11 @@ rustup target add i686-linux-android        # x86
 rustup target add aarch64-linux-android     # arm64
 rustup target add x86_64-linux-android      # x86_64
 
+if [ "$(uname)" == "Darwin" ]; then
+  rustup target add x86_64-apple-darwin     # x86_64 darwin
+  rustup target add aarch64-apple-darwin    # arm64 darwin
+fi
+
 cecho $lgray "Installing cross"
 cargo install cross --git https://github.com/rust-embedded/cross/ --tag v0.2.1 # current requires rust-current
 
@@ -96,4 +101,4 @@ if [[ $(pip3 install stringcase) ]]; then
   ok_echo "Stringcase is installed"
 else
   error_echo "Failed installing stringcase python library"
-fi
\ No newline at end of file
+fi

dae added a commit to ankitects/Anki-Android-Backend that referenced this issue Nov 29, 2022
The 2.1.55 desktop release switched away from Bazel to a new build system,
which required some changes to this repo. Making the changes was a bit complicated
due to the complexity of the current build system, and I ended up shaving some yaks
to make things simpler while I was working on the changes.

Changes:

- Building for the current architecture instead of all architectures is now the
default, so getting started is easier, and a build in Android Studio no longer
requires special flags.
- The build-current.sh script has been split into build-aar and build-robo
for the Android and Robolectric parts, and can be used for both single-arch
and multi-arch builds.
- On arm64 Macs, the build scripts now create arm binaries
- In a multi-arch build, both x86 and arm64 Mac libs are built, and they're
merged into a single library. This can be done in CI, so there is no manual step
required for M1 machines anymore.
- The build now uses protobuf and python binaries/libs that the desktop build
downloads, so they don't need to be installed separately.
- The pinned Rust version and Rust targets are automatically installed as
required.
- The per-platform CI builds now build in debug mode and are faster.
- Updated the docs to explain how the NDK can be installed via Android Studio,
instead of via separate command-line tools.
- The cross/docker stuff has been stripped out, as it's of limited use as it
can't target macOS legally. Easier to use GH actions for the multi-arch
builds, and keep things simple for local development.
- Fix lint not being run in CI; caught an API 23 reference.

Bumps ankidroid#179 (builds on M1 already work, so this may be simpler than expected?)
Bumps ankidroid#174 (a bunch of the doctor stuff is obsolete; updated HOWTO.md and GH actions should be consulted)
Bumps ankidroid#27 (I recommend closing this; single-platform is the default for local builds, and
CI runners don't have any extra compute available)

Tentatively closes ankidroid#109 (didn't see the flake when I was updating the actions)

Closes ankidroid#235 (translation submodules now automatically synced with anki submodule)
Closes ankidroid#213 (path based on script now)
Closes ankidroid#211 (builds for Arm Mac on Arm Macs)
Closes ankidroid#197 (single arch is the default)
Closes ankidroid#196 (desktop venv is used)
Closes ankidroid#195 (can be done via the GUI, and does not require separate cli download)
Closes ankidroid#168 (latest Rust; easier changing via rust-toolchain.toml)
Closes ankidroid#164 (universal dylib)
Closes ankidroid#127 (no docker)
Closes ankidroid#106 (most of those scripts obsolete; some commands moved into build scripts)
Closes ankidroid#99 (no docker)
Closes ankidroid#98 (no docker)
Closes ankidroid#97 (submodule automatically updated)
Closes ankidroid#96 (build will fail if commit unavailable)
Closes ankidroid#53 (no docker)
Closes ankidroid#40 (DEBUG=1 option documented)
Closes ankidroid#9 (simpler OOTB experience, and updated docs)
dae added a commit to ankitects/Anki-Android-Backend that referenced this issue Nov 29, 2022
The 2.1.55 desktop release switched away from Bazel to a new build system,
which required some changes to this repo. Making the changes was a bit complicated
due to the complexity of the current build system, and I ended up shaving some yaks
to make things simpler while I was working on the changes.

Changes:

- Building for the current architecture instead of all architectures is now the
default, so getting started is easier, and a build in Android Studio no longer
requires special flags.
- The build-current.sh script has been split into build-aar and build-robo
for the Android and Robolectric parts, and can be used for both single-arch
and multi-arch builds.
- On arm64 Macs, the build scripts now create arm binaries
- In a multi-arch build, both x86 and arm64 Mac libs are built, and they're
merged into a single library. This can be done in CI, so there is no manual step
required for M1 machines anymore.
- The build now uses protobuf and python binaries/libs that the desktop build
downloads, so they don't need to be installed separately.
- The pinned Rust version and Rust targets are automatically installed as
required.
- The per-platform CI builds now build in debug mode and are faster.
- Updated the docs to explain how the NDK can be installed via Android Studio,
instead of via separate command-line tools.
- The cross/docker stuff has been stripped out, as it's of limited use as it
can't target macOS legally. Easier to use GH actions for the multi-arch
builds, and keep things simple for local development.
- Fix lint not being run in CI; caught an API 23 reference.

Bumps ankidroid#179 (builds on M1 already work, so this may be simpler than expected?)
Bumps ankidroid#174 (a bunch of the doctor stuff is obsolete; updated HOWTO.md and GH actions should be consulted)
Bumps ankidroid#27 (I recommend closing this; single-platform is the default for local builds, and
CI runners don't have any extra compute available)

Tentatively closes ankidroid#109 (didn't see the flake when I was updating the actions)

Closes ankidroid#235 (translation submodules now automatically synced with anki submodule)
Closes ankidroid#213 (path based on script now)
Closes ankidroid#211 (builds for Arm Mac on Arm Macs)
Closes ankidroid#197 (single arch is the default)
Closes ankidroid#196 (desktop venv is used)
Closes ankidroid#195 (can be done via the GUI, and does not require separate cli download)
Closes ankidroid#168 (latest Rust; easier changing via rust-toolchain.toml)
Closes ankidroid#164 (universal dylib)
Closes ankidroid#127 (no docker)
Closes ankidroid#106 (most of those scripts obsolete; some commands moved into build scripts)
Closes ankidroid#99 (no docker)
Closes ankidroid#98 (no docker)
Closes ankidroid#97 (submodule automatically updated)
Closes ankidroid#96 (build will fail if commit unavailable)
Closes ankidroid#53 (no docker)
Closes ankidroid#40 (DEBUG=1 option documented)
Closes ankidroid#9 (simpler OOTB experience, and updated docs)
dae added a commit to ankitects/Anki-Android-Backend that referenced this issue Nov 29, 2022
The 2.1.55 desktop release switched away from Bazel to a new build system,
which required some changes to this repo. Making the changes was a bit complicated
due to the complexity of the current build system, and I ended up shaving some yaks
to make things simpler while I was working on the changes.

Changes:

- Building for the current architecture instead of all architectures is now the
default, so getting started is easier, and a build in Android Studio no longer
requires special flags.
- The build-current.sh script has been split into build-aar and build-robo
for the Android and Robolectric parts, and can be used for both single-arch
and multi-arch builds.
- On arm64 Macs, the build scripts now create arm binaries
- In a multi-arch build, both x86 and arm64 Mac libs are built, and they're
merged into a single library. This can be done in CI, so there is no manual step
required for M1 machines anymore.
- The build now uses protobuf and python binaries/libs that the desktop build
downloads, so they don't need to be installed separately.
- The pinned Rust version and Rust targets are automatically installed as
required.
- The per-platform CI builds now build in debug mode and are faster.
- Updated the docs to explain how the NDK can be installed via Android Studio,
instead of via separate command-line tools.
- The cross/docker stuff has been stripped out, as it's of limited use as it
can't target macOS legally. Easier to use GH actions for the multi-arch
builds, and keep things simple for local development.
- Fix lint not being run in CI; caught an API 23 reference.

Bumps ankidroid#179 (builds on M1 already work, so this may be simpler than expected?)
Bumps ankidroid#174 (a bunch of the doctor stuff is obsolete; updated HOWTO.md and GH actions should be consulted)
Bumps ankidroid#27 (I recommend closing this; single-platform is the default for local builds, and
CI runners don't have any extra compute available)

Tentatively closes ankidroid#109 (didn't see the flake when I was updating the actions)

Closes ankidroid#235 (translation submodules now automatically synced with anki submodule)
Closes ankidroid#213 (path based on script now)
Closes ankidroid#211 (builds for Arm Mac on Arm Macs)
Closes ankidroid#197 (single arch is the default)
Closes ankidroid#196 (desktop venv is used)
Closes ankidroid#195 (can be done via the GUI, and does not require separate cli download)
Closes ankidroid#168 (latest Rust; easier changing via rust-toolchain.toml)
Closes ankidroid#164 (universal dylib)
Closes ankidroid#127 (no docker)
Closes ankidroid#106 (most of those scripts obsolete; some commands moved into build scripts)
Closes ankidroid#99 (no docker)
Closes ankidroid#98 (no docker)
Closes ankidroid#97 (submodule automatically updated)
Closes ankidroid#96 (build will fail if commit unavailable)
Closes ankidroid#53 (no docker)
Closes ankidroid#40 (DEBUG=1 option documented)
Closes ankidroid#9 (simpler OOTB experience, and updated docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant