[Prebuilt Module Cache] Add an environment variable overload to specify location of the prebuilt module cache

Useful for allowing e.g. CI systems to share this parameter without needing to plumb through a new compiler flag everywhere

Resolves rdar://135033114
This commit is contained in:
Artem Chikin
2024-09-10 09:14:38 -07:00
committed by artemcm
parent 7a54784916
commit 12b7df87ee
2 changed files with 65 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/Path.h"
@@ -66,6 +67,11 @@ bool ArgsToFrontendOptionsConverter::convert(
if (const Arg *A = Args.getLastArg(OPT_prebuilt_module_cache_path)) {
Opts.PrebuiltModuleCachePath = A->getValue();
}
if (auto envPrebuiltModuleCachePath =
llvm::sys::Process::GetEnv("SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH")) {
Opts.PrebuiltModuleCachePath = *envPrebuiltModuleCachePath;
}
if (const Arg *A = Args.getLastArg(OPT_module_cache_path)) {
Opts.ExplicitModulesOutputPath = A->getValue();
} else {