Skip to content

Commit

Permalink
perf: optimize build process for sscma-node and sscma-supervisor
Browse files Browse the repository at this point in the history
LynnL4 committed Nov 26, 2024
1 parent c61b821 commit 260a155
Showing 7 changed files with 71 additions and 52 deletions.
4 changes: 2 additions & 2 deletions external/br2-external/Config.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "$BR2_EXTERNAL_BR2EXT_PATH/reCamera/Config.in"
source "$BR2_EXTERNAL_BR2EXT_PATH/sscma-supervisor/Config.in"
source "$BR2_EXTERNAL_BR2EXT_PATH/sscma-app/Config.in"
source "$BR2_EXTERNAL_BR2EXT_PATH/libhv/Config.in"
source "$BR2_EXTERNAL_BR2EXT_PATH/sscma-node/Config.in"
source "$BR2_EXTERNAL_BR2EXT_PATH/sscma-supervisor/Config.in"
6 changes: 0 additions & 6 deletions external/br2-external/sscma-app/Config.in

This file was deleted.

28 changes: 0 additions & 28 deletions external/br2-external/sscma-app/sscma-app.mk

This file was deleted.

6 changes: 6 additions & 0 deletions external/br2-external/sscma-node/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config BR2_PACKAGE_SSCMA_NODE
bool "sscma-node"
default y
help
This is the help text for the ssmca-node package.
It will be displayed in the Buildroot configuration menu.
41 changes: 41 additions & 0 deletions external/br2-external/sscma-node/sscma-node.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
################################################################################
#
# sscma-node
#
################################################################################

SSCMA_NODE_VERSION = 0a62f1816c7fd2effb217f117915676ff70fb369
SSCMA_NODE_SITE = https://github.com/Seeed-Studio/sscma-example-sg200x
SSCMA_NODE_SITE_METHOD = git
SSCMA_NODE_GIT_SUBMODULES = YES
SSCMA_NODE_LICENSE = Apache-2.0
SSCMA_NODE_DEPENDENCIES = host-nodejs mosquitto

# Configure step: prepare the build environment and run CMake to configure the build
define SSCMA_NODE_CONFIGURE_CMDS
mkdir -p $(@D)/solutions/sscma-node/build && \
cd $(@D)/solutions/sscma-node/build && \
SG200X_SDK_PATH=$(shell realpath $(BUILD_DIR)/../../../../) $(BR2_CMAKE) -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=$(TARGET_DIR) ..
endef

# Build step: compile the package using the Makefile in the build directory
define SSCMA_NODE_BUILD_CMDS
$(MAKE) -C $(@D)/solutions/sscma-node/build
endef

# Install step: copy the built files to the target directory
define SSCMA_NODE_INSTALL_TARGET_CMDS
# Install the executable file
$(INSTALL) -D -m 0755 $(@D)/solutions/sscma-node/build/sscma-node $(TARGET_DIR)/usr/local/bin/sscma-node

# Copy other files from the source directory to the target directory
cp -r $(@D)/solutions/sscma-node/files/* $(TARGET_DIR)/

# Create the necessary directories for node-red
mkdir -p $(TARGET_DIR)/home/recamera/.node-red/node_modules

# Use npm to install the node-red-contrib-sscma package
$(NPM) install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict --prefix $(TARGET_DIR)/home/recamera/.node-red node-red-contrib-sscma@0.1.0
endef

$(eval $(generic-package))
8 changes: 4 additions & 4 deletions external/br2-external/sscma-supervisor/Config.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config BR2_PACKAGE_SSCMA_SUPERVISOR
bool "supervisor"
default n
bool "sscma-supervisor"
default y
help
This is the help text for the supervisor package.
It will be displayed in the Buildroot configuration menu.
This is the help text for the ssmca-supervisor package.
It will be displayed in the Buildroot configuration menu.
30 changes: 18 additions & 12 deletions external/br2-external/sscma-supervisor/sscma-supervisor.mk
Original file line number Diff line number Diff line change
@@ -4,25 +4,31 @@
#
################################################################################

SSCMA_SUPERVISOR_SOURCE = supervisor.zip
SSCMA_SUPERVISOR_SITE = https://github.com/Seeed-Studio/sscma-example-sg200x/archive
BR_NO_CHECK_HASH_FOR += $(SSCMA_SUPERVISOR_SOURCE)
SSCMA_SUPERVISOR_VERSION = 0a62f1816c7fd2effb217f117915676ff70fb369
SSCMA_SUPERVISOR_SITE = https://github.com/Seeed-Studio/sscma-example-sg200x
SSCMA_SUPERVISOR_SITE_METHOD = git
SSCMA_SUPERVISOR_GIT_SUBMODULES = YES
SSCMA_SUPERVISOR_LICENSE = Apache-2.0

define SSCMA_SUPERVISOR_EXTRACT_CMDS
$(UNZIP) -d $(@D) $(SSCMA_SUPERVISOR_DL_DIR)/$(SSCMA_SUPERVISOR_SOURCE)
@mv -fv $(@D)/* $(@D)/source
# Configure step: prepare the build environment and run CMake to configure the build
define SSCMA_SUPERVISOR_CONFIGURE_CMDS
mkdir -p $(@D)/solutions/supervisor/build && \
cd $(@D)/solutions/supervisor/build && \
SG200X_SDK_PATH=$(shell realpath $(BUILD_DIR)/../../../../) $(BR2_CMAKE) -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=$(TARGET_DIR) ..
endef

# Build step: compile the package using the Makefile in the build directory
define SSCMA_SUPERVISOR_BUILD_CMDS
(cd $(@D)/source; \
$(TARGET_CONFIGURE_OPTS) \
SG200X_SDK_PATH=$(BASE_DIR)/../../../ \
./build.sh \
)
$(MAKE) -C $(@D)/solutions/supervisor/build
endef

# Install step: copy the built files to the target directory
define SSCMA_SUPERVISOR_INSTALL_TARGET_CMDS
@cp -rf $(@D)/source/install/* $(TARGET_DIR)/
# Install the executable file
$(INSTALL) -D -m 0755 $(@D)/solutions/supervisor/build/supervisor $(TARGET_DIR)/usr/local/bin/supervisor

# Copy other files from the source directory to the target directory
cp -r $(@D)/solutions/supervisor/files/* $(TARGET_DIR)/
endef

$(eval $(generic-package))

0 comments on commit 260a155

Please sign in to comment.