Fixes to Automatic UDEV generation

+ Removing blank vid & pids entries to avoid `invalid value` warnings
+ Changing incorrect syntax from `ATTR` to `ATTRS`
+ Adding `Release` build check to .pro to work around code syntax highlighting issue in QTcreator
This commit is contained in:
Chris 2022-04-20 01:04:19 +10:00
parent 0b515ba901
commit 30c80adbe1
2 changed files with 26 additions and 18 deletions

View file

@ -1357,22 +1357,24 @@ unix:!macx {
# ie. QMAKE_EXTRA_TARGETS += udev_rules #
# PRE_TARGETDEPS += udev_rules #
#-------------------------------------------------------------------------------------------#
udev_rules.CONFIG = no_check_exist
udev_rules.target = 60-openrgb.rules
udev_rules.path = $$PREFIX/lib/udev/rules.d/
exists($$udev_rules.target) {
message($$udev_rules.target " - UDEV rules file exists. Removing from build")
udev_rules.files = $$udev_rules.target
} else {
message($$udev_rules.target " - UDEV rules file missing. Adding script to build")
#-------------------------------------------------------------------------------------------#
# This is a compiler config flag to save the preproccessed .ii & .s #
# files so as to automatically process the UDEV rules and the Supported Devices #
#-------------------------------------------------------------------------------------------#
QMAKE_CXXFLAGS+=-save-temps
udev_rules.extra = $$PWD/scripts/build-udev-rules.sh $$PWD $$GIT_COMMIT_ID
udev_rules.files = $$OUT_PWD/60-openrgb.rules
CONFIG(release, debug|release) {
udev_rules.CONFIG = no_check_exist
udev_rules.target = 60-openrgb.rules
udev_rules.path = $$PREFIX/lib/udev/rules.d/
exists($$udev_rules.target) {
message($$udev_rules.target " - UDEV rules file exists. Removing from build")
udev_rules.files = $$udev_rules.target
} else {
message($$udev_rules.target " - UDEV rules file missing. Adding script to build")
#-------------------------------------------------------------------------------------------#
# This is a compiler config flag to save the preproccessed .ii & .s #
# files so as to automatically process the UDEV rules and the Supported Devices #
#-------------------------------------------------------------------------------------------#
QMAKE_CXXFLAGS+=-save-temps
udev_rules.extra = $$PWD/scripts/build-udev-rules.sh $$PWD $$GIT_COMMIT_ID
udev_rules.files = $$OUT_PWD/60-openrgb.rules
}
}
#-------------------------------------------------------------------------------------------#

View file

@ -78,8 +78,14 @@ do
pid=${pid/0x/}
device_name=${device_name//[^[:alnum:][:blank:]]/}
udev_line=$(printf 'SUBSYSTEMS=="%s|hidraw", ATTR{idVendor}=="%s", ATTR{idProduct}=="%s", TAG+="uaccess", TAG+="%s"\n' ${type,,} ${vid,,} ${pid,,} ${device_name// /_})
echo -e "$udev_line" >>"$UDEV_FILE"
udev_line=$(printf 'SUBSYSTEMS=="%s|hidraw", ATTRS{idVendor}=="%s", ATTRS{idProduct}=="%s", TAG+="uaccess", TAG+="%s"\n' ${type,,} ${vid,,} ${pid,,} ${device_name// /_})
#Check to ensure that the vid and pid are not blank
if [[ $vid = "" || $pid = "" ]]; then
echo -e "Blank VID or PID Skipping: ${udev_line}"
else
echo -e "$udev_line" >>"$UDEV_FILE"
fi
done <<< "$text"
done <<< "$detectors"
fi