Skip to content

Commit

Permalink
Remove controversial stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort committed Dec 29, 2024
1 parent 8f81ce3 commit cedb74a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 133 deletions.
10 changes: 0 additions & 10 deletions include/vcpkg/base/jsonreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,6 @@ namespace vcpkg::Json
static const NaturalNumberDeserializer instance;
};

struct Int64Deserializer final : IDeserializer<int64_t>
{
LocalizedString type_name() const override;

Optional<int64_t> visit_integer(Reader&, int64_t value) const override { return value; }

static Int64Deserializer instance;
};

struct BooleanDeserializer final : IDeserializer<bool>
{
virtual LocalizedString type_name() const override;
Expand Down Expand Up @@ -370,5 +361,4 @@ namespace vcpkg::Json
virtual Optional<std::string> visit_string(Json::Reader&, StringView sv) const override;
static const FeatureNameDeserializer instance;
};

}
1 change: 0 additions & 1 deletion include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ DECLARE_MESSAGE(AndroidHomeDirMissingProps,
"source.properties missing in {env_var} directory: {path}")
DECLARE_MESSAGE(AnExactVersionString, (), "", "an exact version string")
DECLARE_MESSAGE(AnIdentifer, (), "", "an identifier")
DECLARE_MESSAGE(AnInt64, (), "", "a 64-bit integer")
DECLARE_MESSAGE(AnObjectContainingVcpkgArtifactsMetadata,
(),
"'vcpkg-artifacts' is the name of the product feature and should not be localized",
Expand Down
5 changes: 1 addition & 4 deletions include/vcpkg/installedpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ namespace vcpkg
Path vcpkg_dir_updates() const { return vcpkg_dir() / FileUpdates; }
Path lockfile_path() const { return vcpkg_dir() / FileVcpkgLock; }
Path triplet_dir(Triplet t) const { return m_root / t.canonical_name(); }
Path compiler_info_cache_file(Triplet t) const
{
return vcpkg_dir() / "compiler_info_cache" / t.canonical_name();
}
Path compiler_hash_cache_file() const { return vcpkg_dir() / "compiler_hash_cache.json"; }
Path share_dir(const PackageSpec& p) const { return triplet_dir(p.triplet()) / FileShare / p.name(); }
Path usage_file(const PackageSpec& p) const { return share_dir(p) / FileUsage; }
Path spdx_file(const PackageSpec& p) const { return share_dir(p) / FileVcpkgSpdxJson; }
Expand Down
1 change: 0 additions & 1 deletion locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
"AnArtifactsRegistry": "an artifacts registry",
"AnExactVersionString": "an exact version string",
"AnIdentifer": "an identifier",
"AnInt64": "a 64-bit integer",
"AnObjectContainingVcpkgArtifactsMetadata": "an object containing vcpkg-artifacts metadata",
"_AnObjectContainingVcpkgArtifactsMetadata.comment": "'vcpkg-artifacts' is the name of the product feature and should not be localized",
"AnOverlayPath": "an overlay path",
Expand Down
118 changes: 1 addition & 117 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,95 +522,6 @@ namespace vcpkg
});
}

struct CompilerInfoCache
{
CompilerInfo compiler_info;
int64_t c_compiler_last_write_time;
int64_t cxx_compiler_last_write_time;
};

struct CompilerInfoCacheDeserializer : Json::IDeserializer<CompilerInfoCache>
{
LocalizedString type_name() const override { return LocalizedString::from_raw("CompilerInfoCache"); }

constexpr static StringLiteral ID = "id";
constexpr static StringLiteral VERSION = "version";
constexpr static StringLiteral HASH = "hash";
constexpr static StringLiteral C_COMPILER_PATH = "c_compiler_path";
constexpr static StringLiteral CXX_COMPILER_PATH = "cxx_compiler_path";
constexpr static StringLiteral C_COMPILER_PATH_LAST_WRITE_TIME = "c_compiler_path_last_write_time";
constexpr static StringLiteral CXX_COMPILER_PATH_LAST_WRITE_TIME = "cxx_compiler_path_last_write_time";

virtual Span<const StringView> valid_fields() const override
{
static const StringView t[] = {ID,
VERSION,
HASH,
C_COMPILER_PATH,
CXX_COMPILER_PATH,
C_COMPILER_PATH_LAST_WRITE_TIME,
CXX_COMPILER_PATH_LAST_WRITE_TIME};
return t;
}

Optional<CompilerInfoCache> visit_object(Json::Reader& r, const Json::Object& obj) const override
{
CompilerInfoCache cache;
// This is an internal structure never written by a user by hand, so we don't need localization.
r.required_object_field(LocalizedString::from_raw(ID),
obj,
ID,
cache.compiler_info.id,
Json::UntypedStringDeserializer::instance);
r.required_object_field(LocalizedString::from_raw(VERSION),
obj,
VERSION,
cache.compiler_info.version,
Json::UntypedStringDeserializer::instance);
r.required_object_field(LocalizedString::from_raw(HASH),
obj,
HASH,
cache.compiler_info.hash,
Json::UntypedStringDeserializer::instance);
r.required_object_field(LocalizedString::from_raw(C_COMPILER_PATH),
obj,
C_COMPILER_PATH,
cache.compiler_info.c_compiler_path,
Json::PathDeserializer::instance);
r.required_object_field(LocalizedString::from_raw(CXX_COMPILER_PATH),
obj,
CXX_COMPILER_PATH,
cache.compiler_info.cxx_compiler_path,
Json::PathDeserializer::instance);
r.required_object_field(LocalizedString::from_raw(C_COMPILER_PATH_LAST_WRITE_TIME),
obj,
C_COMPILER_PATH_LAST_WRITE_TIME,
cache.c_compiler_last_write_time,
Json::Int64Deserializer::instance);
r.required_object_field(LocalizedString::from_raw(CXX_COMPILER_PATH_LAST_WRITE_TIME),
obj,
CXX_COMPILER_PATH_LAST_WRITE_TIME,
cache.cxx_compiler_last_write_time,
Json::Int64Deserializer::instance);
return cache;
}
static CompilerInfoCacheDeserializer instance;

static Json::Object serialize(const CompilerInfoCache& cache)
{
Json::Object obj;
obj.insert(ID, cache.compiler_info.id);
obj.insert(VERSION, cache.compiler_info.version);
obj.insert(HASH, cache.compiler_info.hash);
obj.insert(C_COMPILER_PATH, cache.compiler_info.c_compiler_path);
obj.insert(CXX_COMPILER_PATH, cache.compiler_info.cxx_compiler_path);
obj.insert(C_COMPILER_PATH_LAST_WRITE_TIME, Json::Value::integer(cache.c_compiler_last_write_time));
obj.insert(CXX_COMPILER_PATH_LAST_WRITE_TIME, Json::Value::integer(cache.cxx_compiler_last_write_time));
return obj;
}
};
CompilerInfoCacheDeserializer CompilerInfoCacheDeserializer::instance;

const CompilerInfo& EnvCache::get_compiler_info(const VcpkgPaths& paths,
const PreBuildInfo& pre_build_info,
const Toolset& toolset)
Expand All @@ -632,34 +543,7 @@ namespace vcpkg
return triplet_entry.compiler_info.get_lazy(toolchain_hash, [&]() -> CompilerInfo {
if (m_compiler_tracking)
{
auto cache_file = paths.installed().compiler_info_cache_file(pre_build_info.triplet);
auto& fs = paths.get_filesystem();
if (fs.exists(cache_file, VCPKG_LINE_INFO))
{
auto json_object = Json::parse_object(fs.read_contents(cache_file, VCPKG_LINE_INFO), cache_file)
.value_or_exit(VCPKG_LINE_INFO);
Json::Reader reader(cache_file);
CompilerInfoCache cache = reader.visit(json_object, CompilerInfoCacheDeserializer::instance)
.value_or_exit(VCPKG_LINE_INFO);
auto needs_update = [&](const Path& path, int64_t last_write_time) {
return !fs.exists(path, VCPKG_LINE_INFO) ||
fs.last_write_time(path, VCPKG_LINE_INFO) != last_write_time;
};
if (!needs_update(cache.compiler_info.c_compiler_path, cache.c_compiler_last_write_time) &&
!needs_update(cache.compiler_info.cxx_compiler_path, cache.cxx_compiler_last_write_time))
{
return cache.compiler_info;
}
}
auto compiler_info = load_compiler_info(paths, pre_build_info, toolset);
CompilerInfoCache cache;
cache.compiler_info = compiler_info;
cache.c_compiler_last_write_time = fs.last_write_time(compiler_info.c_compiler_path, VCPKG_LINE_INFO);
cache.cxx_compiler_last_write_time =
fs.last_write_time(compiler_info.cxx_compiler_path, VCPKG_LINE_INFO);
fs.write_contents_and_dirs(
cache_file, Json::stringify(CompilerInfoCacheDeserializer::serialize(cache)), VCPKG_LINE_INFO);
return compiler_info;
return load_compiler_info(paths, pre_build_info, toolset);
}
else
{
Expand Down

0 comments on commit cedb74a

Please sign in to comment.