Merge pull request #1429 from ankitects/apple-arm

Initial aarch64-apple support
This commit is contained in:
Damien Elmes 2021-10-16 18:22:01 +10:00 committed by GitHub
commit b87c4ee946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 70 additions and 3 deletions

View file

@ -25,6 +25,7 @@ targets = [
"x86_64-apple-ios",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-unknown-linux-gnu",
]

View file

@ -88,6 +88,7 @@ rust_library(
] + selects.with_or({
# cfg(not(target_arch = "wasm32"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -60,6 +60,7 @@ cargo_build_script(
] + selects.with_or({
# cfg(any(target_os = "linux", target_os = "android", target_os = "windows", target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", target_os = "redox", target_os = "cloudabi", target_os = "haiku", target_os = "vxworks", target_os = "emscripten", target_os = "wasi"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
@ -101,6 +102,7 @@ rust_library(
] + selects.with_or({
# cfg(any(target_os = "linux", target_os = "android", target_os = "windows", target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", target_os = "redox", target_os = "cloudabi", target_os = "haiku", target_os = "vxworks", target_os = "emscripten", target_os = "wasi"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -56,6 +56,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -55,6 +55,7 @@ rust_library(
] + selects.with_or({
# cfg(not(target_os = "wasi"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -54,6 +54,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -60,6 +60,7 @@ cargo_build_script(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
@ -100,6 +101,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -58,6 +58,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -122,6 +122,7 @@ rust_library(
] + selects.with_or({
# cfg(any(target_os = "linux", target_os = "macos"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu",

View file

@ -67,6 +67,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -59,6 +59,7 @@ cargo_build_script(
] + selects.with_or({
# cfg(any(target_os = "macos", target_os = "ios"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:x86_64-apple-darwin",
"@rules_rust//rust/platform:x86_64-apple-ios",
@ -114,6 +115,7 @@ rust_library(
] + selects.with_or({
# cfg(any(target_os = "macos", target_os = "ios"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:x86_64-apple-darwin",
"@rules_rust//rust/platform:x86_64-apple-ios",

View file

@ -58,6 +58,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -59,6 +59,7 @@ cargo_build_script(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
@ -105,6 +106,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -79,6 +79,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -65,6 +65,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -98,6 +98,7 @@ rust_library(
] + selects.with_or({
# cfg(not(target_arch = "wasm32"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -84,6 +84,7 @@ cargo_build_script(
}) + selects.with_or({
# cfg(any(unix, windows))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
@ -156,6 +157,7 @@ rust_library(
}) + selects.with_or({
# cfg(any(unix, windows))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -70,6 +70,7 @@ rust_library(
}) + selects.with_or({
# cfg(target_os = "macos")
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:x86_64-apple-darwin",
): [
"@raze__security_framework__2_4_2//:security_framework",

View file

@ -54,6 +54,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -57,6 +57,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -76,6 +76,7 @@ cargo_build_script(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",
@ -143,6 +144,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -68,6 +68,7 @@ rust_library(
}) + selects.with_or({
# cfg(any(target_os = "macos", target_os = "ios"))
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:x86_64-apple-darwin",
"@rules_rust//rust/platform:x86_64-apple-ios",

View file

@ -54,6 +54,7 @@ rust_library(
] + selects.with_or({
# cfg(unix)
(
"@rules_rust//rust/platform:aarch64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-ios",
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@rules_rust//rust/platform:x86_64-apple-darwin",

View file

@ -49,7 +49,10 @@ def setup_deps():
python_runtime = "@python//:python",
)
node_repositories(package_json = ["@ankidesktop//:package.json"])
node_repositories(
package_json = ["@ankidesktop//:package.json"],
node_version = "16.10.0",
)
yarn_install(
name = "npm",

View file

@ -8,6 +8,7 @@ import re
import shutil
import subprocess
import sys
import platform
from pip._internal.commands import create_command
@ -71,6 +72,10 @@ def merge_files(root, source):
else:
shutil.copy2(source_path, target_path)
def fix_webengine_codesigning(base: str):
"Fix a codesigning issue in the 6.2.0 release."
path = os.path.join(base, "PyQt6/Qt6/lib/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess")
subprocess.run(["codesign", "-s", "-", path], check=True)
def main():
base = sys.argv[1]
@ -100,10 +105,20 @@ def main():
("pyqt6-sip", "pyqt6_sip==13.1.0"),
]
arm_darwin = sys.platform.startswith("darwin") and platform.machine() == "arm64"
for (name, with_version) in packages:
# install package in subfolder
folder = os.path.join(base, "temp")
pip_args = []
if arm_darwin:
if name in ("pyqt6-qt6", "pyqt6-webengine-qt6"):
# pyqt messed up the architecture tags
pip_args.extend(
[
"--platform=macosx_10_14_arm64",
"--only-binary=:all:",
])
install_package(with_version, folder, pip_args)
# merge into parent
merge_files(base, folder)
@ -112,6 +127,9 @@ def main():
with open(os.path.join(base, "__init__.py"), "w") as file:
file.write("__path__ = __import__('pkgutil').extend_path(__path__, __name__)")
if arm_darwin:
fix_webengine_codesigning(base)
# add missing py.typed file
with open(os.path.join(base, "py.typed"), "w") as file:
pass

View file

@ -30,6 +30,10 @@ types-protobuf
types-requests
types-waitress
# transitive dependency of black; pinned due to broken wheel
# https://bitbucket.org/mrabarnett/mrab-regex/issues/399/missing-wheel-for-macosx-and-the-new-m1
regex==2021.9.30
# windows only
psutil; sys.platform == "win32"
pywin32; sys.platform == "win32"

View file

@ -113,8 +113,10 @@ pytoml==0.1.21
# via compare-locales
pywin32==302 ; sys_platform == "win32"
# via -r requirements.in
regex==2021.10.8
# via black
regex==2021.9.30
# via
# -r requirements.in
# black
requests==2.26.0
# via -r requirements.in
send2trash==1.8.0

View file

@ -16,6 +16,14 @@ config_setting(
],
)
config_setting(
name = "macos_arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:aarch64",
],
)
config_setting(
name = "linux_x86_64",
constraint_values = [

View file

@ -15,6 +15,7 @@ alias(
name = "clang_format",
actual = select({
"@ankidesktop//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe",
"@ankidesktop//platforms:macos_arm64": "@clang_format_macos_x86_64//:clang-format",
"@ankidesktop//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format",
"@ankidesktop//platforms:linux_x86_64": "@clang_format_linux_x86_64//:clang-format",
}),

View file

@ -13,6 +13,7 @@ alias(
name = "protoc",
actual = select({
"@ankidesktop//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe",
"@ankidesktop//platforms:macos_arm64": "@protoc_bin_macos//:bin/protoc",
"@ankidesktop//platforms:macos_x86_64": "@protoc_bin_macos//:bin/protoc",
"@ankidesktop//platforms:linux_x86_64": "@protoc_bin_linux_x86_64//:bin/protoc",
"@ankidesktop//platforms:linux_arm64": "@protoc_bin_linux_arm64//:bin/protoc"

View file

@ -21,6 +21,7 @@ rust_library(
rustc_flags = selects.with_or({
(
"@rules_rust//rust/platform:x86_64-apple-darwin",
"@rules_rust//rust/platform:aarch64-apple-darwin",
): [
"-Clink-arg=-undefined",
"-Clink-arg=dynamic_lookup",