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

add support for building examples #915

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

databasedav
Copy link
Contributor

rebased version of #457

resolves #423

@ctron
Copy link
Collaborator

ctron commented Jan 13, 2025

Thanks for the PR! Sorry not taking a look at this earlier. I'll give it a manual try and check.

@ctron ctron enabled auto-merge January 13, 2025 10:11
@ctron ctron disabled auto-merge January 13, 2025 10:11
@ctron
Copy link
Collaborator

ctron commented Jan 13, 2025

Ok, I tried to use this in a way like:

trunk serve --example vanilla

However, it won't work. As our examples also have a configuration and have the index.html in the examples folder.

I am wondering what the use case of that PR in its current form would be?

@databasedav
Copy link
Contributor Author

However, it won't work. As our examples also have a configuration and have the index.html in the examples folder.

I am wondering what the use case of that PR in its current form would be?

the PR is quite minimal and doesn't introduce any special considerations for how examples are organized, e.g. like the examples in this repo are, with separate Cargo.tomls for each example, instead it just maintains the status quo and expects the index.html to exist in the directory where trunk is run, this lets one run trunk ... for examples compatible with the classic cargo run --example ...

for example, i released a vendored version of trunk here https://github.com/databasedav/trunk/releases/tag/v0.0.1, which i use in my ci here https://github.com/databasedav/haalka/blob/dd675822a9441f343be64cd280b8c69cb92fc44c/.github/workflows/build_and_deploy_example.yaml#L29 to run a just command here (one for webgl2, one for webgpu) https://github.com/databasedav/haalka/blob/dd675822a9441f343be64cd280b8c69cb92fc44c/.github/workflows/build_and_deploy_example.yaml#L34-L39, which generates an index.html for the example in the root of the checked out directory and then calls trunk build ... here https://github.com/databasedav/haalka/blob/dd675822a9441f343be64cd280b8c69cb92fc44c/justfile#L46-L48

the generated files are viewable (for example) here https://github.com/databasedav/haalka/tree/0b77b1686637ea77659e8a7f61c2ede34e75d263/examples/webgl2/counter and served via github pages here https://databasedav.github.io/haalka/examples/webgl2/counter/

i think having trunk serve --example vanilla work out of the box would be nice, but would be too prescriptive for how consumers should organize their examples e.g. requiring subfolders per example with the corresponding index.html in the subfolder, instead this PR just lets consumers at the very least build examples with the native cargo ... --example ... and manage the configuration with status quo trunk semantics

@ctron ctron enabled auto-merge January 13, 2025 12:14
@ctron ctron force-pushed the fix-build-examples branch from 6d948c8 to b4afb88 Compare January 13, 2025 12:51
@ctron ctron added this pull request to the merge queue Jan 13, 2025
Merged via the queue into trunk-rs:main with commit c5ead2c Jan 13, 2025
59 of 60 checks passed
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.

Can trunk serve examples?
2 participants