@@ -593,6 +593,9 @@ endfunction()
593
593
# [LINK_FLAGS flag1...]
594
594
# [API_NOTES_NON_OVERLAY]
595
595
# [FILE_DEPENDS target1 ...]
596
+ # SWIFT_ENABLE_TENSORFLOW
597
+ # [EXTRA_RPATHS rpath1 ...]
598
+ # END SWIFT_ENABLE_TENSORFLOW
596
599
# [DONT_EMBED_BITCODE]
597
600
# [IS_STDLIB]
598
601
# [FORCE_BUILD_OPTIMIZED]
@@ -652,6 +655,11 @@ endfunction()
652
655
# FILE_DEPENDS
653
656
# Additional files this library depends on.
654
657
#
658
+ # SWIFT_ENABLE_TENSORFLOW
659
+ # EXTRA_RPATHS
660
+ # List of directories to add to this library's RPATH.
661
+ # END SWIFT_ENABLE_TENSORFLOW
662
+ #
655
663
# DONT_EMBED_BITCODE
656
664
# Don't embed LLVM bitcode in this target, even if it is enabled globally.
657
665
#
@@ -695,6 +703,9 @@ function(_add_swift_library_single target name)
695
703
C_COMPILE_FLAGS
696
704
DEPENDS
697
705
FILE_DEPENDS
706
+ # SWIFT_ENABLE_TENSORFLOW
707
+ EXTRA_RPATHS
708
+ # END SWIFT_ENABLE_TENSORFLOW
698
709
FRAMEWORK_DEPENDS
699
710
FRAMEWORK_DEPENDS_WEAK
700
711
INCORPORATE_OBJECT_LIBRARIES
@@ -1031,6 +1042,28 @@ function(_add_swift_library_single target name)
1031
1042
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/cygwin" )
1032
1043
endif ()
1033
1044
1045
+ # SWIFT_ENABLE_TENSORFLOW
1046
+ # Hande extra RPATHs.
1047
+ set (local_rpath "" )
1048
+ if ("${SWIFTLIB_SINGLE_SDK} " STREQUAL "LINUX" AND NOT "${SWIFTLIB_SINGLE_SDK} " STREQUAL "ANDROID" )
1049
+ set (local_rpath "$ORIGIN:/usr/lib/swift/linux" )
1050
+ elseif ("${SWIFTLIB_SINGLE_SDK} " STREQUAL "CYGWIN" )
1051
+ set (local_rpath "$ORIGIN:/usr/lib/swift/cygwin" )
1052
+ endif ()
1053
+ foreach (rpath_element ${SWIFTLIB_SINGLE_EXTRA_RPATHS} )
1054
+ if ("${local_rpath} " STREQUAL "" )
1055
+ set (local_rpath "${rpath_element} " )
1056
+ else ()
1057
+ set (local_rpath "${local_rpath} :${rpath_element} " )
1058
+ endif ()
1059
+ endforeach ()
1060
+ if (NOT "${local_rpath} " STREQUAL "" )
1061
+ set_target_properties ("${target} "
1062
+ PROPERTIES
1063
+ INSTALL_RPATH "${local_rpath} " )
1064
+ endif ()
1065
+ # END SWIFT_ENABLE_TENSORFLOW
1066
+
1034
1067
set_target_properties ("${target} " PROPERTIES BUILD_WITH_INSTALL_RPATH YES )
1035
1068
set_target_properties ("${target} " PROPERTIES FOLDER "Swift libraries" )
1036
1069
@@ -2131,6 +2164,20 @@ function(_add_swift_executable_single name)
2131
2164
"-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK} _LIB_SUBDIR}" )
2132
2165
endif ()
2133
2166
2167
+ # SWIFT_ENABLE_TENSORFLOW
2168
+ set (swift_relative_library_path "../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK} _LIB_SUBDIR}" )
2169
+ is_darwin_based_sdk ("${SWIFTEXE_SINGLE_SDK} " IS_DARWIN )
2170
+ # NOTE: Adding "${SWIFTLIB_DIR}/linux" to the rpath is a hack solely for
2171
+ # working around tests like Driver/linker.swift which copy/hard link Swift
2172
+ # executables to different directories without also copying the "libs"
2173
+ # directory. A more robust solution should be found.
2174
+ if ("${SWIFTEXE_SINGLE_SDK} " STREQUAL "LINUX" AND NOT "${SWIFTEXE_SINGLE_SDK} " STREQUAL "ANDROID" )
2175
+ set (local_rpath "$ORIGIN:$ORIGIN/${swift_relative_library_path} :${SWIFTLIB_DIR} /linux:/usr/lib/swift/linux" )
2176
+ elseif ("${SWIFTEXE_SINGLE_SDK} " STREQUAL "CYGWIN" )
2177
+ set (local_rpath "$ORIGIN:$ORIGIN/${swift_relative_library_path} :${SWIFTLIB_DIR} /cygwin:/usr/lib/swift/cygwin" )
2178
+ endif ()
2179
+ # END SWIFT_ENABLE_TENSORFLOW
2180
+
2134
2181
# Find the names of dependency library targets.
2135
2182
#
2136
2183
# We don't add the ${ARCH} to the target suffix because we want to link
@@ -2192,6 +2239,13 @@ function(_add_swift_executable_single name)
2192
2239
2193
2240
set_target_properties (${name}
2194
2241
PROPERTIES FOLDER "Swift executables" )
2242
+
2243
+ # SWIFT_ENABLE_TENSORFLOW
2244
+ if (NOT "${local_rpath} " STREQUAL "" )
2245
+ set_target_properties ("${name} " PROPERTIES INSTALL_RPATH "${local_rpath} " )
2246
+ endif ()
2247
+ set_target_properties ("${name} " PROPERTIES BUILD_WITH_INSTALL_RPATH YES )
2248
+ # END SWIFT_ENABLE_TENSORFLOW
2195
2249
endfunction ()
2196
2250
2197
2251
# Add an executable for each target variant. Executables are given suffixes
0 commit comments