Skip to content

Commit 6df29e5

Browse files
committed
Add testtool and linkage logic
1 parent 09bbb7f commit 6df29e5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

dependencies.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
hk_package( ToolFrameworkCore *)
22
hk_package( hk-DataModel *)
3+
4+
# custom tools
5+
hk_package( hk-testTool *)

hkinstall.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,57 @@
11
from hkpilot.utils.cmake import CMake
2+
from hkpilot.utils import fancylogger
23

4+
import sys, os
5+
6+
logger = fancylogger.getLogger(__name__)
37

48
class HKToolApp(CMake):
59

610
def __init__(self, path):
711
super().__init__(path)
812
self._package_name = "hk-ToolApp"
13+
14+
def configure(self):
15+
# We override the configure step to add the symlink to the compiled_tools repository
16+
logger.info("Adding linkage to compiled tools directory")
17+
compiledtools_dirname = os.getenv("HK_COMPILEDTOOLS_DIR")
18+
inactivetools_dirname = os.path.join(self._path, "UserTools", "InactiveTools")
19+
activetools_dirname = os.path.join(self._path, "UserTools")
20+
21+
22+
# Find all the inactive tools
23+
list_inactive_tools = []
24+
for name in os.listdir(inactivetools_dirname):
25+
if os.path.isdir(os.path.join(inactivetools_dirname, name)) or os.path.islink(os.path.join(inactivetools_dirname, name)):
26+
list_inactive_tools.append(name)
27+
logger.debug(f"List of inactive tools: {list_inactive_tools}")
28+
29+
# Find all the active tools
30+
list_active_tools = []
31+
for name in os.listdir(activetools_dirname):
32+
if name in ["Factory", "InactiveTools", "template"]:
33+
continue
34+
if os.path.isdir(os.path.join(activetools_dirname, name)) or os.path.islink(os.path.join(activetools_dirname, name)):
35+
list_active_tools.append(name)
36+
logger.debug(f"List of active tools: {list_active_tools}")
37+
38+
for name in os.listdir(compiledtools_dirname):
39+
full = os.path.join(compiledtools_dirname, name)
40+
# only looking for symlink to which we will create another link
41+
if not os.path.islink(full):
42+
continue
43+
# checking the tool is not already active or exists as inactive
44+
if name in list_inactive_tools:
45+
logger.debug(f"Tool {name} is already linked as inactive tool")
46+
continue
47+
if name in list_active_tools:
48+
logger.debug(f"Tool {name} is already linked as active tool")
49+
continue
50+
51+
symlink = os.path.join(inactivetools_dirname, name)
52+
logger.info(f"Adding link of tool {name} -> {symlink}")
53+
os.symlink(full, symlink)
54+
logger.info("Done with linkage")
55+
56+
return super().configure()
57+

0 commit comments

Comments
 (0)