non_third_party_sources = \
src/Args.cpp \
- src/ArgsInfo.cpp \
src/AtomicFile.cpp \
src/CacheEntryReader.cpp \
src/CacheEntryWriter.cpp \
built_dist_files = $(generated_sources) $(generated_docs)
non_third_party_headers_without_cpp = \
+ src/ArgsInfo.hpp \
src/Checksum.hpp \
src/File.hpp \
src/FormatNonstdStringView.hpp \
+++ /dev/null
-// Copyright (C) 2020 Joel Rosdahl and other contributors
-//
-// See doc/AUTHORS.adoc for a complete list of contributors.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3 of the License, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-// more details.
-//
-// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc., 51
-// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-#include "ArgsInfo.hpp"
-
-ArgsInfo::~ArgsInfo()
-{
- for (size_t i = 0; i < debug_prefix_maps_len; i++) {
- free(debug_prefix_maps[i]);
- }
- free(debug_prefix_maps);
-}
std::vector<std::string> arch_args;
// Relocating debuginfo in the format old=new.
- char** debug_prefix_maps = nullptr;
- size_t debug_prefix_maps_len = 0;
+ std::vector<std::string> debug_prefix_maps;
// Argument list to add to compiler invocation in depend mode.
Args depend_extra_args;
-
- ArgsInfo() = default;
- ~ArgsInfo();
-
- ArgsInfo(const ArgsInfo&) = delete;
- ArgsInfo& operator=(const ArgsInfo&) = delete;
-
- ArgsInfo(ArgsInfo&&) = delete;
- ArgsInfo& operator=(ArgsInfo&&) = delete;
};
return nullopt;
}
- if (str_startswith(argv[i], "-fdebug-prefix-map=")
- || str_startswith(argv[i], "-ffile-prefix-map=")) {
- args_info.debug_prefix_maps = static_cast<char**>(
- x_realloc(args_info.debug_prefix_maps,
- (args_info.debug_prefix_maps_len + 1) * sizeof(char*)));
- args_info.debug_prefix_maps[args_info.debug_prefix_maps_len++] =
- x_strdup(&argv[i][argv[i][2] == 'f' ? 18 : 19]);
- args_add(state.common_args, argv[i]);
+ if (Util::starts_with(arg, "-fdebug-prefix-map=")
+ || Util::starts_with(arg, "-ffile-prefix-map=")) {
+ args_info.debug_prefix_maps.push_back(arg.substr(arg.find('=') + 1));
+ state.common_args.push_back(arg);
return nullopt;
}
// Possibly hash the current working directory.
if (args_info.generating_debuginfo && ctx.config.hash_dir()) {
std::string dir_to_hash = ctx.apparent_cwd;
- for (size_t i = 0; i < args_info.debug_prefix_maps_len; i++) {
- char* map = args_info.debug_prefix_maps[i];
- char* sep = strchr(map, '=');
- if (sep) {
- char* old_path = x_strndup(map, sep - map);
- char* new_path = static_cast<char*>(x_strdup(sep + 1));
+ for (const auto& map : args_info.debug_prefix_maps) {
+ size_t sep_pos = map.find('=');
+ if (sep_pos != std::string::npos) {
+ std::string old_path = map.substr(0, sep_pos);
+ std::string new_path = map.substr(sep_pos + 1);
cc_log("Relocating debuginfo from %s to %s (CWD: %s)",
- old_path,
- new_path,
+ old_path.c_str(),
+ new_path.c_str(),
ctx.apparent_cwd.c_str());
if (Util::starts_with(ctx.apparent_cwd, old_path)) {
- dir_to_hash = new_path + ctx.apparent_cwd.substr(strlen(old_path));
+ dir_to_hash = new_path + ctx.apparent_cwd.substr(old_path.size());
}
- free(old_path);
- free(new_path);
}
}
cc_log("Hashing CWD %s", dir_to_hash.c_str());