mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
Merge pull request #1209 from slsdetectorgroup/dev/automate_version_part2
Dev/automate version part2
This commit is contained in:
commit
d0a946a919
@ -28,6 +28,7 @@ requirements:
|
|||||||
- libgl-devel # [linux]
|
- libgl-devel # [linux]
|
||||||
- libtiff
|
- libtiff
|
||||||
- zlib
|
- zlib
|
||||||
|
- expat
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
@ -58,6 +59,7 @@ outputs:
|
|||||||
- {{compiler('cxx')}}
|
- {{compiler('cxx')}}
|
||||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||||
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||||
- qt 5.*
|
- qt 5.*
|
||||||
|
26
slsDetectorServers/compileAllServers.sh
Normal file → Executable file
26
slsDetectorServers/compileAllServers.sh
Normal file → Executable file
@ -1,8 +1,6 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
|
||||||
# empty branch = developer branch in updateAPIVersion.sh
|
|
||||||
branch=""
|
|
||||||
det_list=("ctbDetectorServer
|
det_list=("ctbDetectorServer
|
||||||
gotthard2DetectorServer
|
gotthard2DetectorServer
|
||||||
jungfrauDetectorServer
|
jungfrauDetectorServer
|
||||||
@ -10,7 +8,12 @@ det_list=("ctbDetectorServer
|
|||||||
moenchDetectorServer
|
moenchDetectorServer
|
||||||
xilinx_ctbDetectorServer"
|
xilinx_ctbDetectorServer"
|
||||||
)
|
)
|
||||||
usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'"
|
usage="\nUsage: compileAllServers.sh [server|all(opt)] [update_api(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tupdate_api if true updates the api to version in VERSION file"
|
||||||
|
|
||||||
|
update_api=true
|
||||||
|
target=version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# arguments
|
# arguments
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
@ -34,15 +37,12 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
|
|||||||
declare -a det=("${1}")
|
declare -a det=("${1}")
|
||||||
#echo "Compiling only $1"
|
#echo "Compiling only $1"
|
||||||
fi
|
fi
|
||||||
# branch
|
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
# arg in list
|
update_api=$2
|
||||||
if [[ $det_list == *$2* ]]; then
|
if not $update_api ; then
|
||||||
echo -e "Invalid argument 2: $2. $usage"
|
target=clean
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
branch+=$2
|
|
||||||
#echo "with branch $branch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "Too many arguments.$usage"
|
echo -e "Too many arguments.$usage"
|
||||||
@ -53,6 +53,9 @@ declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")
|
|||||||
|
|
||||||
echo -e "list is ${det[@]}"
|
echo -e "list is ${det[@]}"
|
||||||
|
|
||||||
|
if $update_api; then
|
||||||
|
echo "updating api to $(cat ../VERSION)"
|
||||||
|
fi
|
||||||
# compile each server
|
# compile each server
|
||||||
idet=0
|
idet=0
|
||||||
for i in ${det[@]}
|
for i in ${det[@]}
|
||||||
@ -62,14 +65,13 @@ do
|
|||||||
echo -e "Compiling $dir [$file]"
|
echo -e "Compiling $dir [$file]"
|
||||||
cd $dir
|
cd $dir
|
||||||
make clean
|
make clean
|
||||||
if make version API_BRANCH=$branch; then
|
if make $target; then
|
||||||
deterror[$idet]="OK"
|
deterror[$idet]="OK"
|
||||||
else
|
else
|
||||||
deterror[$idet]="FAIL"
|
deterror[$idet]="FAIL"
|
||||||
fi
|
fi
|
||||||
mv bin/$dir bin/$file
|
mv bin/$dir bin/$file
|
||||||
git add -f bin/$file
|
git add -f bin/$file
|
||||||
cp bin/$file /tftpboot/
|
|
||||||
cd ..
|
cd ..
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
((++idet))
|
((++idet))
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
|
|
||||||
# empty branch = developer branch in updateAPIVersion.sh
|
|
||||||
branch=""
|
|
||||||
det_list=("ctbDetectorServer"
|
|
||||||
"gotthard2DetectorServer"
|
|
||||||
"jungfrauDetectorServer"
|
|
||||||
"mythen3DetectorServer"
|
|
||||||
"moenchDetectorServer"
|
|
||||||
"xilinx_ctbDetectorServer"
|
|
||||||
)
|
|
||||||
usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'"
|
|
||||||
|
|
||||||
# arguments
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
# no argument, all servers
|
|
||||||
declare -a det=${det_list[@]}
|
|
||||||
echo "Compiling all servers"
|
|
||||||
elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
|
|
||||||
# 'all' servers
|
|
||||||
if [[ $1 == "all" ]]; then
|
|
||||||
declare -a det=${det_list[@]}
|
|
||||||
echo "Compiling all servers"
|
|
||||||
else
|
|
||||||
# only one server
|
|
||||||
# arg not in list
|
|
||||||
if [[ $det_list != *$1* ]]; then
|
|
||||||
echo -e "Invalid argument 1: $1. $usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
declare -a det=("${1}")
|
|
||||||
#echo "Compiling only $1"
|
|
||||||
fi
|
|
||||||
# branch
|
|
||||||
if [ $# -eq 2 ]; then
|
|
||||||
# arg in list
|
|
||||||
if [[ $det_list == *$2* ]]; then
|
|
||||||
echo -e "Invalid argument 2: $2. $usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
branch+=$2
|
|
||||||
#echo "with branch $branch"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "Too many arguments.$usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")
|
|
||||||
|
|
||||||
echo -e "list is ${det[@]}"
|
|
||||||
|
|
||||||
# compile each server
|
|
||||||
idet=0
|
|
||||||
for i in ${det[@]}
|
|
||||||
do
|
|
||||||
dir=$i
|
|
||||||
file="${i}_developer"
|
|
||||||
echo -e "Compiling $dir [$file]"
|
|
||||||
cd $dir
|
|
||||||
make clean
|
|
||||||
if make API_BRANCH=$branch; then
|
|
||||||
deterror[$idet]="OK"
|
|
||||||
else
|
|
||||||
deterror[$idet]="FAIL"
|
|
||||||
fi
|
|
||||||
mv bin/$dir bin/$file
|
|
||||||
git add -f bin/$file
|
|
||||||
cp bin/$file /tftpboot/
|
|
||||||
cd ..
|
|
||||||
echo -e "\n\n"
|
|
||||||
((++idet))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo -e "Results:"
|
|
||||||
idet=0
|
|
||||||
for i in ${det[@]}
|
|
||||||
do
|
|
||||||
printf "%s\t\t= %s\n" "$i" "${deterror[$idet]}"
|
|
||||||
((++idet))
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
23
slsDetectorServers/compileEigerServer.sh
Normal file → Executable file
23
slsDetectorServers/compileEigerServer.sh
Normal file → Executable file
@ -3,21 +3,31 @@
|
|||||||
deterror="OK"
|
deterror="OK"
|
||||||
dir="eigerDetectorServer"
|
dir="eigerDetectorServer"
|
||||||
file="${dir}_developer"
|
file="${dir}_developer"
|
||||||
branch=""
|
|
||||||
|
usage="\nUsage: compileAllServers.sh [update_api(opt)]. \n\t update_api if true updates the api to version in VERSION file"
|
||||||
|
|
||||||
|
update_api=true
|
||||||
|
target=version
|
||||||
|
|
||||||
# arguments
|
# arguments
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
branch+=$1
|
update_api=$1
|
||||||
#echo "with branch $branch"
|
if not $update_api ; then
|
||||||
|
target=clean
|
||||||
|
|
||||||
|
fi
|
||||||
elif [ ! $# -eq 0 ]; then
|
elif [ ! $# -eq 0 ]; then
|
||||||
echo -e "Only one optional argument allowed for branch."
|
echo -e "Only one optional argument allowed for update_api."
|
||||||
return -1
|
return -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $update_api; then
|
||||||
|
echo "updating api to $(cat ../VERSION)"
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "Compiling $dir [$file]"
|
echo -e "Compiling $dir [$file]"
|
||||||
cd $dir
|
cd $dir
|
||||||
make clean
|
if make $target; then
|
||||||
if make version API_BRANCH=$branch; then
|
|
||||||
deterror="OK"
|
deterror="OK"
|
||||||
else
|
else
|
||||||
deterror="FAIL"
|
deterror="FAIL"
|
||||||
@ -25,7 +35,6 @@ fi
|
|||||||
|
|
||||||
mv bin/$dir bin/$file
|
mv bin/$dir bin/$file
|
||||||
git add -f bin/$file
|
git add -f bin/$file
|
||||||
cp bin/$file /tftpboot/
|
|
||||||
cd ..
|
cd ..
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
printf "Result:\t\t= %s\n" "${deterror}"
|
printf "Result:\t\t= %s\n" "${deterror}"
|
||||||
|
@ -25,11 +25,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APICTB
|
version_name=APICTB
|
||||||
version_path=slsDetectorServers/ctbDetectorServer
|
version_path=slsDetectorServers/ctbDetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -25,11 +25,10 @@ version: clean versioning $(PROGS) #hv9m_blackfin_server
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIEIGER
|
version_name=APIEIGER
|
||||||
version_path=slsDetectorServers/eigerDetectorServer
|
version_path=slsDetectorServers/eigerDetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -24,11 +24,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIGOTTHARD2
|
version_name=APIGOTTHARD2
|
||||||
version_path=slsDetectorServers/gotthard2DetectorServer
|
version_path=slsDetectorServers/gotthard2DetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -24,11 +24,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIJUNGFRAU
|
version_name=APIJUNGFRAU
|
||||||
version_path=slsDetectorServers/jungfrauDetectorServer
|
version_path=slsDetectorServers/jungfrauDetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -24,11 +24,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIMOENCH
|
version_name=APIMOENCH
|
||||||
version_path=slsDetectorServers/moenchDetectorServer
|
version_path=slsDetectorServers/moenchDetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -25,11 +25,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIMYTHEN3
|
version_name=APIMYTHEN3
|
||||||
version_path=slsDetectorServers/mythen3DetectorServer
|
version_path=slsDetectorServers/mythen3DetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -36,11 +36,10 @@ version: clean versioning $(PROGS)
|
|||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
version_branch=$(API_BRANCH)
|
|
||||||
version_name=APIXILINXCTB
|
version_name=APIXILINXCTB
|
||||||
version_path=slsDetectorServers/xilinx_ctbDetectorServer
|
version_path=slsDetectorServers/xilinx_ctbDetectorServer
|
||||||
versioning:
|
versioning:
|
||||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
|
@ -11,7 +11,7 @@ class Version {
|
|||||||
private:
|
private:
|
||||||
std::string version_;
|
std::string version_;
|
||||||
std::string date_;
|
std::string date_;
|
||||||
const std::string defaultBranch_ = "developer";
|
inline static const std::string defaultVersion_[] = {"developer", "0.0.0"};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Version(const std::string &s);
|
explicit Version(const std::string &s);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
/** API versions */
|
/** API versions */
|
||||||
#define APILIB "developer 0x241122"
|
#define APILIB "0.0.0 0x250523"
|
||||||
#define APIRECEIVER "developer 0x241122"
|
#define APIRECEIVER "0.0.0 0x250523"
|
||||||
#define APIGOTTHARD2 "developer 0x250310"
|
#define APICTB "0.0.0 0x250523"
|
||||||
#define APIMOENCH "developer 0x250310"
|
#define APIGOTTHARD2 "0.0.0 0x250523"
|
||||||
#define APIEIGER "developer 0x250310"
|
#define APIMOENCH "0.0.0 0x250523"
|
||||||
#define APIXILINXCTB "developer 0x250311"
|
#define APIEIGER "0.0.0 0x250523"
|
||||||
#define APIJUNGFRAU "developer 0x250318"
|
#define APIXILINXCTB "0.0.0 0x250523"
|
||||||
#define APIMYTHEN3 "developer 0x250409"
|
#define APIJUNGFRAU "0.0.0 0x250523"
|
||||||
#define APICTB "developer 0x250519"
|
#define APIMYTHEN3 "0.0.0 0x250523"
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ Version::Version(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Version::hasSemanticVersioning() const {
|
bool Version::hasSemanticVersioning() const {
|
||||||
return version_ != defaultBranch_;
|
|
||||||
|
return (version_ != defaultVersion_[0]) && (version_ != defaultVersion_[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Version::getVersion() const { return version_; }
|
std::string Version::getVersion() const { return version_; }
|
||||||
|
@ -14,6 +14,7 @@ target_sources(tests PRIVATE
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-TypeTraits.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-TypeTraits.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-UdpRxSocket.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-UdpRxSocket.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-logger.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-logger.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test-Version.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-ZmqSocket.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-ZmqSocket.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
19
slsSupportLib/tests/test-Version.cpp
Normal file
19
slsSupportLib/tests/test-Version.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#include "catch.hpp"
|
||||||
|
#include "sls/Version.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
TEST_CASE("check if version is semantic", "[.version]") {
|
||||||
|
|
||||||
|
auto [version_string, has_semantic_version] =
|
||||||
|
GENERATE(std::make_tuple("developer 0x250512", false),
|
||||||
|
std::make_tuple("0.0.0 0x250512", false));
|
||||||
|
|
||||||
|
Version version(version_string);
|
||||||
|
|
||||||
|
CHECK(version.hasSemanticVersioning() == has_semantic_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
81
updateAPIVersion.py
Normal file
81
updateAPIVersion.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2025 Contributors to the SLS Detector Package
|
||||||
|
"""
|
||||||
|
Script to update API VERSION file based on the version in VERSION file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
API_FILE = SCRIPT_DIR + "/slsSupportLib/include/sls/versionAPI.h"
|
||||||
|
|
||||||
|
VERSION_FILE = SCRIPT_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')
|
||||||
|
|
||||||
|
def update_api_file(new_api : str, api_module_name : str, api_file_name : str):
|
||||||
|
|
||||||
|
regex_pattern = re.compile(rf'#define\s+{api_module_name}\s+')
|
||||||
|
with open(api_file_name, "r") as api_file:
|
||||||
|
lines = api_file.readlines()
|
||||||
|
|
||||||
|
with open(api_file_name, "w") as api_file:
|
||||||
|
for line in lines:
|
||||||
|
if regex_pattern.match(line):
|
||||||
|
api_file.write(f'#define {api_module_name} "{new_api}"\n')
|
||||||
|
else:
|
||||||
|
api_file.write(line)
|
||||||
|
|
||||||
|
def get_latest_modification_date(directory : 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
|
||||||
|
|
||||||
|
latest_date = datetime.fromtimestamp(latest_time).strftime("%y%m%d")
|
||||||
|
|
||||||
|
return latest_date
|
||||||
|
|
||||||
|
|
||||||
|
def update_api_version(api_module_name : str, api_dir : str):
|
||||||
|
api_date = get_latest_modification_date(api_dir)
|
||||||
|
api_date = "0x"+str(api_date)
|
||||||
|
|
||||||
|
with open(VERSION_FILE, "r") as version_file:
|
||||||
|
api_version = version_file.read().strip()
|
||||||
|
|
||||||
|
api_version = api_version + " " + api_date #not sure if we should give an argument option version_branch
|
||||||
|
|
||||||
|
update_api_file(api_version, api_module_name, API_FILE)
|
||||||
|
|
||||||
|
print(f"updated {api_module_name} api version to: {api_version}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
api_dir = SCRIPT_DIR + "/" + args.api_dir
|
||||||
|
|
||||||
|
|
||||||
|
update_api_version(args.api_module_name, api_dir)
|
||||||
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
usage="\nUsage: updateAPIVersion.sh [API_NAME] [API_DIR] [API_BRANCH(opt)]."
|
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
|
||||||
echo -e "Requires atleast 2 arguments. $usage"
|
|
||||||
return [-1]
|
|
||||||
fi
|
|
||||||
|
|
||||||
API_NAME=$1
|
|
||||||
PACKAGE_DIR=$PWD
|
|
||||||
API_DIR=$PACKAGE_DIR/$2
|
|
||||||
API_FILE=$PACKAGE_DIR/slsSupportLib/include/sls/versionAPI.h
|
|
||||||
CURR_DIR=$PWD
|
|
||||||
|
|
||||||
if [ ! -d "$API_DIR" ]; then
|
|
||||||
echo "[API_DIR] does not exist. $usage"
|
|
||||||
return [-1]
|
|
||||||
fi
|
|
||||||
|
|
||||||
#go to directory
|
|
||||||
cd $API_DIR
|
|
||||||
|
|
||||||
#deleting line from file
|
|
||||||
NUM=$(sed -n '/'$API_NAME' /=' $API_FILE)
|
|
||||||
#echo $NUM
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$NUM" -gt 0 ]; then
|
|
||||||
sed -i ${NUM}d $API_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
#find new API date
|
|
||||||
API_DATE="find . -printf \"%T@ %CY-%Cm-%Cd\n\"| sort -nr | cut -d' ' -f2- | egrep -v '(\.)o' | head -n 1"
|
|
||||||
|
|
||||||
API_DATE=`eval $API_DATE`
|
|
||||||
|
|
||||||
API_DATE=$(sed "s/-//g" <<< $API_DATE | awk '{print $1;}' )
|
|
||||||
|
|
||||||
#extracting only date
|
|
||||||
API_DATE=${API_DATE:2:6}
|
|
||||||
|
|
||||||
#prefix of 0x
|
|
||||||
API_DATE=${API_DATE/#/0x}
|
|
||||||
echo "date="$API_DATE
|
|
||||||
|
|
||||||
|
|
||||||
# API_VAL concatenates branch and date
|
|
||||||
API_VAL=""
|
|
||||||
# API branch is defined (3rd argument)
|
|
||||||
if [ $# -eq 3 ]; then
|
|
||||||
API_BRANCH=$3
|
|
||||||
echo "branch="$API_BRANCH
|
|
||||||
API_VAL+="\"$API_BRANCH $API_DATE\""
|
|
||||||
else
|
|
||||||
# API branch not defined (default is developer)
|
|
||||||
echo "branch=developer"
|
|
||||||
API_VAL+="\"developer $API_DATE\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
#copy it to versionAPI.h
|
|
||||||
echo "#define "$API_NAME $API_VAL >> $API_FILE
|
|
||||||
|
|
||||||
#go back to original directory
|
|
||||||
cd $CURR_DIR
|
|
34
updateClientAPIVersion.py
Normal file
34
updateClientAPIVersion.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2025 Contributors to the SLS Detector Package
|
||||||
|
"""
|
||||||
|
Script to update API VERSION for slsReceiverSoftware or slsDetectorSoftware
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
|
from updateAPIVersion import update_api_version
|
||||||
|
|
||||||
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description = 'updates API version')
|
||||||
|
parser.add_argument('module_name', nargs="?", choices=["slsDetectorSoftware", "slsReceiverSoftware", "all"], default="all", help = 'module name to change api version options are: ["slsDetectorSoftware", "slsReceiverSoftware, "all"]')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.module_name == "all":
|
||||||
|
client_names = ["APILIB", "APIRECEIVER"]
|
||||||
|
client_directories = [SCRIPT_DIR+"/slsDetectorSoftware", SCRIPT_DIR+"/slsReceiverSoftware"]
|
||||||
|
elif args.module_name == "slsDetectorSoftware":
|
||||||
|
client_names = ["APILIB"]
|
||||||
|
client_directories = [SCRIPT_DIR+"/slsDetectorSoftware"]
|
||||||
|
else:
|
||||||
|
client_names = ["APIRECEIVER"]
|
||||||
|
client_directories = [SCRIPT_DIR+"/slsReceiverSoftware"]
|
||||||
|
|
||||||
|
for client_name, client_directory in zip(client_names, client_directories):
|
||||||
|
update_api_version(client_name, client_directory)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
branch=""
|
|
||||||
client_list=("slsDetectorSoftware" "slsReceiverSoftware")
|
|
||||||
usage="\nUsage: updateClientAPI.sh [all|slsDetectorSoftware|slsReceiverSoftware] [branch]. \n\tNo arguments means all with 'developer' branch. \n\tNo 'branch' input means 'developer branch'"
|
|
||||||
|
|
||||||
# arguments
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
declare -a client=${client_list[@]}
|
|
||||||
echo "API Versioning all"
|
|
||||||
elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
|
|
||||||
# 'all' client
|
|
||||||
if [[ $1 == "all" ]]; then
|
|
||||||
declare -a client=${client_list[@]}
|
|
||||||
echo "API Versioning all"
|
|
||||||
else
|
|
||||||
# only one server
|
|
||||||
if [[ $client_list != *$1* ]]; then
|
|
||||||
echo -e "Invalid argument 1: $1. $usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
declare -a client=("${1}")
|
|
||||||
#echo "Versioning only $1"
|
|
||||||
fi
|
|
||||||
if [ $# -eq 2 ]; then
|
|
||||||
if [[ $client_list == *$2* ]]; then
|
|
||||||
echo -e "Invalid argument 2: $2. $usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
branch+=$2
|
|
||||||
#echo "with branch $branch"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "Too many arguments.$usage"
|
|
||||||
return -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#echo "list is: ${client[@]}"
|
|
||||||
|
|
||||||
# versioning each client
|
|
||||||
for i in ${client[@]}
|
|
||||||
do
|
|
||||||
dir=$i
|
|
||||||
case $dir in
|
|
||||||
slsDetectorSoftware)
|
|
||||||
declare -a name=APILIB
|
|
||||||
;;
|
|
||||||
slsReceiverSoftware)
|
|
||||||
declare -a name=APIRECEIVER
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -n "unknown client argument $i"
|
|
||||||
return -1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo -e "Versioning $dir [$name]"
|
|
||||||
./updateAPIVersion.sh $name $dir $branch
|
|
||||||
done
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user