Skip to content

Commit

Permalink
Merge pull request swiftlang#15 from gribozavr/unifdef-tvos-target
Browse files Browse the repository at this point in the history
Remove conditional compilation of tvOS
  • Loading branch information
gribozavr committed Dec 1, 2015
2 parents 5cc14ab + 4324e7c commit 9886aee
Show file tree
Hide file tree
Showing 28 changed files with 26 additions and 121 deletions.
46 changes: 20 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ option(SWIFT_ENABLE_TARGET_LINUX
"Enable compiler support for targeting Linux"
TRUE)

option(SWIFT_ENABLE_TARGET_TVOS
"Enable compiler support for targeting tvOS"
TRUE)

set(SWIFT_VERSION "2.2" CACHE STRING
"The user-visible version of the Swift compiler")
set(SWIFT_VENDOR "" CACHE STRING
Expand Down Expand Up @@ -468,29 +464,27 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
IOS_SIMULATOR-R "iOS Release" IOS_SIMULATOR R "Release")
endif()

if(${SWIFT_ENABLE_TARGET_TVOS})
is_sdk_requested(TVOS swift_build_tvos)
if(swift_build_tvos AND ${swift_can_crosscompile_stdlib})
configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvos tvos tvos "arm64")
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
endif()
is_sdk_requested(TVOS swift_build_tvos)
if(swift_build_tvos AND ${swift_can_crosscompile_stdlib})
configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvos tvos tvos "arm64")
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
endif()

is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
if(swift_build_tvos_simulator AND ${swift_can_crosscompile_stdlib})
configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos-simulator tvos "x86_64")
configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(
TVOS_SIMULATOR-RA "tvOS Release+Asserts" TVOS_SIMULATOR RA "Release+Asserts")
configure_target_variant(
TVOS_SIMULATOR-R "tvOS Release" TVOS_SIMULATOR R "Release")
endif()
is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
if(swift_build_tvos_simulator AND ${swift_can_crosscompile_stdlib})
configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos-simulator tvos "x86_64")
configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(
TVOS_SIMULATOR-RA "tvOS Release+Asserts" TVOS_SIMULATOR RA "Release+Asserts")
configure_target_variant(
TVOS_SIMULATOR-R "tvOS Release" TVOS_SIMULATOR R "Release")
endif()

is_sdk_requested(WATCHOS swift_build_watchos)
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/PlatformKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@

// Reordering these platforms will break serialization.
AVAILABILITY_PLATFORM(iOS, "iOS")
#if defined(SWIFT_ENABLE_TARGET_TVOS)
AVAILABILITY_PLATFORM(tvOS, "tvOS")
#endif // SWIFT_ENABLE_TARGET_TVOS
AVAILABILITY_PLATFORM(watchOS, "watchOS")
AVAILABILITY_PLATFORM(OSX, "OS X")
AVAILABILITY_PLATFORM(iOSApplicationExtension, "iOS application extension")
#if defined(SWIFT_ENABLE_TARGET_TVOS)
AVAILABILITY_PLATFORM(tvOSApplicationExtension, "tvOS application extension")
#endif // SWIFT_ENABLE_TARGET_TVOS
AVAILABILITY_PLATFORM(watchOSApplicationExtension, "watchOS application extension")
AVAILABILITY_PLATFORM(OSXApplicationExtension, "OS X application extension")

Expand Down
2 changes: 0 additions & 2 deletions include/swift/Basic/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ namespace swift {
/// Returns true if the given triple represents iOS running in a simulator.
bool tripleIsiOSSimulator(const llvm::Triple &triple);

#if defined(SWIFT_ENABLE_TARGET_TVOS)
/// Returns true if the given triple represents AppleTV running in a simulator.
bool tripleIsAppleTVSimulator(const llvm::Triple &triple);
#endif // SWIFT_ENABLE_TARGET_TVOS

/// Returns true if the given triple represents watchOS running in a simulator.
bool tripleIsWatchSimulator(const llvm::Triple &triple);
Expand Down
1 change: 0 additions & 1 deletion include/swift/Config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef SWIFT_CONFIG_H
#define SWIFT_CONFIG_H

#cmakedefine SWIFT_ENABLE_TARGET_TVOS 1
#cmakedefine SWIFT_HAVE_WORKING_STD_REGEX 1

#endif // SWIFT_CONFIG_H
10 changes: 1 addition & 9 deletions lib/AST/PlatformKind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,10 @@ bool swift::isPlatformActive(PlatformKind Platform, LangOptions &LangOpts) {
return LangOpts.Target.isMacOSX();
case PlatformKind::iOS:
case PlatformKind::iOSApplicationExtension:
return LangOpts.Target.isiOS()
#if defined(SWIFT_ENABLE_TARGET_TVOS)
&& !LangOpts.Target.isTvOS()
#endif // SWIFT_ENABLE_TARGET_TVOS
;
#if defined(SWIFT_ENABLE_TARGET_TVOS)
return LangOpts.Target.isiOS() && !LangOpts.Target.isTvOS();
case PlatformKind::tvOS:
case PlatformKind::tvOSApplicationExtension:
return LangOpts.Target.isTvOS();
#endif // SWIFT_ENABLE_TARGET_TVOS
case PlatformKind::watchOS:
case PlatformKind::watchOSApplicationExtension:
return LangOpts.Target.isWatchOS();
Expand All @@ -96,13 +90,11 @@ PlatformKind swift::targetPlatform(LangOptions &LangOpts) {
: PlatformKind::OSX);
}

#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (LangOpts.Target.isTvOS()) {
return (LangOpts.EnableAppExtensionRestrictions
? PlatformKind::tvOSApplicationExtension
: PlatformKind::tvOS);
}
#endif // SWIFT_ENABLE_TARGET_TVOS

if (LangOpts.Target.isWatchOS()) {
return (LangOpts.EnableAppExtensionRestrictions
Expand Down
4 changes: 0 additions & 4 deletions lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ using namespace swift;

const std::vector<std::string> LangOptions::SupportedOSBuildConfigArguments = {
"OSX",
#if defined(SWIFT_ENABLE_TARGET_TVOS)
"tvOS",
#endif
"watchOS",
"iOS",
"Linux"
Expand Down Expand Up @@ -92,10 +90,8 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
// Set the "os" target configuration.
if (Target.isMacOSX())
addTargetConfigOption("os", "OSX");
#if defined(SWIFT_ENABLE_TARGET_TVOS)
else if (triple.isTvOS())
addTargetConfigOption("os", "tvOS");
#endif // SWIFT_ENABLE_TARGET_TVOS
else if (triple.isWatchOS())
addTargetConfigOption("os", "watchOS");
else if (triple.isiOS())
Expand Down
13 changes: 3 additions & 10 deletions lib/Basic/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) {
(arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
}

#if defined(SWIFT_ENABLE_TARGET_TVOS)
bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) {
llvm::Triple::ArchType arch = triple.getArch();
return (triple.isTvOS() &&
(arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
}
#endif // SWIFT_ENABLE_TARGET_TVOS

bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) {
llvm::Triple::ArchType arch = triple.getArch();
Expand All @@ -36,23 +34,18 @@ bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) {
}

bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (tripleIsAppleTVSimulator(triple))
return true;
#endif // SWIFT_ENABLE_TARGET_TVOS

return tripleIsiOSSimulator(triple) || tripleIsWatchSimulator(triple);
return tripleIsiOSSimulator(triple) ||
tripleIsWatchSimulator(triple) ||
tripleIsAppleTVSimulator(triple);
}

StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
if (triple.isiOS()) {
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (triple.isTvOS()) {
if (tripleIsAppleTVSimulator(triple))
return "appletvsimulator";
return "appletvos";
}
#endif // SWIFT_ENABLE_TARGET_TVOS

if (tripleIsiOSSimulator(triple))
return "iphonesimulator";
Expand Down
12 changes: 1 addition & 11 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,7 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
unsigned major, minor, micro;
if (triple.isiOS()) {
bool isiOSSimulator = swift::tripleIsiOSSimulator(triple);
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (triple.isTvOS()) {
#else
if (/* DISABLES CODE */ (false)) {
#endif // SWIFT_ENABLE_TARGET_TVOS
if (isiOSSimulator)
minVersionOpt << "-mtvos-simulator-version-min=";
else
Expand Down Expand Up @@ -1031,11 +1027,7 @@ ClangImporter::Implementation::Implementation(ASTContext &ctx,
// applies in Swift, and if so, what is the cutoff for deprecated
// declarations that are now considered unavailable in Swift.

if (ctx.LangOpts.Target.isiOS()
#if defined(SWIFT_ENABLE_TARGET_TVOS)
&& !ctx.LangOpts.Target.isTvOS()
#endif // SWIFT_ENABLE_TARGET_TVOS
) {
if (ctx.LangOpts.Target.isiOS() && !ctx.LangOpts.Target.isTvOS()) {
if (!ctx.LangOpts.EnableAppExtensionRestrictions) {
PlatformAvailabilityFilter =
[](StringRef Platform) { return Platform == "ios"; };
Expand All @@ -1052,7 +1044,6 @@ ClangImporter::Implementation::Implementation(ASTContext &ctx,
DeprecatedAsUnavailableMessage =
"APIs deprecated as of iOS 7 and earlier are unavailable in Swift";
}
#if defined(SWIFT_ENABLE_TARGET_TVOS)
else if (ctx.LangOpts.Target.isTvOS()) {
if (!ctx.LangOpts.EnableAppExtensionRestrictions) {
PlatformAvailabilityFilter =
Expand All @@ -1070,7 +1061,6 @@ ClangImporter::Implementation::Implementation(ASTContext &ctx,
DeprecatedAsUnavailableMessage =
"APIs deprecated as of iOS 7 and earlier are unavailable in Swift";
}
#endif // SWIFT_ENABLE_TARGET_TVOS
else if (ctx.LangOpts.Target.isWatchOS()) {
if (!ctx.LangOpts.EnableAppExtensionRestrictions) {
PlatformAvailabilityFilter =
Expand Down
4 changes: 0 additions & 4 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5761,17 +5761,13 @@ void ClangImporter::Implementation::importAttributes(
llvm::StringSwitch<Optional<PlatformKind>>(Platform)
.Case("ios", PlatformKind::iOS)
.Case("macosx", PlatformKind::OSX)
#if defined(SWIFT_ENABLE_TARGET_TVOS)
.Case("tvos", PlatformKind::tvOS)
#endif // SWIFT_ENABLE_TARGET_TVOS
.Case("watchos", PlatformKind::watchOS)
.Case("ios_app_extension", PlatformKind::iOSApplicationExtension)
.Case("macosx_app_extension",
PlatformKind::OSXApplicationExtension)
#if defined(SWIFT_ENABLE_TARGET_TVOS)
.Case("tvos_app_extension",
PlatformKind::tvOSApplicationExtension)
#endif // SWIFT_ENABLE_TARGET_TVOS
.Case("watchos_app_extension",
PlatformKind::watchOSApplicationExtension)
.Default(None);
Expand Down
4 changes: 0 additions & 4 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,13 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &Args) {
diags.diagnose(SourceLoc(), diag::error_os_minimum_deployment,
"OS X 10.9");
} else if (triple.isiOS()) {
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (triple.isTvOS()) {
if (triple.isOSVersionLT(9, 0)) {
diags.diagnose(SourceLoc(), diag::error_os_minimum_deployment,
"tvOS 9.0");
return;
}
}
#endif // SWIFT_ENABLE_TARGET_TVOS
if (triple.isOSVersionLT(7))
diags.diagnose(SourceLoc(), diag::error_os_minimum_deployment,
"iOS 7");
Expand Down Expand Up @@ -2024,9 +2022,7 @@ const ToolChain *Driver::getToolChain(const ArgList &Args) const {
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
#if defined(SWIFT_ENABLE_TARGET_TVOS)
case llvm::Triple::TvOS:
#endif // SWIFT_ENABLE_TARGET_TVOS
case llvm::Triple::WatchOS:
TC = new toolchains::Darwin(*this, Target);
break;
Expand Down
7 changes: 1 addition & 6 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,9 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,

StringRef RT;
if (Triple.isiOS()) {
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (Triple.isTvOS())
RT = "tvos";
else
#endif // SWIFT_ENABLE_TARGET_TVOS
RT = "ios";
}
else if (Triple.isWatchOS())
Expand All @@ -891,15 +889,12 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
assert(Triple.isiOS() || Triple.isWatchOS() || Triple.isMacOSX());
if (Triple.isiOS()) {
bool isiOSSimulator = tripleIsiOSSimulator(Triple);
#if defined(SWIFT_ENABLE_TARGET_TVOS)
if (Triple.isTvOS()) {
if (isiOSSimulator)
Arguments.push_back("-tvos_simulator_version_min");
else
Arguments.push_back("-tvos_version_min");
} else
#endif // SWIFT_ENABLE_TARGET_TVOS
{
} else {
if (isiOSSimulator)
Arguments.push_back("-ios_simulator_version_min");
else
Expand Down
2 changes: 0 additions & 2 deletions test/BuildConfigurations/arm64AppleTVOSTarget.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %swift -parse %s -verify -D FOO -D BAR -target arm64-apple-tvos9.0 -D FOO -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target arm64-apple-tvos9.0

// REQUIRES: enable_target_appletvos

#if os(iOS)
// This block should not parse.
// os(tvOS) or os(watchOS) does not imply os(iOS).
Expand Down
2 changes: 0 additions & 2 deletions test/BuildConfigurations/i386AppleTVOSTarget.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %swift -parse %s -verify -D FOO -D BAR -target i386-apple-tvos9.0 -D FOO -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target i386-apple-tvos9.0

// REQUIRES: enable_target_appletvos

#if os(iOS)
// This block should not parse.
// os(tvOS) or os(watchOS) does not imply os(iOS).
Expand Down
2 changes: 0 additions & 2 deletions test/BuildConfigurations/x64AppleTVOSTarget.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-apple-tvos9.0 -D FOO -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-tvos9.0

// REQUIRES: enable_target_appletvos

#if os(iOS)
// This block should not parse.
// os(tvOS) or os(watchOS) does not imply os(iOS).
Expand Down
5 changes: 0 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ if(PYTHONINTERP_FOUND)
list(APPEND SWIFT_TEST_EXTRA_ARGS "--param" "leaks-all")
endif()

if(NOT SWIFT_ENABLE_TARGET_APPLETVOS)
list(APPEND SWIFT_TEST_EXTRA_ARGS
"--param" "swift_enable_target_appletvos=false")
endif()

if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
list(APPEND SWIFT_TEST_EXTRA_ARGS
"--param" "build_mode=${CMAKE_CFG_INTDIR}")
Expand Down
2 changes: 0 additions & 2 deletions test/Driver/linker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,3 @@
// Clean up the test executable because hard links are expensive.
// RUN: rm -rf %t/DISTINCTIVE-PATH/usr/bin/swiftc

// REQUIRES: enable_target_appletvos

1 change: 0 additions & 1 deletion test/Driver/os-deployment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
// CHECK-tvOS: Swift requires a minimum deployment target of tvOS 9.0
// CHECK-watchOS: Swift requires a minimum deployment target of watchOS 2.0

// REQUIRES: enable_target_appletvos
2 changes: 0 additions & 2 deletions test/Driver/profiling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@
// LINUX: clang++{{"? }}
// LINUX: lib/swift/clang/{{[^ ]*}}/lib/linux/libclang_rt.profile-x86_64.a

// REQUIRES: enable_target_appletvos

1 change: 0 additions & 1 deletion test/Driver/sdk-apple.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REQUIRES: enable_target_appletvos
// XFAIL: linux

// Test SDK detection for immediate mode.
Expand Down
2 changes: 0 additions & 2 deletions test/IDE/complete_decl_attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=KEYWORD5 | FileCheck %s -check-prefix=KEYWORD5
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=KEYWORD_LAST | FileCheck %s -check-prefix=KEYWORD_LAST

// REQUIRES: enable_target_appletvos

@available(#^AVAILABILITY1^#)

// AVAILABILITY1: Begin completions, 9 items
Expand Down
1 change: 0 additions & 1 deletion test/IRGen/generic_metatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// RUN: %swift -target x86_64-unknown-linux-gnu -disable-objc-interop -emit-ir -parse-stdlib -primary-file %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s

// REQUIRES: X86
// REQUIRES: enable_target_appletvos

// CHECK: define hidden %swift.type* [[GENERIC_TYPEOF:@_TF17generic_metatypes13genericTypeof.*]](%swift.opaque* noalias nocapture, %swift.type* [[TYPE:%.*]])
func genericTypeof<T>(x: T) -> T.Type {
Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/availability_weak_linking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

// REQUIRES: objc_interop
// REQUIRES: executable_test
// REQUIRES: enable_target_appletvos

import StdlibUnittest

Expand Down
2 changes: 0 additions & 2 deletions test/Misc/target-cpu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@
// RUN: not %swift -parse -target x86_64-apple-watchos2 -Xcc -### %s 2>&1 | FileCheck -check-prefix=WATCHSIMULATOR64_CPU %s
// WATCHSIMULATOR64_CPU: "-target-cpu" "core2"

// REQUIRES: enable_target_appletvos

Loading

0 comments on commit 9886aee

Please sign in to comment.