From f842ab7c9d4246d729b832fc93852d3280728ad5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 24 Jan 2022 11:06:02 +1000 Subject: [PATCH] switch convenience symlinks to .bazel/ Unfortunately 5efaf5a4be95e289210e964a5cd40b4f08829c8c broke the Svelte language tools - presumably having paths outside of the repo is confusing them. As a plan B, the symlinks have been shifted to a single subdir. Along with some exclusions in the VS Code config, this should allow VS Code to continue to work out of the box, but the docs will need updating to reflect the extra work required for PyCharm/IntelliJ. + fix svelte-check execution on a system without node installed. It still throws up some errors that are presumably caused by our multiple rootDirs - not sure if there's an easy way to work around that. --- .bazelrc | 5 ++--- .gitignore | 1 + .vscode/settings.json | 14 ++++++++++++-- qt/dmypy.py | 8 ++++---- scripts/build | 2 +- scripts/svelte-check | 3 ++- scripts/ts-run | 2 +- ts/tsconfig.json | 4 ++-- 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.bazelrc b/.bazelrc index 1d3a89210..dc09b785b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,9 +29,8 @@ build:opt -c opt # still running, so shut them down at the end of the build. build:windows --worker_quit_after_build -# place convenience symlinks outside of the source folder, so IDEs don't try to -# monitor Bazel's large symlink tree for changes -build --symlink_prefix=../bazel/anki/ +# place convenience symlinks inside a single folder for easier exclusion in IDEs +build --symlink_prefix=.bazel/ build --experimental_no_product_name_out_symlink # allow extra user customizations in a separate file diff --git a/.gitignore b/.gitignore index e5975dbc1..b59d2f5af 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ user.bazelrc rust-project.json node_modules .idea/ +.bazel diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fd87b113..993214aef 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,22 @@ { "editor.formatOnSave": true, + "files.watcherExclude": { + "**/.git/objects/**": true, + "**/.git/subtree-cache/**": true, + "**/node_modules/*/**": true, + ".bazel/**": true + }, "python.analysis.extraPaths": ["./pylib"], "python.formatting.provider": "black", "rust-analyzer.cargo.runBuildScripts": true, "rust-analyzer.checkOnSave.allTargets": false, - "rust-analyzer.files.excludeDirs": ["node_modules"], + "rust-analyzer.files.excludeDirs": [".bazel", "node_modules"], "rust-analyzer.procMacro.enable": true, // this formats 'use' blocks in a nicer way, but requires you to run // 'rustup install nightly'. - "rust-analyzer.rustfmt.extraArgs": ["+nightly"] + "rust-analyzer.rustfmt.extraArgs": ["+nightly"], + "search.exclude": { + "**/node_modules": true, + ".bazel/**": true + } } diff --git a/qt/dmypy.py b/qt/dmypy.py index 47d266272..65f2460f7 100755 --- a/qt/dmypy.py +++ b/qt/dmypy.py @@ -13,7 +13,7 @@ import time from pathlib import Path workspace = Path(os.environ["BUILD_WORKSPACE_DIRECTORY"]) -binroot = workspace / "../bazel/anki/bin" +binroot = workspace / ".bazel/bin" dmypy_bin = binroot / "external/py_deps_mypy/rules_python_wheel_entry_point_dmypy" if sys.platform.startswith("win32"): @@ -30,13 +30,13 @@ if subprocess.run( "--", "--config-file", "qt/mypy.ini", - "../bazel/anki/bin/qt/dmypy.runfiles/ankidesktop/pylib/anki", - "../bazel/anki/bin/qt/dmypy.runfiles/ankidesktop/qt/aqt", + ".bazel/bin/qt/dmypy.runfiles/ankidesktop/pylib/anki", + ".bazel/bin/qt/dmypy.runfiles/ankidesktop/qt/aqt", "--python-executable", os.path.abspath("python/stubs/extendsitepkgs"), ], env={ - "MYPYPATH": "../bazel/anki/bin/qt/dmypy.runfiles/pyqt6", + "MYPYPATH": ".bazel/bin/qt/dmypy.runfiles/pyqt6", "EXTRA_SITE_PACKAGES": os.path.abspath(os.getenv("EXTRA_SITE_PACKAGES")), }, cwd=workspace, diff --git a/scripts/build b/scripts/build index 2ba907ea2..cb6081935 100755 --- a/scripts/build +++ b/scripts/build @@ -9,4 +9,4 @@ test -e WORKSPACE || ( rm -rf bazel-dist bazel build --config opt dist -tar xvf ../bazel/anki/bin/dist.tar +tar xvf .bazel/bin/dist.tar diff --git a/scripts/svelte-check b/scripts/svelte-check index cc43eb962..0f9732cd7 100755 --- a/scripts/svelte-check +++ b/scripts/svelte-check @@ -1,5 +1,6 @@ #!/bin/bash -SASS_PATH=ts/sass:$(pwd)/../bazel/anki/bin/ts/sass \ +. scripts/node-env +SASS_PATH=ts/sass:$(pwd)/.bazel/bin/ts/sass \ node_modules/.bin/svelte-check \ --workspace ts diff --git a/scripts/ts-run b/scripts/ts-run index 69a7efc51..08cb929c4 100755 --- a/scripts/ts-run +++ b/scripts/ts-run @@ -6,6 +6,6 @@ # The pages can be accessed by, eg surfing to # http://localhost:40000/_anki/pages/deckconfig.html -ANKI_DATA_FOLDER=$(pwd)/../bazel/anki/bin/qt/aqt \ +ANKI_DATA_FOLDER=$(pwd)/.bazel/bin/qt/aqt \ QTWEBENGINE_REMOTE_DEBUGGING=8080 \ ANKI_API_PORT=40000 ANKIDEV=1 ./run $* diff --git a/ts/tsconfig.json b/ts/tsconfig.json index b477c4e80..b8e917aea 100644 --- a/ts/tsconfig.json +++ b/ts/tsconfig.json @@ -35,8 +35,8 @@ "rootDir": "..", "rootDirs": [ ".", - // for VS code - "../../bazel/anki/bin/ts" + // for VS code and svelte-check + "../.bazel/bin/ts" ], "baseUrl": ".", "paths": {},