@@ -1974,6 +1974,82 @@ class PackageBuilderTests: XCTestCase {
1974
1974
}
1975
1975
}
1976
1976
1977
+ func testEmptyUnsafeFlagsAreAllowed( ) throws {
1978
+ let fs = InMemoryFileSystem ( emptyFiles:
1979
+ " /Sources/foo/foo.swift " ,
1980
+ " /Sources/bar/bar.cpp " ,
1981
+ " /Sources/bar/bar.c " ,
1982
+ " /Sources/bar/include/bar.h "
1983
+ )
1984
+
1985
+ let manifest = Manifest . createManifest (
1986
+ name: " pkg " ,
1987
+ v: . v5,
1988
+ targets: [
1989
+ try TargetDescription (
1990
+ name: " foo " ,
1991
+ settings: [
1992
+ . init( tool: . c, name: . unsafeFlags, value: [ ] ) ,
1993
+ . init( tool: . cxx, name: . unsafeFlags, value: [ ] ) ,
1994
+ . init( tool: . cxx, name: . unsafeFlags, value: [ ] , condition: . init( config: " release " ) ) ,
1995
+ . init( tool: . linker, name: . unsafeFlags, value: [ ] ) ,
1996
+ ]
1997
+ ) ,
1998
+ try TargetDescription (
1999
+ name: " bar " ,
2000
+ settings: [
2001
+ . init( tool: . swift, name: . unsafeFlags, value: [ ] , condition: . init( platformNames: [ " macos " ] , config: " debug " ) ) ,
2002
+ . init( tool: . linker, name: . unsafeFlags, value: [ ] ) ,
2003
+ . init( tool: . linker, name: . unsafeFlags, value: [ ] , condition: . init( platformNames: [ " linux " ] ) ) ,
2004
+ ]
2005
+ ) ,
2006
+ ]
2007
+ )
2008
+
2009
+ PackageBuilderTester ( manifest, in: fs) { package , _ in
2010
+ package . checkModule ( " foo " ) { package in
2011
+ let macosDebugScope = BuildSettings . Scope (
2012
+ package . target. buildSettings,
2013
+ environment: BuildEnvironment ( platform: . macOS, configuration: . debug)
2014
+ )
2015
+ XCTAssertEqual ( macosDebugScope. evaluate ( . OTHER_CFLAGS) , [ ] )
2016
+ XCTAssertEqual ( macosDebugScope. evaluate ( . OTHER_CPLUSPLUSFLAGS) , [ ] )
2017
+ XCTAssertEqual ( macosDebugScope. evaluate ( . OTHER_LDFLAGS) , [ ] )
2018
+
2019
+ let macosReleaseScope = BuildSettings . Scope (
2020
+ package . target. buildSettings,
2021
+ environment: BuildEnvironment ( platform: . macOS, configuration: . release)
2022
+ )
2023
+ XCTAssertEqual ( macosReleaseScope. evaluate ( . OTHER_CFLAGS) , [ ] )
2024
+ XCTAssertEqual ( macosReleaseScope. evaluate ( . OTHER_CPLUSPLUSFLAGS) , [ ] )
2025
+ XCTAssertEqual ( macosReleaseScope. evaluate ( . OTHER_LDFLAGS) , [ ] )
2026
+ }
2027
+
2028
+ package . checkModule ( " bar " ) { package in
2029
+ let linuxDebugScope = BuildSettings . Scope (
2030
+ package . target. buildSettings,
2031
+ environment: BuildEnvironment ( platform: . linux, configuration: . debug)
2032
+ )
2033
+ XCTAssertEqual ( linuxDebugScope. evaluate ( . OTHER_SWIFT_FLAGS) , [ ] )
2034
+ XCTAssertEqual ( linuxDebugScope. evaluate ( . OTHER_LDFLAGS) , [ ] )
2035
+
2036
+ let linuxReleaseScope = BuildSettings . Scope (
2037
+ package . target. buildSettings,
2038
+ environment: BuildEnvironment ( platform: . linux, configuration: . release)
2039
+ )
2040
+ XCTAssertEqual ( linuxReleaseScope. evaluate ( . OTHER_SWIFT_FLAGS) , [ ] )
2041
+ XCTAssertEqual ( linuxReleaseScope. evaluate ( . OTHER_LDFLAGS) , [ ] )
2042
+
2043
+ let macosDebugScope = BuildSettings . Scope (
2044
+ package . target. buildSettings,
2045
+ environment: BuildEnvironment ( platform: . macOS, configuration: . debug)
2046
+ )
2047
+ XCTAssertEqual ( macosDebugScope. evaluate ( . OTHER_SWIFT_FLAGS) , [ ] )
2048
+ XCTAssertEqual ( macosDebugScope. evaluate ( . OTHER_LDFLAGS) , [ ] )
2049
+ }
2050
+ }
2051
+ }
2052
+
1977
2053
func testInvalidHeaderSearchPath( ) throws {
1978
2054
let fs = InMemoryFileSystem ( emptyFiles:
1979
2055
" /pkg/Sources/exe/main.swift "
0 commit comments