[rust-project] Always use forward slashes in sysroot paths

Backslashes were not getting escaped in the JSON output, so go back to
using forward slashes which still work on Windows.

Change-Id: Icb395f7daa1c57b418dec791c2ab5d2259dadea9
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/17780
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: Tyler Mandry <tmandry@google.com>
diff --git a/src/gn/rust_project_writer.cc b/src/gn/rust_project_writer.cc
index a77c3f1..6c9aef8 100644
--- a/src/gn/rust_project_writer.cc
+++ b/src/gn/rust_project_writer.cc
@@ -258,15 +258,8 @@
   if (sysroot.has_value()) {
     base::FilePath rebased_out_dir =
         build_settings->GetFullPath(build_settings->build_dir());
-    base::FilePath sysroot_path =
-        rebased_out_dir.Append(UTF8ToFilePath(sysroot.value()));
-    base::FilePath sysroot_src_path = sysroot_path.AppendASCII("lib")
-                                          .AppendASCII("rustlib")
-                                          .AppendASCII("src")
-                                          .AppendASCII("rust")
-                                          .AppendASCII("library");
-    std::string sysroot_dir = FilePathToUTF8(sysroot_path);
-    std::string sysroot_src_dir = FilePathToUTF8(sysroot_src_path);
+    std::string sysroot_dir = FilePathToUTF8(rebased_out_dir) + sysroot.value();
+    std::string sysroot_src_dir = sysroot_dir + "/lib/rustlib/src/rust/library";
     rust_project << "  \"sysroot\": \"" << sysroot_dir << "\"," NEWLINE;
     rust_project << "  \"sysroot_src\": \"" << sysroot_src_dir << "\"," NEWLINE;
   }
diff --git a/src/gn/rust_project_writer_helpers_unittest.cc b/src/gn/rust_project_writer_helpers_unittest.cc
index 7ef39e2..87ccd83 100644
--- a/src/gn/rust_project_writer_helpers_unittest.cc
+++ b/src/gn/rust_project_writer_helpers_unittest.cc
@@ -110,15 +110,9 @@
 
   const char expected_json[] =
       "{\n"
-#if defined(OS_WIN)
-      "  \"sysroot\": \"/root/out/Debug\\sysroot\",\n"
-      "  \"sysroot_src\": "
-      "\"/root/out/Debug\\sysroot\\lib\\rustlib\\src\\rust\\library\",\n"
-#else
       "  \"sysroot\": \"/root/out/Debug/sysroot\",\n"
       "  \"sysroot_src\": "
       "\"/root/out/Debug/sysroot/lib/rustlib/src/rust/library\",\n"
-#endif
       "  \"crates\": [\n"
       "  ]\n"
       "}\n";