Change directory architecture to use 2 separated projects.
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 14 Apr 2017 11:24:07 +0000 (13:24 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 14 Apr 2017 11:24:07 +0000 (13:24 +0200)
Each projects, binder and generator, has to be compiled separatly.
CAN-binder will host high and low level binding
CAN-config-generator only the generator used for low level binding.
build.sh script just launch both build in their respective dir.

Change-Id: Ic77932660fcca507b23a631d4e4e790f608880ae
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
118 files changed:
.gitmodules
CAN-binder/CMakeLists.txt [moved from CMakeLists.txt with 100% similarity]
CAN-binder/Makefile [new file with mode: 0644]
CAN-binder/can_samples/citroen/citroen_c5_highway_1 [moved from can_samples/citroen/citroen_c5_highway_1 with 100% similarity]
CAN-binder/can_samples/citroen/citroen_c5_highway_2 [moved from can_samples/citroen/citroen_c5_highway_2 with 100% similarity]
CAN-binder/can_samples/ford/focus/accel [moved from can_samples/ford/focus/accel with 100% similarity]
CAN-binder/can_samples/ford/focus/alldoors_lock [moved from can_samples/ford/focus/alldoors_lock with 100% similarity]
CAN-binder/can_samples/ford/focus/alldoors_open [moved from can_samples/ford/focus/alldoors_open with 100% similarity]
CAN-binder/can_samples/ford/focus/brake [moved from can_samples/ford/focus/brake with 100% similarity]
CAN-binder/can_samples/ford/focus/handbrake [moved from can_samples/ford/focus/handbrake with 100% similarity]
CAN-binder/can_samples/ford/focus/ignition [moved from can_samples/ford/focus/ignition with 100% similarity]
CAN-binder/can_samples/ford/focus/lights [moved from can_samples/ford/focus/lights with 100% similarity]
CAN-binder/can_samples/ford/focus/turnleft [moved from can_samples/ford/focus/turnleft with 100% similarity]
CAN-binder/can_samples/ford/focus/turnright [moved from can_samples/ford/focus/turnright with 100% similarity]
CAN-binder/can_samples/init_can.sh [moved from can_samples/init_can.sh with 100% similarity]
CAN-binder/can_samples/init_vcan.sh [moved from can_samples/init_vcan.sh with 100% similarity]
CAN-binder/can_samples/toyota/auris/accel [moved from can_samples/toyota/auris/accel with 100% similarity]
CAN-binder/can_samples/toyota/auris/alldoors_lock [moved from can_samples/toyota/auris/alldoors_lock with 100% similarity]
CAN-binder/can_samples/toyota/auris/alldoors_unlock [moved from can_samples/toyota/auris/alldoors_unlock with 100% similarity]
CAN-binder/can_samples/toyota/auris/brake [moved from can_samples/toyota/auris/brake with 100% similarity]
CAN-binder/can_samples/toyota/auris/engineoff [moved from can_samples/toyota/auris/engineoff with 100% similarity]
CAN-binder/can_samples/toyota/auris/handbrake [moved from can_samples/toyota/auris/handbrake with 100% similarity]
CAN-binder/can_samples/toyota/auris/ignition [moved from can_samples/toyota/auris/ignition with 100% similarity]
CAN-binder/can_samples/toyota/auris/keydisengage [moved from can_samples/toyota/auris/keydisengage with 100% similarity]
CAN-binder/can_samples/toyota/auris/keyengage [moved from can_samples/toyota/auris/keyengage with 100% similarity]
CAN-binder/can_samples/toyota/auris/keyin [moved from can_samples/toyota/auris/keyin with 100% similarity]
CAN-binder/can_samples/toyota/auris/keyout [moved from can_samples/toyota/auris/keyout with 100% similarity]
CAN-binder/can_samples/toyota/auris/lights [moved from can_samples/toyota/auris/lights with 100% similarity]
CAN-binder/can_samples/toyota/auris/trip_test_with_obd2_vehicle_speed_requests [moved from can_samples/toyota/auris/trip_test_with_obd2_vehicle_speed_requests with 100% similarity]
CAN-binder/can_samples/toyota/auris/turnleft [moved from can_samples/toyota/auris/turnleft with 100% similarity]
CAN-binder/can_samples/toyota/auris/turnright [moved from can_samples/toyota/auris/turnright with 100% similarity]
CAN-binder/etc/config.cmake [moved from etc/config.cmake with 100% similarity]
CAN-binder/etc/export.map [moved from etc/export.map with 100% similarity]
CAN-binder/examples/basic/generate_example.cpp [moved from examples/basic/generate_example.cpp with 100% similarity]
CAN-binder/examples/basic/handlers.cpp [moved from can-config-generator/tests/handlers.cpp with 100% similarity]
CAN-binder/examples/basic/signals.json [moved from examples/basic/signals.json with 100% similarity]
CAN-binder/examples/toyota/configuration-generated.cpp [moved from examples/toyota/configuration-generated.cpp with 100% similarity]
CAN-binder/examples/toyota/signals.json [moved from examples/toyota/signals.json with 100% similarity]
CAN-binder/libs/CMakeLists.txt [moved from libs/CMakeLists.txt with 100% similarity]
CAN-binder/libs/bitfield-c [moved from libs/bitfield-c with 100% similarity]
CAN-binder/libs/isotp-c [moved from libs/isotp-c with 100% similarity]
CAN-binder/libs/nanopb [moved from libs/nanopb with 100% similarity]
CAN-binder/libs/openxc-message-format [moved from libs/openxc-message-format with 100% similarity]
CAN-binder/libs/uds-c [moved from libs/uds-c with 100% similarity]
CAN-binder/low-can-binding/CMakeLists.txt [moved from low-can-binding/CMakeLists.txt with 100% similarity]
CAN-binder/low-can-binding/can/can-bus-dev.cpp [moved from low-can-binding/can/can-bus-dev.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-bus-dev.hpp [moved from low-can-binding/can/can-bus-dev.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-bus.cpp [moved from low-can-binding/can/can-bus.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-bus.hpp [moved from low-can-binding/can/can-bus.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-command.hpp [moved from low-can-binding/can/can-command.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-decoder.cpp [moved from low-can-binding/can/can-decoder.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-decoder.hpp [moved from low-can-binding/can/can-decoder.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message-definition.cpp [moved from low-can-binding/can/can-message-definition.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message-definition.hpp [moved from low-can-binding/can/can-message-definition.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message-set.cpp [moved from low-can-binding/can/can-message-set.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message-set.hpp [moved from low-can-binding/can/can-message-set.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message.cpp [moved from low-can-binding/can/can-message.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-message.hpp [moved from low-can-binding/can/can-message.hpp with 100% similarity]
CAN-binder/low-can-binding/can/can-signals.cpp [moved from low-can-binding/can/can-signals.cpp with 100% similarity]
CAN-binder/low-can-binding/can/can-signals.hpp [moved from low-can-binding/can/can-signals.hpp with 100% similarity]
CAN-binder/low-can-binding/configuration-generated.cpp [moved from low-can-binding/configuration-generated.cpp with 100% similarity]
CAN-binder/low-can-binding/configuration.cpp [moved from low-can-binding/configuration.cpp with 100% similarity]
CAN-binder/low-can-binding/configuration.hpp [moved from low-can-binding/configuration.hpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp [moved from low-can-binding/diagnostic/active-diagnostic-request.cpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp [moved from low-can-binding/diagnostic/active-diagnostic-request.hpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp [moved from low-can-binding/diagnostic/diagnostic-manager.cpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp [moved from low-can-binding/diagnostic/diagnostic-manager.hpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp [moved from low-can-binding/diagnostic/diagnostic-message.cpp with 100% similarity]
CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp [moved from low-can-binding/diagnostic/diagnostic-message.hpp with 100% similarity]
CAN-binder/low-can-binding/low-can-binding.cpp [moved from low-can-binding/low-can-binding.cpp with 100% similarity]
CAN-binder/low-can-binding/low-can-binding.hpp [moved from low-can-binding/low-can-binding.hpp with 100% similarity]
CAN-binder/low-can-binding/packaging/wgt/config.xml [moved from low-can-binding/packaging/wgt/config.xml with 100% similarity]
CAN-binder/low-can-binding/packaging/wgt/etc/can_buses.json [moved from low-can-binding/packaging/wgt/etc/can_buses.json with 100% similarity]
CAN-binder/low-can-binding/packaging/wgt/icon.png [moved from low-can-binding/packaging/wgt/icon.png with 100% similarity]
CAN-binder/low-can-binding/utils/config-parser.cpp [moved from low-can-binding/utils/config-parser.cpp with 100% similarity]
CAN-binder/low-can-binding/utils/config-parser.hpp [moved from low-can-binding/utils/config-parser.hpp with 100% similarity]
CAN-binder/low-can-binding/utils/openxc-utils.cpp [moved from low-can-binding/utils/openxc-utils.cpp with 100% similarity]
CAN-binder/low-can-binding/utils/openxc-utils.hpp [moved from low-can-binding/utils/openxc-utils.hpp with 100% similarity]
CAN-binder/low-can-binding/utils/signals.cpp [moved from low-can-binding/utils/signals.cpp with 100% similarity]
CAN-binder/low-can-binding/utils/signals.hpp [moved from low-can-binding/utils/signals.hpp with 100% similarity]
CAN-binder/low-can-binding/utils/socket.cpp [moved from low-can-binding/utils/socket.cpp with 100% similarity]
CAN-binder/low-can-binding/utils/socket.hpp [moved from low-can-binding/utils/socket.hpp with 100% similarity]
CAN-binder/low-can-binding/utils/timer.cpp [moved from low-can-binding/utils/timer.cpp with 100% similarity]
CAN-binder/low-can-binding/utils/timer.hpp [moved from low-can-binding/utils/timer.hpp with 100% similarity]
CAN-config-generator/.gitignore [moved from can-config-generator/.gitignore with 100% similarity]
CAN-config-generator/3rdparty/json/json.hpp [moved from can-config-generator/3rdparty/json/json.hpp with 100% similarity]
CAN-config-generator/CMakeLists.txt [new file with mode: 0644]
CAN-config-generator/LICENSE [moved from can-config-generator/LICENSE with 100% similarity]
CAN-config-generator/Makefile [new file with mode: 0644]
CAN-config-generator/README.md [moved from can-config-generator/README.md with 100% similarity]
CAN-config-generator/build.sh [moved from can-config-generator/build.sh with 100% similarity]
CAN-config-generator/can-config-generator.sln [moved from can-config-generator/can-config-generator.sln with 100% similarity]
CAN-config-generator/can-config-generator.vcxproj [moved from can-config-generator/can-config-generator.vcxproj with 100% similarity]
CAN-config-generator/etc/config.cmake [new file with mode: 0644]
CAN-config-generator/etc/export.map [new file with mode: 0644]
CAN-config-generator/src/CMakeLists.txt [moved from can-config-generator/CMakeLists.txt with 81% similarity]
CAN-config-generator/src/main.cpp [moved from can-config-generator/src/main.cpp with 100% similarity]
CAN-config-generator/src/main.hpp [moved from can-config-generator/src/main.hpp with 100% similarity]
CAN-config-generator/src/openxc/can_bus.cpp [moved from can-config-generator/src/openxc/can_bus.cpp with 100% similarity]
CAN-config-generator/src/openxc/can_bus.hpp [moved from can-config-generator/src/openxc/can_bus.hpp with 100% similarity]
CAN-config-generator/src/openxc/can_message.cpp [moved from can-config-generator/src/openxc/can_message.cpp with 100% similarity]
CAN-config-generator/src/openxc/can_message.hpp [moved from can-config-generator/src/openxc/can_message.hpp with 100% similarity]
CAN-config-generator/src/openxc/command.cpp [moved from can-config-generator/src/openxc/command.cpp with 100% similarity]
CAN-config-generator/src/openxc/command.hpp [moved from can-config-generator/src/openxc/command.hpp with 100% similarity]
CAN-config-generator/src/openxc/diagnostic_message.cpp [moved from can-config-generator/src/openxc/diagnostic_message.cpp with 100% similarity]
CAN-config-generator/src/openxc/diagnostic_message.hpp [moved from can-config-generator/src/openxc/diagnostic_message.hpp with 100% similarity]
CAN-config-generator/src/openxc/mapping.cpp [moved from can-config-generator/src/openxc/mapping.cpp with 100% similarity]
CAN-config-generator/src/openxc/mapping.hpp [moved from can-config-generator/src/openxc/mapping.hpp with 100% similarity]
CAN-config-generator/src/openxc/message_set.cpp [moved from can-config-generator/src/openxc/message_set.cpp with 100% similarity]
CAN-config-generator/src/openxc/message_set.hpp [moved from can-config-generator/src/openxc/message_set.hpp with 100% similarity]
CAN-config-generator/src/openxc/signal.cpp [moved from can-config-generator/src/openxc/signal.cpp with 100% similarity]
CAN-config-generator/src/openxc/signal.hpp [moved from can-config-generator/src/openxc/signal.hpp with 100% similarity]
CAN-config-generator/tests/basic.json [moved from can-config-generator/tests/basic.json with 100% similarity]
CAN-config-generator/tests/generated.cpp [moved from can-config-generator/tests/generated.cpp with 100% similarity]
CAN-config-generator/tests/handlers.cpp [moved from examples/basic/handlers.cpp with 100% similarity]
CAN-config-generator/tests/signals.json [moved from can-config-generator/tests/signals.json with 100% similarity]
README.md
build.sh

index db4dd12..8441eea 100644 (file)
@@ -1,15 +1,15 @@
 [submodule "low-can-binding/libs/openxc-message-format"]
-       path = libs/openxc-message-format
+       path = CAN-binder/libs/openxc-message-format
        url = https://github.com/openxc/openxc-message-format
 [submodule "low-can-binding/libs/nanopb"]
-       path = libs/nanopb
+       path = CAN-binder/libs/nanopb
        url = https://github.com/nanopb/nanopb.git
 [submodule "low-can-binding/libs/uds-c"]
-       path = libs/uds-c
+       path = CAN-binder/libs/uds-c
        url = https://github.com/openxc/uds-c.git
 [submodule "low-can-binding/libs/bitfield-c"]
-       path = libs/bitfield-c
+       path = CAN-binder/libs/bitfield-c
        url = https://github.com/openxc/bitfield-c.git
 [submodule "low-can-binding/libs/isotp-c"]
-       path = libs/isotp-c
+       path = CAN-binder/libs/isotp-c
        url = https://github.com/openxc/isotp-c
similarity index 100%
rename from CMakeLists.txt
rename to CAN-binder/CMakeLists.txt
diff --git a/CAN-binder/Makefile b/CAN-binder/Makefile
new file mode 100644 (file)
index 0000000..658ef32
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+BUILD_DIR   := build
+
+.PHONY: all clean mrproper ${BUILD_DIR}/Makefile
+
+all: build package
+
+clean:
+       @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+mrproper:
+       rm -rf ${BUILD_DIR}
+
+build:  ${BUILD_DIR}/Makefile
+       cmake --build ${BUILD_DIR} --clean-first
+
+
+package:
+       cmake --build ${BUILD_DIR} --target widget
+
+${BUILD_DIR}/Makefile:
+       @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+       @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CMAKE_OPTS} ..)
similarity index 100%
rename from etc/config.cmake
rename to CAN-binder/etc/config.cmake
similarity index 100%
rename from etc/export.map
rename to CAN-binder/etc/export.map
similarity index 100%
rename from libs/bitfield-c
rename to CAN-binder/libs/bitfield-c
similarity index 100%
rename from libs/isotp-c
rename to CAN-binder/libs/isotp-c
similarity index 100%
rename from libs/nanopb
rename to CAN-binder/libs/nanopb
similarity index 100%
rename from libs/uds-c
rename to CAN-binder/libs/uds-c
diff --git a/CAN-config-generator/CMakeLists.txt b/CAN-config-generator/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ec91089
--- /dev/null
@@ -0,0 +1,283 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+# contrib: Romain Forlot <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+
+#--------------------------------------------------------------------------
+#  WARNING: 
+#     Do not change this cmake template
+#     Customise your preferences in "./etc/config.cmake"
+#--------------------------------------------------------------------------
+
+
+# Generic useful macro
+# -----------------------
+macro(PROJECT_TARGET_ADD TARGET_NAME)
+       set(PROJECT_TARGETS ${PROJECT_TARGETS} ${TARGET_NAME} CACHE INTERNAL PROJECT_TARGETS)
+       set(TARGET_NAME ${TARGET_NAME})
+endmacro(PROJECT_TARGET_ADD)
+
+macro(defstr name value)
+       add_definitions(-D${name}=${value})
+endmacro(defstr)
+
+macro(setc name value)
+       if(NOT DEFINED ${name})
+       set(${name} ${value})
+       endif(NOT DEFINED ${name})
+endmacro(setc)
+
+# Dumb macro to add each directory under a path. Make sure we grab all header files!
+macro(fill_include_dir path)
+       file(GLOB_RECURSE dirlist LIST_DIRECTORIES true "${path}/*")
+       foreach(filename ${dirlist})
+               if(IS_DIRECTORY ${filename})
+                       include_directories(${filename})
+               endif(IS_DIRECTORY ${filename})
+       endforeach()
+endmacro(fill_include_dir)
+
+# Helper function to retrieve source files from a library repo.
+function(find_source_files path)
+       file(GLOB_RECURSE filelist "${path}/*.[cpx]")
+       foreach(filename ${filelist})
+               if(NOT ${filename} MATCHES ".*(test|example|sample).*")
+                       string(APPEND sources "${filename};")
+               endif(NOT ${filename} MATCHES ".*(test|example|sample).*")
+       endforeach()
+       set(sources_files ${sources} PARENT_SCOPE)
+endfunction(find_source_files)
+
+# WGT packaging function. TYPE can be HTML5, NATIVE, HTML5-HYBRID or BINDING
+macro(build_widget type)
+       message(STATUS "Creation of ${TARGET_NAME}.wgt package for AppFW")
+
+       configure_file(${PROJECT_WGT_DIR}/config.xml config.xml)
+
+       if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/etc")
+               file(GLOB conf_files "${PROJECT_WGT_DIR}/etc/*")
+               foreach(filename ${conf_files})
+                       STRING(REGEX REPLACE "^.*/(.*)$" "\\1" shortname ${filename})
+                       message(STATUS "Copying config file ${shortname}")
+                       configure_file(${filename} ${shortname})
+               endforeach()
+       endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/etc")
+
+       # Include HTML5 files to be packaged
+       if(${type} STREQUAL "HTML5")
+               file(GLOB_RECURSE HTML5FILES app/*)
+
+               if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gulpfile.js")
+                       set(HTML5FILES ${HTML5FILES} "${CMAKE_CURRENT_SOURCE_DIR}/gulpfile.js")
+               endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gulpfile.js")
+
+               if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/bower.json")
+                       set(HTML5FILES ${HTML5FILES} "${CMAKE_CURRENT_SOURCE_DIR}/bower.json")
+               endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/bower.json")
+
+               if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/package.json")
+                       set(HTML5FILES ${HTML5FILES} "${CMAKE_CURRENT_SOURCE_DIR}/package.json")
+               endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/package.json")
+       endif(${type} STREQUAL "HTML5")
+
+       if(${type} STREQUAL "HTML5")
+               add_custom_command(
+                       OUTPUT ${TARGET_NAME}.wgt
+                       DEPENDS ${HTML5FILES} ${PROJECT_WGT_DIR}/config.xml
+                       COMMAND rm -rf package
+                       COMMAND mkdir -p package/lib package/htdocs package/etc package/bin
+                       COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && gulp widget-config-prod
+                       COMMAND cp -a dist.prod/* ${CMAKE_CURRENT_BINARY_DIR}/package/htdocs
+               )
+       endif(${type} STREQUAL "HTML5")
+
+       if(${type} STREQUAL "HTML5-HYBRID")
+               add_custom_command(
+                       OUTPUT ${TARGET_NAME}.wgt
+                       DEPENDS ${HTML5FILES} ${PROJECT_WGT_DIR}/config.xml 
+                       COMMAND rm -rf package
+                       COMMAND mkdir -p package/lib package/htdocs package/etc package/bin
+                       COMMAND cp ${TARGET_NAME}.so package/lib
+               )
+       endif(${type} STREQUAL "HTML5-HYBRID")
+
+       if(${type} STREQUAL "BINDING")
+               add_custom_command(
+                       OUTPUT ${TARGET_NAME}.wgt
+                       DEPENDS ${PROJECT_WGT_DIR}/config.xml
+                       COMMAND rm -rf package
+                       COMMAND mkdir -p package/lib package/htdocs package/etc package/bin
+                       COMMAND cp ${TARGET_NAME}.so package/lib
+               )
+       endif(${type} STREQUAL "BINDING")
+
+       if(${type} STREQUAL "NATIVE")
+               add_custom_command(
+                       OUTPUT ${TARGET_NAME}.wgt
+                       DEPENDS ${PROJECT_WGT_DIR}/config.xml
+                       COMMAND rm -rf package
+                       COMMAND mkdir -p package/lib package/htdocs package/etc package/bin
+                       COMMAND cp ${TARGET_NAME} package/bin
+               )
+       endif(${type} STREQUAL "NATIVE")
+
+       add_custom_command(
+               OUTPUT ${TARGET_NAME}.wgt
+               COMMAND cp config.xml package/
+               COMMAND cp ${conf_files} package/etc
+               COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wgt/${PROJECT_ICON} package/icon.png
+               COMMAND wgtpkg-pack -f -o ${TARGET_NAME}.wgt package
+               APPEND
+       )
+       add_custom_target(widget ALL DEPENDS ${TARGET_NAME}.wgt)
+endmacro()
+
+CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
+setc(CMAKE_BUILD_TYPE Debug)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+set(CMP0048 1)
+
+# Compiler selection should append before project definition
+# -----------------------------------------------------------
+foreach (GCC_VERSION "6" "5")
+       execute_process(COMMAND gcc-${GCC_VERSION} -dumpversion RESULT_VARIABLE GCCRC OUTPUT_QUIET ERROR_QUIET)
+       if(GCCRC EQUAL 0)
+               set(CMAKE_C_COMPILER "gcc-${GCC_VERSION}")
+               set(CMAKE_CXX_COMPILER "g++-${GCC_VERSION}")
+               set(CMAKE_C_VERSION ${GCC_VERSION})
+               break()
+       endif(GCCRC EQUAL 0)
+endforeach(GCC_VERSION)
+
+# Include project configuration
+# ------------------------------
+include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake)
+project(${NAME} VERSION ${VERSION})
+setc(PROJECT_PRETTY_NAME "${PRETTY_NAME}")
+setc(PROJECT_DESCRIPTION "${DESCRIPTION}")
+setc(PROJECT_WGT_DIR "packaging/wgt")
+setc(PROJECT_LIBDIR "libs")
+setc(PROJECT_RESOURCES "data")
+
+message(STATUS "")
+message(STATUS "Project=${PROJECT_NAME}/${VERSION}[${PRETTY_NAME} ${DESCRIPTION}]")
+message(STATUS "")
+message(STATUS "gcc/g++ version-${CMAKE_C_VERSION}.x selected")
+
+INCLUDE(FindPkgConfig)
+INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckLibraryExists)
+INCLUDE(GNUInstallDirs)
+
+# Default compilation options
+############################################################################
+link_libraries(-Wl,--as-needed -Wl,--gc-sections)
+add_compile_options(-Wall -Wextra -Wconversion)
+add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
+add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
+add_compile_options(-Werror=maybe-uninitialized)
+add_compile_options(-Werror=implicit-function-declaration)
+add_compile_options(-ffunction-sections -fdata-sections)
+add_compile_options(-fPIC)
+add_compile_options(-g)
+
+setc(CMAKE_C_FLAGS_PROFILING   "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
+setc(CMAKE_C_FLAGS_DEBUG       "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE")
+setc(CMAKE_C_FLAGS_RELEASE     "-O2")
+setc(CMAKE_C_FLAGS_CCOV        "-g -O2 --coverage")
+
+set(CMAKE_CXX_FLAGS_PROFILING    "-g -O0 -std=c++11 -pg -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_CXX_FLAGS_DEBUG        "-g -O0 -std=c++11 -ggdb -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_CXX_FLAGS_RELEASE      "-g -O2 -std=c++11")
+set(CMAKE_CXX_FLAGS_CCOV "-g -O2 -std=c++11 --coverage")
+
+setc(CMAKE_INSTALL_PREFIX      "${CMAKE_SOURCE_DIR}/Install")
+
+# (BUG!!!) as PKG_CONFIG_PATH does not work [should be en env variable]
+setc(PKG_CONFIG_USE_CMAKE_PREFIX_PATH 1)
+
+# Loop on required package and add options
+foreach (PKG_CONFIG ${PKG_REQUIRED_LIST})
+       PKG_CHECK_MODULES(${PKG_CONFIG} REQUIRED ${PKG_CONFIG})
+
+       INCLUDE_DIRECTORIES(${${PKG_CONFIG}_INCLUDE_DIRS})
+       list (APPEND link_libraries ${${PKG_CONFIG}_LIBRARIES})
+       add_compile_options (${${PKG_CONFIG}_CFLAGS})
+endforeach(PKG_CONFIG)
+
+# Optional LibEfence Malloc debug library
+IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
+CHECK_LIBRARY_EXISTS(efence malloc "" HAVE_LIBEFENCE)
+IF(HAVE_LIBEFENCE)
+       MESSAGE(STATUS "Linking with ElectricFence for debugging purposes...")
+       SET(libefence_LIBRARIES "-lefence")
+       list (APPEND link_libraries libefence_LIBRARIES})
+ENDIF(HAVE_LIBEFENCE)
+ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
+
+# set default include directories
+#INCLUDE_DIRECTORIES(${EXTRA_INCLUDE_DIRS})
+# Brutal but efficace:
+fill_include_dir(${CMAKE_CURRENT_SOURCE_DIR})
+
+# If no install dir try to guest some smart default
+if(BINDINGS_INSTALL_PREFIX)
+       set(BINDINGS_INSTALL_DIR ${BINDINGS_INSTALL_PREFIX}/${PROJECT_NAME})
+else()
+       set(BINDINGS_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME})
+endif()
+
+# Default Linkflag
+if(NOT BINDINGS_LINK_FLAG)
+       set(BINDINGS_LINK_FLAG "-Wl,--version-script=${CMAKE_SOURCE_DIR}/etc/export.map")
+endif()
+
+# Bindings to compile
+# --------------------
+file(GLOB filelist "*")
+foreach(filename ${filelist})
+if(EXISTS "${filename}/CMakeLists.txt")
+       add_subdirectory(${filename})
+endif(EXISTS "${filename}/CMakeLists.txt")
+endforeach()
+
+# Add a dummy target to enable global dependency order
+# -----------------------------------------------------
+if(EXTRA_DEPENDENCIES_ORDER)
+       set(DEPENDENCIES_TARGET ${PROJECT_NAME}_extra_dependencies)
+       add_custom_target(${DEPENDENCIES_TARGET} ALL
+               DEPENDS ${EXTRA_DEPENDENCY_ORDER} 
+       )
+endif()
+
+# Cmake does not maintain targets list before 3.7
+# -------------------------------------------------
+if(${CMAKE_VERSION} VERSION_LESS 3.7)
+       set(GLOBAL_TARGET_LIST ${PROJECT_TARGETS})
+else()
+       get_property(GLOBAL_TARGET_LIST GLOBAL PROPERTY GlobalTargetList)
+endif()
+
+# Print developer helper message when everything is done
+# -------------------------------------------------------
+if(CLOSING_MESSAGE AND GLOBAL_TARGET_LIST)
+       add_custom_target(${PROJECT_NAME}_done ALL
+               DEPENDS ${DEPENDENCIES_TARGET} ${GLOBAL_TARGET_LIST}
+               COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${CLOSING_MESSAGE}"
+       )
+endif()
diff --git a/CAN-config-generator/Makefile b/CAN-config-generator/Makefile
new file mode 100644 (file)
index 0000000..658ef32
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+BUILD_DIR   := build
+
+.PHONY: all clean mrproper ${BUILD_DIR}/Makefile
+
+all: build package
+
+clean:
+       @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+mrproper:
+       rm -rf ${BUILD_DIR}
+
+build:  ${BUILD_DIR}/Makefile
+       cmake --build ${BUILD_DIR} --clean-first
+
+
+package:
+       cmake --build ${BUILD_DIR} --target widget
+
+${BUILD_DIR}/Makefile:
+       @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+       @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CMAKE_OPTS} ..)
diff --git a/CAN-config-generator/etc/config.cmake b/CAN-config-generator/etc/config.cmake
new file mode 100644 (file)
index 0000000..1819daa
--- /dev/null
@@ -0,0 +1,79 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+# Project Info
+# ------------------
+set(NAME can-config-generator)
+set(VERSION "1.0")
+set(PRETTY_NAME "CAN configuration generator")
+set(DESCRIPTION "Generator that convert JSON file following OpenXC spec to configuration-generated.cpp file for the low level CAN binding.")
+set(URL "https://github.com/iotbzh/CAN_signaling")
+set(PROJECT_ICON "icon.png")
+
+# Compilation Mode (DEBUG, RELEASE)
+# ----------------------------------
+setc(CMAKE_BUILD_TYPE "DEBUG")
+
+# PKG_CONFIG required packages
+# -----------------------------
+set (PKG_REQUIRED_LIST
+       json-c
+       libsystemd
+       afb-daemon
+)
+
+# Static constante definition
+# -----------------------------
+add_compile_options(-D_REENTRANT)
+add_compile_options(-DPB_FIELD_16BIT)
+
+# LANG Specific compile flags set for all build types
+set(CMAKE_C_FLAGS "")
+set(CMAKE_CXX_FLAGS "-std=c++11")
+
+# Print a helper message when every thing is finished
+setc(CLOSING_MESSAGE "Test with: ./can-config-generator -m ../tests/basic.json -o configuration-generated.cpp")
+# ----------------------------------------------------
+
+# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]
+# ---------------------------------------------------------------------
+setc(CMAKE_INSTALL_PREFIX ${HOME}/opt)
+setc(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+setc(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib)
+
+# Optional dependencies order
+# ---------------------------
+set(EXTRA_DEPENDENCIES_ORDER can-config-generator low-can-binding)
+
+# Optional Extra global include path
+# -----------------------------------
+#set(EXTRA_INCLUDE_DIRS inc_dir1 inc_dir2 ...)
+
+# Optional extra libraries
+# -------------------------
+#set(EXTRA_LINK_LIBRARIES)
+
+# Optional force binding installation
+# ------------------------------------
+# set(BINDINGS_INSTALL_PREFIX DestinationPath )
+
+# Optional force binding Linking flag
+# ------------------------------------
+# set(BINDINGS_LINK_FLAG LinkOptions )
+
+
diff --git a/CAN-config-generator/etc/export.map b/CAN-config-generator/etc/export.map
new file mode 100644 (file)
index 0000000..52c1b4a
--- /dev/null
@@ -0,0 +1 @@
+{ global: afbBindingV1*; local: *; };
similarity index 81%
rename from can-config-generator/CMakeLists.txt
rename to CAN-config-generator/src/CMakeLists.txt
index 0892d2a..39ceba1 100644 (file)
@@ -22,14 +22,14 @@ PROJECT_TARGET_ADD(can-config-generator)
 
        # Define project Targets
        add_executable(can-config-generator
-               src/main.cpp
-               src/openxc/message_set.cpp
-               src/openxc/can_bus.cpp
-               src/openxc/can_message.cpp
-               src/openxc/command.cpp
-               src/openxc/diagnostic_message.cpp
-               src/openxc/mapping.cpp
-               src/openxc/signal.cpp)
+               main.cpp
+               openxc/message_set.cpp
+               openxc/can_bus.cpp
+               openxc/can_message.cpp
+               openxc/command.cpp
+               openxc/diagnostic_message.cpp
+               openxc/mapping.cpp
+               openxc/signal.cpp)
 
        # Library dependencies (include updates automatically)
        TARGET_LINK_LIBRARIES(can-config-generator
@@ -38,4 +38,4 @@ PROJECT_TARGET_ADD(can-config-generator)
 
        # installation directory
        INSTALL(TARGETS can-config-generator
-               RUNTIME DESTINATION ${BINDINGS_INSTALL_DIR})
\ No newline at end of file
+RUNTIME DESTINATION ${BINDINGS_INSTALL_DIR})
index cbe951b..a608363 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,9 +1,23 @@
-# Low level CAN signaling binder
+# CAN signaling binder
 
-Low level CAN bus binder, based upon OpenXC vi-firmware project.
+CAN bus binder, based upon OpenXC vi-firmware project.
+
+There are 2 separated projects here, one with the CAN-binder that is installed
+on an AGL target and the CAN config generator used to generate a source file for
+the low level binding.
 
 Full document can be found under `docs` directory.
 
+# Fast build procedure
+
+Just use build.sh script:
+
+```bash
+./build.sh
+```
+
+This will build both projects under build directory for each of them.
+
 # Generate documentation
 
 ## Prerequisites
index 9496f00..64bd7f5 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -1,82 +1,4 @@
 #!/bin/bash
 
-function build {
-       echo "ACTION: build"
-       source ~/agl/sdk/porter/environment*
-       if [ ! -d "$1/$2" ]; then
-               echo "INFO: build dir ($1/$2) doesn't exist, created it!"
-               mkdir -p "$1/$2"
-       fi
-       pushd "$1/$2"
-       #cd "$1/$2"
-       cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$3 $1
-       make
-       popd
-}
-
-function clean {
-       echo "ACTION: clean"
-       if [ -d "$1/$2" ]; then
-               rm -vrf "$1/$2"
-       fi
-}
-
-function rebuild {
-       clean $1 $2
-       build $1 $2 $3
-}
-
-function printhelp {
-       echo "Usage: build.sh <action> <subdir> [config]"
-       echo "  action: can be one of the following"
-       echo "          build: build this project."
-       echo "          rebuild: rebuild this project."
-       echo "          clean: clean the previous build."
-       echo "          install: install the build result."
-       echo "  subdir: the subdir into which the build is done."
-       echo "  config: can be Debug or Release. Ignored if the action is 'clean'."
-}
-
-function checkparams {
-       if [ "$#" -ne "$(($1+1))" ]; then
-               echo "ERROR: Wrong number of parameters, expected $1 but got $(($#-1))"
-               printhelp
-               exit 1
-       fi
-}
-
-function main {
-       CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
-       echo "Current script: $CURRENT_DIR"
-
-       if [ "$#" -lt "1" ]; then
-               echo "ERROR: At least <action> must be specified!"
-               exit 1
-       fi
-
-       case "$1" in
-               "build")
-                       checkparams 3 $*
-                       build $CURRENT_DIR $2 $3
-                       ;;
-               "rebuild")
-                       checkparams 3 $*
-                       rebuild $CURRENT_DIR $2 $3
-                       ;;
-               "clean")
-                       checkparams 2 $*
-                       clean $CURRENT_DIR $2
-                       ;;
-               "install")
-                       checkparams 3 $*
-                       echo "ERROR: Not implemented yet!"
-                       ;;
-               *)
-                       echo "ERROR: Unknown action '$3'!"
-                       exit 1 
-                       ;;
-       esac
-}
-
-main $*
-
+cd CAN-config-generator && make build && cd -
+cd CAN-binder && make build && cd -