-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from timrulebosch/oct_update
Build, Packaging and Register schema updates.
- Loading branch information
Showing
13 changed files
with
378 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#*************************************************************************** | ||
# 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 | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
#*************************************************************************** | ||
|
||
|
||
############### | ||
## Builder Images | ||
BUILDER_DOCKER_IMAGES = flatc-builder python-builder | ||
FLATC_BUILDER_IMAGE ?= flatc-builder:latest | ||
PYTHON_BUILDER_IMAGE ?= python-builder:latest | ||
|
||
|
||
############### | ||
## Build parameters. | ||
PLATFORM = linux64 | ||
DIST_DIR = $(shell pwd -P)/dist | ||
OUT_DIR = $(shell pwd -P)/dist/$(PACKAGE_NAME) | ||
# Flatbuffers | ||
FBS_OUT_DIR = $(OUT_DIR)/flatbuffers | ||
FBS_SCHEMA_DIR = $(shell pwd -P)/schemas | ||
FBS_SCHEMA_SOURCES = $(shell ls $(FBS_SCHEMA_DIR)/**/*.fbs) | ||
# FlatC | ||
FLATC = flatc | ||
FLATC_OPTIONS = | ||
FLATCC = flatcc | ||
# FlatCC | ||
FLATCC_SRC_RUNTIME_DIR = /usr/local/src/flatcc/src/runtime | ||
FLATCC_SRC_INCLUDE_DIR = /usr/local/include/flatcc | ||
FLATCC_SRC_LICENSE_DIR = /usr/local/src/flatcc | ||
FLATCC_DIST_RUNTIME_DIR = $(FBS_OUT_DIR)/c/src/flatcc | ||
FLATCC_DIST_INCLUDE_DIR = $(FBS_OUT_DIR)/c/include/flatcc | ||
# MsgPack | ||
MPK_OUT_DIR = $(OUT_DIR)/msgpack | ||
MPK_SCHEMA_DIR = $(shell pwd -P)/schemas | ||
MPK_SCHEMA_SOURCES = $(shell ls $(MPK_SCHEMA_DIR)/**/*.yaml) | ||
# Python (for creating a Python Package) | ||
PYTHON_SRC_DIR = $(FBS_OUT_DIR)/python | ||
PYTHON_DIST_DIR = $(DIST_DIR)/python | ||
|
||
|
||
############### | ||
## Packaging. | ||
PACKAGE_NAME = automotive-bus-schema | ||
PACKAGE_FILENAME = $(PACKAGE_NAME).tar.gz | ||
PACKAGE_VERSION ?= devel | ||
|
||
|
||
default: build | ||
|
||
|
||
builders: | ||
for d in $(BUILDER_DOCKER_IMAGES) ;\ | ||
do \ | ||
docker build -f docker/$$d/Dockerfile \ | ||
--tag $$d:latest ./docker/$$d ;\ | ||
done; | ||
|
||
build: | ||
docker run -it --rm \ | ||
--volume $$(pwd):/tmp/repo \ | ||
--env PACKAGE_VERSION=$(PACKAGE_VERSION) \ | ||
--workdir /tmp/repo \ | ||
$(FLATC_BUILDER_IMAGE) \ | ||
/bin/bash -c "make fbs" | ||
docker run -it --rm \ | ||
--volume $$(pwd):/tmp/repo \ | ||
--env PIP_EXTRA_INDEX_URL=$(PIP_EXTRA_INDEX_URL) \ | ||
--env PACKAGE_VERSION=$(PACKAGE_VERSION) \ | ||
--workdir /tmp/repo \ | ||
$(PYTHON_BUILDER_IMAGE) \ | ||
/bin/bash -c "make python; make msgpack" | ||
|
||
@echo "" | ||
@echo "Generated files:" | ||
@echo "---------------" | ||
@ls -R $(FBS_OUT_DIR) | ||
@ls -R $(MPK_OUT_DIR) | ||
|
||
$(FBS_SCHEMA_SOURCES): | ||
@echo $@ | ||
# Setup the directory structure. | ||
mkdir -p $(FBS_OUT_DIR)/c/$$(basename $$(dirname $@)) | ||
mkdir -p $(FBS_OUT_DIR)/cpp/$$(basename $$(dirname $@)) | ||
mkdir -p $(FBS_OUT_DIR)/fbs/$$(basename $$(dirname $@)) | ||
mkdir -p $(FBS_OUT_DIR)/fbs/$$(basename $$(dirname $@)) | ||
mkdir -p $(FBS_OUT_DIR)/fbs/$$(basename $$(dirname $@)) | ||
# Generate Flatbuffers code. | ||
$(FLATCC) -a $(FLATC_OPTIONS) -o $(FBS_OUT_DIR)/c/$$(basename $$(dirname $@)) $@ | ||
$(FLATC) --cpp $(FLATC_OPTIONS) --filename-suffix '' -o $(FBS_OUT_DIR)/cpp/$$(basename $$(dirname $@)) $@ | ||
$(FLATC) --python $(FLATC_OPTIONS) -o $(FBS_OUT_DIR)/python $@ | ||
$(FLATC) --lua $(FLATC_OPTIONS) -o $(FBS_OUT_DIR)/lua $@ | ||
# Copy over the original Flatbuffer schemas. | ||
cp $@ $(FBS_OUT_DIR)/fbs/$$(basename $$(dirname $@)) | ||
|
||
fbs: $(FBS_SCHEMA_SOURCES) | ||
mkdir -p $(FLATCC_DIST_RUNTIME_DIR) | ||
cp $(FLATCC_SRC_RUNTIME_DIR)/builder.c $(FLATCC_DIST_RUNTIME_DIR) | ||
cp $(FLATCC_SRC_RUNTIME_DIR)/emitter.c $(FLATCC_DIST_RUNTIME_DIR) | ||
cp $(FLATCC_SRC_RUNTIME_DIR)/refmap.c $(FLATCC_DIST_RUNTIME_DIR) | ||
cp $(FLATCC_SRC_LICENSE_DIR)/LICENSE $(FLATCC_DIST_RUNTIME_DIR) | ||
mkdir -p $(FLATCC_DIST_INCLUDE_DIR) | ||
cp -r $(FLATCC_SRC_INCLUDE_DIR)/* $(FLATCC_DIST_INCLUDE_DIR) | ||
|
||
$(MPK_SCHEMA_SOURCES): | ||
@echo $@ | ||
mkdir -p $(MPK_OUT_DIR)/$$(basename $$(dirname $@)) | ||
cp $@ $(MPK_OUT_DIR)/$$(basename $$(dirname $@)) | ||
|
||
msgpack: $(MPK_SCHEMA_SOURCES) | ||
|
||
python: | ||
mkdir -p $(PYTHON_DIST_DIR) | ||
cp -r $(PYTHON_SRC_DIR)/* $(PYTHON_DIST_DIR) | ||
cp -r templates/python/* $(PYTHON_DIST_DIR) | ||
cd $(PYTHON_DIST_DIR) && python3 setup.py sdist bdist_wheel | ||
|
||
dist_package: | ||
mkdir -p $(DIST_DIR) | ||
mkdir -p $(OUT_DIR) | ||
echo $(PACKAGE_VERSION) > $(OUT_DIR)/VERSION | ||
|
||
tar -czvf $(DIST_DIR)/$(PACKAGE_FILENAME) -C $(DIST_DIR) $(PACKAGE_NAME) | ||
|
||
dist: | ||
docker run -it --rm \ | ||
--volume $$(pwd):/tmp/repo \ | ||
--env PIP_EXTRA_INDEX_URL=$(PIP_EXTRA_INDEX_URL) \ | ||
--env PACKAGE_VERSION=$(PACKAGE_VERSION) \ | ||
--workdir /tmp/repo \ | ||
$(PYTHON_BUILDER_IMAGE) \ | ||
/bin/bash -c "make dist_package" | ||
|
||
@echo "" | ||
@echo "Distribution package files:" | ||
@echo "--------------------------" | ||
@ls -1sh $(DIST_DIR)/*.* | ||
@ls -1sh $(PYTHON_DIST_DIR)/dist/*.* | ||
|
||
clean: | ||
-@rm -rf $(DIST_DIR) | ||
|
||
.PHONY: default build fbs msgpack python dist dist_package builders clean $(FBS_SCHEMA_SOURCES) $(MPK_SCHEMA_SOURCES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.