]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Improve MSVC /Fp and /Yu options further
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 5 May 2022 22:01:45 +0000 (00:01 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 6 May 2022 10:44:34 +0000 (12:44 +0200)
Improve 09dea223466e to also handle relative paths to -Fp/-Yu.

src/argprocessing.cpp

index c00c6e076513b56c7e34baff6f8165622202b617..6d3626697a973a24fe2fa92ba62d72111ebbd9b5 100644 (file)
@@ -917,18 +917,28 @@ process_arg(const Context& ctx,
     return nullopt;
   }
 
+  // Detect PCH for options with concatenated path (relative or absolute).
+  if (util::starts_with(args[i], "-Fp") || util::starts_with(args[i], "-Yu")) {
+    const size_t path_pos = 3;
+    if (!detect_pch(args[i].substr(0, path_pos),
+                    args[i].substr(path_pos),
+                    args_info.included_pch_file,
+                    false,
+                    state)) {
+      return Statistic::bad_compiler_arguments;
+    }
+
+    // Fall through to the next section, so intentionally not returning here.
+  }
+
   // Potentially rewrite concatenated absolute path argument to relative.
   if (args[i][0] == '-') {
     const auto path_pos = Util::is_absolute_path_with_prefix(args[i]);
     if (path_pos) {
       const std::string option = args[i].substr(0, *path_pos);
-      const std::string path = args[i].substr(*path_pos);
-      if (!detect_pch(
-            option, path, args_info.included_pch_file, false, state)) {
-        return Statistic::bad_compiler_arguments;
-      }
       if (compopt_takes_concat_arg(option) && compopt_takes_path(option)) {
-        const auto relpath = Util::make_relative_path(ctx, path);
+        const auto relpath =
+          Util::make_relative_path(ctx, string_view(args[i]).substr(*path_pos));
         std::string new_option = option + relpath;
         if (compopt_affects_cpp_output(option)) {
           state.cpp_args.push_back(new_option);