Skip to content

Commit cc7438e

Browse files
committed
updated dependency resolution to automatically add symlinks
Signed-off-by: Zen <[email protected]>
1 parent 33c520d commit cc7438e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

ugrd/base/core.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '1.1.0'
2+
__version__ = '1.1.1'
33

44
from pathlib import Path
55

@@ -12,7 +12,11 @@ def calculate_dependencies(self, binary):
1212
if not binary_path:
1313
raise RuntimeError("'%s' not found in PATH" % binary)
1414

15-
dependencies = run(['lddtree', '-l', binary_path], capture_output=True)
15+
binary_path = Path(binary_path)
16+
17+
self.logger.debug("Calculating dependencies for: %s" % binary_path)
18+
dependencies = run(['lddtree', '-l', str(binary_path)], capture_output=True)
19+
1620
if dependencies.returncode != 0:
1721
self.logger.warning("Unable to calculate dependencies for: %s" % binary)
1822
raise RuntimeError("Unable to resolve dependencies, error: %s" % dependencies.stderr.decode('utf-8'))
@@ -23,8 +27,7 @@ def calculate_dependencies(self, binary):
2327
if dependency.startswith('//'):
2428
dependency = dependency[1:]
2529

26-
dep_path = Path(dependency)
27-
dependency_paths.append(dep_path)
30+
dependency_paths.append(Path(dependency))
2831

2932
return dependency_paths
3033

@@ -34,6 +37,13 @@ def deploy_dependencies(self):
3437
Copies all dependencies to the build directory
3538
"""
3639
for dependency in self.config_dict['dependencies']:
40+
if dependency.is_symlink():
41+
if self.config_dict['symlinks'].get(f'_auto_{dependency.name}'):
42+
self.logger.debug("Dependency is a symlink, skipping: %s" % dependency)
43+
continue
44+
else:
45+
raise ValueError("Dependency is a symlink and not in the symlinks list: %s" % dependency)
46+
3747
self.logger.debug("Copying dependency: %s" % dependency)
3848
self._copy(dependency)
3949

@@ -138,6 +148,15 @@ def _process_dependencies_multi(self, dependency):
138148
if not dependency.exists():
139149
raise FileNotFoundError("Dependency does not exist: %s" % dependency)
140150

151+
if dependency.is_symlink():
152+
if self['symlinks'].get(f'_auto_{dependency.name}'):
153+
self.logger.debug("Dependency is a symlink which is alreadty in the symlinks list, skipping: %s" % dependency)
154+
else:
155+
resolved_path = dependency.resolve()
156+
self.logger.info("Dependency is a symlink, adding to symlinks: %s -> %s" % (dependency, resolved_path))
157+
self['symlinks'][f'_auto_{dependency.name}'] = {'source': resolved_path, 'target': dependency}
158+
dependency = resolved_path
159+
141160
self.logger.debug("Adding dependency: %s" % dependency)
142161
self['dependencies'].append(dependency)
143162

0 commit comments

Comments
 (0)