canonical / matter-pi-gpio-commander

Matter Raspberry Pi GPIO Commander - Turn your Pi into a Matter lighting device!
Apache License 2.0
94 stars 2 forks source link

Use pre built zap binary #29

Closed MonicaisHer closed 11 months ago

MonicaisHer commented 11 months ago

This PR downloads and unzips the prebuilt ZAP (Zigbee Cluster Library configuration tool and generator) binary for the ARM64 architecture, which will make the build more efficient.

MonicaisHer commented 11 months ago

$ZAP_INSTALL_PATH to point to where zap-linux-x64.zip, zap-linux-arm64.zip or zap-mac-x64.zip was unpacked

reference: https://project-chip.github.io/connectedhomeip-doc/guides/BUILDING.html#which-zap-to-use

According to the above reference, that only $ZAP_INSTALL_PATH is necessary, and setting $PATH is not necessary.

MonicaisHer commented 11 months ago

The code can be built successfully on arm64 Pi, but it failed on snapcraft remote-build with the following error:

:: Searching for zcl file from /build/snapcraft-matter-pi-gpio-commander-d84885e7425e7d765a8664aaae9a4d2d/parts/connectedhomeip/src/examples/lighting-app/linux/third_party/connectedhomeip/examples/lighting-app/lighting-common/lighting-app.zap
:: FAILED TO EXECUTE ZAP GENERATION: No such file or directory - "zap-cli"
:: ********************************************************************************
:: * You may need to install zap. Please ensure one of these applies:
:: * - `zap-cli` is in $PATH. Install from https://github.com/project-chip/zap/releases
:: *   see docs/guides/BUILDING.md for details
:: * - `zap-cli` is in $ZAP_INSTALL_PATH. Use this option if you
:: *   installed zap but do not want to update $PATH
:: * - Point $ZAP_DEVELOPMENT_PATH to your local copy of zap that you
:: *   develop on (to use a developer build of zap)
:: ********************************************************************************
:: [34/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/wpa:wpa_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [35/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/openthread:openthread_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [36/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/bluez:bluez_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [37/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/wpa:wpa_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [38/555] ACTION //third_party/connectedhomeip/examples/lighting-app/lighting-common:lighting-common_codegen_codegen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: ninja: build stopped: subcommand failed.
'override-build' in part 'lighting' failed with code 1.
farshidtz commented 11 months ago

The code can be built successfully on arm64 Pi, but it failed on snapcraft remote-build with the following error:

:: Searching for zcl file from /build/snapcraft-matter-pi-gpio-commander-d84885e7425e7d765a8664aaae9a4d2d/parts/connectedhomeip/src/examples/lighting-app/linux/third_party/connectedhomeip/examples/lighting-app/lighting-common/lighting-app.zap
:: FAILED TO EXECUTE ZAP GENERATION: No such file or directory - "zap-cli"
:: ********************************************************************************
:: * You may need to install zap. Please ensure one of these applies:
:: * - `zap-cli` is in $PATH. Install from https://github.com/project-chip/zap/releases
:: *   see docs/guides/BUILDING.md for details
:: * - `zap-cli` is in $ZAP_INSTALL_PATH. Use this option if you
:: *   installed zap but do not want to update $PATH
:: * - Point $ZAP_DEVELOPMENT_PATH to your local copy of zap that you
:: *   develop on (to use a developer build of zap)
:: ********************************************************************************
:: [34/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/wpa:wpa_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [35/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/openthread:openthread_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [36/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/bluez:bluez_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [37/555] ACTION //third_party/connectedhomeip/src/platform/Linux/dbus/wpa:wpa_gen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: [38/555] ACTION //third_party/connectedhomeip/examples/lighting-app/lighting-common:lighting-common_codegen_codegen(//third_party/connectedhomeip/build/toolchain/linux:linux_arm64_gcc)
:: ninja: build stopped: subcommand failed.
'override-build' in part 'lighting' failed with code 1.

The issue isn't related to zap. On remote build, the env file created in zap part doesn't get loaded in the lighting part. See the relevant logs below:

Remote build:

:: + echo 'export ZAP_INSTALL_PATH=/build/snapcraft-matter-pi-gpio-commander-dcf72f424a2401ddf9b69c72baccc6c2/parts/zap/build'
...
:: + test -f /root/parts/zap/build/env
:: + cd ../../connectedhomeip/src

On Pi:

+ echo 'export ZAP_INSTALL_PATH=/root/parts/zap/build'                                                                                              
...                                                                                                        
:: + test -f /root/parts/zap/build/env                                                                                                                 
:: + source /root/parts/zap/build/env                                                                                                                  
:: ++ export ZAP_INSTALL_PATH=/root/parts/zap/build                                                                                                    
:: ++ ZAP_INSTALL_PATH=/root/parts/zap/build                                                                                                           
:: + cd ../../connectedhomeip/src

Note that remote build uses Launchpad and as far as I know those builds use the destructive mode, i.e. building directly on the host. The difference in paths appears related to that.