mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Support build and target configurations
These changes add support for build and target configurations in the compiler. Build and target configurations, combined with the use of #if/#else/#endif allow for conditional compilation within declaration and statement contexts. Build configurations can be passed into the compiler via the new '-D' flag, or set within the LangOptions class. Target configurations are implicit, and currently only "os" and "arch" are supported. Swift SVN r14305
This commit is contained in:
@@ -18,7 +18,11 @@
|
||||
#ifndef SWIFT_LANGOPTIONS_H
|
||||
#define SWIFT_LANGOPTIONS_H
|
||||
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include <map>
|
||||
|
||||
namespace swift {
|
||||
|
||||
/// \brief A collection of options that affect the language dialect and
|
||||
/// provide compiler debugging facilities.
|
||||
class LangOptions {
|
||||
@@ -46,6 +50,22 @@ namespace swift {
|
||||
|
||||
/// \brief Keep comments during lexing and attach them to declarations.
|
||||
bool AttachCommentsToDecls = false;
|
||||
|
||||
/// \brief Implicit target configuration options. There are currently two
|
||||
/// supported target configuration values:
|
||||
/// os - The active os target (OSX or IOS)
|
||||
/// arch - The active arch target (X64, I386, ARM, ARM64)
|
||||
std::map<llvm::StringRef, llvm::StringRef> TargetConfigOptions;
|
||||
|
||||
/// \brief Explicit build configuration options, initialized via the '-D'
|
||||
/// compiler flag.
|
||||
std::map<llvm::StringRef, llvm::StringRef> BuildConfigOptions;
|
||||
|
||||
/// \brief A convenience method for determining if a given build
|
||||
/// configuration has been defined
|
||||
bool hasBuildConfig(llvm::StringRef name) {
|
||||
return BuildConfigOptions.count(name) != 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user