Adding V8 as a GN dependency

106 views
Skip to first unread message

Dan Farley

unread,
Jan 5, 2022, 12:09:38 AM1/5/22
to v8-users
Hopefully this isn't off topic since it's more about GN than V8, but figured y'all might have some ideas.

We're using GN as our build system for a project which embeds V8. Right now have the V8 repo living under our project's repo at /depot/vendor/v8. We build the V8 static library separately (using Make) and then link it into our project using GN: 

executable("foo") {
libs = [ "/depot/vendor/v8/out.gn/x64.release/obj/libwee8.a" ]
}

I'd like to do it "correctly" and add V8 as a dependency to our project via GN, but I'm unsure how to do it without mucking around in V8's BUILD.gn files too much. I tried directly adding V8 as a dependency:
executable("foo") {
deps = [ "//vendor/v8:wee8" ]
}

But then get an error about missing files under //build:
$ gn gen  /depot/out/Default ...
ERROR at //vendor/v8/BUILD.gn:5:1: Can't load input file.
import("//build/config/arm.gni")
^------------------------------
Unable to load:
  /depot/build/config/arm.gni


It should be looking at /depot/vendor/v8/build/config/arm.gni instead.
To my unfamiliar eye it seems like V8 expects itself to be the root of the project, not in a sub-directory.

Is there any way to tell the V8 targets that it should "rebase" its file references and whatnot into its sub-directory without making edits to V8's BUILD.gn files directly? It'd make upgrading V8 a pain if we have to apply a bunch of build modifications on top of it.

Thanks so much!

dcer...@gmail.com

unread,
Jan 6, 2022, 1:55:02 PM1/6/22
to v8-users
Perhaps you should be building the V8 repo with GN (not Make) as a submodule of your git project.

There are two scripts in the V8 repo that do the heavy lifting:
v8gen.py (generates build files from configs)
gm.py (runs the resulting build and most importantly installs all the resulting artifacts in the right places)

I worked on a project recently that had forked V8 and built in a separate project and then imported the static library, etc into a CMAKE build that did not use submodules.
That was very hard to maintain.


Dan Farley

unread,
Jan 10, 2022, 1:10:56 PM1/10/22
to v8-users
Sorry I should have explained the setup a little better.
I'm not using Make itself to build V8 (or my own project), but we use Make as an outer wrapper around GN calls for convenience. 

So our current build ends up doing something like this:
# make -C /depot/vendor/v8
/depot/vendor/v8 $ gn gen out.gn/x64.release
/depot/vendor/v8 $ ninja -C out.gn/x64.release
# make -C /depot/foo
/depot/foo $ gn gen /depot/out/Default ...
/depot/foo $ ninja -C /depot/out/Default ...

I want to eliminate the Make component entirely and have V8 be built as a proper dependency in the larger GN project.
That's why I tried to add V8 as a deps target to our project. But that doesn't seem to be working because of the error in my original message.



Reply all
Reply to author
Forward
0 new messages