Skip to content

support combining SDKs with multiple WIT worlds#35

Open
dicej wants to merge 1 commit intobytecodealliance:mainfrom
dicej:multiple-sdks
Open

support combining SDKs with multiple WIT worlds#35
dicej wants to merge 1 commit intobytecodealliance:mainfrom
dicej:multiple-sdks

Conversation

@dicej
Copy link

@dicej dicej commented Mar 25, 2026

This adds two new features:

  • Multiple --world options are accepted, in which case the worlds will be
    merged into a single world for building, testing, or bindings generation.

  • In addition to any worlds and/or WIT paths specified explicitly via CLI
    options, componentize-go will use go list to scan the current module and
    its dependencies, looking for files named componentize-go.toml in their
    source trees. For each such file found, any worlds and/or WIT paths
    referenced therein will be added to the respective lists. This behavior can
    be disabled using the --ignore-toml-files option if desired.

In combination, these options make it easier to use multiple SDKs or other
libraries which contain wit-bindgen-go-generated code.

Note that I've also removed the wat dependency because go build always
generates a binary Wasm file, so no need to check for or parse WAT.

Fixes #28

dicej added a commit to dicej/spin-go-sdk that referenced this pull request Mar 25, 2026
Per bytecodealliance/componentize-go#35, Spin
applications can now refer to WIT files by way of the
`github.com/spinframework/spin-go-sdk/v3` source package; no need for the
application to supply them itself.

That PR also allows us to pass multiple `--world` flags to `componentize-go`,
allowing us to target e.g. the `fermyon:spin/redis-trigger` _and_
`spin:up/platform` worlds at the same time (which is what Spin actually
implements for Redis triggers).

Signed-off-by: Joel Dice <joel.dice@akamai.com>
dicej added a commit to dicej/spin-go-sdk that referenced this pull request Mar 25, 2026
Per bytecodealliance/componentize-go#35, Spin
applications can now refer to WIT files by way of the
`github.com/spinframework/spin-go-sdk/v3` source package; no need for the
application to supply them itself.

That PR also allows us to pass multiple `--world` flags to `componentize-go`,
allowing us to target e.g. the `fermyon:spin/redis-trigger` _and_
`spin:up/platform` worlds at the same time (which is what Spin actually
implements for Redis triggers).

Signed-off-by: Joel Dice <joel.dice@akamai.com>
dicej added a commit to dicej/spin-go-sdk that referenced this pull request Mar 25, 2026
Per bytecodealliance/componentize-go#35, Spin
applications can now refer to WIT files by way of the
`github.com/spinframework/spin-go-sdk/v3` source package; no need for the
application to supply them itself.

That PR also allows us to pass multiple `--world` flags to `componentize-go`,
allowing us to target e.g. the `fermyon:spin/redis-trigger` _and_
`spin:up/platform` worlds at the same time (which is what Spin actually
implements for Redis triggers).

Signed-off-by: Joel Dice <joel.dice@akamai.com>
@asteurer
Copy link
Contributor

Thanks for this Joel! I'm wondering if you might be open to having componentize-go automatically scan the go.mod dependencies for a componentize-go.toml file in the root? I have an incomplete implementation here. If I'm not mistaken, doing it this way would completely eliminate the need for passing additional arguments to componentize-go.

@dicej
Copy link
Author

dicej commented Mar 26, 2026

Thanks for this Joel! I'm wondering if you might be open to having componentize-go automatically scan the go.mod dependencies for a componentize-go.toml file in the root? I have an incomplete implementation here. If I'm not mistaken, doing it this way would completely eliminate the need for passing additional arguments to componentize-go.

Yeah, I was just thinking the same thing now that I've read up more on what go list can do. Are you planning to post a PR for that branch? Happy to close this one in favor of yours.

@asteurer
Copy link
Contributor

I was planning on finishing that PR when I got back from Europe; however, if you have the bandwidth to incorporate the go.mod search feature into this PR, I won't be offended 😄

@dicej
Copy link
Author

dicej commented Mar 26, 2026

I'll give that a shot today.

@dicej
Copy link
Author

dicej commented Mar 26, 2026

@asteurer I just pushed an update. My version doesn't look at go.mod directly and instead uses go list -mod=readonly -m -f '{{.Dir}}' all, which lists the paths to the current module and any dependencies. The end result is pretty much the same, though. Let me know what you think.

This adds two new features:

- Multiple `--world` options are accepted, in which case the worlds will be
  merged into a single world for building, testing, or bindings generation.

- In addition to any worlds and/or WIT paths specified explicitly via CLI
  options, `componentize-go` will use `go list` to scan the current module and
  its dependencies, looking for files named `componentize-go.toml` in their
  source trees.  For each such file found, any worlds and/or WIT paths
  referenced therein will be added to the respective lists.  This behavior can
  be disabled using the `--ignore-toml-files` option if desired.

In combination, these options make it easier to use multiple SDKs or other
libraries which contain `wit-bindgen-go`-generated code.

Note that I've also removed the `wat` dependency because `go build` always
generates a binary Wasm file, so no need to check for or parse WAT.

Fixes bytecodealliance#28
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.

WIT management with multiple SDKs

2 participants