Skip to content

Commit

Permalink
Move client-affecting configuration options into a generated Config.h.
Browse files Browse the repository at this point in the history
This way they can be used from other projects, like LLDB. The downside
is we now have to make sure the header is included consistently in all
the places we care about, but I think in practice that won't be a problem,
especially not with tests.

rdar://problem/22240127

Swift SVN r31173
  • Loading branch information
jrose-apple committed Aug 12, 2015
1 parent c5161a9 commit f5b1efb
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 18 deletions.
8 changes: 0 additions & 8 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ function(_add_variant_c_compile_flags
list(APPEND result "-DNDEBUG")
endif()

if(SWIFT_ENABLE_TARGET_TVOS)
list(APPEND result "-DSWIFT_ENABLE_TARGET_TVOS=\"1\"")
endif()

if(SWIFT_ENABLE_OBJECT_LITERALS)
list(APPEND result "-DSWIFT_ENABLE_OBJECT_LITERALS=\"1\"")
endif()

set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()

Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/DiagnosticsCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#ifndef SWIFT_DIAGNOSTICSCOMMON_H
#define SWIFT_DIAGNOSTICSCOMMON_H

#include "swift/Basic/LLVM.h"
#include "swift/AST/DiagnosticEngine.h"
#include "swift/Basic/LLVM.h"
#include "swift/Config.h"

namespace swift {
template<typename ...ArgTypes>
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "swift/AST/TypeLoc.h"
#include "swift/AST/Availability.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/Config.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"

Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/KnownProtocols.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#ifndef SWIFT_AST_KNOWNPROTOCOLS_H
#define SWIFT_AST_KNOWNPROTOCOLS_H

#include "swift/Config.h"

namespace llvm {
class StringRef;
}
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/PlatformKind.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define SWIFT_AST_PLATFORM_KIND_H

#include "swift/Basic/LLVM.h"
#include "swift/Config.h"
#include "llvm/ADT/StringRef.h"

namespace swift {
Expand Down
1 change: 1 addition & 0 deletions include/swift/Basic/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define SWIFT_BASIC_PLATFORM_H

#include "swift/Basic/LLVM.h"
#include "swift/Config.h"
#include "llvm/ADT/StringRef.h"

namespace llvm {
Expand Down
3 changes: 3 additions & 0 deletions include/swift/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
ESCAPE_QUOTES @ONLY)

add_subdirectory(Option)
10 changes: 10 additions & 0 deletions include/swift/Config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is processed by CMake.
// See http://www.cmake.org/cmake/help/v3.0/command/configure_file.html.

#ifndef SWIFT_CONFIG_H
#define SWIFT_CONFIG_H

#cmakedefine SWIFT_ENABLE_OBJECT_LITERALS 1
#cmakedefine SWIFT_ENABLE_TARGET_TVOS 1

#endif // SWIFT_CONFIG_H
3 changes: 2 additions & 1 deletion include/swift/IDE/SyntaxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#ifndef SWIFT_IDE_SYNTAX_MODEL_H
#define SWIFT_IDE_SYNTAX_MODEL_H

#include "swift/Basic/SourceLoc.h"
#include "swift/AST/Attr.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/Config.h"

#include <vector>

Expand Down
1 change: 1 addition & 0 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "swift/Parse/Token.h"
#include "swift/Parse/ParserResult.h"
#include "swift/Basic/OptionSet.h"
#include "swift/Config.h"
#include "llvm/ADT/SetVector.h"

namespace llvm {
Expand Down
1 change: 1 addition & 0 deletions include/swift/Parse/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/LLVM.h"
#include "swift/Config.h"
#include "llvm/ADT/StringRef.h"

namespace swift {
Expand Down
1 change: 1 addition & 0 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "swift/Basic/Fallthrough.h"
#include "swift/Basic/PrimitiveParsing.h"
#include "swift/Basic/STLExtras.h"
#include "swift/Config.h"
#include "swift/Strings.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
Expand Down
3 changes: 2 additions & 1 deletion lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
//
//===----------------------------------------------------------------------===//

#include "swift/AST/DiagnosticEngine.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/Decl.h"
#include "swift/AST/DiagnosticEngine.h"
#include "swift/AST/Module.h"
#include "swift/AST/Pattern.h"
#include "swift/AST/PrintOptions.h"
#include "swift/AST/TypeRepr.h"
#include "swift/Basic/SourceManager.h"
#include "swift/Parse/Lexer.h" // bad dependency
#include "swift/Config.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
1 change: 1 addition & 0 deletions lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "swift/Basic/LangOptions.h"
#include "swift/Basic/Range.h"
#include "swift/Config.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "swift/Basic/StringExtras.h"
#include "swift/ClangImporter/ClangImporterOptions.h"
#include "swift/Parse/Lexer.h"
#include "swift/Config.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/IdentifierTable.h"
Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "swift/Basic/Fallthrough.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/Parse/Lexer.h"
#include "swift/Config.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclVisitor.h"
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "swift/Driver/ToolChain.h"
#include "swift/Option/Options.h"
#include "swift/Parse/Lexer.h"
#include "swift/Config.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "swift/Driver/Job.h"
#include "swift/Frontend/Frontend.h"
#include "swift/Option/Options.h"
#include "swift/Config.h"
#include "clang/Basic/Version.h"
#include "clang/Driver/Util.h"
#include "llvm/ADT/StringSwitch.h"
Expand Down
3 changes: 2 additions & 1 deletion lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#include "swift/AST/KnownProtocols.h"
#include "swift/AST/LazyResolver.h"
#include "swift/AST/TypeRefinementContext.h"
#include "swift/Parse/Lexer.h"
#include "swift/Basic/Fallthrough.h"
#include "swift/Basic/OptionSet.h"
#include "swift/Parse/Lexer.h"
#include "swift/Config.h"
#include "llvm/ADT/SetVector.h"
#include <functional>

Expand Down
1 change: 1 addition & 0 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "swift/IDE/SyntaxModel.h"
#include "swift/IDE/Utils.h"
#include "swift/Markup/Markup.h"
#include "swift/Config.h"
#include "clang/APINotes/APINotesReader.h"
#include "clang/APINotes/APINotesWriter.h"
#include "clang/Rewrite/Core/RewriteBuffer.h"
Expand Down
6 changes: 0 additions & 6 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ function(add_swift_unittest test_dirname)
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx")
endif()

if(SWIFT_ENABLE_OBJECT_LITERALS)
set_property(TARGET "${test_dirname}" APPEND_STRING
PROPERTY COMPILE_FLAGS
" -DSWIFT_ENABLE_OBJECT_LITERALS=\"1\"")
endif()
endfunction()

if(SWIFT_BUILD_TOOLS)
Expand Down

0 comments on commit f5b1efb

Please sign in to comment.