mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 16:40:08 -03:00
get jnaerator from a jitpack jar
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
This commit is contained in:
parent
f53abe6bc2
commit
2825eb22e6
@ -3,6 +3,7 @@ JARS_DIR=./lib
|
|||||||
JAR=$(JARS_DIR)/enry.jar
|
JAR=$(JARS_DIR)/enry.jar
|
||||||
JNAERATOR_DIR=./.jnaerator
|
JNAERATOR_DIR=./.jnaerator
|
||||||
JNAERATOR_JAR=$(JNAERATOR_DIR)/jnaerator.jar
|
JNAERATOR_JAR=$(JNAERATOR_DIR)/jnaerator.jar
|
||||||
|
JNAERATOR_JAR_URL="https://jitpack.io/com/github/nativelibs4java/JNAerator/jnaerator/$(JNAERATOR_VERSION)/jnaerator-$(JNAERATOR_VERSION)-shaded.jar"
|
||||||
RESOURCES_SRC=../.shared
|
RESOURCES_SRC=../.shared
|
||||||
RESOURCES_DIR=./shared
|
RESOURCES_DIR=./shared
|
||||||
HEADER_FILE=$(RESOURCES_DIR)/libenry.h
|
HEADER_FILE=$(RESOURCES_DIR)/libenry.h
|
||||||
@ -25,12 +26,8 @@ $(RESOURCES_DIR): os-shared-lib
|
|||||||
cp -R $(RESOURCES_SRC) $(RESOURCES_DIR)
|
cp -R $(RESOURCES_SRC) $(RESOURCES_DIR)
|
||||||
|
|
||||||
$(JNAERATOR_JAR): $(RESOURCES_DIR)
|
$(JNAERATOR_JAR): $(RESOURCES_DIR)
|
||||||
git clone --depth 1 https://github.com/nativelibs4java/jnaerator.git $(JNAERATOR_DIR) && \
|
mkdir $(JNAERATOR_DIR) && \
|
||||||
cd $(JNAERATOR_DIR) && \
|
wget $(JNAERATOR_JAR_URL) -O $(JNAERATOR_JAR)
|
||||||
git checkout $(JNAERATOR_VERSION) && \
|
|
||||||
mvn clean install && \
|
|
||||||
mv jnaerator/target/jnaerator-*-shaded.jar ./jnaerator.jar && \
|
|
||||||
cd ..;
|
|
||||||
|
|
||||||
os-shared-lib:
|
os-shared-lib:
|
||||||
@os_name="$(shell uname -s)" && \
|
@os_name="$(shell uname -s)" && \
|
||||||
|
@ -37,11 +37,15 @@ public class Enry {
|
|||||||
* If there are more than one possible language, it returns the first
|
* If there are more than one possible language, it returns the first
|
||||||
* language in alphabetical order and safe to false.
|
* language in alphabetical order and safe to false.
|
||||||
*
|
*
|
||||||
* @param content of the file
|
* @param filename name of the file with the extension
|
||||||
|
* @param content of the file
|
||||||
* @return guessed result
|
* @return guessed result
|
||||||
*/
|
*/
|
||||||
public static Guess getLanguageByContent(byte[] content) {
|
public static Guess getLanguageByContent(String filename, byte[] content) {
|
||||||
GetLanguageByContent_return.ByValue res = nativeLib.GetLanguageByContent(toGoByteSlice(content));
|
GetLanguageByContent_return.ByValue res = nativeLib.GetLanguageByContent(
|
||||||
|
toGoString(filename),
|
||||||
|
toGoByteSlice(content)
|
||||||
|
);
|
||||||
return new Guess(toJavaString(res.r0), toJavaBool(res.r1));
|
return new Guess(toJavaString(res.r0), toJavaBool(res.r1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,14 +18,13 @@ public class EnryTest {
|
|||||||
assertEquals("PHP", Enry.getLanguage("foobar.php", code.getBytes()));
|
assertEquals("PHP", Enry.getLanguage("foobar.php", code.getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is a bug in enry, fix when it's fixed there
|
@Test
|
||||||
@Test(expected = AssertionError.class)
|
|
||||||
public void getLanguageByContent() {
|
public void getLanguageByContent() {
|
||||||
String code = "<?php $foo = bar();";
|
String code = "<?php $foo = bar();";
|
||||||
assertGuess(
|
assertGuess(
|
||||||
"PHP",
|
"PHP",
|
||||||
true,
|
true,
|
||||||
Enry.getLanguageByContent(code.getBytes())
|
Enry.getLanguageByContent("foo.php", code.getBytes())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user