Skip to content

Commit

Permalink
Merge pull request #578 from cloudflare/orion-bazelisk-plus
Browse files Browse the repository at this point in the history
Update README.md and docs/vscode.md
  • Loading branch information
ohodson authored Apr 28, 2023
2 parents 0a37335 + ba6531e commit 13b380f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ On other platforms, you may have to do tinkering to make things work.
To build `workerd`, you need:

* [Bazel](https://bazel.build/)
* If you use [Bazelisk](https://github.com/bazelbuild/bazelisk) (recommended), it will automatically download and use the right version of Bazel for building workerd.
* On Linux:
* Clang 11+ (e.g. package `clang` on Debian Bullseye)
* libc++ 11+ (e.g. packages `libc++-dev` and `libc++abi-dev` on Debian Bullseye)
Expand All @@ -89,12 +90,14 @@ To build `workerd`, you need:
* When developing at the command-line, run [bazel-env.bat](tools/windows/bazel-env.bat) in your shell first
to select tools and Windows SDK versions before running bazel.

You may then build using:
You may then build `workerd` at the command-line with:

```
bazel build -c opt //src/workerd/server:workerd
bazel build //src/workerd/server:workerd
```

You can also build from within Visual Studio Code using the instructions in [docs/vscode.md](docs/vscode.md).

The compiled binary will be located at `bazel-bin/src/workerd/server/workerd`.

If you run a Bazel build before you've installed some dependencies (like clang or libc++), and then you install the dependencies, you must resync locally cached toolchains, or clean Bazel's cache, otherwise you might get strange errors:
Expand Down
24 changes: 13 additions & 11 deletions docs/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ A few helpful tips for developing workerd with Visual Studio Code.
We use [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd)
for code completion and diagnostics.

For debugging, you will need the [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).
For debugging, you will need the [Microsoft C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) installed.

The Microsoft C/C++ Intellisense plugin is not compatible with the clangd extension. We recommend disabling the
Microsoft Intellisense extension for this project.
The Microsoft C/C++ extension has IntelliSense support that is not compatible with the clangd extension. We recommend disabling the
Microsoft IntelliSense Engine for this project (`Settings -> C_Cpp.intelliSenseEngine -> disabled`).

## Generate a compile_commands.json file
For clangd to work well, you need to generate a `compile_commands.json` file. This can be done from within VSCode using
`Run Task -> Generate compile_commands.json` or at the command-line:

```sh
# Build workerd to ensure all generated sources are present.
Expand All @@ -32,32 +33,33 @@ https://github.com/cloudflare/workerd/issues/506).

## VSCode Tasks

The [.vscode/tasks.json](../.vscode/tasks.json) file included provides a few useful tasks for use within VSCode:
The [.vscode/tasks.json](../.vscode/tasks.json) file provides a few useful tasks for use within VSCode:

* Bazel build workerd (dbg)
* Bazel build workerd (fastbuild)
* Bazel build workerd (opt)
* Bazel build all (dbg)
* Bazel run all tests
* Generate compile_commands.json
* Generate rust-project.json

## Debugging

There are workerd debugging targets within Visual Studio Code. These
are supported on Linux (x64) and OS X (arm64).
There are workerd debugging targets within Visual Studio Code which are supported on Linux (x64), OS X (arm64), and Windows (x64).

The file [.vscode/launch.json](../.vscode/launch.json) has launch targets to that can be debugged within VSCode.
The [.vscode/launch.json](../.vscode/launch.json) file has launch targets to that can be debugged within VSCode.

Before you start debugging, ensure that you have saved a vscode workspace for workerd,
`File -> Save Workspace As...`, then `Run -> Start Debugging (F5)`.
`File -> Save Workspace As...`, then `Run -> Start Debugging (F5)`. For more information about workspaces, see https://code.visualstudio.com/docs/editor/workspaces.

The main targets of interest are:

* `workerd debug`
* `workerd debug with inspector enabled`
* `workerd test case`

Launching either `workerd debug` or `workerd debug with inspector enabled` will prompt for a workerd configuration to launch
workerd with, the default is `${workspaceFolder}/samples/helloworld/config.capnp`.
Launching either `workerd debug` or `workerd debug with inspector enabled` will prompt for a workerd configuration for
workerd to serve, the default is `${workspaceFolder}/samples/helloworld/config.capnp`.

Launching `workerd test case` will prompt for a test to debug, the default is `bazel-bin/src/workerd/jsg/jsg-test`.

0 comments on commit 13b380f

Please # to comment.