Skip to content
Permalink
Browse files

asn1: add infrastructure messages such as SPATEM etc.

- fetch ITS ASN.1 module from ETSI
- regenerate code using asn1c with "generate_asn1c" target

Change-Id: I43c9f1ca07e67cd73423de0223d063b4e3b95474
  • Loading branch information...
riebl committed Dec 31, 2017
1 parent b0dedcb commit e4f4b3c655651fbb2530a96fe443355bb452573a
Showing 1,360 changed files with 81,603 additions and 43,226 deletions.
@@ -110,7 +110,7 @@ install(EXPORT ${PROJECT_NAME} NAMESPACE Vanetza:: FILE VanetzaTargets.cmake DES

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vanetza
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp" PATTERN "asn1/gen/*.h" PATTERN "/tests/*.hpp" EXCLUDE)
FILES_MATCHING PATTERN "*.hpp" PATTERN "asn1/its/*.h" PATTERN "/tests/*.hpp" EXCLUDE)

# export build tree (allows import by outside projects)
export(EXPORT ${PROJECT_NAME} NAMESPACE Vanetza:: FILE VanetzaExports.cmake)
@@ -828,8 +828,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*

EXCLUDE_PATTERNS = */asn1/gen/* \
*/asn1/bundled-gen/* \
EXCLUDE_PATTERNS = */asn1/its/* \
*/tests/*

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
@@ -0,0 +1,13 @@
find_program(ASN1C_EXECUTABLE NAMES asn1c DOC "ASN.1 compiler")
if(ASN1C_EXECUTABLE)
execute_process(COMMAND ${ASN1C_EXECUTABLE} -version ERROR_VARIABLE _asn1c_version)
string(REGEX MATCH "[0-9]\\.[0-9]\\.[0-9]+" ASN1C_VERSION ${_asn1c_version})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(asn1c
REQUIRED_VARS ASN1C_EXECUTABLE
FOUND_VAR ASN1C_FOUND
VERSION_VAR ASN1C_VERSION)

mark_as_advanced(ASN1C_EXECUTABLE)

This file was deleted.

@@ -0,0 +1 @@
ITS_ASN1.r*.tar.gz
@@ -1,90 +1,72 @@
include(UseAsn1c)
set(ASN1C_GEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gen")
set(ASN1C_BUNDLED_GEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bundled-gen")
file(GLOB ASN1_SOURCES *.asn1)

if(ASN1C_EXECUTABLE)
set(_with_asn1c ON)
else()
set(_with_asn1c OFF)
endif()
option(VANETZA_ASN1_WITH_ASN1C "Generate ASN.1 code using asn1c (instead of using bundled code)" ${_with_asn1c})

option(VANETZA_ASN1_WITH_ASN1C "Enable asn1c targets" OFF)
if(VANETZA_ASN1_WITH_ASN1C)
if(NOT ASN1C_EXECUTABLE)
message(SEND_ERROR "asn1c not found, cannot generate ASN.1 code from sources")
endif()
find_package(ASN1C 0.9.29 REQUIRED MODULE)
set(ASN1C_FLAGS "-fcompound-names -fincludes-quoted" CACHE STRING "asn1c compiler options")
mark_as_advanced(ASN1C_FLAGS)
string(REPLACE " " ";" _asn1c_flags "${ASN1C_FLAGS}")

set(ASN1C_ARGS -fcompound-names -gen-PER -pdu=auto)
if("${ASN1C_VERSION}" VERSION_LESS "0.9.26")
# These options became default with 0.9.26
list(APPEND ASN1C_ARGS -fnative-types -fskeletons-copy)
endif()

add_custom_command(
OUTPUT
${ASN1C_GEN_DIR}/CAM.h
${ASN1C_GEN_DIR}/DENM.h
${ASN1C_GEN_DIR}/VanetzaTest.h
COMMAND ${ASN1C_EXECUTABLE} ${ASN1C_ARGS} ${ASN1_SOURCES}
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch_asn1c.cmake
DEPENDS ${ASN1C_SOURCES}
WORKING_DIRECTORY ${ASN1C_GEN_DIR}
VERBATIM)
set(_its_asn1_files
CDD_TS102894-2/ITS-Container.asn
CAM_EN302637-2/CAM.asn
DENM_EN302637-3/DENM.asn
IS_TS103301/ISO_TS_24534-3.asn
IS_TS103301/ISO_TS_14816.asn
IS_TS103301/ISO_TS_14906_Application.asn
IS_TS103301/ISO_TS_17419.asn
IS_TS103301/ISO_TS_19091.asn
IS_TS103301/ISO_TS_19321.asn
IS_TS103301/ETSI_TS_103301.asn
)
set(_its_asn1_revision 24)
set(_its_asn1_name "ITS_ASN1.r${_its_asn1_revision}")
set(_its_asn1_archive "${_its_asn1_name}.tar.gz")
set(_its_asn1_dir "${CMAKE_CURRENT_SOURCE_DIR}/its")
set(_its_asn1_source_file "asn1c_its_sources.txt")

add_custom_target(update_asn1c_bundle
COMMAND ${CMAKE_COMMAND} -E remove_directory ${ASN1C_BUNDLED_GEN_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${ASN1C_GEN_DIR} ${ASN1C_BUNDLED_GEN_DIR}
DEPENDS ${ASN1C_GEN_DIR}/CAM.h ${ASN1C_GEN_DIR}/DENM.h
add_custom_target(clean_asn1c
COMMAND ${CMAKE_COMMAND} -DASN1C_OUTPUT_DIR=its -P clean_asn1c.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(DOWNLOAD
"http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftrunk%2F&isdir=1&rev=${_its_asn1_revision}"
"${CMAKE_CURRENT_SOURCE_DIR}/${_its_asn1_archive}"
EXPECTED_HASH SHA256=5a02659c8fd45a0708d64e52a9fb7f98e18daf981c990afb572383a64d28e52b
SHOW_PROGRESS)
add_custom_command(OUTPUT ${_its_asn1_name}/${_its_asn1_files}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_its_asn1_archive}
COMMAND ${CMAKE_COMMAND} -E tar xfz ${CMAKE_CURRENT_SOURCE_DIR}/${_its_asn1_archive}
COMMENT "Extracting ITS ASN.1 modules"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM)
add_custom_command(TARGET update_asn1c_bundle PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E remove .gitignore converter-sample.c Makefile.am.sample
WORKING_DIRECTORY ${ASN1C_BUNDLED_GEN_DIR}
VERBATIM)

else()
message(STATUS "Using bundled ASN.1 code instead of asn1c")
set(_bundle_dir ${ASN1C_BUNDLED_GEN_DIR})
set(_gen_dir ${ASN1C_GEN_DIR})
file(GLOB _bundle_files RELATIVE ${_bundle_dir} ${_bundle_dir}/*.c ${_bundle_dir}/*.h)
file(GLOB _gen_files RELATIVE ${_gen_dir} ${_gen_dir}/*.c ${_gen_dir}/*.h)

# remove surplus files
foreach(_gen_file IN LISTS _gen_files)
list(FIND _bundle_files ${_gen_file} _bundle_index)
if(_bundle_index LESS 0)
file(REMOVE ${_gen_dir}/${_gen_file})
endif()
endforeach()

# synchronize bundled files into gen directory
if(${CMAKE_VERSION} VERSION_LESS 3.5)
foreach(_bundle_file IN LISTS _bundle_files)
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${_bundle_file} ${_gen_dir}
WORKING_DIRECTORY ${_bundle_dir})
endforeach()
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${_bundle_files} ${_gen_dir}
WORKING_DIRECTORY ${_bundle_dir})
endif()
add_custom_command(OUTPUT ${_its_asn1_dir}
DEPENDS ${_its_asn1_name}/${_its_asn1_files}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_its_asn1_dir}
COMMAND ${ASN1C_EXECUTABLE} ${_asn1c_flags} -D ${_its_asn1_dir} ${_its_asn1_files} ${CMAKE_CURRENT_SOURCE_DIR}/test.asn
COMMENT "Generating code from ITS ASN.1 modules" VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_its_asn1_name})
add_custom_command(OUTPUT "${_its_asn1_source_file}"
DEPENDS ${_its_asn1_dir}
COMMAND ${CMAKE_COMMAND} -DASN1C_OUTPUT_DIR=its -DASN1C_SOURCE_FILE=${_its_asn1_source_file} -P collect_asn1c_sources.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(generate_asn1c DEPENDS ${_its_asn1_dir} ${_its_asn1_source_file})
add_custom_command(TARGET generate_asn1c POST_BUILD
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch_asn1c_sources.cmake
COMMENT "Patching ITS asn1c files"
WORKING_DIRECTORY ${_its_asn1_dir})
# wipe directory with generated files before generating
add_dependencies(generate_asn1c clean_asn1c)
endif()

add_custom_target(asn1_gen DEPENDS ${ASN1C_GEN_DIR}/CAM.h ${ASN1C_GEN_DIR}/DENM.h)

set(CXX_SOURCES asn1c_wrapper.cpp)
asn1c_sources(ASN1C_SOURCES ${ASN1C_GEN_DIR})
file(STRINGS "${_its_asn1_source_file}" ASN1C_SOURCES REGEX "^[^#]+")
add_vanetza_component(asn1 ${CXX_SOURCES} ${ASN1C_SOURCES})
add_dependencies(asn1 asn1_gen)
target_link_libraries(asn1 Boost::boost)
target_include_directories(asn1 PUBLIC
$<BUILD_INTERFACE:${ASN1C_GEN_DIR}>
$<INSTALL_INTERFACE:include/vanetza/asn1/gen>)
target_link_libraries(asn1 PUBLIC Boost::boost)
#target_include_directories(asn1 PUBLIC
#$<BUILD_INTERFACE:${_its_asn1_dir}>
#$<INSTALL_INTERFACE:include/vanetza/asn1/its>)

# Silence warnings in code generated by asn1c
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set_property(TARGET asn1 APPEND PROPERTY COMPILE_OPTIONS "-Wno-parentheses-equality")
set_property(SOURCE ${ASN1C_SOURCES} APPEND PROPERTY COMPILE_OPTIONS "-Wno-parentheses-equality")
endif()

add_test_subdirectory(tests)

This file was deleted.

0 comments on commit e4f4b3c

Please sign in to comment.
You can’t perform that action at this time.