I using gn
for generating ninja
files, and ninja to build them, but I cannot achieve one thing in specific I want to copy/move my builded libs to given path.
In gn
doku I found things as output_dir
or copy
but using them I can only place libs inside gn
building directory, but I want to place them outside of that directory. Any knows how to specify this directory without any limitations ?
Asked
Active
Viewed 61 times
0

AnDevi
- 67
- 7
1 Answers
0
What you're talking about sounds a little like an "install" step, to move files around to places you want them after your build has fully completed.
Sorry to say it, but you can't do that from inside of GN and have GN know about it. GN is an "out-of-source" build system and you've discovered one of its core constraints: GN refuses to let you create target outputs outside of your build root.
You do have a few options, though-
- Invoke GN from a script that does your build and copies the things you care about after the build succeeds.
- Create custom action targets inside your GN builds that copy files to wherever you want, and use "proxy" in-build-root timestamp files as outputs. When your action copies files to wherever you want them, it also touches an empty file inside your build tree that GN does know about.
- Do things the "GN way", and put a "bin" (or similar) directory inside of your build root. GN likes having multiple top-level configuration directories; in our current project I have
out/dbg
,out/rel
, etc, and each one is a separate GN configuration. Inside of each root we have abin
directory:out/dbg/bin
,out/rel/bin
, and that's where we tell GN to put final binaries.
For a while, we did #1, but in the end it was less friction to go to #3. If I absolutely needed to do it, though, I'd probably explore #2. At least that way the copy-out action is managed by GN + Ninja and dirty/clean is managed by ninja and your proxy timestamp file.

Charles Nicholson
- 888
- 1
- 8
- 21