Update CI recipe to build using out/Default output directory.

This should allow us to catch issues where our tests are reliant on
specific relative paths.

Change-Id: Ie712f64d42db9f37d2eeb27a1b5a36b36a6a6964
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/23941
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: Matt Stark <msta@google.com>
diff --git a/infra/recipes/gn.expected/ci_linux.json b/infra/recipes/gn.expected/ci_linux.json
index ecde480..d4c741e 100644
--- a/infra/recipes/gn.expected/ci_linux.json
+++ b/infra/recipes/gn.expected/ci_linux.json
@@ -576,7 +576,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -607,7 +609,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -638,7 +640,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -669,7 +671,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -777,6 +779,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-amd64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -808,7 +812,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -839,7 +843,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -870,7 +874,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -972,7 +976,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1026,6 +1030,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-arm64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1057,7 +1063,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1098,7 +1104,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1152,6 +1158,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-riscv64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1183,7 +1191,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1224,7 +1232,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
diff --git a/infra/recipes/gn.expected/ci_mac.json b/infra/recipes/gn.expected/ci_mac.json
index 2893a86..b4a0ff6 100644
--- a/infra/recipes/gn.expected/ci_mac.json
+++ b/infra/recipes/gn.expected/ci_mac.json
@@ -310,7 +310,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -341,7 +343,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -372,7 +374,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -403,7 +405,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -502,7 +504,9 @@
       "-u",
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -533,7 +537,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -564,7 +568,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -595,7 +599,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -635,7 +639,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/mac-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/mac-amd64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -742,7 +746,9 @@
       "-u",
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -773,7 +779,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -814,7 +820,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/mac-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/mac-arm64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
diff --git a/infra/recipes/gn.expected/ci_win.json b/infra/recipes/gn.expected/ci_win.json
index 4797f32..e0b5ebd 100644
--- a/infra/recipes/gn.expected/ci_win.json
+++ b/infra/recipes/gn.expected/ci_win.json
@@ -247,7 +247,9 @@
       "[START_DIR]\\gn\\build\\gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]\\gn\\out\\Default"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -279,7 +281,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "gn.exe",
       "gn_unittests.exe"
     ],
@@ -311,7 +313,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]\\gn\\out\\gn_unittests"
+      "[START_DIR]\\gn\\out\\Default\\gn_unittests"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -343,7 +345,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]\\gn",
@@ -389,7 +391,9 @@
       "-u",
       "[START_DIR]\\gn\\build\\gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]\\gn\\out\\Default"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -421,7 +425,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "gn.exe",
       "gn_unittests.exe"
     ],
@@ -453,7 +457,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]\\gn\\out\\gn_unittests"
+      "[START_DIR]\\gn\\out\\Default\\gn_unittests"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -485,7 +489,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]\\gn",
@@ -526,7 +530,7 @@
       "cipd.bat",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn.exe\"}, {\"version_file\": \".versions/gn.exe.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/windows-amd64\", \"root\": \"[START_DIR]\\\\gn\\\\out\"}",
+      "{\"data\": [{\"file\": \"gn.exe\"}, {\"version_file\": \".versions/gn.exe.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/windows-amd64\", \"root\": \"[START_DIR]\\\\gn\\\\out\\\\Default\"}",
       "-out",
       "[CLEANUP]\\gn.cipd",
       "-hash-algo",
diff --git a/infra/recipes/gn.expected/cipd_exists.json b/infra/recipes/gn.expected/cipd_exists.json
index 100acbc..47dceaf 100644
--- a/infra/recipes/gn.expected/cipd_exists.json
+++ b/infra/recipes/gn.expected/cipd_exists.json
@@ -576,7 +576,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -607,7 +609,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -638,7 +640,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -669,7 +671,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -777,6 +779,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-amd64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -808,7 +812,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -839,7 +843,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -870,7 +874,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -972,7 +976,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1077,6 +1081,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-arm64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1108,7 +1114,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1149,7 +1155,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1254,6 +1260,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-riscv64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1285,7 +1293,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1326,7 +1334,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
diff --git a/infra/recipes/gn.expected/cipd_register.json b/infra/recipes/gn.expected/cipd_register.json
index 9ca936a..73674e8 100644
--- a/infra/recipes/gn.expected/cipd_register.json
+++ b/infra/recipes/gn.expected/cipd_register.json
@@ -576,7 +576,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -607,7 +609,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -638,7 +640,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -669,7 +671,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -777,6 +779,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-amd64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -808,7 +812,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -839,7 +843,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -870,7 +874,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -972,7 +976,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1112,6 +1116,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-arm64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1143,7 +1149,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1184,7 +1190,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -1289,6 +1295,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-riscv64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1320,7 +1328,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1361,7 +1369,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-riscv64\", \"root\": \"[START_DIR]/gn/out/Default\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
diff --git a/infra/recipes/gn.expected/cq_linux.json b/infra/recipes/gn.expected/cq_linux.json
index 89f9f2b..1dc70c7 100644
--- a/infra/recipes/gn.expected/cq_linux.json
+++ b/infra/recipes/gn.expected/cq_linux.json
@@ -627,7 +627,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -658,7 +660,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -689,7 +691,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -720,7 +722,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -828,6 +830,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-amd64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -859,7 +863,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -890,7 +894,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -921,7 +925,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1163,7 +1167,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]/gn/out\", \"gn\"]]"
+      "[[\"[START_DIR]/gn/out/Default\", \"gn\"]]"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -1206,6 +1210,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-arm64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1237,7 +1243,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1284,7 +1290,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]/gn/out\", \"gn\"]]"
+      "[[\"[START_DIR]/gn/out/Default\", \"gn\"]]"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -1327,6 +1333,8 @@
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
       "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default",
       "--link-lib=[START_DIR]/jemalloc/build-linux-riscv64/lib/libjemalloc.a"
     ],
     "cwd": "[START_DIR]/gn",
@@ -1358,7 +1366,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1405,7 +1413,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]/gn/out\", \"gn\"]]"
+      "[[\"[START_DIR]/gn/out/Default\", \"gn\"]]"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
diff --git a/infra/recipes/gn.expected/cq_mac.json b/infra/recipes/gn.expected/cq_mac.json
index b7b5bfd..f6dc982 100644
--- a/infra/recipes/gn.expected/cq_mac.json
+++ b/infra/recipes/gn.expected/cq_mac.json
@@ -361,7 +361,9 @@
       "[START_DIR]/gn/build/gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -392,7 +394,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -423,7 +425,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -454,7 +456,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -553,7 +555,9 @@
       "-u",
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -584,7 +588,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -615,7 +619,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]/gn/out/gn_unittests"
+      "[START_DIR]/gn/out/Default/gn_unittests"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -646,7 +650,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]/gn",
@@ -826,7 +830,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]/gn/out\", \"gn\"]]"
+      "[[\"[START_DIR]/gn/out/Default\", \"gn\"]]"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -922,7 +926,9 @@
       "-u",
       "[START_DIR]/gn/build/gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]/gn/out/Default"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
@@ -953,7 +959,7 @@
     "cmd": [
       "[START_DIR]/cipd/ninja",
       "-C",
-      "[START_DIR]/gn/out",
+      "[START_DIR]/gn/out/Default",
       "gn",
       "gn_unittests"
     ],
@@ -1000,7 +1006,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]/gn/out\", \"gn\"]]"
+      "[[\"[START_DIR]/gn/out/Default\", \"gn\"]]"
     ],
     "cwd": "[START_DIR]/gn",
     "env": {
diff --git a/infra/recipes/gn.expected/cq_win.json b/infra/recipes/gn.expected/cq_win.json
index f84cf02..966e487 100644
--- a/infra/recipes/gn.expected/cq_win.json
+++ b/infra/recipes/gn.expected/cq_win.json
@@ -298,7 +298,9 @@
       "[START_DIR]\\gn\\build\\gen.py",
       "-d",
       "--use-asan",
-      "--use-ubsan"
+      "--use-ubsan",
+      "--out-path",
+      "[START_DIR]\\gn\\out\\Default"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -330,7 +332,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "gn.exe",
       "gn_unittests.exe"
     ],
@@ -362,7 +364,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]\\gn\\out\\gn_unittests"
+      "[START_DIR]\\gn\\out\\Default\\gn_unittests"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -394,7 +396,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]\\gn",
@@ -440,7 +442,9 @@
       "-u",
       "[START_DIR]\\gn\\build\\gen.py",
       "--use-lto",
-      "--use-icf"
+      "--use-icf",
+      "--out-path",
+      "[START_DIR]\\gn\\out\\Default"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -472,7 +476,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "gn.exe",
       "gn_unittests.exe"
     ],
@@ -504,7 +508,7 @@
   },
   {
     "cmd": [
-      "[START_DIR]\\gn\\out\\gn_unittests"
+      "[START_DIR]\\gn\\out\\Default\\gn_unittests"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
@@ -536,7 +540,7 @@
     "cmd": [
       "[START_DIR]\\cipd\\ninja",
       "-C",
-      "[START_DIR]\\gn\\out",
+      "[START_DIR]\\gn\\out\\Default",
       "run_integration_tests"
     ],
     "cwd": "[START_DIR]\\gn",
@@ -720,7 +724,7 @@
       "-dump-digest",
       "/path/to/tmp/",
       "-paths-json",
-      "[[\"[START_DIR]\\\\gn\\\\out\", \"gn.exe\"]]"
+      "[[\"[START_DIR]\\\\gn\\\\out\\\\Default\", \"gn.exe\"]]"
     ],
     "cwd": "[START_DIR]\\gn",
     "env": {
diff --git a/infra/recipes/gn.py b/infra/recipes/gn.py
index f75507e..c8ea376 100644
--- a/infra/recipes/gn.py
+++ b/infra/recipes/gn.py
@@ -97,6 +97,9 @@
 
 def RunSteps(api, repository):
   src_dir = api.path['start_dir'].join('gn')
+  # By running with a custom output directory, we can make tests that are
+  # reliant on relative paths fail.
+  out_dir = src_dir.join('out', 'Default')
 
   # TODO: Verify that building and linking jemalloc works on OS X and Windows as
   # well.
@@ -253,17 +256,15 @@
           env = _get_compilation_environment(api, target, cipd_dir)
           with api.step.nest(target.platform), api.context(
               env=env, cwd=src_dir):
-            args = config['args']
+            args = config['args'] + ['--out-path', out_dir]
             if config.get('use_jemalloc', False):
-              args = args[:] + [
-                  '--link-lib=%s' % jemalloc_static_libs[target.platform]
-              ]
+              args.append('--link-lib=%s' % jemalloc_static_libs[target.platform])
 
             api.step('generate',
                      ['python3', '-u', src_dir.join('build', 'gen.py')] + args)
 
             # Windows requires the environment modifications when building too.
-            ninja_cmd = [cipd_dir.join('ninja'), '-C', src_dir.join('out')]
+            ninja_cmd = [cipd_dir.join('ninja'), '-C', out_dir]
             exe_suffix = '.exe' if target.is_win else ''
             api.step('build', ninja_cmd + [
               f'gn{exe_suffix}',
@@ -271,7 +272,7 @@
             ])
 
             if target.is_host:
-              api.step('test', [src_dir.join('out', 'gn_unittests')])
+              api.step('test', [out_dir.join('gn_unittests')])
               api.step(
                   'integration tests', ninja_cmd + ['run_integration_tests']
               )
@@ -293,17 +294,17 @@
 
               if build_input.gerrit_changes:
                 # Upload to CAS from CQ.
-                api.cas.archive('upload binary to CAS', src_dir.join('out'),
-                                src_dir.join('out', gn))
+                api.cas.archive('upload binary to CAS', out_dir,
+                                out_dir.join(gn))
                 continue
 
               cipd_pkg_name = 'gn/gn/%s' % target.platform
 
               pkg_def = api.cipd.PackageDefinition(
                   package_name=cipd_pkg_name,
-                  package_root=src_dir.join('out'),
+                  package_root=out_dir,
                   install_mode='copy')
-              pkg_def.add_file(src_dir.join('out', gn))
+              pkg_def.add_file(out_dir.join(gn))
               pkg_def.add_version_file('.versions/%s.cipd_version' % gn)
 
               cipd_pkg_file = api.path['cleanup'].join('gn.cipd')