Skip to content

Commit

Permalink
Add testtool and linkage logic
Browse files Browse the repository at this point in the history
  • Loading branch information
guiguem committed Oct 13, 2023
1 parent 09bbb7f commit 6df29e5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
hk_package( ToolFrameworkCore *)
hk_package( hk-DataModel *)

# custom tools
hk_package( hk-testTool *)
49 changes: 49 additions & 0 deletions hkinstall.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
from hkpilot.utils.cmake import CMake
from hkpilot.utils import fancylogger

import sys, os

logger = fancylogger.getLogger(__name__)

class HKToolApp(CMake):

def __init__(self, path):
super().__init__(path)
self._package_name = "hk-ToolApp"

def configure(self):
# We override the configure step to add the symlink to the compiled_tools repository
logger.info("Adding linkage to compiled tools directory")
compiledtools_dirname = os.getenv("HK_COMPILEDTOOLS_DIR")
inactivetools_dirname = os.path.join(self._path, "UserTools", "InactiveTools")
activetools_dirname = os.path.join(self._path, "UserTools")


# Find all the inactive tools
list_inactive_tools = []
for name in os.listdir(inactivetools_dirname):
if os.path.isdir(os.path.join(inactivetools_dirname, name)) or os.path.islink(os.path.join(inactivetools_dirname, name)):
list_inactive_tools.append(name)
logger.debug(f"List of inactive tools: {list_inactive_tools}")

# Find all the active tools
list_active_tools = []
for name in os.listdir(activetools_dirname):
if name in ["Factory", "InactiveTools", "template"]:
continue
if os.path.isdir(os.path.join(activetools_dirname, name)) or os.path.islink(os.path.join(activetools_dirname, name)):
list_active_tools.append(name)
logger.debug(f"List of active tools: {list_active_tools}")

for name in os.listdir(compiledtools_dirname):
full = os.path.join(compiledtools_dirname, name)
# only looking for symlink to which we will create another link
if not os.path.islink(full):
continue
# checking the tool is not already active or exists as inactive
if name in list_inactive_tools:
logger.debug(f"Tool {name} is already linked as inactive tool")
continue
if name in list_active_tools:
logger.debug(f"Tool {name} is already linked as active tool")
continue

symlink = os.path.join(inactivetools_dirname, name)
logger.info(f"Adding link of tool {name} -> {symlink}")
os.symlink(full, symlink)
logger.info("Done with linkage")

return super().configure()

0 comments on commit 6df29e5

Please sign in to comment.