import os
fileSymbolName = "CAL_FILE_SRC_TNG_"
numFileCntr = 0
def AddFile(component, src_path, dest_path, proj_path, file_type = "SOURCE", isMarkup = False):
global fileSymbolName
global numFileCntr
srcFile = component.createFileSymbol(fileSymbolName + str(numFileCntr) , None)
srcFile.setSourcePath(src_path)
srcFile.setDestPath(dest_path)
srcFile.setProjectPath(proj_path)
srcFile.setType(file_type)
srcFile.setMarkup(isMarkup)
numFileCntr += 1
def AddFilesDir(component, configName, dirPath):
modulePath = Module.getPath()
dirPath = str(modulePath + dirPath)
for (root, dirs, files) in os.walk(dirPath):
for filename in files:
filepath = str(root + os.sep + filename)
source_path = filepath[len(modulePath):]
destination_path = "library" + os.sep + "cryptoauthlib" + os.sep + "tng" + root[len(dirPath):]
project_path = str("config" + os.sep + configName + os.sep + destination_path)
if (".c" in filename):
AddFile(component, source_path , destination_path, project_path)
elif (".h" in filename):
AddFile(component, source_path , destination_path, project_path, "HEADER")
def onAttachmentConnected(source, target):
pass
def onAttachmentDisconnected(source, target):
pass
def instantiateComponent(tngComponent):
Database.activateComponents(['cryptoauthlib'])
configName = Variables.get("__CONFIGURATION_NAME")
AddFilesDir(tngComponent, configName, 'app/tng')