mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add Builtin.ifdef_<FLAGNAME> as a facility to peek at -D flag that client code is building with (#39797)
This commit is contained in:
committed by
GitHub
parent
223dbd445b
commit
b413a0f4dd
34
test/stdlib/builtin-ifdef.swift
Normal file
34
test/stdlib/builtin-ifdef.swift
Normal file
@@ -0,0 +1,34 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-build-swift %s -parse-stdlib -whole-module-optimization -D LIBRARY -emit-module -o %t/Library.swiftmodule
|
||||
// RUN: %target-build-swift %s -parse-stdlib -whole-module-optimization -D LIBRARY -emit-bc -o %t/Library.bc
|
||||
// RUN: %target-build-swift %s -parse-as-library -D CLIENT -I %t -o %t/R1 -O && %target-run %t/R1 | %FileCheck %s
|
||||
// RUN: %target-build-swift %s -parse-as-library -D CLIENT -I %t -o %t/R2 -O -D FOO_BAR && %target-run %t/R2 | %FileCheck %s --check-prefix CHECK-FOO-BAR
|
||||
|
||||
// REQUIRES: executable_test
|
||||
|
||||
#if LIBRARY
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
public func ifdefFooBar() -> Builtin.Int1 {
|
||||
return Builtin.ifdef_FOO_BAR()
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CLIENT
|
||||
|
||||
import Library
|
||||
|
||||
@_cdecl("main")
|
||||
func main() -> Int32 {
|
||||
print("Hello")
|
||||
print(Bool(_builtinBooleanLiteral: ifdefFooBar()))
|
||||
// CHECK: Hello
|
||||
// CHECK: false
|
||||
|
||||
// CHECK-FOO-BAR: Hello
|
||||
// CHECK-FOO-BAR: true
|
||||
return 0
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user