From 432f2ba5119a61d477d77764a4cbb57729c35c45 Mon Sep 17 00:00:00 2001 From: Ambroz Bizjak Date: Sat, 27 Aug 2016 17:09:48 +0200 Subject: [PATCH] NCD: Fix evdev event code names with newer headers. Most of the event codes may be defined in another header file not directly in linux/input.h. Also remove _MAX and _CNT codes. --- ncd/CMakeLists.txt | 13 ++++++++++--- ncd/parse_linux_input.sh | 13 ++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ncd/CMakeLists.txt b/ncd/CMakeLists.txt index a4feb27f3..9bd820444 100644 --- a/ncd/CMakeLists.txt +++ b/ncd/CMakeLists.txt @@ -171,12 +171,19 @@ if (BADVPN_USE_LINUX_INPUT) message(FATAL_ERROR "failed to match preprocessor output for path of linux/input.h") endif () set(LINUX_INPUT_H_PATH ${CMAKE_MATCH_1}) - - message(STATUS "Generating linux_input_names.h from ${LINUX_INPUT_H_PATH}") + + string(REGEX MATCH "\"(/[^\"]+/linux/input-event-codes.h)\"" LINUX_INPUT_EVENT_CODES_MATCH ${LINUX_INPUT_PREPROCESS_OUTPUT}) + if (NOT LINUX_INPUT_EVENT_CODES_MATCH) + set(LINUX_INPUT_EVENT_CODES_H_PATH) + else () + set(LINUX_INPUT_EVENT_CODES_H_PATH ${CMAKE_MATCH_1}) + endif () + + message(STATUS "Generating linux_input_names.h from ${LINUX_INPUT_H_PATH} ${LINUX_INPUT_EVENT_CODES_H_PATH}") execute_process(COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/parse_linux_input.sh - ${LINUX_INPUT_H_PATH} ${CMAKE_CURRENT_BINARY_DIR}/linux_input_names.h + ${LINUX_INPUT_H_PATH} ${LINUX_INPUT_EVENT_CODES_H_PATH} RESULT_VARIABLE LINUX_INPUT_PARSE_RESULT) if (NOT LINUX_INPUT_PARSE_RESULT EQUAL 0) message(FATAL_ERROR "failed to generate linux_input_names.h") diff --git a/ncd/parse_linux_input.sh b/ncd/parse_linux_input.sh index 9064c1d16..65e140915 100755 --- a/ncd/parse_linux_input.sh +++ b/ncd/parse_linux_input.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -INPUT=$1 -OUTPUT=$2 +OUTPUT=$1 +shift +INPUTS=("$@") types="" keys="" @@ -18,10 +19,12 @@ ffstatuss="" while read LINE; do tab=$'\t' space="[ ${tab}]" - regex="^#define ((EV|SYN|KEY|BTN|REL|ABS|SW|MSC|LED|REP|SND|FF_STATUS)_[A-Z0-9_]+)${space}" + regex="^#define ((EV|SYN|KEY|BTN|REL|ABS|SW|MSC|LED|REP|SND|FF_STATUS)_([A-Z0-9_]+))${space}" if [[ $LINE =~ $regex ]]; then - type=${BASH_REMATCH[2]} name=${BASH_REMATCH[1]} + type=${BASH_REMATCH[2]} + nameonly=${BASH_REMATCH[3]} + [[ $nameonly = "MAX" || $nameonly = "CNT" ]] && continue if [[ $type = "EV" ]]; then if [[ $name != "EV_VERSION" ]]; then types="${types} [${name}] = \"${name}\", @@ -61,7 +64,7 @@ while read LINE; do " fi fi -done < "${INPUT}" +done < <(cat "${INPUTS[@]}") ( echo "