Skip to content

Generate example scripts from Literate .lit sources - #6

Merged
peremato merged 7 commits into
mainfrom
literate-sources
Oct 29, 2026
Merged

peremato merged 7 commits into
mainfrom
literate-sources

Conversation

@peremato

@peremato peremato commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Makes the .lit files the single source for the examples, and has the tests regenerate each script before running it, so that the scripts can't drift from their sources.

Changes

  • src/generate.jl: generates X.jl and X.ipynb from every X.lit in the repo, or only the names given as arguments (julia --project=. src/generate.jl [name ...]). It uses the same Literate options as docs/literate.jl in Geant4.jl.
  • test/runtests.jl: run_example regenerates a script from its .lit (if one exists) and then runs it. The extended examples are now enabled.
  • New .lit sources for Scintillation, UserLib, JuliaAction and WaterPhantom. The older *_lit.jl files are removed. Each script generated from a .lit matches the committed .jl.
  • Notebooks regenerated. Most of the diff is key reordering from the newer Literate version.
  • JuliaAction: julia-config.jl --ldlibs wraps paths in shell quotes. These were passed literally to the linker and caused ld: warning: search path ''…'' not found. They are now stripped, and the duplicate -rpath is dropped.
  • UserLib: UserLibrary.cpp is renamed to UserLib.cpp, the name the script compiles. UserLib.cpp now comes before the Geant4 libraries on the compile command, so the library also loads on Linux (undefined symbol: _ZTI8G4VSolid with --as-needed).
  • .gitignore: ignores the built .exe/.dylib/.so files and edepHist.png.
  • Project.toml: adds Libdl, and a [sources] entry that points Geant4 at a local checkout.

Notes for reviewers

  • The [sources] path (/Users/mato/Development/Geant4.jl) only exists on the author's machine, so CI will fail to resolve the environment while it is there.
  • Running the tests rewrites any committed .jl that is out of sync with its .lit.

🤖 Generated with Claude Code

peremato and others added 7 commits October 28, 2026 18:42
- Add src/generate.jl to produce X.jl and X.ipynb from every X.lit
- Regenerate each example's script from its .lit before running it in the tests
- Add .lit sources for Scintillation, UserLib, JuliaAction and WaterPhantom,
  and remove the older *_lit.jl sources
- Fix JuliaAction linking: strip shell quotes from julia-config.jl output
- Rename UserLibrary.cpp to UserLib.cpp to match the UserLib example
- Ignore build outputs of the CustomLib and EmbedJulia examples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Put UserLib.cpp before the Geant4 libraries on the compile command.
With --as-needed (the Ubuntu default) libraries listed before the code
that uses them are dropped, which left G4VSolid undefined at load time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peremato
peremato merged commit 1c09eb9 into main Oct 29, 2026
2 checks passed
@peremato
peremato deleted the literate-sources branch October 29, 2026 08:39
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.

1 participant