01-基于SOA架构someip 开发-Linux开发环境搭建

  1. 前言:

SOME/IP 是一个汽车的中间件解决方案,可用于控制消息。从一开始,它的设计就是为了完美地适应不同尺寸和不同操作系统的设备。这包括小型设备,如相机、AUTOSAR设备,以及头部单元或远程信息处理设备。同时还确保了SOME/IP支持信息娱乐域以及车内其他域的功能,从而使SOME/IP可以用于多数替换场景以及更传统的CAN场景,在智能网联汽车,面向服务开发SOA架构思想环境下,SOME/IP扮演着非常重要的角色--通信。

2. 准备工作

2.1 下载开源code (3.2.0版本)

capicxx-core-runtime

github/镜像下载地址:https://hub.yzuu.cf/COVESA/capicxx-core-runtime/tree/89720d3c63bbd22cbccc80cdc92c2f2dd20193ba

https://github.com/COVESA/capicxx-core-runtime/tree/89720d3c63bbd22cbccc80cdc92c2f2dd20193ba

或者通过tag 选择对应的版本下载:如下图

01-基于SOA架构someip 开发-Linux开发环境搭建_第1张图片

capicxx-someip-runtime

github/镜像下载地址:https://hub.yzuu.cf/COVESA/capicxx-someip-runtime/tree/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13

TAG下载操作如上图

capicxx-dbus-runtime

github/镜像下载地址:https://hub.yzuu.cf/COVESA/capicxx-dbus-runtime/tree/d1610ad0d6f1b6751964af41a0cc1599e2d7a955

TAG下载操作如上图

vsomeip

github/镜像下载地址:https://hub.yzuu.cf/COVESA/vsomeip/tree/13f9c89ced6ffaeb1faf485152e27e1f40d234cd

TAG下载操作如上图

2.2 下载工具 (最新)

commonapi_core_generator

下载地址:https://hub.yzuu.cf/GENIVI/capicxx-core-tools/releases/latest/download/commonapi_core_generator.zip

commonapi_dbus_generator

下载地址:https://hub.yzuu.cf/GENIVI/capicxx-dbus-tools/releases/latest/download/commonapi_dbus_generator.zip

commonapi_someip_generator

下载地址:https://hub.yzuu.cf/GENIVI/capicxx-someip-tools/releases/latest/download/commonapi_someip_generator.zip

2.3 下载dbus1.10.10 (dbus-1.10.10.tar.gz)

下载地址:http://dbus.freedesktop.org/releases/dbus/dbus-1.10.10.tar.gz

2.4 boost_1_74_0.tar.gz

下载地址:https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.gz

1.65.0之前版本:

https://ufpr.dl.sourceforge.net/project/boost/boost

比如下载1.55.0版本

https://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.gz

2.5 下载 dlt-daemon-2.18.8.tar.gz

下载地址:https://hub.yzuu.cf/COVESA/dlt-daemon/tags

选择 最新:v2.18.8

2.6 安装依赖文件

ubuntu

sudo apt install -y asciidoc source-highlight doxygen graphviz asciidoc pkg-config

3. 开发框架

开发项目离不开开发框架搭建,如何运作整个资源。

3.1 开发框架

.
├── build
├── build_x86.sh
├── cfg
│ ├── commonapi.ini
│ ├── vsomeip_client.json
│ ├── vsomeip.json
│ └── vsomeip_server.json
├── CMakeLists.txt
├── doc
│ ├── CommonAPICppSpecification.pdf
│ ├── CommonAPICppUserGuide.pdf
├── examples
│ ├── CMakeLists.txt
│ ├── fidl
│ ├── src
│ └── src-gen
│ └── v0
├── host_tools
│ ├── commonapi_core_generator
│ ├── commonapi_dbus_generator
│ └── commonapi_someip_generator
├── thirdparty
│ ├── archive
│ │ ├── capicxx-core-runtime-89720d3c63bbd22cbccc80cdc92c2f2dd20193ba.zip
│ │ ├── capicxx-dbus-runtime-d1610ad0d6f1b6751964af41a0cc1599e2d7a955.zip
│ │ ├── capicxx-someip-runtime-0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13.zip
│ │ ├── dbus-1.10.10.tar.gz
│ │ └── vsomeip-13f9c89ced6ffaeb1faf485152e27e1f40d234cd.zip
│ ├── capicxx-core-runtime
│ ├── capicxx-dbus-runtime
│ ├── capicxx-someip-runtime
│ ├── CMakeLists.txt
│ ├── dbus-1.10.10
│ └── vsomeip
├── toolchains
│ ├── archive
│ │ ├── boost_1_74_0.tar.gz
│ │ ├── commonapi_core_generator.zip
│ │ ├── commonapi_dbus_generator.zip
│ │ ├── commonapi_someip_generator.zip
│ │ └── dlt-daemon-2.18.8.tar.gz
│ ├── boost_1_74_0
│ ├── dlt-daemon-2.18.8
│ └── scripts
│ ├── build_boost_android.sh
│ └── build_boost_common.sh

3.2 编译脚本

3.2.1 Ubuntu Linux 编译脚本:

#!/bin/bash
#
#----------------------------------------------------------
#    author: Tim
#    email : [email protected]                                                              
#    description: SOA someip build script                                                   
# ---------------------------------------------------------
#    Warm reminder :Abort operation with Ctrl+C
# ---------------------------------------------------------

ROOT_DIR=$(pwd)

DBUS_ARCHIVE_PATH=${ROOT_DIR}/thirdparty/archive/dbus-1.10.10.tar.gz
DBUS_DIR=${ROOT_DIR}/thirdparty/dbus-1.10.10

BOOST_ARCHIVE_PATH=${ROOT_DIR}/toolchains/archive/boost_1_74_0.tar.gz
BOOST_DIR=${ROOT_DIR}/toolchains/boost_1_74_0

DLT_ARCHIVE_PATH=${ROOT_DIR}/toolchains/archive/dlt-daemon-2.18.8.tar.gz
DLT_DIR=${ROOT_DIR}/toolchains/dlt-daemon-2.18.8

PREFIX_DIR=${ROOT_DIR}/build/x86
PREFIX_INSTALL_DIR=${PREFIX_DIR}/install

echo -e "Project dir: $ROOT_DIR"

if [ -d ${PREFIX_INSTALL_DIR} ];then
    rm -rf $PREFIX_INSTALL_DIR
    mkdir -p $PREFIX_INSTALL_DIR
else
    mkdir -p $PREFIX_INSTALL_DIR
fi

if [ ! -d ${DBUS_DIR} ];then
    if [ -e  ${DBUS_ARCHIVE_PATH} ];then
        echo -e "archive $DBUS_ARCHIVE_PATH is exist. now do it."
        tar -xzf ${DBUS_ARCHIVE_PATH} -C ${ROOT_DIR}/thirdparty/ 
        cd ${DBUS_DIR}
        for i in ${ROOT_DIR}/thirdparty/capicxx-dbus-runtime/src/dbus-patches/*.patch; do patch -p1 < $i; done
        ./configure
        make
            cd ${ROOT_DIR}
    else
        echo -e "archive ${DBUS_ARCHIVE_PATH} is not exist. now get it."
        cd thirdparty/archive/
        wget http://dbus.freedesktop.org/releases/dbus/dbus-1.10.10.tar.gz
        cd ${ROOT_DIR}
        tar -xzf ${DBUS_ARCHIVE_PATH} -C ${ROOT_DIR}/thirdparty/  
        cd thirdparty/dbus-1.10.10
        for i in ${ROOT_DIR}/thirdparty/capicxx-dbus-runtime/src/dbus-patches/*.patch; do patch -p1 < $i; done
        ./configure
        make
            cd ${ROOT_DIR}
    fi
fi

if [ ! -d ${BOOST_DIR} ];then
    echo -e "dir ${BOOST_DIR} is not exist. now do it."
    if [ -e  ${BOOST_ARCHIVE_PATH} ];then
        echo -e "archive $BOOST_ARCHIVE_PATH is exist. now do it."
        tar -xzf ${BOOST_ARCHIVE_PATH} -C ${ROOT_DIR}/toolchains/ 
        mkdir -p ${BOOST_DIR}/build/x86
        cd ${BOOST_DIR}
        ./bootstrap.sh --prefix=build/x86
        ./b2 install
        sudo ./bootstrap.sh --prefix=/usr/local
        sudo ./b2 install
            cd ${ROOT_DIR}
    else
        echo -e "archive ${BOOST_ARCHIVE_PATH} is not exist. now get it."
        cd ${ROOT_DIR}/toolchains/archive
        wget https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.gz
        tar -xzf boost_1_74_0.tar.gz -C ${ROOT_DIR}/toolchains/
        mkdir -p ${BOOST_DIR}/build/x86
        cd ${BOOST_DIR}
        ./bootstrap.sh --prefix=build/x86
        ./b2 install
        sudo ./bootstrap.sh --prefix=/usr/local
        sudo ./b2 install
            cd ${ROOT_DIR}
    fi
fi

if [ ! -d ${DLT_DIR} ];then
    echo -e "dir ${DLT_DIR} is not exist. now do it."
    if [ -e  ${DLT_ARCHIVE_PATH} ];then
        echo -e "archive $DLT_ARCHIVE_PATH is exist. now do it."
        tar -xzf ${DLT_ARCHIVE_PATH} -C ${ROOT_DIR}/toolchains/ 
        mkdir -p ${DLT_DIR}/build/x86
        cd ${DLT_DIR}/build/x86
        cmake ../../
        make
        sudo make install
            cd ${ROOT_DIR}
    fi
fi

if [ ! -d ${ROOT_DIR}/host_tools ];then
    mkdir host_tools
fi

if [ ! -e ${ROOT_DIR}/toolchains/archive/commonapi_core_generator.zip ]; then
    cd ${ROOT_DIR}/toolchains/archive
    echo -e "archive file commonapi_core_generator.zip is not exist. now get it.."
    wget https://hub.yzuu.cf/GENIVI/capicxx-core-tools/releases/latest/download/commonapi_core_generator.zip
    cd ${ROOT_DIR}
fi

if [ ! -d host_tools/commonapi_core_generator ];then
    unzip -o toolchains/archive/commonapi_core_generator.zip -d host_tools/commonapi_core_generator
fi

if [ ! -e ${ROOT_DIR}/toolchains/archive/commonapi_dbus_generator.zip ];then
    cd ${ROOT_DIR}/toolchains/archive
    echo -e "archive file commonapi_dbus_generator.zip is not exist. now get it.."
    wget https://hub.yzuu.cf/GENIVI/capicxx-dbus-tools/releases/latest/download/commonapi_dbus_generator.zip
    cd ${ROOT_DIR}
fi

if [ ! -d host_tools/commonapi_dbus_generator ];then
    unzip -o toolchains/archive/commonapi_dbus_generator.zip -d host_tools/commonapi_dbus_generator
fi

if [ ! -e ${ROOT_DIR}/toolchains/archive/commonapi_someip_generator.zip ];then
    cd ${ROOT_DIR}/toolchains/archive
    echo -e "archive file commonapi_someip_generator.zip is not exist. now get it.."
    wget https://hub.yzuu.cf/GENIVI/capicxx-someip-tools/releases/latest/download/commonapi_someip_generator.zip
    cd ${ROOT_DIR}
fi

if [ ! -d host_tools/commonapi_someip_generator ];then
    unzip -o toolchains/archive/commonapi_someip_generator.zip -d host_tools/commonapi_someip_generator
fi


echo "---------------------------"
echo " > start to build X86."
echo "---------------------------"

cmake -B $PREFIX_DIR \
    -DCMAKE_INSTALL_PREFIX=$PREFIX_INSTALL_DIR \

cmake --build $PREFIX_DIR --target install

补充两个CMakefile:

A. 根目录下

#config projects#
project(soa_someip)
cmake_minimum_required(VERSION 3.1.3)

option(CMAKE_HOST_LINUX "build tartget host is Linux" ON)
option(CMAKE_HOST_WIN32 "build tartget host is WIN32" OFF)
option(CMAKE_LINK_PTHREAD_LIB "build tartget link phread lib" OFF)
#
#incldue
include(${CMAKE_SOURCE_DIR}/cmake/func.define.cmake)

set_property(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1)
#WIND32
if (CMAKE_HOST_WIN32)
    set(FIDL_CORE_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_core_generator/commonapi-core-generator-windows-x86.exe)
    set(FIDL_DBUS_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_dbus_generator/commonapi-dbus-generator-windows-x86.exe)
    set(FIDL_SOMEIP_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_someip_generator/commonapi-someip-generator-windows-x86.exe)
## Linux
else () 
    set(FIDL_CORE_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_core_generator/commonapi-core-generator-linux-x86_64)
    set(FIDL_DBUS_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_dbus_generator/commonapi-dbus-generator-linux-x86_64)
    set(FIDL_SOMEIP_GENERATOR ${CMAKE_SOURCE_DIR}/host_tools/commonapi_someip_generator/commonapi-someip-generator-linux-x86_64)
endif()

print_variable(CMAKE_HOST_LINUX)
print_variable(CMAKE_HOST_WIN32)
print_variable(CMAKE_LINK_PTHREAD_LIB)

add_subdirectory(thirdparty)
add_subdirectory(examples)

B. thirdparty目录下

set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.10.10")
message("PKG_CONFIG_PATH variable is $ENV{PKG_CONFIG_PATH}")

SET(USE_INSTALLED_COMMONAPI OFF CACHE BOOL "Use installed commonapi OFF")
SET(USE_INSTALLED_DBUS OFF CACHE BOOL "Use installed commonapi OFF")
SET(ENABLE_SIGNAL_HANDLING 1 CACHE BOOL "Use installed commonapi")
SET(DIAGNOSIS_ADDRESS 0x10 CACHE INT "Diagnosis address 0x10")

add_subdirectory(capicxx-core-runtime)
add_subdirectory(capicxx-dbus-runtime)
add_subdirectory(vsomeip)
add_subdirectory(capicxx-someip-runtime)

3.2.2 Android NDK 编译脚本:

//TODO

3.2.3 QNX编译脚本:

//TODO

4. 结果输出

.
└── x86
├── CMakeCache.txt
├── CMakeDoxyfile.in
├── CMakeDoxygenDefaults.cmake
├── CMakeFiles
│ ├── 3.20.0
│ │ ├── CMakeCCompiler.cmake
│ │ ├── CMakeCXXCompiler.cmake
│ │ ├── CMakeDetermineCompilerABI_C.bin
│ │ ├── CMakeDetermineCompilerABI_CXX.bin
│ │ ├── CMakeSystem.cmake
│ │ ├── CompilerIdC
│ │ └── CompilerIdCXX
│ ├── cmake.check_cache
│ ├── CMakeDirectoryInformation.cmake
│ ├── CMakeError.log
│ ├── CMakeOutput.log
│ ├── CMakeRuleHashes.txt
│ ├── CMakeTmp
│ ├── Makefile2
│ ├── Makefile.cmake
│ ├── progress.marks
│ └── TargetDirectories.txt
├── cmake_install.cmake
├── examples
│ ├── CMakeFiles
│ │ ├── CMakeDirectoryInformation.cmake
│ │ ├── fidl_gen.dir
│ │ ├── HelloWorldClient.dir
│ │ ├── HelloWorldService.dir
│ │ ├── HelloWorldSomeIPClient.dir
│ │ ├── HelloWorldSomeIPService.dir
│ │ └── progress.marks
│ ├── cmake_install.cmake
│ ├── HelloWorldClient
│ ├── HelloWorldService
│ ├── HelloWorldSomeIPClient
│ ├── HelloWorldSomeIPService
│ └── Makefile
├── install
│ ├── etc
│ │ └── vsomeip
│ ├── include
│ │ └── CommonAPI-3.2
│ └── lib
│ ├── cmake
│ ├── libCommonAPI-DBus.so -> libCommonAPI-DBus.so.3.2.0
│ ├── libCommonAPI-DBus.so.3.2.0
│ ├── libCommonAPI.so -> libCommonAPI.so.3.2.0
│ ├── libCommonAPI.so.3.2.0
│ ├── libCommonAPI-SomeIP.so -> libCommonAPI-SomeIP.so.3.2.0
│ ├── libCommonAPI-SomeIP.so.3.2.0
│ ├── libvsomeip3-cfg.so -> libvsomeip3-cfg.so.3
│ ├── libvsomeip3-cfg.so.3 -> libvsomeip3-cfg.so.3.1.20
│ ├── libvsomeip3-cfg.so.3.1.20
│ ├── libvsomeip3-e2e.so -> libvsomeip3-e2e.so.3
│ ├── libvsomeip3-e2e.so.3 -> libvsomeip3-e2e.so.3.1.20
│ ├── libvsomeip3-e2e.so.3.1.20
│ ├── libvsomeip3-sd.so -> libvsomeip3-sd.so.3
│ ├── libvsomeip3-sd.so.3 -> libvsomeip3-sd.so.3.1.20
│ ├── libvsomeip3-sd.so.3.1.20
│ ├── libvsomeip3.so -> libvsomeip3.so.3
│ ├── libvsomeip3.so.3 -> libvsomeip3.so.3.1.20
│ ├── libvsomeip3.so.3.1.20
│ └── pkgconfig
├── install_manifest.txt
├── Makefile
└── thirdparty
├── capicxx-core-runtime
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── CommonAPIConfig.cmake
│ ├── CommonAPIConfigVersion.cmake
│ ├── CommonAPI.pc
│ ├── commonapi.spec
│ ├── CommonAPITargets.cmake
│ ├── Doxyfile
│ ├── libCommonAPI.so -> libCommonAPI.so.3.2.0
│ ├── libCommonAPI.so.3.2.0
│ └── Makefile
├── capicxx-dbus-runtime
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── CommonAPI-DBusConfig.cmake
│ ├── CommonAPI-DBusConfigVersion.cmake
│ ├── CommonAPI-DBus.pc
│ ├── commonapi-dbus.spec
│ ├── CommonAPI-DBusTargets.cmake
│ ├── Doxyfile
│ ├── libCommonAPI-DBus.so -> libCommonAPI-DBus.so.3.2.0
│ ├── libCommonAPI-DBus.so.3.2.0
│ └── Makefile
├── capicxx-someip-runtime
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── CommonAPI-SomeIPConfig.cmake
│ ├── CommonAPI-SomeIPConfigVersion.cmake
│ ├── CommonAPI-SomeIP.pc
│ ├── CommonAPI-SomeIPTargets.cmake
│ ├── libCommonAPI-SomeIP.so -> libCommonAPI-SomeIP.so.3.2.0
│ ├── libCommonAPI-SomeIP.so.3.2.0
│ └── Makefile
├── CMakeFiles
│ ├── CMakeDirectoryInformation.cmake
│ └── progress.marks
├── cmake_install.cmake
├── Makefile
└── vsomeip
├── CMakeFiles
├── cmake_install.cmake
├── Doxyfile
├── examples
├── libvsomeip3-cfg.so -> libvsomeip3-cfg.so.3
├── libvsomeip3-cfg.so.3 -> libvsomeip3-cfg.so.3.1.20
├── libvsomeip3-cfg.so.3.1.20
├── libvsomeip3-e2e.so -> libvsomeip3-e2e.so.3
├── libvsomeip3-e2e.so.3 -> libvsomeip3-e2e.so.3.1.20
├── libvsomeip3-e2e.so.3.1.20
├── libvsomeip3-sd.so -> libvsomeip3-sd.so.3
├── libvsomeip3-sd.so.3 -> libvsomeip3-sd.so.3.1.20
├── libvsomeip3-sd.so.3.1.20
├── libvsomeip3.so -> libvsomeip3.so.3
├── libvsomeip3.so.3 -> libvsomeip3.so.3.1.20
├── libvsomeip3.so.3.1.20
├── Makefile
├── tools
├── vsomeip3Config.cmake
├── vsomeip3ConfigVersion.cmake
├── vsomeip3.pc
└── vsomeip3Targets.cmake

你可能感兴趣的:(汽车电子,someip,someip开发,someip,环境搭建,someip,soa)