Skip to content

Commit

Permalink
Update cloud action to allow platform specific builds
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel committed Sep 2, 2024
1 parent 168a52e commit 1262e02
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- Developers can either have a single build file for all platforms, or platform specific files: -->

<!-- { {< tabs >}}
{ {% tab name="Single Build File" %}} -->
{{< tabs >}}
{{% tab name="Single Build File" %}}

```json {class="line-numbers linkable-line-numbers"}
"build": {
Expand All @@ -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"}
Expand Down Expand Up @@ -941,27 +961,9 @@ tar -czvf dist/archive.tar.gz <PATH-TO-EXECUTABLE>

{{% /expand%}}

<!-- { {% /tab %}} -->
<!-- { {% tab name="Platform Specific" %}}
{{%expand "Click to view example build-linux-arm64.sh" %}}

```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
}
```
{ {%expand "Click to view example build-linux-arm64.sh" %}}
```sh { class="command-line"}
```sh {class="line-numbers linkable-line-numbers"}
#!/bin/bash
set -e

Expand Down Expand Up @@ -989,10 +991,7 @@ python3 -m PyInstaller --onefile --hidden-import="googleapiclient" src/main.py
tar -czvf dist/archive.tar.gz <PATH-TO-EXECUTABLE>
```

{ {% /expand%}}
{{ % /tab %}}
{ {< /tabs >}} -->
{{% /expand%}}

For example, the following extends the `my-module` <file>meta.json</file> 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`:

Expand Down

0 comments on commit 1262e02

Please sign in to comment.