rules_synology
v0.2.0
published 8 months ago
1 stars
0 forks
1 watchers
MIT License
public
1 assets
2,007 downloads
49 KB
Compatibility level unknown
wN/rKIaLXDeXI/CODmom7HOrmqpXZfdr0JXhNmalO+k=
Maintained byAllan Clark
v0.2.0
December 16, 2024
[expand for release notes]

Bazel Rules for Synology NAS Products

... or ... Can we build SPKs with a Bazel Cross toolchain?

Status

rules_synology is targeting the Denverton architecture initially -- it's what I have to test with -- but new toolchains can be added on request (via github "Issues"). Minimum-Viable may be the Denverton, but if you're willing to sign up as a tester, I'm willing to make changes to help you unblock yourself.

Overview

rules_synology offers a set of rules to work with Synology NAS products: cross-compile toolchains, file-generation, image-manipulation, etc. Rather than try to stuff one-off cases into, say, rules_pkg, let's define them here and help keep things interoperable.

The short-term goal includes a basic build command such as:

bazel build //... --platforms=@rules_synology/models:ds918-7.1

The longer-term objective would be to allow as minimal initial config to define a package, leveraging sensible defaults: perhaps a series of macros or facade-pattern wrappers to keep minimal the user-investment to try these rules. If the barrier-to-entry remains low, we can help more to try this resource, helping as many as possible bring more cool things to Synology users.

... but right now, we're in Minimum-Viable-Product stage: cross-compile and package a binary tool or service.

Setup / Suggested Usage

Simplest usage is a goal; currently, the recommended usage, as confirmed by the examples/cross-helloworld, looks like:

(MODULE.bazel)

bazel_dep(name = "rules_synology", version = "0.0.1")

# If you need cross-build toolchains
register_toolchains("@rules_synology//toolchains:all")

In order to use this, you'll need to activate a specific platform at build (or in a .bazelrc):

bazel build --incompatible_enable_cc_toolchain_resolution --platforms=@rules_synology//models:ds1819+-7.1

...this it's down to creating a SPK. At this stage, the easiest method forward is to look at the examples in the examples directory.

Testing

In order to ensure that the crosstool selection still works despite whatever changes, I've cut a script that shows an example of running the cross-build, and confirming that the cross toolchain is considered and ultimately chosen.

bash -x  examples/cross-helloworld/confirm-cross-selection.bash

References:

Older