rename workspace

I'd forgotten that Bazel "helpfully" adds __init__.py files into folders
that match the workspace name, breaking imports.
This commit is contained in:
Damien Elmes 2021-07-10 23:58:53 +10:00
parent 185e9acd22
commit 372a28be29
9 changed files with 26 additions and 26 deletions

View file

@ -1,5 +1,5 @@
workspace( workspace(
name = "anki", name = "ankidesktop",
managed_directories = {"@npm": [ managed_directories = {"@npm": [
"ts/node_modules", "ts/node_modules",
]}, ]},

View file

@ -1,7 +1,7 @@
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@bazel_skylib//lib:versions.bzl", "versions") load("@bazel_skylib//lib:versions.bzl", "versions")
load("@rules_rust//rust:repositories.bzl", "rust_repositories") 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(":python.bzl", "setup_local_python")
load("//proto:protobuf.bzl", "setup_protobuf_binary") load("//proto:protobuf.bzl", "setup_protobuf_binary")
load("//proto:format.bzl", "setup_clang_format") load("//proto:format.bzl", "setup_clang_format")
@ -35,7 +35,7 @@ def setup_deps():
pip_import( pip_import(
name = "py_deps", name = "py_deps",
requirements = "@anki//pip:requirements.txt", requirements = "@ankidesktop//pip:requirements.txt",
python_runtime = "@python//:python", python_runtime = "@python//:python",
) )
@ -44,12 +44,12 @@ def setup_deps():
python_runtime = "@python//:python", python_runtime = "@python//:python",
) )
node_repositories(package_json = ["@anki//ts:package.json"]) node_repositories(package_json = ["@ankidesktop//ts:package.json"])
yarn_install( yarn_install(
name = "npm", name = "npm",
package_json = "@anki//ts:package.json", package_json = "@ankidesktop//ts:package.json",
yarn_lock = "@anki//ts:yarn.lock", yarn_lock = "@ankidesktop//ts:yarn.lock",
) )
sass_repositories() sass_repositories()

View file

@ -74,14 +74,14 @@ index eff3d9df2..fb2e9f7fe 100644
python_runtime = "@python//:python", python_runtime = "@python//:python",
) )
- node_repositories(package_json = ["@anki//ts:package.json"]) - node_repositories(package_json = ["@ankidesktop//ts:package.json"])
+ native.local_repository( + native.local_repository(
+ name = "local_node", + name = "local_node",
+ path = "local_node", + path = "local_node",
+ ) + )
+ +
+ node_repositories( + node_repositories(
+ package_json = ["@anki//ts:package.json"], + package_json = ["@ankidesktop//ts:package.json"],
+ vendored_node = "@local_node//:node", + vendored_node = "@local_node//:node",
+ ) + )

View file

@ -14,9 +14,9 @@ def _impl(rctx):
alias( alias(
name = "clang_format", name = "clang_format",
actual = select({ actual = select({
"@anki//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", "@ankidesktop//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe",
"@anki//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", "@ankidesktop//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:linux_x86_64": "@clang_format_linux_x86_64//:clang-format",
}), }),
visibility = ["//visibility:public"] visibility = ["//visibility:public"]
) )
@ -68,7 +68,7 @@ def proto_format(name, srcs, **kwargs):
py_test( py_test(
name = name, name = name,
srcs = [ srcs = [
"@anki//proto:format.py", "@ankidesktop//proto:format.py",
], ],
data = ["@clang_format//:clang_format"] + srcs, data = ["@clang_format//:clang_format"] + srcs,
args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs], args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs],

View file

@ -14,9 +14,9 @@ def _impl(rctx):
alias( alias(
name = "clang_format", name = "clang_format",
actual = select({ actual = select({
"@anki//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe", "@ankidesktop//platforms:windows_x86_64": "@clang_format_windows_x86_64//:clang-format.exe",
"@anki//platforms:macos_x86_64": "@clang_format_macos_x86_64//:clang-format", "@ankidesktop//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:linux_x86_64": "@clang_format_linux_x86_64//:clang-format",
}), }),
visibility = ["//visibility:public"] visibility = ["//visibility:public"]
) )
@ -68,7 +68,7 @@ def proto_format(name, srcs, **kwargs):
py_test( py_test(
name = name, name = name,
srcs = [ srcs = [
"@anki//format.py", "@ankidesktop//format.py",
], ],
data = ["@clang_format//:clang_format"] + srcs, data = ["@clang_format//:clang_format"] + srcs,
args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs], args = ["$(location @clang_format//:clang_format)"] + [native.package_name() + "/" + f for f in srcs],

View file

@ -12,10 +12,10 @@ def _impl(rctx):
alias( alias(
name = "protoc", name = "protoc",
actual = select({ actual = select({
"@anki//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe", "@ankidesktop//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe",
"@anki//platforms:macos_x86_64": "@protoc_bin_macos//:bin/protoc", "@ankidesktop//platforms:macos_x86_64": "@protoc_bin_macos//:bin/protoc",
"@anki//platforms:linux_x86_64": "@protoc_bin_linux_x86_64//:bin/protoc", "@ankidesktop//platforms:linux_x86_64": "@protoc_bin_linux_x86_64//:bin/protoc",
"@anki//platforms:linux_arm64": "@protoc_bin_linux_arm64//:bin/protoc" "@ankidesktop//platforms:linux_arm64": "@protoc_bin_linux_arm64//:bin/protoc"
}), }),
visibility = ["//visibility:public"] visibility = ["//visibility:public"]
) )

View file

@ -13,7 +13,7 @@ import sys
(protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:] (protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:]
if protos[0].startswith("external"): if protos[0].startswith("external"):
prefix = "external/anki/proto/" prefix = "external/ankidesktop/proto/"
else: else:
prefix = "proto/" prefix = "proto/"
@ -25,7 +25,7 @@ subprocess.run(
"--python_out=.", "--python_out=.",
"--mypy_out=.", "--mypy_out=.",
"-I" + prefix, "-I" + prefix,
"-Iexternal/anki/" + prefix, "-Iexternal/ankidesktop/" + prefix,
*protos, *protos,
], ],
# mypy prints to stderr on success :-( # mypy prints to stderr on success :-(

View file

@ -14,7 +14,7 @@ def compile_sass(group, srcs, deps = [], visibility = ["//visibility:private"]):
sourcemap = False, sourcemap = False,
deps = deps, deps = deps,
visibility = visibility, visibility = visibility,
include_paths = ["external/anki"], include_paths = ["external/ankidesktop"],
) )
native.filegroup( native.filegroup(

View file

@ -157,9 +157,9 @@ async function writeJs(
genDir, genDir,
// a nasty hack to ensure ts/sass/... resolves correctly // a nasty hack to ensure ts/sass/... resolves correctly
// when invoked from an external workspace // when invoked from an external workspace
binDir + "/external/anki", binDir + "/external/ankidesktop",
genDir + "/external/anki", genDir + "/external/ankidesktop",
binDir + "/../../../external/anki", binDir + "/../../../external/ankidesktop",
], ],
}, },
}); });