From 260a155403fd9420d1eeb0d40986e0cbd8c09f61 Mon Sep 17 00:00:00 2001 From: LynnL4 Date: Tue, 26 Nov 2024 09:28:48 +0000 Subject: [PATCH] perf: optimize build process for sscma-node and sscma-supervisor --- external/br2-external/Config.in | 4 +- external/br2-external/sscma-app/Config.in | 6 --- external/br2-external/sscma-app/sscma-app.mk | 28 ------------- external/br2-external/sscma-node/Config.in | 6 +++ .../br2-external/sscma-node/sscma-node.mk | 41 +++++++++++++++++++ .../br2-external/sscma-supervisor/Config.in | 8 ++-- .../sscma-supervisor/sscma-supervisor.mk | 30 ++++++++------ 7 files changed, 71 insertions(+), 52 deletions(-) delete mode 100644 external/br2-external/sscma-app/Config.in delete mode 100644 external/br2-external/sscma-app/sscma-app.mk create mode 100644 external/br2-external/sscma-node/Config.in create mode 100644 external/br2-external/sscma-node/sscma-node.mk diff --git a/external/br2-external/Config.in b/external/br2-external/Config.in index 2aad1c53..4d5804c3 100644 --- a/external/br2-external/Config.in +++ b/external/br2-external/Config.in @@ -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" \ No newline at end of file diff --git a/external/br2-external/sscma-app/Config.in b/external/br2-external/sscma-app/Config.in deleted file mode 100644 index 6daf7e9f..00000000 --- a/external/br2-external/sscma-app/Config.in +++ /dev/null @@ -1,6 +0,0 @@ -config BR2_PACKAGE_SSCMA_APP - bool "sscma-app" - default y - help - This is the help text for the supervisor and sscma-node package. - It will be displayed in the Buildroot configuration menu. diff --git a/external/br2-external/sscma-app/sscma-app.mk b/external/br2-external/sscma-app/sscma-app.mk deleted file mode 100644 index 4f17da7d..00000000 --- a/external/br2-external/sscma-app/sscma-app.mk +++ /dev/null @@ -1,28 +0,0 @@ -################################################################################ -# -# sscma-app -# -################################################################################ - -SSCMA_APP_VERSION = 0.0.7 -SSCMA_APP_SITE = https://github.com/Seeed-Studio/sscma-example-sg200x.git -SSCMA_APP_SITE_METHOD = git -SSCMA_APP_GIT_SUBMODULES = YES -SSCMA_APP_LICENSE = Apache-2.0 -SSCMA_APP_DEPENDENCIES = mosquitto host-nodejs - -define SSCMA_APP_BUILD_CMDS - (cd $(@D); \ - $(TARGET_CONFIGURE_OPTS) \ - SG200X_SDK_PATH=$(BASE_DIR)/../../../ \ - ./build.sh \ - ) -endef - -define SSCMA_APP_INSTALL_TARGET_CMDS - @cp -rf $(@D)/install/* $(TARGET_DIR)/ - mkdir -p $(TARGET_DIR)/home/recamera/.node-red/node_modules - $(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)) diff --git a/external/br2-external/sscma-node/Config.in b/external/br2-external/sscma-node/Config.in new file mode 100644 index 00000000..261d3aa2 --- /dev/null +++ b/external/br2-external/sscma-node/Config.in @@ -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. \ No newline at end of file diff --git a/external/br2-external/sscma-node/sscma-node.mk b/external/br2-external/sscma-node/sscma-node.mk new file mode 100644 index 00000000..8964cce5 --- /dev/null +++ b/external/br2-external/sscma-node/sscma-node.mk @@ -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)) diff --git a/external/br2-external/sscma-supervisor/Config.in b/external/br2-external/sscma-supervisor/Config.in index c06eac6c..327d3f6d 100644 --- a/external/br2-external/sscma-supervisor/Config.in +++ b/external/br2-external/sscma-supervisor/Config.in @@ -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. \ No newline at end of file diff --git a/external/br2-external/sscma-supervisor/sscma-supervisor.mk b/external/br2-external/sscma-supervisor/sscma-supervisor.mk index 1f25477f..15ccf7f4 100644 --- a/external/br2-external/sscma-supervisor/sscma-supervisor.mk +++ b/external/br2-external/sscma-supervisor/sscma-supervisor.mk @@ -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))