Skip to content

release/v2.0.0#4

Merged
melbasiouny-riverside merged 14 commits into
microhammerfrom
feature/language-bindings
Apr 6, 2026
Merged

release/v2.0.0#4
melbasiouny-riverside merged 14 commits into
microhammerfrom
feature/language-bindings

Conversation

@Lurk390
Copy link
Copy Markdown
Collaborator

@Lurk390 Lurk390 commented Mar 27, 2026

  • Reintroduce Python, Java/JNI, and C++ language bindings via SWIG and a header-only wrapper
  • Fix SCons warnings when building Python bindings
  • Fix outdated upstandinghackers package references, renaming to riversideresearch
  • Add bindings=all support to build and test all language bindings together
  • Add scons bindings=all test step to the CI pipeline
  • Refactor scons test output with labeled sections per language and a final summary table of pass/fail counts

@Lurk390 Lurk390 added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 27, 2026
@Lurk390 Lurk390 removed their assignment Mar 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reintroduces and wires up multi-language bindings (Python via SWIG, Java/JNI via SWIG, and a header-only C++ wrapper), and updates the SCons/CI test flow to run binding tests with per-language output sections and a final summary.

Changes:

  • Add SWIG-based Python and Java/JNI bindings plus a header-only C++ wrapper, each with basic smoke tests and SCons build/test targets.
  • Introduce a tools/test_reporter.py wrapper to label streamed test output and record pass/fail counts for a final summary.
  • Update SCons/CI/docs to support building/testing bindings alongside core tests and to modernize org/package naming (upstandinghackersriversideresearch).

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tools/test_reporter.py Runs tests with labeled headers and writes pass/fail counts to a results file.
tests/t_misc.c Updates test token-type namespace strings to com.riversideresearch....
src/t_misc.c Same namespace update in source-side test.
src/bindings/swig/hammer.i New unified SWIG interface with Python typemaps and Java/JNI typemaps/extends.
src/bindings/python/setup.py Setuptools/SWIG build script for Python extension module.
src/bindings/python/hammer_tests.py Python unittest smoke tests for the Python bindings.
src/bindings/python/SConscript SCons build/test/install wiring for Python bindings.
src/bindings/python/README.md Python binding build/test/usage documentation.
src/bindings/java/SConscript SCons build/test/install wiring for Java/JNI bindings and jar packaging.
src/bindings/java/README.md Java binding build/test/usage documentation.
src/bindings/java/HammerTests.java Java smoke tests emitting Results: X passed, Y failed.
src/bindings/cpp/hammer/hammer_test.hpp C++ gtest assertion helpers for parsing.
src/bindings/cpp/hammer/hammer.hpp Header-only C++ wrapper API around the C library.
src/bindings/cpp/cpp_tests.cpp C++ gtest smoke tests for the wrapper.
src/bindings/cpp/SConscript SCons build/test/install wiring for C++ wrapper and tests.
src/bindings/cpp/README.md C++ binding build/test/usage documentation.
src/SConscript Integrates binding test execution/results reporting into scons test.
ruff.toml Excludes build/ from Ruff linting.
SConstruct Adds bindings option, exports binding result lists, and prints summary table after tests.
README.md Documents newly supported language bindings and updates formatting/links.
DEVELOPMENT.md Adds instructions for building/testing bindings and improves command formatting.
.github/workflows/pipeline.yml Adds dependency installs and a CI step to run binding tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bindings/swig/hammer.i Outdated
Comment thread src/t_misc.c Outdated
Comment thread src/bindings/java/SConscript Outdated
Comment on lines +57 to +58
pyinstallexec = pythonenv.Command(
None, libhammer_python, "%s %s install" % (env["python"], pysetup)
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

installpython runs setup.py install, which typically ignores SCons’ prefix/DESTDIR settings and installs directly into the interpreter’s site-packages (often requiring root). This is inconsistent with the rest of the build’s install semantics and complicates packaging. Consider installing into $prefix/$DESTDIR via pip install --prefix .../--root ..., or using env.Install() to place artifacts under the SCons-controlled install tree.

Suggested change
pyinstallexec = pythonenv.Command(
None, libhammer_python, "%s %s install" % (env["python"], pysetup)
destdir = env.get("DESTDIR", "")
prefix = env.get("prefix", sys.prefix)
install_cmd_parts = [env["python"], "-m", "pip", "install", "--no-deps"]
if destdir:
install_cmd_parts.extend(["--root", destdir])
if prefix:
install_cmd_parts.extend(["--prefix", prefix])
install_cmd_parts.append(pydir)
install_cmd = " ".join(install_cmd_parts)
pyinstallexec = pythonenv.Command(
None,
libhammer_python,
install_cmd,

Copilot uses AI. Check for mistakes.
Comment thread src/bindings/cpp/README.md Outdated
Comment thread src/bindings/cpp/hammer/hammer.hpp
Comment thread SConstruct
Comment thread src/SConscript
Export("libhammer_static")
Export("libhammer_static libhammer_shared")

for b in env.get("bindings", []):
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

env.get('bindings', []) will include the default ['none'] from the ListVariable, so this loop will attempt to load src/bindings/none/SConscript and fail. After normalizing the bindings option in SConstruct, this loop should only iterate real binding names (or be guarded to skip none).

Suggested change
for b in env.get("bindings", []):
for b in env.get("bindings", []):
if b == "none":
continue

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/pipeline.yml
Comment thread tests/t_misc.c Outdated
Comment thread src/bindings/cpp/hammer/hammer.hpp
Parser p = Uint8();
EXPECT_TRUE(ParsesTo(p, "\x78", "u0x78"));
EXPECT_TRUE(ParseFails(p, ""));
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All of these tests above are testing the same failure case for too short of a length passed in, should we add other value type tests with failure cases for taking too much input?

Comment thread src/bindings/cpp/cpp_tests.cpp Outdated
EXPECT_TRUE(ParseFails(p, " ab"));
}

#include <ctype.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Put this at the top

Comment thread src/bindings/cpp/README.md
Import("env libhammer_shared testruns targets binding_results binding_test_stamps")

if libhammer_shared is None:
print("Warning: C++ bindings require the shared library (not available in coverage/gprof builds). Skipping.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this imply that you need to build with tests to get the C++ bindings? Could we allow c++ bindings without needing test packages?

Comment thread src/bindings/java/HammerTests.java Outdated
import com.riversideresearch.hammer.*;

/**
* Basic smoke tests for the Hammer Java bindings, mirroring hammer_tests.py.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can this get reworded to be more specific?

Comment thread src/bindings/java/HammerTests.java
Comment thread src/bindings/java/README.md Outdated
Or run the full test suite including all language bindings:

```bash
scons bindings=python,java test
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would appear to lose CPP bindings?

Comment thread src/bindings/java/README.md
```bash
scons bindings=python
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we investigate how this interacts with python VENVs

Comment thread src/bindings/python/README.md
Comment thread src/bindings/swig/hammer.i Outdated
}
%typemap(out) struct HParseResult_* {
if ($1 == NULL) {
// TODO: raise parse failure
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should cleanup inline TODOs and bring them to readme or fix them

Comment thread README.md
Copy link
Copy Markdown
Collaborator

@GJames-RiversideResearch GJames-RiversideResearch left a comment

Choose a reason for hiding this comment

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

Generally looks good, I would just like to see more consistent combinator reachability across different bindings, the addition of h_put_value, h_get_value, and h_free_value, and some other minor cleanups

@melbasiouny-riverside melbasiouny-riverside removed their request for review April 1, 2026 01:39
@melbasiouny-riverside melbasiouny-riverside merged commit 83143ac into microhammer Apr 6, 2026
3 checks passed
@melbasiouny-riverside melbasiouny-riverside deleted the feature/language-bindings branch April 6, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants