mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Driver][Frontend] Add a -nostdlibimport argument
Add a -nostdlibimport (analagous to clang's -nostdlibinc) to remove the SDK paths from the import search paths, but leave the toolchain paths. rdar://139322299
This commit is contained in:
@@ -507,6 +507,9 @@ public:
|
|||||||
/// Don't look in for compiler-provided modules.
|
/// Don't look in for compiler-provided modules.
|
||||||
bool SkipRuntimeLibraryImportPaths = false;
|
bool SkipRuntimeLibraryImportPaths = false;
|
||||||
|
|
||||||
|
/// Don't include SDK paths in the RuntimeLibraryImportPaths
|
||||||
|
bool ExcludeSDKPathsFromRuntimeLibraryImportPaths = false;
|
||||||
|
|
||||||
/// Scanner Prefix Mapper.
|
/// Scanner Prefix Mapper.
|
||||||
std::vector<std::string> ScannerPrefixMapper;
|
std::vector<std::string> ScannerPrefixMapper;
|
||||||
|
|
||||||
|
|||||||
@@ -359,6 +359,8 @@ def incremental : Flag<["-"], "incremental">,
|
|||||||
HelpText<"Perform an incremental build if possible">;
|
HelpText<"Perform an incremental build if possible">;
|
||||||
|
|
||||||
def nostdimport : Flag<["-"], "nostdimport">, Flags<[FrontendOption]>,
|
def nostdimport : Flag<["-"], "nostdimport">, Flags<[FrontendOption]>,
|
||||||
|
HelpText<"Don't search the standard library or toolchain import paths for modules">;
|
||||||
|
def nostdlibimport : Flag<["-"], "nostdlibimport">, Flags<[FrontendOption]>,
|
||||||
HelpText<"Don't search the standard library import path for modules">;
|
HelpText<"Don't search the standard library import path for modules">;
|
||||||
|
|
||||||
def output_file_map : Separate<["-"], "output-file-map">,
|
def output_file_map : Separate<["-"], "output-file-map">,
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
|
|||||||
inputArgs.AddLastArg(arguments, options::OPT_package_name);
|
inputArgs.AddLastArg(arguments, options::OPT_package_name);
|
||||||
inputArgs.AddLastArg(arguments, options::OPT_export_as);
|
inputArgs.AddLastArg(arguments, options::OPT_export_as);
|
||||||
inputArgs.AddLastArg(arguments, options::OPT_nostdimport);
|
inputArgs.AddLastArg(arguments, options::OPT_nostdimport);
|
||||||
|
inputArgs.AddLastArg(arguments, options::OPT_nostdlibimport);
|
||||||
inputArgs.AddLastArg(arguments, options::OPT_parse_stdlib);
|
inputArgs.AddLastArg(arguments, options::OPT_parse_stdlib);
|
||||||
inputArgs.AddLastArg(arguments, options::OPT_resource_dir);
|
inputArgs.AddLastArg(arguments, options::OPT_resource_dir);
|
||||||
inputArgs.AddLastArg(arguments, options::OPT_solver_memory_threshold);
|
inputArgs.AddLastArg(arguments, options::OPT_solver_memory_threshold);
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
|
|||||||
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
|
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SearchPathOpts.getSDKPath().empty()) {
|
if (!SearchPathOpts.ExcludeSDKPathsFromRuntimeLibraryImportPaths && !SearchPathOpts.getSDKPath().empty()) {
|
||||||
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
|
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
|
||||||
? "swift" : "swift_static";
|
? "swift" : "swift_static";
|
||||||
|
|
||||||
@@ -2261,6 +2261,7 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
|
|||||||
Opts.RuntimeResourcePath = A->getValue();
|
Opts.RuntimeResourcePath = A->getValue();
|
||||||
|
|
||||||
Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg(OPT_nostdimport);
|
Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg(OPT_nostdimport);
|
||||||
|
Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg(OPT_nostdlibimport);
|
||||||
|
|
||||||
Opts.DisableModulesValidateSystemDependencies |=
|
Opts.DisableModulesValidateSystemDependencies |=
|
||||||
Args.hasArg(OPT_disable_modules_validate_system_headers);
|
Args.hasArg(OPT_disable_modules_validate_system_headers);
|
||||||
|
|||||||
Reference in New Issue
Block a user