From 4173b03f546d48b15ad900367a21e82a01802858 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 14 Sep 2021 02:21:40 -0700 Subject: [PATCH] Include a build id --- Makefile | 5 +++++ build-id | 1 + src/global.zig | 2 ++ src/http.zig | 10 +++++++--- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 build-id diff --git a/Makefile b/Makefile index 8abe17d0c816a..e35fe3809c731 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,11 @@ jsc-bindings-headers: mkdir -p src/JavaScript/jsc/bindings-obj/ zig build headers +bump: + expr $(BUILD_ID) + 1 > build-id + +BUILD_ID := $(shell cat ./build-id) + jsc-copy-headers: find src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/JavaScriptCore \; diff --git a/build-id b/build-id new file mode 100644 index 0000000000000..45a4fb75db864 --- /dev/null +++ b/build-id @@ -0,0 +1 @@ +8 diff --git a/src/global.zig b/src/global.zig index 38ceac9164e42..55ffbc55bbd40 100644 --- a/src/global.zig +++ b/src/global.zig @@ -384,6 +384,8 @@ pub const Output = struct { }; pub const Global = struct { + pub const build_id = std.fmt.parseInt(u64, @embedFile("../build-id"), 10) catch unreachable; + pub fn panic(comptime fmt: string, args: anytype) noreturn { @setCold(true); if (comptime isWasm) { diff --git a/src/http.zig b/src/http.zig index a38a50c46a036..b6a14357b1578 100644 --- a/src/http.zig +++ b/src/http.zig @@ -2538,25 +2538,29 @@ pub const Server = struct { if (std.mem.readIntNative(u32, &addr.ipv4.host.octets) == 0 or std.mem.readIntNative(u128, &addr.ipv6.host.octets) == 0) { if (server.bundler.options.routes.single_page_app_routing) { Output.prettyError( - " Bun!!\n\n\n Link: http://localhost:{d}\n ./{s}/index.html \n\n\n", + " Bun!! build {d}\n\n\n Link: http://localhost:{d}\n ./{s}/index.html \n\n\n", .{ + Global.build_id, addr.ipv4.port, resolve_path.relative(server.bundler.fs.top_level_dir, server.bundler.options.routes.static_dir), }, ); } else { - Output.prettyError(" Bun!!\n\n\n Link: http://localhost:{d}\n\n\n", .{ + Output.prettyError(" Bun!! build {d}\n\n\n Link: http://localhost:{d}\n\n\n", .{ + Global.build_id, addr.ipv4.port, }); } } else { if (server.bundler.options.routes.single_page_app_routing) { Output.prettyError(" Bun!!\n\n\n Link: http://{s}\n ./{s}/index.html \n\n\n", .{ + Global.build_id, addr, resolve_path.relative(server.bundler.fs.top_level_dir, server.bundler.options.routes.static_dir), }); } else { - Output.prettyError(" Bun!!\n\n\n Link: http://{s}\n\n\n", .{ + Output.prettyError(" Bun!! build {d}\n\n\n Link: http://{s}\n\n\n", .{ + Global.build_id, addr, }); }