mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 06:33:29 +00:00
Fix dockerfile (hopefully)
Add dummy --json stats output to tests Comment typos fixed Add make get-v8, build-v8 and build-v8-dev make targets
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,4 +4,4 @@ zig-out
|
||||
/vendor/netsurf/out
|
||||
/vendor/libiconv/
|
||||
lightpanda.id
|
||||
v8/
|
||||
/v8/
|
||||
|
||||
@@ -61,8 +61,8 @@ RUN make install-libiconv && \
|
||||
|
||||
# download and install v8
|
||||
RUN curl --fail -L -o libc_v8.a https://github.com/lightpanda-io/zig-v8-fork/releases/download/${ZIG_V8}/libc_v8_${V8}_linux_${ARCH}.a && \
|
||||
mkdir -p vendor/zig-js-runtime/vendor/v8/${ARCH}-linux/release && \
|
||||
mv libc_v8.a vendor/zig-js-runtime/vendor/v8/${ARCH}-linux/release/libc_v8.a
|
||||
mkdir -p v8/build/${ARCH}-linux/release/ninja/obj/zig/ && \
|
||||
mv libc_v8.a v8/build/${ARCH}-linux/release/ninja/obj/zig/libc_v8.a
|
||||
|
||||
# build release
|
||||
RUN make build
|
||||
|
||||
15
Makefile
15
Makefile
@@ -47,7 +47,7 @@ help:
|
||||
|
||||
# $(ZIG) commands
|
||||
# ------------
|
||||
.PHONY: build build-dev run run-release shell test bench download-zig wpt data
|
||||
.PHONY: build build-dev run run-release shell test bench download-zig wpt data get-v8 build-v8 build-v8-dev
|
||||
|
||||
zig_version = $(shell grep 'recommended_zig_version = "' "vendor/zig-js-runtime/build.zig" | cut -d'"' -f2)
|
||||
|
||||
@@ -94,6 +94,19 @@ wpt-summary:
|
||||
test:
|
||||
@TEST_FILTER='${F}' $(ZIG) build test -freference-trace --summary all
|
||||
|
||||
## v8
|
||||
get-v8:
|
||||
@printf "\e[36mGetting v8 source...\e[0m\n"
|
||||
@$(ZIG) build get-v8
|
||||
|
||||
build-v8-dev:
|
||||
@printf "\e[36mBuilding v8 (dev)...\e[0m\n"
|
||||
@$(ZIG) build build-v8
|
||||
|
||||
build-v8:
|
||||
@printf "\e[36mBuilding v8...\e[0m\n"
|
||||
@$(ZIG) build -Doptimize=ReleaseSafe build-v8
|
||||
|
||||
# Install and build required dependencies commands
|
||||
# ------------
|
||||
.PHONY: install-submodule
|
||||
|
||||
@@ -221,15 +221,17 @@ env var `MIMALLOC_SHOW_STATS=1`. See
|
||||
First, get the tools necessary for building V8, as well as the V8 source code:
|
||||
|
||||
```
|
||||
zig build get-v8
|
||||
make get-v8
|
||||
```
|
||||
|
||||
Next, build v8. This build task is very long and cpu consuming, as you will build v8 from sources.
|
||||
|
||||
```
|
||||
zig build build-v8
|
||||
make build-v8-dev
|
||||
```
|
||||
|
||||
For dev env, use `make build-v8-dev`.
|
||||
|
||||
## Test
|
||||
|
||||
### Unit Tests
|
||||
|
||||
@@ -129,7 +129,6 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
|
||||
var prototype_index = i;
|
||||
const Struct = @field(types, s.name);
|
||||
if (@hasDecl(Struct, "prototype")) {
|
||||
prototype_index = 1;
|
||||
const TI = @typeInfo(Struct.prototype);
|
||||
const proto_name = @typeName(Receiver(TI.pointer.child));
|
||||
prototype_index = @field(TYPE_LOOKUP, proto_name);
|
||||
@@ -776,8 +775,8 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
|
||||
scope_arena: ArenaAllocator,
|
||||
|
||||
// When we need to load a resource (i.e. an external script), we call
|
||||
// this function to get the source. This is always a refernece to the
|
||||
// Browser Session's fetchModuleSource, but we use a funciton pointer
|
||||
// this function to get the source. This is always a reference to the
|
||||
// Browser Session's fetchModuleSource, but we use a function pointer
|
||||
// since this js module is decoupled from the browser implementation.
|
||||
module_loader: ModuleLoader,
|
||||
|
||||
@@ -931,7 +930,7 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
|
||||
|
||||
// To turn a Zig instance into a v8 object, we need to do a number of things.
|
||||
// First, if it's a struct, we need to put it on the heap
|
||||
// Second, if we've alrady returned this instance, we should return
|
||||
// Second, if we've already returned this instance, we should return
|
||||
// the same object. Hence, our executor maintains a map of Zig objects
|
||||
// to v8.PersistentObject (the "identity_map").
|
||||
// Finally, if this is the first time we've seen this instance, we need to:
|
||||
|
||||
@@ -46,6 +46,19 @@ pub fn main() !void {
|
||||
var slowest = SlowTracker.init(allocator, 5);
|
||||
defer slowest.deinit();
|
||||
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
defer args.deinit();
|
||||
|
||||
// ignore the exec name.
|
||||
_ = args.next();
|
||||
var json_stats = false;
|
||||
while (args.next()) |arg| {
|
||||
if (std.mem.eql(u8, "--json", arg)) {
|
||||
json_stats = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var pass: usize = 0;
|
||||
var fail: usize = 0;
|
||||
var skip: usize = 0;
|
||||
@@ -155,6 +168,37 @@ pub fn main() !void {
|
||||
printer.fmt("\n", .{});
|
||||
try slowest.display(printer);
|
||||
printer.fmt("\n", .{});
|
||||
|
||||
// TODO: at the very least, `browser` should return real stats
|
||||
if (json_stats) {
|
||||
try std.json.stringify(&.{
|
||||
.{ .name = "browser", .bench = .{
|
||||
.duration = 3180096049,
|
||||
.alloc_nb = 6,
|
||||
.realloc_nb = 278,
|
||||
.alloc_size = 24711226,
|
||||
} },
|
||||
.{ .name = "libdom", .bench = .{
|
||||
.duration = 3180096049,
|
||||
.alloc_nb = 0,
|
||||
.realloc_nb = 0,
|
||||
.alloc_size = 0,
|
||||
} },
|
||||
.{ .name = "v8", .bench = .{
|
||||
.duration = 3180096049,
|
||||
.alloc_nb = 0,
|
||||
.realloc_nb = 0,
|
||||
.alloc_size = 0,
|
||||
} },
|
||||
.{ .name = "main", .bench = .{
|
||||
.duration = 3180096049,
|
||||
.alloc_nb = 0,
|
||||
.realloc_nb = 0,
|
||||
.alloc_size = 0,
|
||||
} },
|
||||
}, .{ .whitespace = .indent_2 }, std.io.getStdOut().writer());
|
||||
}
|
||||
|
||||
std.posix.exit(if (fail == 0) 0 else 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user