mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Define availability via compiler flag
Introduce availability macros defined by a frontend flag.
This feature makes it possible to set the availability
versions at the moment of compilation instead of having
it hard coded in the sources. It can be used by projects
with a need to change the availability depending on the
compilation context while using the same sources.
The availability macro is defined with the `-define-availability` flag:
swift MyLib.swift -define-availability "_iOS8Aligned:macOS 10.10, iOS 8.0" ..
The macro can be used in code instead of a platform name and version:
@available(_iOS8Aligned, *)
public func foo() {}
rdar://problem/65612624
This commit is contained in:
@@ -504,6 +504,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
}
|
||||
}
|
||||
|
||||
for (const Arg *A : Args.filtered(OPT_define_availability)) {
|
||||
Opts.AvailabilityMacros.push_back(A->getValue());
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_value_recursion_threshold)) {
|
||||
unsigned threshold;
|
||||
if (StringRef(A->getValue()).getAsInteger(10, threshold)) {
|
||||
|
||||
Reference in New Issue
Block a user