Skip to content

up-cpp-server simulator initial commit #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright (c) 9-7-2024 Cummins Inc
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
FROM mcr.microsoft.com/vscode/devcontainers/base:0-focal
ARG DEBIAN_FRONTEND=noninteractive
ARG SETUP_DIR="/root"
WORKDIR ${SETUP_DIR}
RUN apt-get update \
&& apt-get install cmake \
make \
g++ \
tcl-dev \
clang \
git \
unzip \
wget \
gdb \
libfmt-dev \
libssl-dev -y \
python3-pip

##General dependencies

WORKDIR ${SETUP_DIR}
ARG SPD_LOG_VERSION="v1.9.2"
RUN git clone https://github.com/gabime/spdlog.git
WORKDIR ${SETUP_DIR}/spdlog
RUN git checkout ${SPD_LOG_VERSION}
WORKDIR ${SETUP_DIR}/spdlog/build
RUN cmake .. -DSPDLOG_BUILD_SHARED=ON
RUN make && make install

WORKDIR ${SETUP_DIR}
ARG GOOGLE_TEST_VERSION="release-1.11.0"
RUN git clone https://github.com/google/googletest.git
WORKDIR ${SETUP_DIR}/googletest
RUN git checkout ${GOOGLE_TEST_VERSION}
RUN cmake . && make && make install

WORKDIR ${SETUP_DIR}
ARG PAHO_MQTT_C_VERSION="v1.3.9"
RUN git clone https://github.com/eclipse/paho.mqtt.c.git
WORKDIR ${SETUP_DIR}/paho.mqtt.c
RUN git checkout ${PAHO_MQTT_C_VERSION}
RUN cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_WITH_SSL=OFF -DPAHO_HIGH_PERFORMANCE=ON
RUN cmake --build build/ --target install

WORKDIR ${SETUP_DIR}
ARG PAHO_MQTT_CPP_VERSION="v1.2.0"
RUN git clone https://github.com/eclipse/paho.mqtt.cpp.git
WORKDIR ${SETUP_DIR}/paho.mqtt.cpp
RUN git checkout ${PAHO_MQTT_CPP_VERSION}
RUN cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_WITH_SSL=OFF -DPAHO_BUILD_SAMPLES=TRUE
RUN cmake --build build/ --target install

WORKDIR ${SETUP_DIR}
ARG NLOHMANN_VERSION="v3.11.2"
RUN git clone https://github.com/nlohmann/json json --recursive
WORKDIR ${SETUP_DIR}/json
RUN git checkout ${NLOHMANN_VERSION}
WORKDIR ${SETUP_DIR}/json/build-dir
RUN cmake .. -DMAKE_BUILD_TYPE=Release -DBUILD_TESTING:BOOL=OFF -DJSON_BuildTests=OFF
RUN cmake --build . --config Release --target install -- -j${nproc}

WORKDIR ${SETUP_DIR}
ARG JSON_SCHEMA_VALIDATOR_VERSION=2.2.0
RUN git clone https://github.com/pboettch/json-schema-validator.git
WORKDIR ${SETUP_DIR}/json-schema-validator
RUN git checkout tags/${JSON_SCHEMA_VALIDATOR_VERSION}
WORKDIR ${SETUP_DIR}/json-schema-validator/build-dir
RUN cmake -DBUILD_SHARED_LIBS=ON .. && make && make install

WORKDIR ${SETUP_DIR}
ARG PROTOBUF_VERSION=v3.21.12
RUN git clone https://github.com/protocolbuffers/protobuf.git
WORKDIR ${SETUP_DIR}/protobuf
RUN git submodule update --init --recursive
RUN git checkout tags/${PROTOBUF_VERSION}
WORKDIR ${SETUP_DIR}/protobuf/build-dir
RUN cmake -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF .. && make && make install

WORKDIR ${SETUP_DIR}
RUN rm -rf * && sync
RUN ldconfig
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu
{
"name": "Ubuntu 18.04 & Git",
"dockerFile": "Dockerfile",
// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [
// Uncomment the line if you will use a ptrace-based debugger like C++, Go, and Rust.
// "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined",

// Uncomment the next line to use a non-root user. On Linux, this will prevent
// new files getting created as root, but you may need to update the USER_UID
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
// "-u", "vscode"
],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build/
googletest/
build*/
bin/
CMakeFiles/
src/main
src/CMakeFiles/
src/CmakeCache.txt
*.a
Empty file added .gitmodules
Empty file.
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
96 changes: 96 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"files.associations": {
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"typeindex": "cpp",
"xstring": "cpp",
"charconv": "cpp",
"compare": "cpp",
"concepts": "cpp",
"format": "cpp",
"ios": "cpp",
"locale": "cpp",
"stop_token": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"xthread": "cpp",
"xmemory0": "cpp",
"queue": "cpp",
"codecvt": "cpp",
"filesystem": "cpp",
"cinttypes": "cpp",
"unordered_set": "cpp"
},
"C_Cpp.dimInactiveRegions": false,
}
26 changes: 26 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "docker-compose -f docker-compose.dev.yml up",
"group": "build",
"problemMatcher": []
},
{
"label": "Clear All Containers",
"type": "shell",
"command": "docker ps -a -q | % { docker stop $_ | docker rm $_ }",
"group": "build",
"problemMatcher": []
},
{
"label": "CleanUp",
"type": "shell",
"command": "docker-compose -f docker-compose.dev.yml down",
"group": "build",
"problemMatcher": []
}
]
}
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 9-7-2024 Cummins Inc
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0

project(up-cpp-server)
cmake_minimum_required(VERSION 3.5)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a" )
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH} /usr/local/lib")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(TEST_BINARY test-${PROJECT_NAME})

if(ENABLE_TESTING)
add_subdirectory(src)
add_subdirectory(test)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -D GTEST" )
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)
endif()
else()
add_subdirectory(src)
endif()
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 9-7-2024 Cummins Inc
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0

#this dockerfile is intended to work in parallel with Dockerfile,
#official chnages outside of architecture should be made to both
FROM opensource-base AS dev
ARG PROJECT_NAME="canought-up-cpp-server"
ARG SETUP_DIR="/root"
ARG BUILD_FOLDER="build-dir"
ARG BUILD_TYPE="Release"
WORKDIR ${SETUP_DIR}
COPY src src
COPY test test
COPY CMakeLists.txt .
WORKDIR ${SETUP_DIR}/${BUILD_FOLDER}/${BUILD_TYPE}
RUN cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DAPP_NAME:STRING=${PROJECT_NAME} ../..
RUN make
RUN make install
WORKDIR ${SETUP_DIR}
#Strip libraries
RUN strip /usr/local/lib/*.so* --strip-all
RUN strip /usr/local/bin/${PROJECT_NAME} --strip-all

ENV RUN_APP=${PROJECT_NAME}

WORKDIR /root
CMD ${RUN_APP}
24 changes: 24 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 9-7-2024 Cummins Inc
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# #this dockerfile is intended to run development quality tools as Unit Testing and Static Code analysis
FROM opensource-ut AS ut
ARG PROJECT_NAME="canought-up-cpp-server"
ARG SETUP_DIR="/root"
ARG BUILD_FOLDER="build-dir"
ARG BUILD_TYPE="Debug"
WORKDIR ${SETUP_DIR}
ADD src src
ADD test test
ADD CMakeLists.txt .
WORKDIR ${SETUP_DIR}/${BUILD_FOLDER}
RUN cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DAPP_NAME:STRING=${PROJECT_NAME} -DENABLE_TESTING:BOOL=ON ..
RUN make && make install
RUN ldconfig
WORKDIR ${SETUP_DIR}
ENV PROJECT_NAME_APP=${PROJECT_NAME}
CMD runTesting.sh ${PROJECT_NAME_APP}
Loading