From f60a32990d7293be375f410f154033c7c231aec5 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:07:17 +0200 Subject: [PATCH] Update cloud action to allow platform specific builds --- docs/cli.md | 65 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index 99b4d60be3..bae04028fe 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -861,12 +861,11 @@ You can use the `module build start` or `module build local` commands to build y - Use `build start` to build or compile your module on a cloud build host that might offer more platform support than you have access to locally. - Use `build local` to quickly test that your module builds or compiles as expected on your local hardware. -To configure your module's build steps, add a `build` object to your [`meta.json` file](#the-metajson-file) like the following: +To configure your module's build steps, add a `build` object to your [`meta.json` file](#the-metajson-file) like the following. +You can either have a single build file for all platforms, or platform specific files. - - - +{{< tabs >}} +{{% tab name="Single Build File" %}} ```json {class="line-numbers linkable-line-numbers"} "build": { @@ -878,6 +877,27 @@ To configure your module's build steps, add a `build` object to your [`meta.json } ``` +{{% /tab %}} +{{% tab name="Platform Specific" %}} + +```json {class="line-numbers linkable-line-numbers"} +"build": { + "path" : "dist/archive.tar.gz", // optional - path to your built module + // (passed to the 'viam module upload' command) + "arch": { + "linux/arm64": { + "build": "./build-linux-arm64.sh" // command that will build your module + }, + "darwin/arm64": { + "build": "./build-darwin-arm64.sh" // command that will build your module + } + } // architecture(s) to build for +} +``` + +{{% /tab %}} +{{< /tabs >}} + {{% expand "Click to view example setup.sh" %}} ```sh {class="line-numbers linkable-line-numbers"} @@ -903,7 +923,7 @@ pip3 install -r requirements.txt {{% /expand %}} -{{%expand "Click to view example build.sh (with setup.sh)" %}} +{{% expand "Click to view example build.sh (with setup.sh)" %}} ```sh {class="line-numbers linkable-line-numbers"} #!/bin/bash @@ -939,29 +959,11 @@ python3 -m PyInstaller --onefile --hidden-import="googleapiclient" src/main.py tar -czvf dist/archive.tar.gz ``` -{{% /expand%}} - - - +{{% /expand %}} For example, the following extends the `my-module` meta.json file from the previous section using the single build file approach, adding a new `build` object to control its build parameters when used with `module build start` or `module build local`: