mirror of
https://github.com/google/brotli.git
synced 2024-11-21 19:20:09 +00:00
Improve Bazel/JNI portability (#611)
* Improve Bazel/JNI portability * Update go and closure bazel addons
This commit is contained in:
parent
4f8cd4c0f4
commit
42d78807bb
28
BUILD
28
BUILD
@ -147,46 +147,42 @@ cc_binary(
|
|||||||
########################################################
|
########################################################
|
||||||
# WARNING: do not (transitively) depend on this target!
|
# WARNING: do not (transitively) depend on this target!
|
||||||
########################################################
|
########################################################
|
||||||
cc_library(
|
cc_binary(
|
||||||
name = "jni",
|
name = "brotli_jni.dll",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
":common_headers",
|
||||||
":common_sources",
|
":common_sources",
|
||||||
|
":dec_headers",
|
||||||
":dec_sources",
|
":dec_sources",
|
||||||
|
":enc_headers",
|
||||||
":enc_sources",
|
":enc_sources",
|
||||||
"//java/org/brotli/wrapper/common:jni_src",
|
"//java/org/brotli/wrapper/common:jni_src",
|
||||||
"//java/org/brotli/wrapper/dec:jni_src",
|
"//java/org/brotli/wrapper/dec:jni_src",
|
||||||
"//java/org/brotli/wrapper/enc:jni_src",
|
"//java/org/brotli/wrapper/enc:jni_src",
|
||||||
],
|
],
|
||||||
hdrs = [
|
|
||||||
":common_headers",
|
|
||||||
":dec_headers",
|
|
||||||
":enc_headers",
|
|
||||||
],
|
|
||||||
deps = [
|
deps = [
|
||||||
":brotli_inc",
|
":brotli_inc",
|
||||||
":jni_inc",
|
":jni_inc",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
linkshared = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
# WARNING: do not (transitively) depend on this target!
|
# WARNING: do not (transitively) depend on this target!
|
||||||
########################################################
|
########################################################
|
||||||
cc_library(
|
cc_binary(
|
||||||
name = "jni_no_dictionary_data",
|
name = "brotli_jni_no_dictionary_data.dll",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
":common_headers",
|
||||||
":common_sources",
|
":common_sources",
|
||||||
|
":dec_headers",
|
||||||
":dec_sources",
|
":dec_sources",
|
||||||
|
":enc_headers",
|
||||||
":enc_sources",
|
":enc_sources",
|
||||||
"//java/org/brotli/wrapper/common:jni_src",
|
"//java/org/brotli/wrapper/common:jni_src",
|
||||||
"//java/org/brotli/wrapper/dec:jni_src",
|
"//java/org/brotli/wrapper/dec:jni_src",
|
||||||
"//java/org/brotli/wrapper/enc:jni_src",
|
"//java/org/brotli/wrapper/enc:jni_src",
|
||||||
],
|
],
|
||||||
hdrs = [
|
|
||||||
":common_headers",
|
|
||||||
":dec_headers",
|
|
||||||
":enc_headers",
|
|
||||||
],
|
|
||||||
defines = [
|
defines = [
|
||||||
"BROTLI_EXTERNAL_DICTIONARY_DATA=",
|
"BROTLI_EXTERNAL_DICTIONARY_DATA=",
|
||||||
],
|
],
|
||||||
@ -194,7 +190,7 @@ cc_library(
|
|||||||
":brotli_inc",
|
":brotli_inc",
|
||||||
":jni_inc",
|
":jni_inc",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
linkshared = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
11
WORKSPACE
11
WORKSPACE
@ -11,14 +11,17 @@ maven_jar(
|
|||||||
git_repository(
|
git_repository(
|
||||||
name = "io_bazel_rules_go",
|
name = "io_bazel_rules_go",
|
||||||
remote = "https://github.com/bazelbuild/rules_go.git",
|
remote = "https://github.com/bazelbuild/rules_go.git",
|
||||||
tag = "0.4.4",
|
tag = "0.5.5",
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "io_bazel_rules_closure",
|
name = "io_bazel_rules_closure",
|
||||||
strip_prefix = "rules_closure-0.4.1",
|
strip_prefix = "rules_closure-0.4.2",
|
||||||
sha256 = "ba5e2e10cdc4027702f96e9bdc536c6595decafa94847d08ae28c6cb48225124",
|
sha256 = "25f5399f18d8bf9ce435f85c6bbf671ec4820bc4396b3022cc5dc4bc66303609",
|
||||||
url = "http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.4.1.tar.gz",
|
urls = [
|
||||||
|
"http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.4.2.tar.gz",
|
||||||
|
"https://github.com/bazelbuild/rules_closure/archive/0.4.2.tar.gz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
new_http_archive(
|
new_http_archive(
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Description:
|
# Description:
|
||||||
# Integration test runner + corpus for Java port of Brotli decoder.
|
# Integration test runner + corpus for Java port of Brotli decoder.
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = "brotli_jni_test_base",
|
||||||
|
srcs = ["BrotliJniTestBase.java"],
|
||||||
|
visibility = [
|
||||||
|
"//java/org/brotli/wrapper/common:__pkg__",
|
||||||
|
"//java/org/brotli/wrapper/dec:__pkg__",
|
||||||
|
"//java/org/brotli/wrapper/enc:__pkg__",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "bundle_helper",
|
name = "bundle_helper",
|
||||||
srcs = ["BundleHelper.java"],
|
srcs = ["BundleHelper.java"],
|
||||||
|
13
java/org/brotli/integration/BrotliJniTestBase.java
Executable file
13
java/org/brotli/integration/BrotliJniTestBase.java
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
package org.brotli.integration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionally loads brotli JNI wrapper native library.
|
||||||
|
*/
|
||||||
|
public class BrotliJniTestBase {
|
||||||
|
static {
|
||||||
|
String jniLibrary = System.getProperty("BROTLI_JNI_LIBRARY");
|
||||||
|
if (jniLibrary != null) {
|
||||||
|
System.load(new java.io.File(jniLibrary).getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,37 +7,32 @@ filegroup(
|
|||||||
srcs = ["common_jni.cc"],
|
srcs = ["common_jni.cc"],
|
||||||
)
|
)
|
||||||
|
|
||||||
#########################################
|
filegroup(
|
||||||
# WARNING: do not depend on this target!
|
name = "brotli_jni_no_dictionary_data",
|
||||||
#########################################
|
srcs = ["//:brotli_jni_no_dictionary_data.dll"],
|
||||||
java_library(
|
|
||||||
name = "common_no_dictionary_data",
|
|
||||||
srcs = glob(
|
|
||||||
["*.java"],
|
|
||||||
exclude = ["*Test*.java"],
|
|
||||||
),
|
|
||||||
deps = ["//:jni_no_dictionary_data"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#########################################
|
|
||||||
# WARNING: do not depend on this target!
|
|
||||||
#########################################
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "common",
|
name = "common",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
["*.java"],
|
["*.java"],
|
||||||
exclude = ["*Test*.java"],
|
exclude = ["*Test*.java"],
|
||||||
),
|
),
|
||||||
deps = ["//:jni"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
java_test(
|
java_test(
|
||||||
name = "SetZeroDictionaryTest",
|
name = "SetZeroDictionaryTest",
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["SetZeroDictionaryTest.java"],
|
srcs = ["SetZeroDictionaryTest.java"],
|
||||||
data = ["//:jni_no_dictionary_data"], # Bazel JNI workaround
|
data = [
|
||||||
|
":brotli_jni_no_dictionary_data", # Bazel JNI workaround
|
||||||
|
],
|
||||||
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":common_no_dictionary_data",
|
":common",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/wrapper/dec",
|
"//java/org/brotli/wrapper/dec",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
],
|
],
|
||||||
@ -54,11 +49,15 @@ java_test(
|
|||||||
srcs = ["SetRfcDictionaryTest.java"],
|
srcs = ["SetRfcDictionaryTest.java"],
|
||||||
data = [
|
data = [
|
||||||
":rfc_dictionary",
|
":rfc_dictionary",
|
||||||
"//:jni_no_dictionary_data", # Bazel JNI workaround
|
":brotli_jni_no_dictionary_data", # Bazel JNI workaround
|
||||||
|
],
|
||||||
|
jvm_flags = [
|
||||||
|
"-DRFC_DICTIONARY=$(location :rfc_dictionary)",
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DRFC_DICTIONARY=$(location :rfc_dictionary)"],
|
|
||||||
deps = [
|
deps = [
|
||||||
":common_no_dictionary_data",
|
":common",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/wrapper/dec",
|
"//java/org/brotli/wrapper/dec",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
],
|
],
|
||||||
|
@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.wrapper.dec.BrotliInputStream;
|
import org.brotli.wrapper.dec.BrotliInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -25,13 +26,7 @@ import org.junit.runners.JUnit4;
|
|||||||
* Tests for {@link BrotliCommon}.
|
* Tests for {@link BrotliCommon}.
|
||||||
*/
|
*/
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class SetRfcDictionaryTest {
|
public class SetRfcDictionaryTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni_Uno_Udictionary_Udata.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRfcDictionaryChecksums() throws IOException, NoSuchAlgorithmException {
|
public void testRfcDictionaryChecksums() throws IOException, NoSuchAlgorithmException {
|
||||||
|
@ -9,6 +9,7 @@ package org.brotli.wrapper.common;
|
|||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.wrapper.dec.BrotliInputStream;
|
import org.brotli.wrapper.dec.BrotliInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -20,13 +21,7 @@ import org.junit.runners.JUnit4;
|
|||||||
* Tests for {@link BrotliCommon}.
|
* Tests for {@link BrotliCommon}.
|
||||||
*/
|
*/
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class SetZeroDictionaryTest {
|
public class SetZeroDictionaryTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni_Uno_Udictionary_Udata.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZeroDictionary() throws IOException {
|
public void testZeroDictionary() throws IOException {
|
||||||
|
@ -7,16 +7,17 @@ filegroup(
|
|||||||
srcs = ["decoder_jni.cc"],
|
srcs = ["decoder_jni.cc"],
|
||||||
)
|
)
|
||||||
|
|
||||||
#########################################
|
|
||||||
# WARNING: do not depend on this target!
|
|
||||||
#########################################
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "dec",
|
name = "dec",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
["*.java"],
|
["*.java"],
|
||||||
exclude = ["*Test*.java"],
|
exclude = ["*Test*.java"],
|
||||||
),
|
),
|
||||||
deps = ["//:jni"],
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "brotli_jni",
|
||||||
|
srcs = ["//:brotli_jni.dll"],
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
@ -29,12 +30,16 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["BrotliDecoderChannelTest.java"],
|
srcs = ["BrotliDecoderChannelTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":dec",
|
":dec",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
],
|
],
|
||||||
@ -45,12 +50,16 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["BrotliInputStreamTest.java"],
|
srcs = ["BrotliInputStreamTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":dec",
|
":dec",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
],
|
],
|
||||||
@ -61,12 +70,16 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["DecoderTest.java"],
|
srcs = ["DecoderTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":dec",
|
":dec",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
],
|
],
|
||||||
|
@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -23,13 +24,7 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.dec.BrotliDecoderChannel}. */
|
/** Tests for {@link org.brotli.wrapper.dec.BrotliDecoderChannel}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class BrotliDecoderChannelTest {
|
public class BrotliDecoderChannelTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
||||||
|
@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -21,13 +22,7 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.dec.BrotliInputStream}. */
|
/** Tests for {@link org.brotli.wrapper.dec.BrotliInputStream}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class BrotliInputStreamTest {
|
public class BrotliInputStreamTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
||||||
|
@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -21,13 +22,7 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.dec.Decoder}. */
|
/** Tests for {@link org.brotli.wrapper.dec.Decoder}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class DecoderTest {
|
public class DecoderTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
||||||
|
@ -7,16 +7,17 @@ filegroup(
|
|||||||
srcs = ["encoder_jni.cc"],
|
srcs = ["encoder_jni.cc"],
|
||||||
)
|
)
|
||||||
|
|
||||||
#########################################
|
filegroup(
|
||||||
# WARNING: do not depend on this target!
|
name = "brotli_jni",
|
||||||
#########################################
|
srcs = ["//:brotli_jni.dll"],
|
||||||
|
)
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "enc",
|
name = "enc",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
["*.java"],
|
["*.java"],
|
||||||
exclude = ["*Test*.java"],
|
exclude = ["*Test*.java"],
|
||||||
),
|
),
|
||||||
deps = ["//:jni"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
@ -29,13 +30,17 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["BrotliEncoderChannelTest.java"],
|
srcs = ["BrotliEncoderChannelTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
shard_count = 15,
|
shard_count = 15,
|
||||||
deps = [
|
deps = [
|
||||||
":enc",
|
":enc",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"//java/org/brotli/wrapper/dec",
|
"//java/org/brotli/wrapper/dec",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
@ -47,13 +52,17 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["BrotliOutputStreamTest.java"],
|
srcs = ["BrotliOutputStreamTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
shard_count = 15,
|
shard_count = 15,
|
||||||
deps = [
|
deps = [
|
||||||
":enc",
|
":enc",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"//java/org/brotli/wrapper/dec",
|
"//java/org/brotli/wrapper/dec",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
@ -65,13 +74,17 @@ java_test(
|
|||||||
size = "large",
|
size = "large",
|
||||||
srcs = ["EncoderTest.java"],
|
srcs = ["EncoderTest.java"],
|
||||||
data = [
|
data = [
|
||||||
|
":brotli_jni", # Bazel JNI workaround
|
||||||
":test_bundle",
|
":test_bundle",
|
||||||
"//:jni", # Bazel JNI workaround
|
|
||||||
],
|
],
|
||||||
jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
|
jvm_flags = [
|
||||||
|
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
|
||||||
|
"-DTEST_BUNDLE=$(location :test_bundle)",
|
||||||
|
],
|
||||||
shard_count = 15,
|
shard_count = 15,
|
||||||
deps = [
|
deps = [
|
||||||
":enc",
|
":enc",
|
||||||
|
"//java/org/brotli/integration:brotli_jni_test_base",
|
||||||
"//java/org/brotli/integration:bundle_helper",
|
"//java/org/brotli/integration:bundle_helper",
|
||||||
"//java/org/brotli/wrapper/dec",
|
"//java/org/brotli/wrapper/dec",
|
||||||
"@junit_junit//jar",
|
"@junit_junit//jar",
|
||||||
|
@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import org.brotli.wrapper.dec.BrotliInputStream;
|
import org.brotli.wrapper.dec.BrotliInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -20,19 +21,13 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.enc.BrotliEncoderChannel}. */
|
/** Tests for {@link org.brotli.wrapper.enc.BrotliEncoderChannel}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class BrotliEncoderChannelTest {
|
public class BrotliEncoderChannelTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
private enum TestMode {
|
private enum TestMode {
|
||||||
WRITE_ALL,
|
WRITE_ALL,
|
||||||
WRITE_CHUNKS
|
WRITE_CHUNKS
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int CHUNK_SIZE = 256;
|
private static final int CHUNK_SIZE = 256;
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
|
@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import org.brotli.wrapper.dec.BrotliInputStream;
|
import org.brotli.wrapper.dec.BrotliInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -18,7 +19,7 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.enc.BrotliOutputStream}. */
|
/** Tests for {@link org.brotli.wrapper.enc.BrotliOutputStream}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class BrotliOutputStreamTest {
|
public class BrotliOutputStreamTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
private enum TestMode {
|
private enum TestMode {
|
||||||
WRITE_ALL,
|
WRITE_ALL,
|
||||||
@ -26,12 +27,6 @@ public class BrotliOutputStreamTest {
|
|||||||
WRITE_BYTE
|
WRITE_BYTE
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int CHUNK_SIZE = 256;
|
private static final int CHUNK_SIZE = 256;
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
|
@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.brotli.integration.BrotliJniTestBase;
|
||||||
import org.brotli.integration.BundleHelper;
|
import org.brotli.integration.BundleHelper;
|
||||||
import org.brotli.wrapper.dec.BrotliInputStream;
|
import org.brotli.wrapper.dec.BrotliInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -16,14 +17,7 @@ import org.junit.runners.AllTests;
|
|||||||
|
|
||||||
/** Tests for {@link org.brotli.wrapper.enc.Encoder}. */
|
/** Tests for {@link org.brotli.wrapper.enc.Encoder}. */
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
public class EncoderTest {
|
public class EncoderTest extends BrotliJniTestBase {
|
||||||
|
|
||||||
// TODO: remove when Bazel get JNI support.
|
|
||||||
static {
|
|
||||||
System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
|
|
||||||
"liblibjni.so").getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
static InputStream getBundle() throws IOException {
|
static InputStream getBundle() throws IOException {
|
||||||
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
|
||||||
}
|
}
|
||||||
|
14
js/BUILD
14
js/BUILD
@ -10,16 +10,21 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
|
|||||||
closure_js_library(
|
closure_js_library(
|
||||||
name = "polyfill",
|
name = "polyfill",
|
||||||
srcs = ["polyfill.js"],
|
srcs = ["polyfill.js"],
|
||||||
language = "ECMASCRIPT6_STRICT",
|
suppress = [
|
||||||
suppress = ["JSC_MISSING_JSDOC"],
|
"JSC_MISSING_JSDOC",
|
||||||
|
"JSC_TYPE_MISMATCH",
|
||||||
|
"JSC_UNKNOWN_EXPR_TYPE",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Do NOT use this artifact; it is for test purposes only.
|
# Do NOT use this artifact; it is for test purposes only.
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
name = "decode",
|
name = "decode",
|
||||||
srcs = ["decode.js"],
|
srcs = ["decode.js"],
|
||||||
language = "ECMASCRIPT6_STRICT",
|
suppress = [
|
||||||
suppress = ["JSC_USELESS_BLOCK"],
|
"JSC_DUP_VAR_DECLARATION",
|
||||||
|
"JSC_USELESS_BLOCK",
|
||||||
|
],
|
||||||
deps = [":polyfill"],
|
deps = [":polyfill"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,7 +33,6 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_test")
|
|||||||
closure_js_test(
|
closure_js_test(
|
||||||
name = "all_tests",
|
name = "all_tests",
|
||||||
srcs = ["decode_test.js"],
|
srcs = ["decode_test.js"],
|
||||||
language = "ECMASCRIPT6_STRICT",
|
|
||||||
deps = [
|
deps = [
|
||||||
":decode",
|
":decode",
|
||||||
":polyfill",
|
":polyfill",
|
||||||
|
65
js/decode.js
65
js/decode.js
@ -4,8 +4,8 @@
|
|||||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @export */
|
/** @return {function(!Int8Array):!Int8Array} */
|
||||||
var BrotliDecode = (function() {
|
function BrotliDecodeClosure() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/** @type {!Int8Array} */
|
/** @type {!Int8Array} */
|
||||||
@ -61,7 +61,7 @@ var BrotliDecode = (function() {
|
|||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @param {!InputStream} input
|
* @param {!InputStream} input
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function initState(s, input) {
|
function initState(s, input) {
|
||||||
if (s.runningState != 0) {
|
if (s.runningState != 0) {
|
||||||
@ -80,7 +80,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function close(s) {
|
function close(s) {
|
||||||
if (s.runningState == 0) {
|
if (s.runningState == 0) {
|
||||||
@ -116,7 +116,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function decodeMetaBlockLength(s) {
|
function decodeMetaBlockLength(s) {
|
||||||
if (s.bitOffset >= 16) {
|
if (s.bitOffset >= 16) {
|
||||||
@ -226,7 +226,7 @@ var BrotliDecode = (function() {
|
|||||||
/**
|
/**
|
||||||
* @param {!Int32Array} v
|
* @param {!Int32Array} v
|
||||||
* @param {!number} index
|
* @param {!number} index
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function moveToFront(v, index) {
|
function moveToFront(v, index) {
|
||||||
var /** !number */ value = v[index];
|
var /** !number */ value = v[index];
|
||||||
@ -238,7 +238,7 @@ var BrotliDecode = (function() {
|
|||||||
/**
|
/**
|
||||||
* @param {!Int8Array} v
|
* @param {!Int8Array} v
|
||||||
* @param {!number} vLen
|
* @param {!number} vLen
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function inverseMoveToFrontTransform(v, vLen) {
|
function inverseMoveToFrontTransform(v, vLen) {
|
||||||
var /** !Int32Array */ mtf = new Int32Array(256);
|
var /** !Int32Array */ mtf = new Int32Array(256);
|
||||||
@ -258,7 +258,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!number} numSymbols
|
* @param {!number} numSymbols
|
||||||
* @param {!Int32Array} codeLengths
|
* @param {!Int32Array} codeLengths
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function readHuffmanCodeLengths(codeLengthCodeLengths, numSymbols, codeLengths, s) {
|
function readHuffmanCodeLengths(codeLengthCodeLengths, numSymbols, codeLengths, s) {
|
||||||
var /** !number */ symbol = 0;
|
var /** !number */ symbol = 0;
|
||||||
@ -343,7 +343,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!Int32Array} table
|
* @param {!Int32Array} table
|
||||||
* @param {!number} offset
|
* @param {!number} offset
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function readHuffmanCode(alphabetSize, table, offset, s) {
|
function readHuffmanCode(alphabetSize, table, offset, s) {
|
||||||
var /** !number */ ok = 1;
|
var /** !number */ ok = 1;
|
||||||
@ -517,7 +517,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function decodeLiteralBlockSwitch(s) {
|
function decodeLiteralBlockSwitch(s) {
|
||||||
s.literalBlockLength = decodeBlockTypeAndLength(s, 0, s.numLiteralBlockTypes);
|
s.literalBlockLength = decodeBlockTypeAndLength(s, 0, s.numLiteralBlockTypes);
|
||||||
@ -531,7 +531,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function decodeCommandBlockSwitch(s) {
|
function decodeCommandBlockSwitch(s) {
|
||||||
s.commandBlockLength = decodeBlockTypeAndLength(s, 1, s.numCommandBlockTypes);
|
s.commandBlockLength = decodeBlockTypeAndLength(s, 1, s.numCommandBlockTypes);
|
||||||
@ -539,7 +539,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function decodeDistanceBlockSwitch(s) {
|
function decodeDistanceBlockSwitch(s) {
|
||||||
s.distanceBlockLength = decodeBlockTypeAndLength(s, 2, s.numDistanceBlockTypes);
|
s.distanceBlockLength = decodeBlockTypeAndLength(s, 2, s.numDistanceBlockTypes);
|
||||||
@ -547,7 +547,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function maybeReallocateRingBuffer(s) {
|
function maybeReallocateRingBuffer(s) {
|
||||||
var /** !number */ newSize = s.maxRingBufferSize;
|
var /** !number */ newSize = s.maxRingBufferSize;
|
||||||
@ -573,7 +573,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function readNextMetablockHeader(s) {
|
function readNextMetablockHeader(s) {
|
||||||
if (s.inputEnd != 0) {
|
if (s.inputEnd != 0) {
|
||||||
@ -626,7 +626,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function readMetablockHuffmanCodesAndContextMaps(s) {
|
function readMetablockHuffmanCodesAndContextMaps(s) {
|
||||||
s.numLiteralBlockTypes = decodeVarLenUnsignedByte(s) + 1;
|
s.numLiteralBlockTypes = decodeVarLenUnsignedByte(s) + 1;
|
||||||
@ -690,7 +690,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function copyUncompressedData(s) {
|
function copyUncompressedData(s) {
|
||||||
var /** !Int8Array */ ringBuffer = s.ringBuffer;
|
var /** !Int8Array */ ringBuffer = s.ringBuffer;
|
||||||
@ -748,7 +748,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function decompress(s) {
|
function decompress(s) {
|
||||||
if (s.runningState == 0) {
|
if (s.runningState == 0) {
|
||||||
@ -1044,7 +1044,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!Int32Array} transforms
|
* @param {!Int32Array} transforms
|
||||||
* @param {!string} prefixSuffixSrc
|
* @param {!string} prefixSuffixSrc
|
||||||
* @param {!string} transformsSrc
|
* @param {!string} transformsSrc
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function unpackTransforms(prefixSuffix, prefixSuffixHeads, transforms, prefixSuffixSrc, transformsSrc) {
|
function unpackTransforms(prefixSuffix, prefixSuffixHeads, transforms, prefixSuffixSrc, transformsSrc) {
|
||||||
var /** !number */ n = prefixSuffixSrc.length;
|
var /** !number */ n = prefixSuffixSrc.length;
|
||||||
@ -1142,7 +1142,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!number} step
|
* @param {!number} step
|
||||||
* @param {!number} end
|
* @param {!number} end
|
||||||
* @param {!number} item
|
* @param {!number} item
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function replicateValue(table, offset, step, end, item) {
|
function replicateValue(table, offset, step, end, item) {
|
||||||
do {
|
do {
|
||||||
@ -1174,7 +1174,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!number} rootBits
|
* @param {!number} rootBits
|
||||||
* @param {!Int32Array} codeLengths
|
* @param {!Int32Array} codeLengths
|
||||||
* @param {!number} codeLengthsSize
|
* @param {!number} codeLengthsSize
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function buildHuffmanTable(rootTable, tableOffset, rootBits, codeLengths, codeLengthsSize) {
|
function buildHuffmanTable(rootTable, tableOffset, rootBits, codeLengths, codeLengthsSize) {
|
||||||
var /** !number */ key;
|
var /** !number */ key;
|
||||||
@ -1232,7 +1232,7 @@ var BrotliDecode = (function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function doReadMoreInput(s) {
|
function doReadMoreInput(s) {
|
||||||
if (s.endOfStreamReached != 0) {
|
if (s.endOfStreamReached != 0) {
|
||||||
@ -1261,7 +1261,7 @@ var BrotliDecode = (function() {
|
|||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @param {!number} endOfStream
|
* @param {!number} endOfStream
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function checkHealth(s, endOfStream) {
|
function checkHealth(s, endOfStream) {
|
||||||
if (s.endOfStreamReached == 0) {
|
if (s.endOfStreamReached == 0) {
|
||||||
@ -1298,7 +1298,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function initBitReader(s) {
|
function initBitReader(s) {
|
||||||
s.byteBuffer = new Int8Array(4160);
|
s.byteBuffer = new Int8Array(4160);
|
||||||
@ -1311,7 +1311,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function prepare(s) {
|
function prepare(s) {
|
||||||
if (s.halfOffset > 2030) {
|
if (s.halfOffset > 2030) {
|
||||||
@ -1325,7 +1325,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function reload(s) {
|
function reload(s) {
|
||||||
if (s.bitOffset == 32) {
|
if (s.bitOffset == 32) {
|
||||||
@ -1334,7 +1334,7 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function jumpToByteBoundary(s) {
|
function jumpToByteBoundary(s) {
|
||||||
var /** !number */ padding = (32 - s.bitOffset) & 7;
|
var /** !number */ padding = (32 - s.bitOffset) & 7;
|
||||||
@ -1361,7 +1361,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!Int8Array} data
|
* @param {!Int8Array} data
|
||||||
* @param {!number} offset
|
* @param {!number} offset
|
||||||
* @param {!number} length
|
* @param {!number} length
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function copyBytes(s, data, offset, length) {
|
function copyBytes(s, data, offset, length) {
|
||||||
if ((s.bitOffset & 7) != 0) {
|
if ((s.bitOffset & 7) != 0) {
|
||||||
@ -1412,7 +1412,7 @@ var BrotliDecode = (function() {
|
|||||||
/**
|
/**
|
||||||
* @param {!State} s
|
* @param {!State} s
|
||||||
* @param {!number} byteLen
|
* @param {!number} byteLen
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function bytesToNibbles(s, byteLen) {
|
function bytesToNibbles(s, byteLen) {
|
||||||
var /** !Int8Array */ byteBuffer = s.byteBuffer;
|
var /** !Int8Array */ byteBuffer = s.byteBuffer;
|
||||||
@ -1428,7 +1428,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!Int32Array} lookup
|
* @param {!Int32Array} lookup
|
||||||
* @param {!string} map
|
* @param {!string} map
|
||||||
* @param {!string} rle
|
* @param {!string} rle
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function unpackLookupTable(lookup, map, rle) {
|
function unpackLookupTable(lookup, map, rle) {
|
||||||
for (var /** !number */ i = 0; i < 256; ++i) {
|
for (var /** !number */ i = 0; i < 256; ++i) {
|
||||||
@ -1603,7 +1603,7 @@ var BrotliDecode = (function() {
|
|||||||
* @param {!string} data0
|
* @param {!string} data0
|
||||||
* @param {!string} data1
|
* @param {!string} data1
|
||||||
* @param {!string} skipFlip
|
* @param {!string} skipFlip
|
||||||
* @return {!void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function unpackDictionaryData(dictionary, data0, data1, skipFlip) {
|
function unpackDictionaryData(dictionary, data0, data1, skipFlip) {
|
||||||
var /** !number */ n0 = data0.length;
|
var /** !number */ n0 = data0.length;
|
||||||
@ -1708,6 +1708,9 @@ var BrotliDecode = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return decode;
|
return decode;
|
||||||
})();
|
}
|
||||||
|
|
||||||
|
/** @export */
|
||||||
|
var BrotliDecode = BrotliDecodeClosure();
|
||||||
|
|
||||||
window["BrotliDecode"] = BrotliDecode;
|
window["BrotliDecode"] = BrotliDecode;
|
||||||
|
@ -2,7 +2,7 @@ goog.require('goog.testing.asserts');
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} bytes
|
* @param {!Int8Array} bytes
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
function bytesToString(bytes) {
|
function bytesToString(bytes) {
|
||||||
@ -20,6 +20,7 @@ function testBaseDictWord() {
|
|||||||
0x1b, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe3, 0xb4, 0x0d, 0x00, 0x00,
|
0x1b, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe3, 0xb4, 0x0d, 0x00, 0x00,
|
||||||
0x07, 0x5b, 0x26, 0x31, 0x40, 0x02, 0x00, 0xe0, 0x4e, 0x1b, 0x41, 0x02
|
0x07, 0x5b, 0x26, 0x31, 0x40, 0x02, 0x00, 0xe0, 0x4e, 0x1b, 0x41, 0x02
|
||||||
]);
|
]);
|
||||||
|
/** @type {!Int8Array} */
|
||||||
var output = BrotliDecode(input);
|
var output = BrotliDecode(input);
|
||||||
assertEquals("time", bytesToString(output));
|
assertEquals("time", bytesToString(output));
|
||||||
}
|
}
|
||||||
@ -30,6 +31,7 @@ function testBlockCountMessage() {
|
|||||||
0x65, 0xe1, 0xfc, 0xfd, 0x22, 0x2c, 0xc4, 0x00, 0x00, 0x38, 0xd8, 0x32,
|
0x65, 0xe1, 0xfc, 0xfd, 0x22, 0x2c, 0xc4, 0x00, 0x00, 0x38, 0xd8, 0x32,
|
||||||
0x89, 0x01, 0x12, 0x00, 0x00, 0x77, 0xda, 0x04, 0x10, 0x42, 0x00, 0x00, 0x00
|
0x89, 0x01, 0x12, 0x00, 0x00, 0x77, 0xda, 0x04, 0x10, 0x42, 0x00, 0x00, 0x00
|
||||||
]);
|
]);
|
||||||
|
/** @type {!Int8Array} */
|
||||||
var output = BrotliDecode(input);
|
var output = BrotliDecode(input);
|
||||||
assertEquals("aabbaaaaabab", bytesToString(output));
|
assertEquals("aabbaaaaabab", bytesToString(output));
|
||||||
}
|
}
|
||||||
@ -42,6 +44,7 @@ function testCompressedUncompressedShortCompressedSmallWindow() {
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x4e, 0xdb, 0x00, 0x00, 0x70, 0xb0,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x4e, 0xdb, 0x00, 0x00, 0x70, 0xb0,
|
||||||
0x65, 0x12, 0x03, 0x24, 0x00, 0x00, 0xee, 0xb4, 0x11, 0x24, 0x00
|
0x65, 0x12, 0x03, 0x24, 0x00, 0x00, 0xee, 0xb4, 0x11, 0x24, 0x00
|
||||||
]);
|
]);
|
||||||
|
/** @type {!Int8Array} */
|
||||||
var output = BrotliDecode(input);
|
var output = BrotliDecode(input);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
|
||||||
@ -67,6 +70,7 @@ function testIntactDistanceRingBuffer0() {
|
|||||||
0x07, 0x5b, 0x26, 0x31, 0x40, 0x02, 0x00, 0xe0, 0x4e, 0x1b, 0xa1, 0x80,
|
0x07, 0x5b, 0x26, 0x31, 0x40, 0x02, 0x00, 0xe0, 0x4e, 0x1b, 0xa1, 0x80,
|
||||||
0x20, 0x00
|
0x20, 0x00
|
||||||
]);
|
]);
|
||||||
|
/** @type {!Int8Array} */
|
||||||
var output = BrotliDecode(input);
|
var output = BrotliDecode(input);
|
||||||
assertEquals("himselfself", bytesToString(output));
|
assertEquals("himselfself", bytesToString(output));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user