Skip to content

Generate the SWIG wrappers again for 51degrees-cxx 4.5.101 - #22

Draft
jwrosewell wants to merge 4 commits into
mainfrom
feature/cxx-4.5.101
Draft

jwrosewell wants to merge 4 commits into
mainfrom
feature/cxx-4.5.101

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The 4.5.101 release of 51degrees-cxx, which is not merged or tagged yet, removes the C++ process overloads that take required property indexes. At 4e023aaa the engines keep only these overloads.

  • src/dd/hash/EngineHash.hpp line 161 process(EvidenceDeviceDetection *evidence) and line 166 process(const char *userAgent)
  • src/ipi/EngineIpi.hpp line 177 process(EvidenceIpi *evidence), line 189 process(const char *ipAddress) and the byte address form at line 207

The wrappers on main were generated from 4.5.100 (4110d681) in fe9d0cbd. They still call the removed overloads, so the native libraries will not compile once cxx moves to 4.5.101.

The Java proxies declare them too, in EngineHashSwig.java lines 97 and 102 and EngineIpiSwig.java lines 102, 107 and 112, with their JNI module classes.

What was checked

  • The Java engines do not call the removed overloads. DeviceDetectionHashEngine.java line 327 and IPIntelligenceOnPremiseEngine.java line 317 call engine.process(relevantEvidence), and DeviceDataHashDefault.java and IPIntelligenceDataHashDefault.java read values by property name. GitHub code search finds SWIGTYPE_p_int and requiredPropertyIndexes only in generated files.
  • Between 4110d681 and 4e023aaa four SWIG interfaces change. They are src/dd/hash/ConfigHash.i, src/dd/hash/EngineHash.i, src/ipi/EngineIpi.i and src/ipi/ResultsIpi.i, and the last of them only gains comments. No interface in cxx includes a C or C++ header for SWIG to parse, so header changes alter the generated wrappers only through these four files.
  • SWIG 4.5.1 was built on ubuntu-latest from the tag v4.5.1, commit 88649f559942c29a228fa783dd01581e217bcb20. With cxx at 4110d681 the commands below, writing to a separate folder, give all 89 committed Java files byte for byte.
  • The two C++ files differ only in comments of the form /*@SWIG:<path>,28,JAVA_UBYTE_ARR_TYPEMAP_BODY@*/, where SWIG records the path it read JavaTypes.i from. There are 4 such lines in Java_Hash_Engine.cpp and 8 in Java_Ipi_Engine.cpp. With that path replaced, both files are byte for byte the same as the committed ones.
  • The committed files give that path as ../../../../..\cxx\src\common\JavaTypes.i. The backslashes are the separator a Windows build of SWIG uses (swigfile.h lines 37 to 41), and the prefix is the include flag -I../../../../... SWIG opens an included file relative to the current folder first and only then tries the include folders (include.c lines 173 to 180), so the recorded path also depends on the folder SWIG runs in. Nothing points to a different SWIG version, different flags or an interface edited by hand.
  • Every file in the two interop/swig folders carries SWIG's generated header and is one the generation makes, so removing them before generating again removes nothing written by hand.

What changed

cxx moves from 4110d681 (4.5.100) to 4e023aaa, the head of the release/4.5.101 branch of 51degrees-cxx, and both wrappers are generated again in 0aae3377. The generated .java files and the two .cpp files were removed first, as RegenSwig.ps1 does. These are the commands, where <root> is the repository root.

# Device Detection, the RebuildSwig command at line 80 of its CMakeLists.txt,
# with FIFTYONE_ROOT and SRCOUT as lines 61 and 66 set them. Run from <root>.
swig -c++ -java -I<root> -package fiftyone.devicedetection.hash.engine.onpremise.interop.swig -outdir <root>/device-detection/device-detection.hash.engine.on-premise/src/main/cxx/../java/fiftyone/devicedetection/hash/engine/onpremise/interop/swig -o <root>/device-detection/device-detection.hash.engine.on-premise/src/main/cxx/Java_Hash_Engine.cpp <root>/device-detection/device-detection.hash.engine.on-premise/src/main/cxx/hash_java.i

# IP Intelligence, the command in RegenSwig.ps1.
# Run from ip-intelligence/ip-intelligence.engine.on-premise/src/main/cxx.
swig -c++ -java "-I../../../../.." -package fiftyone.ipintelligence.engine.onpremise.interop.swig -module IpIntelligenceOnPremiseEngineModule -outdir ../java/fiftyone/ipintelligence/engine/onpremise/interop/swig -o Java_Ipi_Engine.cpp hash_java.i

The Device Detection command runs from the repository root, so SWIG finds JavaTypes.i by its relative path and writes no path from the machine into those comments.

Device Detection

  • Removed EngineHashSwig.process(EvidenceDeviceDetectionSwig, SWIGTYPE_p_int, int) and process(String, SWIGTYPE_p_int, int), their natives EngineHashSwig_process__SWIG_2 and EngineHashSwig_process__SWIG_3, and their C++ functions.
  • Removed SWIGTYPE_p_int.java, which nothing else uses.
  • Added EngineHashSwig.getProfileIdsForPropertyValue(String propertyName, String valueName), which returns the new VectorUInt32Swig, a wrapper for std::vector<uint32_t>.
  • Added setPropertyValueIndex(boolean), getPropertyValueIndex(), setIndexedProperties(VectorStringSwig) and getIndexedProperties() to ConfigHashSwig.

IP Intelligence

  • Removed EngineIpiSwig.process(EvidenceIpiSwig, SWIGTYPE_p_int, int), process(String, SWIGTYPE_p_int, int) and process(byte[], IpTypeSwig, SWIGTYPE_p_int, int), their natives EngineIpiSwig_process__SWIG_3 to EngineIpiSwig_process__SWIG_5, and their C++ functions.
  • Removed SWIGTYPE_p_int.java.
  • Nothing is added, because the change to ResultsIpi.i is comments only.

Both C++ files

  • The /*@SWIG:...@*/ comments now give cxx/src/common/JavaTypes.i for Device Detection and ../../../../../cxx/src/common/JavaTypes.i for IP Intelligence, for the reason above. They are comments, so nothing that is compiled changes.

How it was verified

  • The generation run built SWIG, compared its output at 4110d681 with the committed files, generated the wrappers at 4e023aaa and pushed 0aae337. Its swig-wrappers artifact holds both sets of output and the diffs. An earlier run found the comment difference and stopped without committing. The temporary workflow that did this was removed again in 55a4b3a1, so the branch changes only cxx and the wrappers.
  • The full build and test run passed. It calls common-ci's nightly-pull-request.yml with dryrun: 'true', so nothing is merged. Its Configure job set PullRequestSha to 55a4b3a, the head of this pull request, with cxx at 4e023aaa.
  • All 15 Build and Test jobs passed and each compiled both wrappers. They cover Ubuntu with Java 8, 11, 17 and 21, Ubuntu ARM with Java 17, Windows with Java 8, 11, 17 and 21, macOS arm64 with Java 11, 17 and 21, and macOS x64 with Java 11, 17 and 21. The Complete job printed "Dry run - not merging", and Compare Performance was skipped.
  • In every configuration the test classes, and their counts of tests run, failures, errors and skipped tests, are the same as in the build of main at 3df49028, which used cxx at 4.5.100.

What remains

  1. Point cxx at the 4.5.101 tag once it is published. If the release changes before it merges, generate the wrappers again with the commands above.
  2. Build again. The tmp/pr-matrix-22 branch holds the workflow that started the build above, and changing its name: line starts a new run.
  3. A person reviews this and marks it ready.

The workflow builds SWIG 4.5.1 from its tag, checks that it gives the
committed wrappers with cxx at 4110d681, then generates them with cxx
at 4e023aaa and commits them. It is removed again before the pull
request is opened.
With cxx at 4110d681 the Java files come out byte for byte the same as
the committed ones, and the two C++ files differ only in the comments
where SWIG records the path it read JavaTypes.i from. The committed
files give that path with Windows separators. The workflow now checks
that those comments are the only difference before it commits.
51degrees-cxx 4.5.101 removes the process overloads of EngineHash and
EngineIpi that take required property indexes. The committed wrappers
still call them, so the native libraries would not compile once cxx
moves to that release.

This moves cxx to 4e023aaa5c1f5ec56d475c75a91761d8ef55dc20, the head of
the 4.5.101 release pull request in 51degrees-cxx, and generates both
wrappers again from its interfaces with SWIG 4.5.1 built on Linux.
Device Detection uses the RebuildSwig command in its CMakeLists.txt, run
from the repository root, and IP Intelligence uses the command in its
RegenSwig.ps1, run from its cxx folder.

With cxx at 4110d6813e167a803a06489318b33b83a230fa32 the same commands
give the committed Java files byte for byte. The two C++ files differ
only in the comments where SWIG records the path it read JavaTypes.i
from. The committed files were generated by a Windows build of SWIG
with the include flag -I../../../../.., which gives that path as
../../../../..\cxx\src\common\JavaTypes.i, so those comments change
here as well.
@ben51degrees

Copy link
Copy Markdown
Contributor

@jwrosewell I've left this in draft, so it won't be included in todays release. Please mark as ready if there are no more changes, and I'll rerun the pipeline to publish

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