Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
closes #9 #10

Signed-off-by: Timothy Rule (VM/EMT3) <[email protected]>
  • Loading branch information
timrulebosch committed Jan 30, 2025
1 parent 1e6f3eb commit efb9a3c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 33 deletions.
4 changes: 3 additions & 1 deletion examples/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2021 Robert Bosch GmbH
# Copyright 2021 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.18)

Expand Down
56 changes: 31 additions & 25 deletions examples/cmake/Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
#***************************************************************************
# Copyright (c) 2021 for information on the respective copyright owner
# see the NOTICE file and/or the following repository:
# https://github.com/boschglobal/automotive-bus-schema
# Copyright 2021 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0
#***************************************************************************

CONTAINER_REPO ?= ghcr.io
CONTAINER_PREFIX ?= boschglobal/automotive-bus-schema-
CONTAINER_TAG ?= main
GCC_BUILDER_IMAGE ?= $(CONTAINER_REPO)/$(CONTAINER_PREFIX)gcc-builder:$(CONTAINER_TAG)

###############
## Builder Images
FLATC_BUILDER_IMAGE ?= flatc-builder:latest

ifneq ($(CI), true)
DOCKER_BUILDER_CMD := docker run -it --rm \
--volume $$(pwd)/../..:/tmp/repo \
--workdir /tmp/repo/examples/streams \
$(GCC_BUILDER_IMAGE)
endif

default: build_docker
.PHONY: build clean do-build run

all: build
cd build; make
default: build

build:
mkdir build;
cd build; cmake ..
@${DOCKER_BUILDER_CMD} $(MAKE) do-build

do-build:
# Build from scratch if no build dir.
@if [ ! -d "build" ]; then \
mkdir -p build; \
cd build; \
cmake .. ; \
fi
# Build incremental.
cd build; make
cd build; make install
@echo ""
@echo "Sandbox files: - $$(pwd)/build/_out"
@echo "--------------"
@find build/_out/ -type f -name '*' -exec ls -sh --color=auto {} \;

build_docker:
@docker run -it --rm \
--volume $$(pwd)/../..:/tmp/repo \
--workdir /tmp/repo/examples/cmake \
$(FLATC_BUILDER_IMAGE) \
/bin/bash -c "make all"
run:
@build/_out/bin/frames

clean:
rm -rf build

cleanall: clean


.PHONY: default all clean cleanall
6 changes: 4 additions & 2 deletions examples/cmake/example.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* Copyright (C) 2021 Robert Bosch GmbH */
// Copyright 2021 Robert Bosch GmbH
//
// SPDX-License-Identifier: Apache-2.0

#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -79,7 +81,7 @@ int main(int argc, char **argv)
}

/* Cleanup. */
free(buf);
FLATCC_BUILDER_FREE(buf);
flatcc_builder_clear(B);
exit(0);
}
4 changes: 4 additions & 0 deletions examples/streams/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2022 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.21)

project(stream-frames-example)
Expand Down
11 changes: 8 additions & 3 deletions examples/streams/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright (C) 2022 Robert Bosch GmbH

GCC_BUILDER_IMAGE ?= gcc-builder:latest
# Copyright 2022 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0

CONTAINER_REPO ?= ghcr.io
CONTAINER_PREFIX ?= boschglobal/automotive-bus-schema-
CONTAINER_TAG ?= main
GCC_BUILDER_IMAGE ?= $(CONTAINER_REPO)/$(CONTAINER_PREFIX)gcc-builder:$(CONTAINER_TAG)

ifneq ($(CI), true)
DOCKER_BUILDER_CMD := docker run -it --rm \
Expand Down
6 changes: 4 additions & 2 deletions examples/streams/frames.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* Copyright (C) 2022 Robert Bosch GmbH */
// Copyright 2022 Robert Bosch GmbH
//
// SPDX-License-Identifier: Apache-2.0

#include <stdio.h>
#include <stdint.h>
Expand Down Expand Up @@ -145,7 +147,7 @@ int main(int argc, char **argv)

/* Process the stream of frames. */
process_stream(buffer, length);
flatcc_builder_free(buffer);
FLATCC_BUILDER_FREE(buffer);

/* Clear out the FBS Builder. */
flatcc_builder_clear(&builder);
Expand Down

0 comments on commit efb9a3c

Please sign in to comment.