• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/src/gn/filesystem_utils.cc b/src/gn/filesystem_utils.cc
2index 58d8cca..5f61443 100644
3--- a/src/gn/filesystem_utils.cc
4+++ b/src/gn/filesystem_utils.cc
5@@ -1069,25 +1069,10 @@ OutputFile GetSubBuildDirAsOutputFile(const BuildDirContext& context,
6   OutputFile result = GetBuildDirAsOutputFile(context, type);
7
8   if (source_dir.is_source_absolute()) {
9-    std::string_view build_dir = context.build_settings->build_dir().value();
10-    std::string_view source_dir_path = source_dir.value();
11-    if (source_dir_path.substr(0, build_dir.size()) == build_dir) {
12-      // The source dir is source-absolute, but in the build directory
13-      // (e.g. `//out/Debug/gen/src/foo.cc` or
14-      // `//out/Debug/toolchain1/gen/foo.cc`), which happens for generated
15-      // sources. In this case, remove the build directory prefix, and replace
16-      // it with `BUILD_DIR`. This will create results like `obj/BUILD_DIR/gen`
17-      // or `toolchain2/obj/BUILD_DIR/toolchain1/gen` which look surprising,
18-      // but guarantee unicity.
19-      result.value().append("BUILD_DIR/");
20-      result.value().append(&source_dir_path[build_dir.size()],
21-                            source_dir_path.size() - build_dir.size());
22-    } else {
23-      // The source dir is source-absolute, so we trim off the two leading
24-      // slashes to append to the toolchain object directory.
25-      result.value().append(&source_dir.value()[2],
26-                            source_dir.value().size() - 2);
27-    }
28+    // The source dir is source-absolute, so we trim off the two leading
29+    // slashes to append to the toolchain object directory.
30+    result.value().append(&source_dir.value()[2],
31+                          source_dir.value().size() - 2);
32   } else {
33     // System-absolute.
34     AppendFixedAbsolutePathSuffix(context.build_settings, source_dir, &result);
35diff --git a/src/gn/ninja_c_binary_target_writer_unittest.cc b/src/gn/ninja_c_binary_target_writer_unittest.cc
36index 9476193..6056c36 100644
37--- a/src/gn/ninja_c_binary_target_writer_unittest.cc
38+++ b/src/gn/ninja_c_binary_target_writer_unittest.cc
39@@ -405,18 +405,18 @@ TEST_F(NinjaCBinaryTargetWriterTest, NoHardDepsToNoPublicHeaderTarget) {
40       "target_out_dir = obj/foo\n"
41       "target_output_name = gen_obj\n"
42       "\n"
43-      "build obj/BUILD_DIR/gen_obj.generated.o: cxx generated.cc"
44+      "build obj/out/Debug/gen_obj.generated.o: cxx generated.cc"
45       " || obj/foo/generate.stamp\n"
46       "  source_file_part = generated.cc\n"
47       "  source_name_part = generated\n"
48       "\n"
49-      "build obj/foo/gen_obj.stamp: stamp obj/BUILD_DIR/gen_obj.generated.o"
50+      "build obj/foo/gen_obj.stamp: stamp obj/out/Debug/gen_obj.generated.o"
51       // The order-only dependency here is strictly unnecessary since the
52       // sources list this as an order-only dep.
53       " || obj/foo/generate.stamp\n";
54
55   std::string obj_str = obj_out.str();
56-  EXPECT_EQ(std::string(obj_expected), obj_str);
57+  EXPECT_EQ(obj_expected, obj_str);
58
59   // A shared library depends on gen_obj, having corresponding header for
60   // generated obj.
61@@ -442,7 +442,7 @@ TEST_F(NinjaCBinaryTargetWriterTest, NoHardDepsToNoPublicHeaderTarget) {
62       "target_output_name = libgen_lib\n"
63       "\n"
64       "\n"
65-      "build ./libgen_lib.so: solink obj/BUILD_DIR/gen_obj.generated.o"
66+      "build ./libgen_lib.so: solink obj/out/Debug/gen_obj.generated.o"
67       // The order-only dependency here is strictly unnecessary since
68       // obj/out/Debug/gen_obj.generated.o has dependency to
69       // obj/foo/gen_obj.stamp
70diff --git a/src/gn/substitution_writer_unittest.cc b/src/gn/substitution_writer_unittest.cc
71index eaa521a..fc3c446 100644
72--- a/src/gn/substitution_writer_unittest.cc
73+++ b/src/gn/substitution_writer_unittest.cc
74@@ -45,12 +45,6 @@ TEST(SubstitutionWriter, ApplyPatternToSource) {
75   SourceFile result = SubstitutionWriter::ApplyPatternToSource(
76       nullptr, setup.settings(), pattern, SourceFile("//foo/bar/myfile.txt"));
77   ASSERT_EQ("//out/Debug/gen/foo/bar/myfile.tmp", result.value());
78-
79-  result = SubstitutionWriter::ApplyPatternToSource(
80-      nullptr, setup.settings(), pattern,
81-      SourceFile("//out/Debug/gen/generated_file.cc"));
82-  ASSERT_EQ("//out/Debug/gen/BUILD_DIR/gen/generated_file.tmp", result.value())
83-      << result.value();
84 }
85
86 TEST(SubstitutionWriter, ApplyPatternToSourceAsOutputFile) {
87