Skip to content

add compatibility with compiler option -no-indent - #359

Merged
keynmol merged 6 commits into
indoorvivants:mainfrom
jbwheatley:main
Jun 11, 2025
Merged

add compatibility with compiler option -no-indent#359
keynmol merged 6 commits into
indoorvivants:mainfrom
jbwheatley:main

Conversation

@jbwheatley

Copy link
Copy Markdown
Contributor

see #353

This PR adds support for projects that use the compiler option -no-indent. As part of the sbt plugin it checks whether the build has the -no-indent compiler option set and swap whitespace for braces accordingly.
Also adds a CLI option for generating sources with braces.

@jbwheatley

Copy link
Copy Markdown
Contributor Author

ran ci locally and latest commit seemed to fix

Comment thread modules/bindgen/src/main/scala/render/enumeration.scala Outdated
@jbwheatley

Copy link
Copy Markdown
Contributor Author

@keynmol is there an easy way to see the generated code from the tests? I've got a couple of bugs in the refactor and AFAICT it gets cleaned up after the CI run so i can't easily pinpoint the issue. A couple of the pluginTests are failing for me

@keynmol

keynmol commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

@jbwheatley You can just do ~bindgen/run --package bla --out scala --header <full path to test binding file> – that's what I usually do when developing.

Alternatively, you can see where the files are generated:

sbt:root> show testsNative3/Test/managedSources
[info] Build skipped: No changes detected in build configuration and class path contents since last build.
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_multi_file/functions.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_multi_file/unions.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_built_in_types.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test.mty.bla.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_global_enums.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_struct_passing.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_enums.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_structs.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_scala_keywords.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test_closure.scala
[info] * /Users/velvetbaldmime/projects/indoorvivants/sn-bindgen/modules/tests/target/native-3/src_managed/test/lib_test.mty.bla.multi/functions.scala

Another alternative is you can wait until I'm done with #360 which checks-in the generated bindings into the stable locations in the repo, to make it

@keynmol

keynmol commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Plugin tests are a bit wonkier, as SBT scripted tests are opaque and sandboxed.
You can still do the bindgen/run on those bindings with absolute header path to see what's up

@jbwheatley

Copy link
Copy Markdown
Contributor Author

thanks for the help, managed to fix things pretty quickly after that. I broke out some util functions as suggested, I think it definitely helps readability and uniformity :)

Comment thread modules/bindgen/src/main/scala/Config.scala Outdated
if hasUnions then l(s"export _root_.${packageName}.unions.*")
if hasAnyEnums then l(s"export _root_.${packageName}.enumerations.*")
objectBlock(l)("object types") {
nest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extra nesting is unnecessary (no need to fix, I will address myself after merging this)

@keynmol keynmol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this!
I will make a release of it when #360 is updated and merged, so that we can see the bindings generated.

@keynmol
keynmol merged commit fefbcd3 into indoorvivants:main Jun 11, 2025
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.

2 participants