mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #445 from karlseguin/capture_git_commit
Some checks are pending
e2e-test / zig build release (push) Waiting to run
e2e-test / puppeteer (push) Blocked by required conditions
wpt / web platform tests (push) Waiting to run
wpt / perf-fmt (push) Blocked by required conditions
zig-test / zig build dev (push) Waiting to run
zig-test / zig test (push) Waiting to run
zig-test / perf-fmt (push) Blocked by required conditions
Some checks are pending
e2e-test / zig build release (push) Waiting to run
e2e-test / puppeteer (push) Blocked by required conditions
wpt / web platform tests (push) Waiting to run
wpt / perf-fmt (push) Blocked by required conditions
zig-test / zig build dev (push) Waiting to run
zig-test / zig test (push) Waiting to run
zig-test / perf-fmt (push) Blocked by required conditions
Make the the short git SHA available within the program
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
|||||||
- uses: ./.github/actions/install
|
- uses: ./.github/actions/install
|
||||||
|
|
||||||
- name: zig build
|
- name: zig build
|
||||||
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64
|
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
|
||||||
|
|
||||||
- name: Rename binary
|
- name: Rename binary
|
||||||
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
|
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
arch: ${{env.ARCH}}
|
arch: ${{env.ARCH}}
|
||||||
|
|
||||||
- name: zig build
|
- name: zig build
|
||||||
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8
|
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
|
||||||
|
|
||||||
- name: Rename binary
|
- name: Rename binary
|
||||||
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
|
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -59,13 +59,13 @@ download-zig:
|
|||||||
## Build in release-safe mode
|
## Build in release-safe mode
|
||||||
build:
|
build:
|
||||||
@printf "\e[36mBuilding (release safe)...\e[0m\n"
|
@printf "\e[36mBuilding (release safe)...\e[0m\n"
|
||||||
@$(ZIG) build -Doptimize=ReleaseSafe -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
$(ZIG) build -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||||
@printf "\e[33mBuild OK\e[0m\n"
|
@printf "\e[33mBuild OK\e[0m\n"
|
||||||
|
|
||||||
## Build in debug mode
|
## Build in debug mode
|
||||||
build-dev:
|
build-dev:
|
||||||
@printf "\e[36mBuilding (debug)...\e[0m\n"
|
@printf "\e[36mBuilding (debug)...\e[0m\n"
|
||||||
@$(ZIG) build -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
@$(ZIG) build -Dengine=v8 -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||||
@printf "\e[33mBuild OK\e[0m\n"
|
@printf "\e[33mBuild OK\e[0m\n"
|
||||||
|
|
||||||
## Run the server in debug mode
|
## Run the server in debug mode
|
||||||
|
|||||||
@@ -58,6 +58,15 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.optimize = mode,
|
.optimize = mode,
|
||||||
});
|
});
|
||||||
try common(b, exe, options);
|
try common(b, exe, options);
|
||||||
|
{
|
||||||
|
var opt = b.addOptions();
|
||||||
|
opt.addOption(
|
||||||
|
[]const u8,
|
||||||
|
"git_commit",
|
||||||
|
b.option([]const u8, "git_commit", "Current git commit") orelse "dev",
|
||||||
|
);
|
||||||
|
exe.root_module.addImport("build_info", opt.createModule());
|
||||||
|
}
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
// run
|
// run
|
||||||
|
|||||||
18
src/main.zig
18
src/main.zig
@@ -59,6 +59,10 @@ pub fn main() !void {
|
|||||||
|
|
||||||
switch (args.mode) {
|
switch (args.mode) {
|
||||||
.help => args.printUsageAndExit(args.mode.help),
|
.help => args.printUsageAndExit(args.mode.help),
|
||||||
|
.version => {
|
||||||
|
std.debug.print("{s}\n", .{@import("build_info").git_commit});
|
||||||
|
return std.process.cleanExit();
|
||||||
|
},
|
||||||
.serve => |opts| {
|
.serve => |opts| {
|
||||||
const address = std.net.Address.parseIp4(opts.host, opts.port) catch |err| {
|
const address = std.net.Address.parseIp4(opts.host, opts.port) catch |err| {
|
||||||
log.err("address (host:port) {any}\n", .{err});
|
log.err("address (host:port) {any}\n", .{err});
|
||||||
@@ -125,12 +129,14 @@ const Command = struct {
|
|||||||
help,
|
help,
|
||||||
fetch,
|
fetch,
|
||||||
serve,
|
serve,
|
||||||
|
version,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Mode = union(ModeType) {
|
const Mode = union(ModeType) {
|
||||||
help: bool, // false when being printed because of an error
|
help: bool, // false when being printed because of an error
|
||||||
fetch: Fetch,
|
fetch: Fetch,
|
||||||
serve: Serve,
|
serve: Serve,
|
||||||
|
version: void,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Serve = struct {
|
const Serve = struct {
|
||||||
@@ -172,10 +178,13 @@ const Command = struct {
|
|||||||
\\--timeout Inactivity timeout in seconds before disconnecting clients
|
\\--timeout Inactivity timeout in seconds before disconnecting clients
|
||||||
\\ Defaults to 3 (seconds)
|
\\ Defaults to 3 (seconds)
|
||||||
\\
|
\\
|
||||||
|
\\version command
|
||||||
|
\\Displays the version of {s}
|
||||||
|
\\
|
||||||
\\help command
|
\\help command
|
||||||
\\Displays this message
|
\\Displays this message
|
||||||
;
|
;
|
||||||
std.debug.print(usage, .{ self.exec_name, self.exec_name, self.exec_name });
|
std.debug.print(usage, .{ self.exec_name, self.exec_name, self.exec_name, self.exec_name });
|
||||||
if (success) {
|
if (success) {
|
||||||
return std.process.cleanExit();
|
return std.process.cleanExit();
|
||||||
}
|
}
|
||||||
@@ -210,9 +219,10 @@ fn parseArgs(allocator: Allocator) !Command {
|
|||||||
};
|
};
|
||||||
|
|
||||||
cmd.mode = switch (mode) {
|
cmd.mode = switch (mode) {
|
||||||
.help => Command.Mode{ .help = true },
|
.help => .{ .help = true },
|
||||||
.serve => Command.Mode{ .serve = parseServeArgs(allocator, &args) catch return cmd },
|
.serve => .{ .serve = parseServeArgs(allocator, &args) catch return cmd },
|
||||||
.fetch => Command.Mode{ .fetch = parseFetchArgs(allocator, &args) catch return cmd },
|
.fetch => .{ .fetch = parseFetchArgs(allocator, &args) catch return cmd },
|
||||||
|
.version => .{ .version = {} },
|
||||||
};
|
};
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user