From 85c5662dbc4bc9bd541544d95de252d971870f7a Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 10:35:14 +0200 Subject: [PATCH 1/8] vendor: add lexbor deps submodule --- .gitignore | 1 - .gitmodules | 3 +++ vendor/lexbor | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 vendor/lexbor diff --git a/.gitignore b/.gitignore index 4f05ca29..4c82b07c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ zig-cache zig-out -vendor \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..cb09976a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/lexbor"] + path = vendor/lexbor + url = https://github.com/lexbor/lexbor diff --git a/vendor/lexbor b/vendor/lexbor new file mode 160000 index 00000000..b2c0a617 --- /dev/null +++ b/vendor/lexbor @@ -0,0 +1 @@ +Subproject commit b2c0a617f3f3ccbef9b51aa8910711b75c45f903 From 257d0337f08770699c3f003cffcf4dfbd7c9d240 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 13:54:16 +0200 Subject: [PATCH 2/8] build: lexbor is now under vendor/ --- build.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 62c4e783..56649a37 100644 --- a/build.zig +++ b/build.zig @@ -76,7 +76,7 @@ fn common( fn linkLexbor(step: *std.build.LibExeObjStep) void { // cmake . -DLEXBOR_BUILD_SHARED=OFF - const lib_path = "../lexbor/liblexbor_static.a"; + const lib_path = "vendor/lexbor/liblexbor_static.a"; step.addObjectFile(lib_path); - step.addIncludePath("../lexbor/source"); + step.addIncludePath("vendor/lexbor/source"); } From 4124b6e4c063d5f1b7bbe32008297aefdcc07cf3 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 10:25:09 +0200 Subject: [PATCH 3/8] readme: add install instructions --- Makefile | 31 +++++++++++++++++++++++++ README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 README.md diff --git a/Makefile b/Makefile index 04f39d6e..c1397aaf 100644 --- a/Makefile +++ b/Makefile @@ -45,3 +45,34 @@ test: @printf "\e[36mTesting...\e[0m\n" @zig build test -Dengine=v8 || (printf "\e[33mTest ERROR\e[0m\n"; exit 1;) @printf "\e[33mTest OK\e[0m\n" + +# Install and build required dependencies commands +# ------------ +.PHONY: install-submodule +.PHONY: install-lexbor install-jsruntime install-jsruntime-dev +.PHONY: install-dev install + +## Install and build dependencies for release +install: install-submodule install-lexbor install-jsruntime + +## Install and build dependencies for dev +install-dev: install-submodule install-lexbor install-jsruntime-dev + +## Install and build v8 engine for dev +install-lexbor: + @cd vendor/lexbor && \ + cmake . -DLEXBOR_BUILD_TESTS=ON -DLEXBOR_BUILD_EXAMPLES=ON && \ + make + +install-jsruntime-dev: + @cd vendor/jsruntime-lib && \ + make install-dev + +install-jsruntime: + @cd vendor/jsruntime-lib && \ + make install + +## Init and update git submodule +install-submodule: + @git submodule init && \ + git submodule update diff --git a/README.md b/README.md new file mode 100644 index 00000000..a8d87e54 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Browsercore + +## Build + +### Prerequisites + +Browsercore is written with [Zig](https://ziglang.org/) `0.10.1`. You have to +install it with the right version in order to build the project. + +Browsercore also depends on +[js-runtimelib](https://github.com/francisbouvier/jsruntime-lib/) and +[lexbor](https://github.com/lexbor/lexbor) libs. + +To be able to build the v8 engine for js-runtimelib, you have to install some libs: + +For Debian/Ubuntu based Linux: +``` +sudo apt install xz-utils \ + python3 ca-certificates git \ + pkg-config libglib2.0-dev \ + cmake +``` + +For MacOS, you only need Python 3 and cmake. + +To be able to build lexbor, you need to install also `cmake`. + +### Install and build dependencies + +The project uses git submodule for dependencies. +The `make install-submodule` will init and update the submodules in the `vendor/` +directory. + +``` +make install-submodule +``` + +### Build lexbor + +The command `make install-lexbor` will build lexbor lib used by browsercore. +``` +make install-lexbor +``` + +### Build jsruntime-lib + +The command `make install-jsruntime-dev` uses jsruntime-lib's `zig-v8` dependency to build v8 engine lib. +Be aware the build task is very long and cpu consuming. + +Build v8 engine for debug/dev version, it creates +`vendor/jsruntime-lib/vendor/v8/$ARCH/debug/libc_v8.a` file. + +``` +make install-jsruntime-dev +``` + +You should also build a release vesion of v8 with: + +``` +make install-jsruntime +``` + +### All in one build + +You can run `make intall` and `make install-dev` to install deps all in one. + +## Test + +You can test browsercore by running `make test`. From 2df7a542e7bb7ea05c8c0d940fa8e33bdd196705 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 14:13:46 +0200 Subject: [PATCH 4/8] vendor: add jsruntime-lib submodule --- .gitmodules | 3 +++ vendor/jsruntime-lib | 1 + 2 files changed, 4 insertions(+) create mode 160000 vendor/jsruntime-lib diff --git a/.gitmodules b/.gitmodules index cb09976a..55f0b4b8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/lexbor"] path = vendor/lexbor url = https://github.com/lexbor/lexbor +[submodule "vendor/jsruntime-lib"] + path = vendor/jsruntime-lib + url = https://github.com/francisbouvier/jsruntime-lib diff --git a/vendor/jsruntime-lib b/vendor/jsruntime-lib new file mode 160000 index 00000000..a0832359 --- /dev/null +++ b/vendor/jsruntime-lib @@ -0,0 +1 @@ +Subproject commit a083235918ee1b2c26b9408f4e0e051b7a51e6a1 From 999e1747bbc931d156faed4a6eae0ca24a6a5ee5 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 14:47:05 +0200 Subject: [PATCH 5/8] make: improve lexbor build options --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c1397aaf..c38fba8d 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ install-dev: install-submodule install-lexbor install-jsruntime-dev ## Install and build v8 engine for dev install-lexbor: @cd vendor/lexbor && \ - cmake . -DLEXBOR_BUILD_TESTS=ON -DLEXBOR_BUILD_EXAMPLES=ON && \ + cmake . -DLEXBOR_BUILD_SHARED=OFF -DLEXBOR_BUILD_STATIC=ON -DLEXBOR_BUILD_TESTS_CPP=OFF -DLEXBOR_INSTALL_HEADERS=OFF && \ make install-jsruntime-dev: From 8d82bf0434713a7623a8873c22eae3251c5d953b Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 15:03:06 +0200 Subject: [PATCH 6/8] vendor: remove vendor/lexbor submodule --- .gitmodules | 3 --- vendor/lexbor | 1 - 2 files changed, 4 deletions(-) delete mode 160000 vendor/lexbor diff --git a/.gitmodules b/.gitmodules index 55f0b4b8..10d64d5f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "vendor/lexbor"] - path = vendor/lexbor - url = https://github.com/lexbor/lexbor [submodule "vendor/jsruntime-lib"] path = vendor/jsruntime-lib url = https://github.com/francisbouvier/jsruntime-lib diff --git a/vendor/lexbor b/vendor/lexbor deleted file mode 160000 index b2c0a617..00000000 --- a/vendor/lexbor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b2c0a617f3f3ccbef9b51aa8910711b75c45f903 From 3bfefcb0471c503ed354bef85997a0c9d36851e2 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 15:14:23 +0200 Subject: [PATCH 7/8] vendor: seperate lexbor source from build * add `vendor/lexbor-src` submodule * build lexbor static lib into `vendor/lexbor` --- .gitignore | 1 + .gitmodules | 3 +++ Makefile | 3 ++- build.zig | 2 +- vendor/lexbor-src | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) create mode 160000 vendor/lexbor-src diff --git a/.gitignore b/.gitignore index 4c82b07c..f78e00fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ zig-cache zig-out +/vendor/lexbor/ diff --git a/.gitmodules b/.gitmodules index 10d64d5f..26181de6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/jsruntime-lib"] path = vendor/jsruntime-lib url = https://github.com/francisbouvier/jsruntime-lib +[submodule "vendor/lexbor-src"] + path = vendor/lexbor-src + url = https://github.com/lexbor/lexbor diff --git a/Makefile b/Makefile index c38fba8d..461e0812 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,9 @@ install-dev: install-submodule install-lexbor install-jsruntime-dev ## Install and build v8 engine for dev install-lexbor: + @mkdir -p vendor/lexbor @cd vendor/lexbor && \ - cmake . -DLEXBOR_BUILD_SHARED=OFF -DLEXBOR_BUILD_STATIC=ON -DLEXBOR_BUILD_TESTS_CPP=OFF -DLEXBOR_INSTALL_HEADERS=OFF && \ + cmake ../lexbor-src -DLEXBOR_BUILD_SHARED=OFF -DLEXBOR_BUILD_STATIC=ON -DLEXBOR_BUILD_TESTS_CPP=OFF -DLEXBOR_INSTALL_HEADERS=ON && \ make install-jsruntime-dev: diff --git a/build.zig b/build.zig index 56649a37..0baab40b 100644 --- a/build.zig +++ b/build.zig @@ -78,5 +78,5 @@ fn linkLexbor(step: *std.build.LibExeObjStep) void { // cmake . -DLEXBOR_BUILD_SHARED=OFF const lib_path = "vendor/lexbor/liblexbor_static.a"; step.addObjectFile(lib_path); - step.addIncludePath("vendor/lexbor/source"); + step.addIncludePath("vendor/lexbor-src/source"); } diff --git a/vendor/lexbor-src b/vendor/lexbor-src new file mode 160000 index 00000000..b2c0a617 --- /dev/null +++ b/vendor/lexbor-src @@ -0,0 +1 @@ +Subproject commit b2c0a617f3f3ccbef9b51aa8910711b75c45f903 From cda5b2029f403e778fa35b2a15212acebb451c18 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 1 Sep 2023 17:29:31 +0200 Subject: [PATCH 8/8] make: build lexbor the way commented in `build.zig` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 461e0812..d40f686d 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ install-dev: install-submodule install-lexbor install-jsruntime-dev install-lexbor: @mkdir -p vendor/lexbor @cd vendor/lexbor && \ - cmake ../lexbor-src -DLEXBOR_BUILD_SHARED=OFF -DLEXBOR_BUILD_STATIC=ON -DLEXBOR_BUILD_TESTS_CPP=OFF -DLEXBOR_INSTALL_HEADERS=ON && \ + cmake ../lexbor-src -DLEXBOR_BUILD_SHARED=OFF && \ make install-jsruntime-dev: