-
Notifications
You must be signed in to change notification settings - Fork 6
US1107290: Build libcld2.so #201
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
Open
kusumaghoshdastidar
wants to merge
26
commits into
develop
Choose a base branch
from
US1107290-native
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9052d89
US1107290: Building libcld2.so
kusumaghoshdastidar dd027c6
Fix formatting of new feature entry in release notes
kusumaghoshdastidar 5efca53
Remove native libraries
kusumaghoshdastidar e72cb87
Build native library
kusumaghoshdastidar b1124a8
Add log
kusumaghoshdastidar 1d19465
Use native function mapper
kusumaghoshdastidar c8332a1
Use native library built locally
kusumaghoshdastidar f101d45
Update logs
kusumaghoshdastidar ff1aa27
Build new module
kusumaghoshdastidar 53c2ab7
Revert formatting
kusumaghoshdastidar 6638491
Revert formatting
kusumaghoshdastidar 7fec06b
Use c++ build environment image
kusumaghoshdastidar 9c56922
Update cld2 version to use project.version
kusumaghoshdastidar bf6c181
Update cld2 version to use project version variable
kusumaghoshdastidar 970f859
Pick the function that takes hints
kusumaghoshdastidar 4ebd16b
Remove commented code
kusumaghoshdastidar 266bcde
Remove comment
kusumaghoshdastidar acd2812
Remove comment
kusumaghoshdastidar 1c8af0b
Update plugin management
kusumaghoshdastidar 5887913
Add new line
kusumaghoshdastidar 59ae5fb
Rename function
kusumaghoshdastidar a056c30
Breaking change
kusumaghoshdastidar 3394e4f
Up the optimization
kusumaghoshdastidar 6cbf8c1
Update build image version
kusumaghoshdastidar d5b973f
Update build image version
kusumaghoshdastidar 5987d98
Add SHA256 checksum
kusumaghoshdastidar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ### Build Compact Language Detector 2 | ||
|
|
||
| Build in the `libcld2.so` from [CLD2Owners/cld2: Compact Language Detector 2](https://github.com/CLD2Owners/cld2) source code. | ||
| Download [commit]((https://github.com/CLD2Owners/cld2/commit/b56fa78a2fe44ac2851bae5bf4f4693a0644da7b)) as zip file, unpack its contents and compile the code with gcc. | ||
|
|
||
|
|
||
| ### Finding the correct mangled function name to use in `Cld2Library.java` | ||
| ``` | ||
| OTX-44M2N13:/mnt/d/Projects/github/worker-languagedetection-agg # docker container run -it --rm --network=host -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -v ~/.m2:/root/.m2 -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/wd -w /wd dev/cafapi/buildenv-cpp:8.3.0-SNAPSHOT | ||
|
|
||
| OTX-44M2N13:/wd # nm -D cld2/target/libcld2.so | grep -i "ExtDetectLanguageSummary" | ||
| 0000000000025050 T _ZN4CLD224ExtDetectLanguageSummaryEPKcibPKNS_8CLDHintsEiPNS_8LanguageEPiPdPSt6vectorINS_11ResultChunkESaISA_EES7_Pb | ||
| 0000000000024e90 T _ZN4CLD224ExtDetectLanguageSummaryEPKcibPNS_8LanguageEPiS4_Pb | ||
| 0000000000024f60 T _ZN4CLD224ExtDetectLanguageSummaryEPKcibS1_iNS_8LanguageEPS2_PiPdS4_Pb | ||
| 0000000000024f00 T _ZN4CLD224ExtDetectLanguageSummaryEPKcibS1_iNS_8LanguageEPS2_PiS4_Pb | ||
| 0000000000024fb0 T _ZN4CLD233ExtDetectLanguageSummaryCheckUTF8EPKcibPKNS_8CLDHintsEiPNS_8LanguageEPiPdPSt6vectorINS_11ResultChunkESaISA_EES7_PbS7_ | ||
|
|
||
| nm -DC cld2/target/libcld2.so | grep "CLD2::ExtDetectLanguageSummary" | ||
| 0000000000025050 T CLD2::ExtDetectLanguageSummary(char const*, int, bool, CLD2::CLDHints const*, int, CLD2::Language*, int*, double*, std::vector<CLD2::ResultChunk, std::allocator<CLD2::ResultChunk> >*, int*, bool*) | ||
| 0000000000024e90 T CLD2::ExtDetectLanguageSummary(char const*, int, bool, CLD2::Language*, int*, int*, bool*) | ||
| 0000000000024f60 T CLD2::ExtDetectLanguageSummary(char const*, int, bool, char const*, int, CLD2::Language, CLD2::Language*, int*, double*, int*, bool*) | ||
| 0000000000024f00 T CLD2::ExtDetectLanguageSummary(char const*, int, bool, char const*, int, CLD2::Language, CLD2::Language*, int*, int*, bool*) | ||
| 0000000000024fb0 T CLD2::ExtDetectLanguageSummaryCheckUTF8(char const*, int, bool, CLD2::CLDHints const*, int, CLD2::Language*, int*, double*, std::vector<CLD2::ResultChunk, std::allocator<CLD2::ResultChunk> >*, int*, bool*, int*) | ||
|
|
||
| nm -D cld2/target/libcld2.so | grep "0000000000024fb0" | ||
| 0000000000024fb0 T _ZN4CLD233ExtDetectLanguageSummaryCheckUTF8EPKcibPKNS_8CLDHintsEiPNS_8LanguageEPiPdPSt6vectorINS_11ResultChunkESaISA_EES7_PbS7_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
|
|
||
| Copyright 2015-2026 Open Text. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>cld2</artifactId> | ||
| <name>cld2</name> | ||
| <packaging>pom</packaging> | ||
|
|
||
| <parent> | ||
| <groupId>com.github.cafdataprocessing.workers.languagedetection</groupId> | ||
| <artifactId>worker-languagedetection-aggregator</artifactId> | ||
| <version>7.0.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <properties> | ||
| <cld2.commit>b56fa78a2fe44ac2851bae5bf4f4693a0644da7b</cld2.commit> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>io.github.download-maven-plugin</groupId> | ||
| <artifactId>download-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>download-cld2-source</id> | ||
| <phase>generate-sources</phase> | ||
| <goals> | ||
| <goal>wget</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <url>https://github.com/CLD2Owners/cld2/archive/${cld2.commit}.zip</url> | ||
| <unpack>true</unpack> | ||
| <outputDirectory>${project.build.directory}/external-source</outputDirectory> | ||
| <outputFileName>cld2.zip</outputFileName> | ||
| <sha256>6d8681eadbb64d8fcd3c6c620e81bed16d99ff75627324d66ee2d54bf2b7d749</sha256> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>compile-cld2-native</id> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>exec</goal> | ||
| </goals> | ||
| <configuration> | ||
| <executable>bash</executable> | ||
| <workingDirectory>${project.build.directory}/external-source/cld2-${cld2.commit}/internal</workingDirectory> | ||
| <arguments> | ||
| <argument>-c</argument> | ||
| <argument>./compile_libs.sh && mv ./libcld2.so ${project.build.directory}</argument> | ||
| </arguments> | ||
| <environmentVariables> | ||
| <CFLAGS>-O3 -Wno-narrowing</CFLAGS> | ||
| </environmentVariables> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>build-helper-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>attach-cld2-native-binary</id> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>attach-artifact</goal> | ||
| </goals> | ||
| <configuration> | ||
| <artifacts> | ||
| <artifact> | ||
| <file>${project.build.directory}/libcld2.so</file> | ||
| <type>so</type> | ||
| <classifier>native</classifier> | ||
| </artifact> | ||
| </artifacts> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...2/src/main/java/com/github/cafdataprocessing/workers/languagedetection/cld2/CLDHints.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2015-2026 Open Text. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.github.cafdataprocessing.workers.languagedetection.cld2; | ||
|
|
||
| import com.sun.jna.Structure; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| public final class CLDHints extends Structure { | ||
| public String content_language_hint; | ||
| public String tld_hint; | ||
| public int encoding_hint; | ||
| public int language_hint; | ||
|
|
||
| public CLDHints() { | ||
| super(); | ||
| } | ||
|
|
||
| @Override | ||
| protected List<String> getFieldOrder() { | ||
| return Arrays.asList("content_language_hint", "tld_hint", "encoding_hint", "language_hint"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The digest needs to be checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added sha256 checksum