Rework J1939 and ISO TP feature enabling 37/25137/1 9.99.3 9.99.4 jellyfish/9.99.3 jellyfish/9.99.4 jellyfish_9.99.3 jellyfish_9.99.4
authorScott Murray <scott.murray@konsulko.com>
Wed, 19 Aug 2020 17:08:30 +0000 (13:08 -0400)
committerScott Murray <scott.murray@konsulko.com>
Wed, 19 Aug 2020 17:19:58 +0000 (13:19 -0400)
Rework the J1939 and ISO TP feature enabling logic in config.cmake to:
- define WITH_FEATURE_J1939 and WITH_FEATURE_ISOTP to default to off,
  thus requiring explicit enabling.  This is safer than making
  assumptions based solely on the presence of the headers at build
  time.
- honor WITH_FEATURE_* definitions given on the cmake command-line;
  the checks for header presence only over-ride an "ON" value if the
  required header is not present.

Bug-AGL: SPEC-3538

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: Ie2b84ac50bbed0bbb775cae49f7f4fbe14f2f8ae

conf.d/cmake/config.cmake
docs/3-Installation-J1939.md
docs/4-Installation-ISOTP.md

index 3453d66..5eab8bd 100644 (file)
@@ -44,33 +44,53 @@ set(BUILD_TYPE "DEBUG" CACHE STRING "Default Build variant chosen. (Overwritten
 # Need module in kernel
 # --------------
 
+# Default to off
+set(WITH_FEATURE_J1939 OFF CACHE BOOL "")
+
 execute_process(COMMAND ls $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/can/j1939.h RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET)
 
 if(result)
-       message("Feature J1939 disabled")
+       message("J1939 header not detected!")
+       # Over-ride cached value
        set(WITH_FEATURE_J1939 OFF)
 else()
+       message("J1939 header detected")
+       # Check cache to allow over-ride
+       set(WITH_FEATURE_J1939 ON CACHE BOOL "")
+       # Define name for ECU
+       set(J1939_NAME_ECU 0x1239 CACHE STRING "")
+endif()
+if(WITH_FEATURE_J1939)
        message("Feature J1939 enabled")
-       set(WITH_FEATURE_J1939 ON)
        add_definitions(-DUSE_FEATURE_J1939)
-       # Define name for ECU
-       set(J1939_NAME_ECU 0x1239)
        add_definitions(-DJ1939_NAME_ECU=${J1939_NAME_ECU})
+else()
+       message("Feature J1939 disabled")
 endif()
 
 # Activate ISO TP
 # Need module in kernel
 # --------------
 
+# Default to off
+set(WITH_FEATURE_ISOTP OFF CACHE BOOL "")
+
 execute_process(COMMAND ls $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/can/isotp.h RESULT_VARIABLE result2 OUTPUT_QUIET ERROR_QUIET)
 
 if(result2)
-    message("Feature ISO TP disabled")
-    set(WITH_FEATURE_ISOTP OFF)
+       message("ISO TP header not detected!")
+       # Over-ride cached value
+       set(WITH_FEATURE_ISOTP OFF)
+else()
+       message("ISO TP header detected")
+       # Check cache to allow over-ride
+       set(WITH_FEATURE_ISOTP ON CACHE BOOL "")
+endif()
+if(WITH_FEATURE_ISOTP)
+       message("Feature ISOTP enabled")
+       add_definitions(-DUSE_FEATURE_ISOTP)
 else()
-    message("Feature ISOTP enabled")
-    set(WITH_FEATURE_ISOTP ON)
-    add_definitions(-DUSE_FEATURE_ISOTP)
+       message("Feature ISO TP disabled")
 endif()
 
 
index 8098d47..71595e4 100644 (file)
@@ -79,3 +79,7 @@ cp include/uapi/linux/can.h /usr/include/linux/can.h
 cp include/uapi/linux/can/j1939.h /usr/include/linux/can/
 ```
 
+## Enable support at build time
+
+To enable J1939 support, the binding must be built with -DWITH_FEATURE_J1939=ON.
+If using the autobuild script, add CONFIGURE_ARGS="-DWITH_FEATURE_J1939=ON" to the command used.
index c8fc31f..32a767b 100644 (file)
@@ -47,4 +47,9 @@ sudo insmod ./net/can/can-isotp.ko
 
 ```bash
 sudo cp include/uapi/linux/can/isotp.h /usr/include/linux/can/
-```
\ No newline at end of file
+```
+
+## Enable support at build time
+
+To enable ISO TP support, the binding must be built with -DWITH_FEATURE_ISOTP=ON.
+If using the autobuild script, add CONFIGURE_ARGS="-DWITH_FEATURE_ISOTP=ON" to the command used.