mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-06-10 16:15:15 +02:00
automatically update matterhorn api version when cross compiling binaries
This commit is contained in:
+17
-16
@@ -20,8 +20,8 @@ API_FILE = ROOT_DIR / "slsSupportLib/include/sls/versionAPI.h"
|
||||
VERSION_FILE = ROOT_DIR / "VERSION"
|
||||
|
||||
parser = argparse.ArgumentParser(description = 'updates API version')
|
||||
parser.add_argument('api_module_name', choices=["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"], help = 'module name to change api version options are: ["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"]')
|
||||
parser.add_argument('api_dir', help = 'Relative or absolute path to the module code')
|
||||
parser.add_argument('api_module_name', choices=["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3", "APIMATTERHORN"], help = 'module name to change api version options are: ["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3", "APIMATTERHORN"]')
|
||||
parser.add_argument('api_dirs', nargs="+", help = 'Relative or absolute paths to the module code')
|
||||
|
||||
def update_api_file(new_api : str, api_module_name : str, api_file_name : str):
|
||||
|
||||
@@ -36,21 +36,22 @@ def update_api_file(new_api : str, api_module_name : str, api_file_name : str):
|
||||
else:
|
||||
api_file.write(line)
|
||||
|
||||
def get_latest_modification_date(directory : str):
|
||||
def get_latest_modification_date(directories : list[str]):
|
||||
latest_time = 0
|
||||
latest_date = None
|
||||
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if file.endswith(".o"):
|
||||
continue
|
||||
full_path = os.path.join(root, file)
|
||||
try:
|
||||
mtime = os.path.getmtime(full_path)
|
||||
if mtime > latest_time:
|
||||
latest_time = mtime
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
for directory in directories:
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if file.endswith(".o"):
|
||||
continue
|
||||
full_path = os.path.join(root, file)
|
||||
try:
|
||||
mtime = os.path.getmtime(full_path)
|
||||
if mtime > latest_time:
|
||||
latest_time = mtime
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
latest_date = datetime.fromtimestamp(latest_time).strftime("%y%m%d")
|
||||
|
||||
@@ -74,9 +75,9 @@ if __name__ == "__main__":
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
api_dir = ROOT_DIR / args.api_dir
|
||||
api_dirs = [ROOT_DIR / api_dir for api_dir in args.api_dirs]
|
||||
|
||||
|
||||
update_api_version(args.api_module_name, api_dir)
|
||||
update_api_version(args.api_module_name, api_dirs)
|
||||
|
||||
|
||||
|
||||
@@ -41,8 +41,22 @@ endif() # maybe better to have a else if build with simulators on one always use
|
||||
|
||||
list(APPEND MATTERHORN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/MatterhornServer.cpp)
|
||||
|
||||
#mmh should slsSupportLib be considered as well when updating version?
|
||||
if(CMAKE_TOOLCHAIN_FILE AND NOT CMAKE_TOOLCHAIN_FILE STREQUAL "") # only update version if cross compiling binaries
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter REQUIRED)
|
||||
add_custom_target(update_server_version ALL
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/updateAPIVersion.py APIMATTERHORN ${CMAKE_SOURCE_DIR}/slsDetectorServers/matterhornServer ${CMAKE_SOURCE_DIR}/slsDetectorServers/slsDetectorServer_cpp ${CMAKE_SOURCE_DIR}/slsSupportLib
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Updating APIMATTERHORN version"
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
add_executable(matterhornDetectorServer ${MATTERHORN_SOURCES})
|
||||
|
||||
if(CMAKE_TOOLCHAIN_FILE AND NOT CMAKE_TOOLCHAIN_FILE STREQUAL "") # only update version if cross compiling binaries
|
||||
add_dependencies(matterhornDetectorServer update_server_version)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(matterhornDetectorServer PRIVATE
|
||||
MATTERHORN_SERVER_HEADER=<MatterhornServer.h>
|
||||
MATTERHORN_SERVER_CLASS=MatterhornServer
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
#define APIXILINXCTB "0.0.0 0x260506"
|
||||
#define APIJUNGFRAU "0.0.0 0x260424"
|
||||
#define APIMYTHEN3 "0.0.0 0x260506"
|
||||
#define APIMATTERHORN "0.0.0 0x260212"
|
||||
#define APIMATTERHORN "0.0.0 0x260529"
|
||||
|
||||
Reference in New Issue
Block a user