Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pre built zap binary #29

Merged
merged 4 commits into from Nov 6, 2023
Merged

Conversation

MonicaisHer
Copy link
Contributor

@MonicaisHer MonicaisHer commented Oct 25, 2023

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.

snap/snapcraft.yaml Outdated Show resolved Hide resolved
@MonicaisHer MonicaisHer marked this pull request as ready for review October 26, 2023 15:38

# Install zap
npm install
mkdir -p /bin && mv zap-cli /bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the bin directory meant to be relative to the current directory, as added to the PATH?

Suggested change
mkdir -p /bin && mv zap-cli /bin
mkdir -p bin && mv zap-cli bin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this comment; the zap-cli doesn't need to be moved to the bin directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needed to be in the ./bin directory because your environment variables pointed to that:

        echo "export ZAP_DEVELOPMENT_PATH=$PWD/bin" >> env
        echo "export ZAP_INSTALL_PATH=$PWD/bin" >> env
        echo "export PATH=$PWD/bin:$PATH" > env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the doc, ZAP_DEVELOPMENT_PATH and PATH are no longer needed. Only ZAP_INSTALL_PATH needs to point to where zap-linux-arm64.zip was unpacked.

The code is already updated as follows::

  wget https://github.com/project-chip/zap/releases/download/$ZAP_VERSION/zap-linux-$SNAP_ARCH.zip
  unzip -o zap-linux-$SNAP_ARCH.zip

  # Define the environment needed for the app build
  echo "export ZAP_INSTALL_PATH=$PWD" >> env

@MonicaisHer
Copy link
Contributor Author

$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
Copy link
Contributor Author

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.

snap/snapcraft.yaml Outdated Show resolved Hide resolved
@farshidtz
Copy link
Member

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.

snap/snapcraft.yaml Outdated Show resolved Hide resolved
@farshidtz farshidtz merged commit 421c20b into canonical:main Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants