Skip to content

Commit ce94247

Browse files
authored
Merge pull request #30035 from compnerd/extended-symlinks
build: extend the symlink tree
2 parents 075f3b0 + 74eeff4 commit ce94247

File tree

1 file changed

+25
-10
lines changed
  • utils/swift_build_support/swift_build_support/products

1 file changed

+25
-10
lines changed

utils/swift_build_support/swift_build_support/products/tensorflow.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def _get_tensorflow_library(self, host):
130130

131131
raise RuntimeError('unknown host target {}'.format(host))
132132

133+
def _symlink(self, dest, src):
134+
try:
135+
os.unlink(src)
136+
except OSError:
137+
pass
138+
os.symlink(dest, src)
139+
133140
def build(self, host_target):
134141
with shell.pushd(self.source_dir):
135142
# Run the TensorFlow configure script: `yes "" | ./configure`.
@@ -202,16 +209,24 @@ def install(self, host_target):
202209
'usr', 'lib', 'swift',
203210
subdir, suffixed_lib_name))
204211

205-
try:
206-
os.unlink(os.path.join(self.install_toolchain_path(),
207-
'usr', 'lib', 'swift',
208-
subdir, unsuffixed_lib_name))
209-
except OSError:
210-
pass
211-
os.symlink(suffixed_lib_name,
212-
os.path.join(self.install_toolchain_path(),
213-
'usr', 'lib', 'swift',
214-
subdir, unsuffixed_lib_name))
212+
if host_target.startswith('linux'):
213+
versions = (
214+
'libtensorflow.so.2.1.0',
215+
'libtensorflow.so.2.1',
216+
'libtensorflow.so.2',
217+
'libtensorflow.so',
218+
)
219+
220+
for (index, value) in enumerate(versions[:-1]):
221+
self._symlink(value,
222+
os.path.join(self.install_toolchain_path(),
223+
'usr', 'lib', 'swift', subdir,
224+
versions[index + 1]))
225+
else:
226+
self._symlink(suffixed_lib_name,
227+
os.path.join(self.install_toolchain_path(),
228+
'usr', 'lib', 'swift', subdir,
229+
unsuffixed_lib_name))
215230

216231
try:
217232
shutil.rmtree(os.path.join(self.install_toolchain_path(),

0 commit comments

Comments
 (0)