diff --git a/config/jumbo.gni b/config/jumbo.gni index 4a5f22f4a..364485cb4 100644 --- a/config/jumbo.gni +++ b/config/jumbo.gni @@ -66,6 +66,25 @@ template("jumbo_target") { invoker_sources = invoker.sources gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") assert(excluded_sources != [] || true) # Prevent "unused variable". + + # Find the gen_target_dir directory with shortest path. Short paths + # are nice in themselves since they mean shorter error messages and + # fewer bytes to parse, but the currently deployed version of ninja + # also has a limitation where it only allows 32 path components in + # Windows. + # See https://crbug.com/738186 and + # https://github.com/ninja-build/ninja/issues/1161 + foreach(source_file, invoker.sources) { + possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") + possibly_better_gen_target_dir_2 = + get_path_info(possibly_better_gen_target_dir, "dir") + alt_gen_target_dir = get_path_info(source_file, "gen_dir") + if (alt_gen_target_dir == possibly_better_gen_target_dir || + alt_gen_target_dir == possibly_better_gen_target_dir_2) { + gen_target_dir = alt_gen_target_dir + } + } + assert(gen_target_dir != "") # Prevent "unused variable". if (use_jumbo_build_for_target) {