From 372a28be2996fec96cef9f49d86bf6bcabc22531 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 10 Jul 2021 23:58:53 +1000 Subject: [PATCH] rename workspace I'd forgotten that Bazel "helpfully" adds __init__.py files into folders that match the workspace name, breaking imports. --- WORKSPACE | 2 +- defs.bzl | 10 +++++----- docs/new-platform.md | 4 ++-- proto/clang_format.bzl | 8 ++++---- proto/format.bzl | 8 ++++---- proto/protobuf.bzl | 8 ++++---- pylib/tools/protoc_wrapper.py | 4 ++-- ts/compile_sass.bzl | 2 +- ts/svelte/svelte.ts | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a33c39caa..26a551657 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,5 @@ workspace( - name = "anki", + name = "ankidesktop", managed_directories = {"@npm": [ "ts/node_modules", ]}, diff --git a/defs.bzl b/defs.bzl index bda94d69e..f65f0b02a 100644 --- a/defs.bzl +++ b/defs.bzl @@ -1,7 +1,7 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") load("@bazel_skylib//lib:versions.bzl", "versions") load("@rules_rust//rust:repositories.bzl", "rust_repositories") -load("@anki//cargo:crates.bzl", "raze_fetch_remote_crates") +load("@ankidesktop//cargo:crates.bzl", "raze_fetch_remote_crates") load(":python.bzl", "setup_local_python") load("//proto:protobuf.bzl", "setup_protobuf_binary") load("//proto:format.bzl", "setup_clang_format") @@ -35,7 +35,7 @@ def setup_deps(): pip_import( name = "py_deps", - requirements = "@anki//pip:requirements.txt", + requirements = "@ankidesktop//pip:requirements.txt", python_runtime = "@python//:python", ) @@ -44,12 +44,12 @@ def setup_deps(): python_runtime = "@python//:python", ) - node_repositories(package_json = ["@anki//ts:package.json"]) + node_repositories(package_json = ["@ankidesktop//ts:package.json"]) yarn_install( name = "npm", - package_json = "@anki//ts:package.json", - yarn_lock = "@anki//ts:yarn.lock", + package_json = "@ankidesktop//ts:package.json", + yarn_lock = "@ankidesktop//ts:yarn.lock", ) sass_repositories() diff --git a/docs/new-platform.md b/docs/new-platform.md index 3c276a114..ffdb67bb1 100644 --- a/docs/new-platform.md +++ b/docs/new-platform.md @@ -74,14 +74,14 @@ index eff3d9df2..fb2e9f7fe 100644 python_runtime = "@python//:python", ) -- node_repositories(package_json = ["@anki//ts:package.json"]) +- node_repositories(package_json = ["@ankidesktop//ts:package.json"]) + native.local_repository( + name = "local_node", + path = "local_node", + ) + + node_repositories( -+ package_json = ["@anki//ts:package.json"], ++ package_json = ["@ankidesktop//ts:package.json"], + vendored_node = "@local_node//:node", + ) diff --git a/proto/clang_format.bzl b/proto/clang_format.bzl index 4af4ad56e..164fcb8b1 100644 --- a/proto/clang_format.bzl +++ b/proto/clang_format.bzl @@ -14,9 +14,9 @@ def _impl(rctx): alias( name = "clang_format", actual = select({ - "@anki//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", - "@anki//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", - "@anki//platforms:linux_x86_64": "@clang_format_linux_x86_64//:clang-format", + "@ankidesktop//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", + "@ankidesktop//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", + "@ankidesktop//platforms:linux_x86_64": "@clang_format_linux_x86_64//:clang-format", }), visibility = ["//visibility:public"] ) @@ -68,7 +68,7 @@ def proto_format(name, srcs, **kwargs): py_test( name = name, srcs = [ - "@anki//proto:format.py", + "@ankidesktop//proto:format.py", ], data = ["@clang_format//:clang_format"] + srcs, args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs], diff --git a/proto/format.bzl b/proto/format.bzl index 08e92a099..fd91d5fe7 100644 --- a/proto/format.bzl +++ b/proto/format.bzl @@ -14,9 +14,9 @@ def _impl(rctx): alias( name = "clang_format", actual = select({ - "@anki//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", - "@anki//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", - "@anki//platforms:linux_x86_64": "@clang_format_linux_x86_64//:clang-format", + "@ankidesktop//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", + "@ankidesktop//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", + "@ankidesktop//platforms:linux_x86_64": "@clang_format_linux_x86_64//:clang-format", }), visibility = ["//visibility:public"] ) @@ -68,7 +68,7 @@ def proto_format(name, srcs, **kwargs): py_test( name = name, srcs = [ - "@anki//format.py", + "@ankidesktop//format.py", ], data = ["@clang_format//:clang_format"] + srcs, args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs], diff --git a/proto/protobuf.bzl b/proto/protobuf.bzl index 79a4690c0..2e42c5511 100644 --- a/proto/protobuf.bzl +++ b/proto/protobuf.bzl @@ -12,10 +12,10 @@ def _impl(rctx): alias( name = "protoc", actual = select({ - "@anki//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe", - "@anki//platforms:macos_x86_64": "@protoc_bin_macos//:bin/protoc", - "@anki//platforms:linux_x86_64": "@protoc_bin_linux_x86_64//:bin/protoc", - "@anki//platforms:linux_arm64": "@protoc_bin_linux_arm64//:bin/protoc" + "@ankidesktop//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe", + "@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" }), visibility = ["//visibility:public"] ) diff --git a/pylib/tools/protoc_wrapper.py b/pylib/tools/protoc_wrapper.py index f98967aa1..f10af3464 100644 --- a/pylib/tools/protoc_wrapper.py +++ b/pylib/tools/protoc_wrapper.py @@ -13,7 +13,7 @@ import sys (protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:] if protos[0].startswith("external"): - prefix = "external/anki/proto/" + prefix = "external/ankidesktop/proto/" else: prefix = "proto/" @@ -25,7 +25,7 @@ subprocess.run( "--python_out=.", "--mypy_out=.", "-I" + prefix, - "-Iexternal/anki/" + prefix, + "-Iexternal/ankidesktop/" + prefix, *protos, ], # mypy prints to stderr on success :-( diff --git a/ts/compile_sass.bzl b/ts/compile_sass.bzl index 256504a5c..7ab1aba6a 100644 --- a/ts/compile_sass.bzl +++ b/ts/compile_sass.bzl @@ -14,7 +14,7 @@ def compile_sass(group, srcs, deps = [], visibility = ["//visibility:private"]): sourcemap = False, deps = deps, visibility = visibility, - include_paths = ["external/anki"], + include_paths = ["external/ankidesktop"], ) native.filegroup( diff --git a/ts/svelte/svelte.ts b/ts/svelte/svelte.ts index f4acb040e..0f05831bc 100644 --- a/ts/svelte/svelte.ts +++ b/ts/svelte/svelte.ts @@ -157,9 +157,9 @@ async function writeJs( genDir, // a nasty hack to ensure ts/sass/... resolves correctly // when invoked from an external workspace - binDir + "/external/anki", - genDir + "/external/anki", - binDir + "/../../../external/anki", + binDir + "/external/ankidesktop", + genDir + "/external/ankidesktop", + binDir + "/../../../external/ankidesktop", ], }, });