Skip to content

Commit

Permalink
[nfc] 08/10/24 Build/Docs cleanup
Browse files Browse the repository at this point in the history
- Emphasize that building on macOS requires Xcode.
- Clean up Windows dependency script, the workaround is no longer needed.
- Fix cargo-culted comment in encoding-test.js
- Drop unused perfetto dependency for node target
- Mark a few classes as final, expand anonymous namespace usage.
  • Loading branch information
fhanau committed Aug 10, 2024
1 parent 6152883 commit 3789627
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ To build `workerd`, you need:
* LLD 15+ (e.g. package `lld-15`). The build may still succeed if a recent version of GNU gold or the system linker is installed, but lld is highly recommended for link performance.
* `python3`, `python3-distutils`, and `tcl8.6`
* On macOS:
* Xcode 15 installation (available on macOS 13 and higher)
* Xcode 15 installation (available on macOS 13 and higher). Full Xcode is required, the Xcode command line tools alone are not sufficient for building.
* Homebrew installed `tcl-tk` package (provides Tcl 8.6)
* On Windows:
* Install [App Installer](https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget)
Expand Down
8 changes: 4 additions & 4 deletions src/workerd/api/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Decoder {
};

// Decoder implementation that provides a fast-track for US-ASCII.
class AsciiDecoder: public Decoder {
class AsciiDecoder final: public Decoder {
public:
AsciiDecoder() = default;
AsciiDecoder(AsciiDecoder&&) = default;
Expand All @@ -94,7 +94,7 @@ class AsciiDecoder: public Decoder {
// Decoder implementation that uses ICU's built-in conversion APIs.
// ICU's decoder is fairly comprehensive, covering the full range
// of encodings required by the Encoding specification.
class IcuDecoder: public Decoder {
class IcuDecoder final: public Decoder {
public:
IcuDecoder(Encoding encoding, UConverter* converter, bool ignoreBom)
: encoding(encoding), inner(converter), ignoreBom(ignoreBom), bomSeen(false) {}
Expand Down Expand Up @@ -126,7 +126,7 @@ class IcuDecoder: public Decoder {

// Implements the TextDecoder interface as prescribed by:
// https://encoding.spec.whatwg.org/#interface-textdecoder
class TextDecoder: public jsg::Object {
class TextDecoder final: public jsg::Object {
public:
using DecoderImpl = kj::OneOf<AsciiDecoder, IcuDecoder>;

Expand Down Expand Up @@ -191,7 +191,7 @@ class TextDecoder: public jsg::Object {

// Implements the TextEncoder interface as prescribed by:
// https://encoding.spec.whatwg.org/#interface-textencoder
class TextEncoder: public jsg::Object {
class TextEncoder final: public jsg::Object {
public:
struct EncodeIntoResult {
int read;
Expand Down
8 changes: 4 additions & 4 deletions src/workerd/api/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace workerd::api {

struct QueueResponse;

class Headers: public jsg::Object {
class Headers final: public jsg::Object {
private:
template <typename T>
struct IteratorState {
Expand Down Expand Up @@ -760,7 +760,7 @@ struct RequestInitializerDict {
});
};

class Request: public Body {
class Request final: public Body {
public:
enum class Redirect {
FOLLOW,
Expand Down Expand Up @@ -985,7 +985,7 @@ class Request: public Body {
}
};

class Response: public Body {
class Response final: public Body {
public:
enum class BodyEncoding {
AUTO,
Expand Down Expand Up @@ -1200,7 +1200,7 @@ class Response: public Body {
}
};

class FetchEvent: public ExtendableEvent {
class FetchEvent final: public ExtendableEvent {
public:
FetchEvent(jsg::Ref<Request> request)
: ExtendableEvent("fetch"), request(kj::mv(request)),
Expand Down
1 change: 0 additions & 1 deletion src/workerd/api/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ wd_cc_library(
srcs = glob(["**/*.c++"], exclude = ["**/*-test.c++"]),
hdrs = glob(["**/*.h"]),
implementation_deps = [
"//src/workerd/util:perfetto",
"@capnp-cpp//src/kj/compat:kj-brotli",
"@capnp-cpp//src/kj/compat:kj-gzip",
"@simdutf",
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/streams/internal.c++
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kj::Promise<void> pumpTo(ReadableStreamSource& input, WritableStreamSink& output
}

// Modified from AllReader in kj/async-io.c++.
class AllReader {
class AllReader final {
public:
explicit AllReader(ReadableStreamSource& input, uint64_t limit)
: input(input), limit(limit) {
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/streams/readable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace workerd::api {
class ReadableStreamDefaultReader;
class ReadableStreamBYOBReader;

class ReaderImpl {
class ReaderImpl final {
public:
ReaderImpl(ReadableStreamController::Reader& reader);

Expand Down
10 changes: 6 additions & 4 deletions src/workerd/api/streams/standard.c++
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace workerd::api {
using DefaultController = jsg::Ref<ReadableStreamDefaultController>;
using ByobController = jsg::Ref<ReadableByteStreamController>;

namespace {
struct ValueReadable;
struct ByteReadable;
}

// =======================================================================================
// The Unlocked, Locked, ReaderLocked, and WriterLocked structs
Expand Down Expand Up @@ -80,7 +82,7 @@ public:
}

private:
class PipeLocked: public PipeController {
class PipeLocked final: public PipeController {
public:
explicit PipeLocked(Controller& inner, jsg::Ref<WritableStream> ref)
: inner(inner), writableStreamRef(kj::mv(ref)) {}
Expand Down Expand Up @@ -652,7 +654,7 @@ jsg::Promise<ReadResult> deferControllerStateChange(
// jsg::Ref<ReadableStreamDefaultController> or jsg::Ref<ReadableByteStreamController>.
// These are the objects that are actually passed on to the user-code's Underlying Source
// implementation.
class ReadableStreamJsController: public ReadableStreamController {
class ReadableStreamJsController final: public ReadableStreamController {
public:
using ReadableLockImpl = ReadableLockImpl<ReadableStreamJsController>;

Expand Down Expand Up @@ -791,7 +793,7 @@ private:
// The WritableStreamJsController provides the implementation of custom
// WritableStream's backed by a user-code provided Underlying Sink. The implementation
// is fairly complicated and defined entirely by the streams specification.
class WritableStreamJsController: public WritableStreamController {
class WritableStreamJsController final: public WritableStreamController {
public:
using WritableLockImpl = WritableLockImpl<WritableStreamJsController>;

Expand Down Expand Up @@ -1680,7 +1682,6 @@ struct ReadableState {
return ReadableState(controller.addRef(), consumer->clone(js, listener), owner);
}
};
} // namespace

struct ValueReadable final: private api::ValueQueue::ConsumerImpl::StateListener {

Expand Down Expand Up @@ -1952,6 +1953,7 @@ struct ByteReadable final: private api::ByteQueue::ConsumerImpl::StateListener {
return state.map([](State& state) { return state.controller.addRef(); });
}
};
} // namespace

// =======================================================================================

Expand Down
4 changes: 2 additions & 2 deletions src/workerd/api/tests/encoding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
ok,
} from 'node:assert';

// Test for the Event and EventTarget standard Web API implementations.
// The implementation for these are in api/basics.{h|c++}
// Test for the Encoding standard Web API implementation.
// The implementation for these are in api/encoding.{h|c++}

function decodeStreaming(decoder, input) {
// Test truncation behavior while streaming by feeding the decoder a single byte at a time.
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/io/io-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class WarningAggregator final: public kj::AtomicRefcounted {
// heuristic approximation, we attribute each subrequest (and all other forms of resource
// usage) to the "current" incoming request, which is defined as the newest request that hasn't
// already completed.
class IoContext_IncomingRequest {
class IoContext_IncomingRequest final {
public:
IoContext_IncomingRequest(kj::Own<IoContext> context,
kj::Own<IoChannelFactory> ioChannelFactory,
Expand Down
8 changes: 7 additions & 1 deletion src/workerd/server/workerd-api.c++
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace workerd::server {

using api::pyodide::PythonConfig;

namespace {
JSG_DECLARE_ISOLATE_TYPE(JsgWorkerdIsolate,
// Declares the listing of host object types and structs that the jsg
// automatic type mapping will understand. Each of the various
Expand Down Expand Up @@ -124,8 +125,9 @@ static PythonConfig defaultConfig {
.createSnapshot = false,
.createBaselineSnapshot = false,
};
}

struct WorkerdApi::Impl {
struct WorkerdApi::Impl final {
kj::Own<CompatibilityFlags::Reader> features;
kj::Maybe<kj::Own<jsg::modules::ModuleRegistry>> maybeOwnedModuleRegistry;
JsgWorkerdIsolate jsgIsolate;
Expand Down Expand Up @@ -436,6 +438,7 @@ kj::Maybe<jsg::ModuleRegistry::ModuleInfo> WorkerdApi::tryCompileModule(
KJ_UNREACHABLE;
}

namespace {
kj::Path getPyodideBundleFileName(kj::StringPtr version) {
return kj::Path(kj::str("pyodide-", version, ".capnp.bin"));
}
Expand Down Expand Up @@ -522,6 +525,7 @@ bool fetchPyodideBundle(const api::pyodide::PythonConfig& pyConfig, kj::StringPt
return true;

}
}

void WorkerdApi::compileModules(
jsg::Lock& lockParam, config::Worker::Reader conf,
Expand Down Expand Up @@ -670,6 +674,7 @@ void WorkerdApi::compileModules(
});
}

namespace {
static v8::Local<v8::Value> createBindingValue(
JsgWorkerdIsolate::Lock& lock,
const WorkerdApi::Global& global,
Expand Down Expand Up @@ -820,6 +825,7 @@ static v8::Local<v8::Value> createBindingValue(

return value;
}
}

void WorkerdApi::compileGlobals(
jsg::Lock& lockParam, kj::ArrayPtr<const Global> globals,
Expand Down
4 changes: 3 additions & 1 deletion src/workerd/server/workerd.c++
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include <workerd/util/use-perfetto-categories.h>

namespace workerd::server {
namespace {

static kj::StringPtr getVersionString() {
static const kj::String result = kj::str("workerd ", SUPPORTED_COMPATIBILITY_DATE);
Expand Down Expand Up @@ -609,7 +610,7 @@ private:

// =======================================================================================

class CliMain: public SchemaFileImpl::ErrorReporter {
class CliMain final: public SchemaFileImpl::ErrorReporter {
public:
CliMain(kj::ProcessContext& context, char** argv)
: context(context), argv(argv),
Expand Down Expand Up @@ -1513,6 +1514,7 @@ private:
#endif
};

} // namespace
} // namespace workerd::server

int main(int argc, char* argv[]) {
Expand Down
5 changes: 1 addition & 4 deletions src/workerd/tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//:build/cc_ast_dump.bzl", "cc_ast_dump")
load("//:build/run_binary_target.bzl", "run_binary_target")
load("//:build/wd_cc_binary.bzl", "wd_cc_binary")
load("//:build/wd_cc_library.bzl", "wd_cc_library")

# ========================================================================================
# Parameter Name Extractor
Expand All @@ -21,9 +18,9 @@ cc_ast_dump(
}),
deps = [
"//src/workerd/api:html-rewriter",
"//src/workerd/api/node",
"//src/workerd/io",
"//src/workerd/jsg",
"//src/workerd/api/node:node",
"@capnp-cpp//src/capnp",
],
)
Expand Down
8 changes: 3 additions & 5 deletions tools/windows/install-deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ call :AddToUserPathInEnvironment C:\msys64\usr\bin

echo.
echo.* Step 7: Install LLVM compiler toolchain.
@rem workerd is tied to 16.0.6 for the time being (https://github.com/cloudflare/workerd/pull/1092).
winget install "LLVM" --version 16.0.6
@rem Work around for clang / bazel not agreeing on install location, will be fixed by
@rem https://github.com/bazelbuild/bazel/pull/1939.
move "C:\Program Files\LLVM\lib\clang\16" "C:\Program Files\LLVM\lib\clang\16.0.6"
@rem The MSVC build frequently breaks in some ways when the LLVM version is updated, we may have to
@rem manually install a different version again soon.
@rem winget install "LLVM" --version 18.1.8

echo.
echo.* Step 8: Install bazelisk as %LOCALAPPDATA%\Programs\bazelisk\bazel.exe.
Expand Down

0 comments on commit 3789627

Please sign in to comment.