Skip to content

Commit

Permalink
[DEV] use LOCAL_COPY_FROM to copy .proto files
Browse files Browse the repository at this point in the history
Change-Id: I26017a88da2b6ed1d9fa3f04a842c25096b4d13f
Reviewed-on: https://gerrit-doc.parrot.biz/c/drones/sdk/olympe/+/200693
Reviewed-by: Nicolas Dessart <nicolas.dessart@parrot.com>
  • Loading branch information
ndessart committed Jul 24, 2024
1 parent 7901869 commit 23f36ed
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions atom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LOCAL_MODULE := olympe-base
LOCAL_CATEGORY_PATH := libs
LOCAL_DESCRIPTION := Olympe pure python module
LOCAL_DEPENDS_MODULES := python arsdkparser parrot-protobuf-extensions-proto protobuf-base
LOCAL_LIBRARIES := arsdkparser parrot-protobuf-extensions-proto
LOCAL_LIBRARIES := arsdkparser parrot-protobuf-extensions-proto protobuf-base

PRIVATE_OLYMPE_OUT_DIR=$(TARGET_OUT_STAGING)$(shell echo $${TARGET_DEPLOY_ROOT:-/usr})

Expand All @@ -26,20 +26,14 @@ LOCAL_COPY_FILES := \
)

# Install .proto files in python site-packages/olympe_protobuf staging directory
PRIVATE_OLYMPE_PROTOBUF_SRC_DIRS := $(PRIVATE_OLYMPE_OUT_DIR)/share/protobuf:$(PRIVATE_OLYMPE_OUT_DIR)/lib/python/site-packages
PRIVATE_OLYMPE_PROTOBUF_DST_DIR := $(PRIVATE_OLYMPE_OUT_DIR)/lib/python/site-packages/olympe_protobuf
define LOCAL_CMD_POST_INSTALL
while read -d ':' src_dir; do \
protobuf_src_files=$$(find $$src_dir -type f -name '*.proto'); \
protobuf_dst_files=$$(echo $$protobuf_src_files | xargs -I{} -d' ' bash -c "echo \"{}\" | \
sed 's#\s*$$src_dir#$(PRIVATE_OLYMPE_PROTOBUF_DST_DIR)#g'"); \
while read -ra src <&3 && read -ra dst <&4; do \
echo "$$src is in $$dst"; \
install -Dp -m0660 $$src $$dst; \
done 3<<<"$$protobuf_src_files" 4<<<"$$protobuf_dst_files"; \
done <<< $(PRIVATE_OLYMPE_PROTOBUF_SRC_DIRS):; \
echo $$protobuf_files;
endef
PRIVATE_OLYMPE_PROTOBUF_SHARE_DIR := $(PRIVATE_OLYMPE_OUT_DIR)/share/protobuf
PRIVATE_OLYMPE_PROTOBUF_SP_DIR := $(PRIVATE_OLYMPE_OUT_DIR)/lib/python/site-packages
PRIVATE_OLYMPE_PROTOBUF_DST_DIR := \
$(PRIVATE_OLYMPE_OUT_DIR)/lib/python/site-packages/olympe_protobuf
LOCAL_COPY_FROM := \
arsdkparser:$(PRIVATE_OLYMPE_PROTOBUF_SP_DIR):$(PRIVATE_OLYMPE_PROTOBUF_DST_DIR):%.proto \
protobuf-base:$(PRIVATE_OLYMPE_PROTOBUF_SHARE_DIR):$(PRIVATE_OLYMPE_PROTOBUF_DST_DIR):%.proto \
parrot-protobuf-extensions-proto:$(PRIVATE_OLYMPE_PROTOBUF_SHARE_DIR):$(PRIVATE_OLYMPE_PROTOBUF_DST_DIR):%.proto

include $(BUILD_CUSTOM)

Expand Down

0 comments on commit 23f36ed

Please sign in to comment.