Skip to content

Commit

Permalink
Make more things project-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeLyon committed Oct 19, 2023
1 parent 36939cd commit 9fc3974
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
20 changes: 6 additions & 14 deletions .devcontainer/cmake-helper
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ set -euo pipefail

# Calls CMake, loading arguments from devcontainer settings to maintain a single source of truth.

PROJECT_NAME=circt

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_ROOT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)

LLVM_DIR=${LLVM_DIR:-${PROJECT_ROOT}/llvm/llvm}
CMAKE_HELPER_BUILD_DIR=${CMAKE_HELPER_BUILD_DIR:-$PROJECT_ROOT/build/$PROJECT_NAME}
CMAKE_HELPER_BUILD_DIR=${CMAKE_HELPER_BUILD_DIR:-$PROJECT_ROOT/build/$(basename "$PROJECT_ROOT")}

case "$1" in
"print-configure-args")
Expand Down Expand Up @@ -39,17 +37,11 @@ case "$1" in
"configure")
shift 1 # Remove "configure" from the arguments

(
set -x
"${BASH_SOURCE[0]}" print-configure-args | xargs cmake \
"-S$LLVM_DIR" \
"-B$CMAKE_HELPER_BUILD_DIR"
)
(
cd "$PROJECT_ROOT/build"
rm -f compile_commands.json
ln -s "$PROJECT_NAME/compile_commands.json" compile_commands.json
)
"${BASH_SOURCE[0]}" print-configure-args | xargs cmake \
"-S$LLVM_DIR" \
"-B$CMAKE_HELPER_BUILD_DIR"
rm -f "$PROJECT_ROOT/build/compile_commands.json"
ln -s "$CMAKE_HELPER_BUILD_DIR/compile_commands.json" "$PROJECT_ROOT/build/compile_commands.json"
;;
"build"|"test")
TASK_KIND=$1
Expand Down
6 changes: 4 additions & 2 deletions .devcontainer/default/VSCode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
// -- CMake Tools
"cmake.sourceDirectory": "${workspaceFolder}/llvm/llvm",
"cmake.buildDirectory": "${workspaceFolder}/build/circt",
"cmake.buildDirectory": "${workspaceFolder}/build/${workspaceFolderBasename}",
"cmake.installPrefix": "/usr/local",
"cmake.configureOnOpen": false,
"cmake.configureOnEdit": false,
"cmake.generator": "Ninja",
"cmake.configureArgs": [
// CMAKE
"-DCMAKE_WARN_DEPRECATED=OFF",
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER=clang++",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",

// LLVM
Expand Down Expand Up @@ -38,7 +40,7 @@
"clangd.onConfigChanged": "restart",
"clangd.arguments": [
"--all-scopes-completion",
"--compile-commands-dir=${workspaceFolder}/build/circt",
"--compile-commands-dir=${workspaceFolder}/build/${workspaceFolderBasename}",
"--header-insertion=never",
"--clang-tidy",
"--pch-storage=memory"
Expand Down
16 changes: 8 additions & 8 deletions .devcontainer/default/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Reference: https://containers.dev/implementors/json_reference/
{
"name": "CIRCT",
"dockerFile": "Dockerfile",
"runArgs": [
// Allow the processes in the container to attach a debugger
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],

// Allow the processes in the container to attach a debugger
"capAdd": [ "SYS_PTRACE" ],
"securityOpt": [ "seccomp=unconfined" ],

"mounts": [
// VSCode settings in Docker need to be different from the host machine
"source=${localWorkspaceFolder}/.devcontainer/default/VSCode,target=${containerWorkspaceFolder}/.vscode,type=bind",
Expand All @@ -18,7 +18,7 @@
],
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
"PATH": "${containerWorkspaceFolder}/build/circt/bin:${containerEnv:PATH}"
"PATH": "${containerWorkspaceFolder}/build/${containerWorkspaceFolderBasename}/bin:${containerEnv:PATH}"
},
"customizations": {
"vscode": {
Expand All @@ -33,7 +33,7 @@
],
"settings": {
// This must be set in devcontainer.json because it must be an absolute path and thus cannot use `${workspaceFolder}` if defined in `settings.json`
"mlir.server_path": "${containerWorkspaceFolder}/build/circt/bin/circt-lsp-server"
"mlir.server_path": "${containerWorkspaceFolder}/build/${containerWorkspaceFolderBasename}/bin/circt-lsp-server"
}
}
}
Expand Down

0 comments on commit 9fc3974

Please sign in to comment.