gn: Include source files outside the source root for Xcode workspace

This change unifies Xcode workspaces with projects for other IDEs.

BUG=n/a

Review-Url: https://codereview.chromium.org/2489673004
Cr-Original-Commit-Position: refs/heads/master@{#431856}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b9f57fffd94bdfe264ddaf220dfecac603075540
diff --git a/tools/gn/xcode_writer.cc b/tools/gn/xcode_writer.cc
index e6b66d5..bce396b 100644
--- a/tools/gn/xcode_writer.cc
+++ b/tools/gn/xcode_writer.cc
@@ -191,9 +191,9 @@
                                   root_target_name, ninja_extra_args,
                                   build_settings, target_os);
 
-  workspace.CreateSourcesProject(all_targets, build_settings->build_dir(),
-                                 attributes, source_path, config_name,
-                                 target_os);
+  workspace.CreateSourcesProject(
+      all_targets, build_settings->build_dir(), attributes, source_path,
+      build_settings->root_path_utf8(), config_name, target_os);
 
   return workspace.WriteFiles(build_settings, err);
 }
@@ -321,14 +321,12 @@
     const SourceDir& root_build_dir,
     const PBXAttributes& attributes,
     const std::string& source_path,
+    const std::string& absolute_source_path,
     const std::string& config_name,
     TargetOsType target_os) {
   std::vector<SourceFile> sources;
   for (const Target* target : targets) {
     for (const SourceFile& source : target->sources()) {
-      if (source.is_system_absolute())
-        continue;
-
       if (IsStringInOutputDir(root_build_dir, source.value()))
         continue;
 
@@ -347,7 +345,8 @@
 
   SourceDir source_dir("//");
   for (const SourceFile& source : sources) {
-    std::string source_file = RebasePath(source.value(), source_dir);
+    std::string source_file =
+        RebasePath(source.value(), source_dir, absolute_source_path);
     sources_for_indexing->AddSourceFile(source_file);
   }
 
diff --git a/tools/gn/xcode_writer.h b/tools/gn/xcode_writer.h
index 5148788..87a7d58 100644
--- a/tools/gn/xcode_writer.h
+++ b/tools/gn/xcode_writer.h
@@ -82,6 +82,7 @@
                             const SourceDir& root_build_dir,
                             const PBXAttributes& attributes,
                             const std::string& source_path,
+                            const std::string& absolute_source_path,
                             const std::string& config_name,
                             TargetOsType target_os);