Skip to content

Commit 1e7ea1d

Browse files
authored
Inverse bazel project/workspace tree (google#677)
* Inverse bazel workspace tree. Now each subproject directly depends on root (c) project. This helps to mitigate Bazel bug bazelbuild/bazel#2391; short summary: Bazel does not work if referenced subproject `WORKSPACE` uses any repositories that embedding project does not. Bright side: building C project is much faster; no need to download closure, go and JDK...
1 parent 29dc2cc commit 1e7ea1d

File tree

21 files changed

+319
-294
lines changed

21 files changed

+319
-294
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ bin/
44
buildfiles/
55
**/obj/
66
dist/
7+
**/bazel-*
78

89
# Python
910
__pycache__/

BUILD

-87
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ licenses(["notice"]) # MIT
99

1010
exports_files(["LICENSE"])
1111

12-
# >>> JNI headers
13-
1412
config_setting(
1513
name = "darwin",
1614
values = {"cpu": "darwin"},
@@ -47,38 +45,6 @@ config_setting(
4745
visibility = ["//visibility:public"],
4846
)
4947

50-
genrule(
51-
name = "copy_link_jni_header",
52-
srcs = ["@openjdk_linux//:jni_h"],
53-
outs = ["jni/jni.h"],
54-
cmd = "cp -f $< $@",
55-
)
56-
57-
genrule(
58-
name = "copy_link_jni_md_header",
59-
srcs = select({
60-
":darwin": ["@openjdk_macos//:jni_md_h"],
61-
":darwin_x86_64": ["@openjdk_macos//:jni_md_h"],
62-
":windows_msys": ["@openjdk_win//:jni_md_h"],
63-
":windows_msvc": ["@openjdk_win//:jni_md_h"],
64-
":windows": ["@openjdk_win//:jni_md_h"],
65-
"//conditions:default": ["@openjdk_linux//:jni_md_h"],
66-
}),
67-
outs = ["jni/jni_md.h"],
68-
cmd = "cp -f $< $@",
69-
)
70-
71-
cc_library(
72-
name = "jni_inc",
73-
hdrs = [
74-
":jni/jni.h",
75-
":jni/jni_md.h",
76-
],
77-
includes = ["jni"],
78-
)
79-
80-
# <<< JNI headers
81-
8248
STRICT_C_OPTIONS = select({
8349
":msvc": [],
8450
"//conditions:default": [
@@ -174,60 +140,7 @@ cc_binary(
174140
],
175141
)
176142

177-
########################################################
178-
# WARNING: do not (transitively) depend on this target!
179-
########################################################
180-
cc_binary(
181-
name = "brotli_jni.dll",
182-
srcs = [
183-
":common_headers",
184-
":common_sources",
185-
":dec_headers",
186-
":dec_sources",
187-
":enc_headers",
188-
":enc_sources",
189-
"//java/org/brotli/wrapper/common:jni_src",
190-
"//java/org/brotli/wrapper/dec:jni_src",
191-
"//java/org/brotli/wrapper/enc:jni_src",
192-
],
193-
deps = [
194-
":brotli_inc",
195-
":jni_inc",
196-
],
197-
linkshared = 1,
198-
)
199-
200-
########################################################
201-
# WARNING: do not (transitively) depend on this target!
202-
########################################################
203-
cc_binary(
204-
name = "brotli_jni_no_dictionary_data.dll",
205-
srcs = [
206-
":common_headers",
207-
":common_sources",
208-
":dec_headers",
209-
":dec_sources",
210-
":enc_headers",
211-
":enc_sources",
212-
"//java/org/brotli/wrapper/common:jni_src",
213-
"//java/org/brotli/wrapper/dec:jni_src",
214-
"//java/org/brotli/wrapper/enc:jni_src",
215-
],
216-
defines = [
217-
"BROTLI_EXTERNAL_DICTIONARY_DATA=",
218-
],
219-
deps = [
220-
":brotli_inc",
221-
":jni_inc",
222-
],
223-
linkshared = 1,
224-
)
225-
226143
filegroup(
227144
name = "dictionary",
228145
srcs = ["c/common/dictionary.bin"],
229146
)
230-
231-
load("@io_bazel_rules_go//go:def.bzl", "go_prefix")
232-
233-
go_prefix("github.com/google/brotli")

WORKSPACE

+12-87
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,21 @@
1-
# Description:
2-
# Bazel workspace file for Brotli.
3-
41
workspace(name = "org_brotli")
52

6-
maven_jar(
7-
name = "junit_junit",
8-
artifact = "junit:junit:4.12",
3+
local_repository(
4+
name = "ignore_org_brotli_go",
5+
path = "go",
96
)
107

11-
http_archive(
12-
name = "io_bazel_rules_go",
13-
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.12.0/rules_go-0.12.0.tar.gz"],
14-
sha256 = "c1f52b8789218bb1542ed362c4f7de7052abcf254d865d96fb7ba6d44bc15ee3",
8+
local_repository(
9+
name = "ignore_org_brotli_java",
10+
path = "java",
1511
)
1612

17-
http_archive(
18-
name = "io_bazel_rules_closure",
19-
sha256 = "a80acb69c63d5f6437b099c111480a4493bad4592015af2127a2f49fb7512d8d",
20-
strip_prefix = "rules_closure-0.7.0",
21-
urls = [
22-
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.7.0.tar.gz",
23-
"https://github.com/bazelbuild/rules_closure/archive/0.7.0.tar.gz",
24-
],
13+
local_repository(
14+
name = "ignore_org_brotli_js",
15+
path = "js",
2516
)
2617

27-
new_http_archive(
28-
name = "openjdk_linux",
29-
urls = [
30-
"https://mirror.bazel.build/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz",
31-
"https://bazel-mirror.storage.googleapis.com/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz",
32-
"https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz",
33-
],
34-
sha256 = "7e6284739c0e5b7142bc7a9adc61ced70dc5bb26b130b582b18e809013bcb251",
35-
build_file_content = """
36-
package(
37-
default_visibility = ["//visibility:public"],
38-
)
39-
filegroup(
40-
name = "jni_h",
41-
srcs = ["zulu8.23.0.3-jdk8.0.144-linux_x64/include/jni.h"],
18+
local_repository(
19+
name = "ignore_org_brotli_research",
20+
path = "research",
4221
)
43-
filegroup(
44-
name = "jni_md_h",
45-
srcs = ["zulu8.23.0.3-jdk8.0.144-linux_x64/include/linux/jni_md.h"],
46-
)""",
47-
)
48-
49-
new_http_archive(
50-
name = "openjdk_macos",
51-
urls = [
52-
"https://mirror.bazel.build/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-macosx_x64.zip",
53-
"https://bazel-mirror.storage.googleapis.com/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-macosx_x64.zip",
54-
"https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-macosx_x64.zip",
55-
],
56-
sha256 = "ff533364c9cbd3b271ab5328efe28e2dd6d7bae5b630098a5683f742ecf0709d",
57-
build_file_content = """
58-
package(
59-
default_visibility = ["//visibility:public"],
60-
)
61-
filegroup(
62-
name = "jni_md_h",
63-
srcs = ["zulu8.23.0.3-jdk8.0.144-macosx_x64/include/darwin/jni_md.h"],
64-
)""",
65-
)
66-
67-
new_http_archive(
68-
name = "openjdk_win",
69-
urls = [
70-
"https://mirror.bazel.build/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-win_x64.zip",
71-
"https://bazel-mirror.storage.googleapis.com/openjdk/azul-zulu-8.23.0.3-jdk8.0.144/zulu8.23.0.3-jdk8.0.144-win_x64.zip",
72-
"https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-win_x64.zip",
73-
],
74-
sha256 = "f1d9d3341ef7c8c9baff3597953e99a6a7c64f8608ee62c03fdd7574b7655c02",
75-
build_file_content = """
76-
package(
77-
default_visibility = ["//visibility:public"],
78-
)
79-
filegroup(
80-
name = "jni_md_h",
81-
srcs = ["zulu8.23.0.3-jdk8.0.144-win_x64/include/win32/jni_md.h"],
82-
)""",
83-
)
84-
85-
new_local_repository(
86-
name = "divsufsort",
87-
build_file = "//research:BUILD.libdivsufsort",
88-
path = "research/libdivsufsort",
89-
)
90-
91-
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
92-
closure_repositories()
93-
94-
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
95-
go_rules_dependencies()
96-
go_register_toolchains()

c/common/transform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ BROTLI_COMMON_API const BrotliTransforms* BrotliGetTransforms(void);
7171

7272
BROTLI_COMMON_API int BrotliTransformDictionaryWord(
7373
uint8_t* dst, const uint8_t* word, int len,
74-
const BrotliTransforms* transforms, int transform_idx);
74+
const BrotliTransforms* BROTLI_RESTRICT transforms, int transform_idx);
7575

7676
#if defined(__cplusplus) || defined(c_plusplus)
7777
} /* extern "C" */

go/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_prefix")
2+
3+
go_prefix("github.com/google/brotli")

go/WORKSPACE

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
workspace(name = "org_brotli_go")
2+
3+
local_repository(
4+
name = "org_brotli",
5+
path = "..",
6+
)
7+
8+
http_archive(
9+
name = "io_bazel_rules_go",
10+
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.12.0/rules_go-0.12.0.tar.gz"],
11+
sha256 = "c1f52b8789218bb1542ed362c4f7de7052abcf254d865d96fb7ba6d44bc15ee3",
12+
)
13+
14+
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
15+
go_rules_dependencies()
16+
go_register_toolchains()

go/cbrotli/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ go_library(
1313
"writer.go",
1414
],
1515
cdeps = [
16-
"//:brotlidec",
17-
"//:brotlienc",
16+
"@org_brotli//:brotlidec",
17+
"@org_brotli//:brotlienc",
1818
],
1919
cgo=True,
2020
)

java/BUILD

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package(
2+
default_visibility = ["//visibility:public"],
3+
)
4+
5+
# >>> JNI headers
6+
7+
genrule(
8+
name = "copy_link_jni_header",
9+
srcs = ["@openjdk_linux//:jni_h"],
10+
outs = ["jni/jni.h"],
11+
cmd = "cp -f $< $@",
12+
)
13+
14+
genrule(
15+
name = "copy_link_jni_md_header",
16+
srcs = select({
17+
"@org_brotli//:darwin": ["@openjdk_macos//:jni_md_h"],
18+
"@org_brotli//:darwin_x86_64": ["@openjdk_macos//:jni_md_h"],
19+
"@org_brotli//:windows_msys": ["@openjdk_win//:jni_md_h"],
20+
"@org_brotli//:windows_msvc": ["@openjdk_win//:jni_md_h"],
21+
"@org_brotli//:windows": ["@openjdk_win//:jni_md_h"],
22+
"//conditions:default": ["@openjdk_linux//:jni_md_h"],
23+
}),
24+
outs = ["jni/jni_md.h"],
25+
cmd = "cp -f $< $@",
26+
)
27+
28+
cc_library(
29+
name = "jni_inc",
30+
hdrs = [
31+
":jni/jni.h",
32+
":jni/jni_md.h",
33+
],
34+
includes = ["jni"],
35+
)
36+
37+
# <<< JNI headers
38+
39+
########################################################
40+
# WARNING: do not (transitively) depend on this target!
41+
########################################################
42+
cc_binary(
43+
name = "brotli_jni.dll",
44+
srcs = [
45+
"@org_brotli//:common_headers",
46+
"@org_brotli//:common_sources",
47+
"@org_brotli//:dec_headers",
48+
"@org_brotli//:dec_sources",
49+
"@org_brotli//:enc_headers",
50+
"@org_brotli//:enc_sources",
51+
"//org/brotli/wrapper/common:jni_src",
52+
"//org/brotli/wrapper/dec:jni_src",
53+
"//org/brotli/wrapper/enc:jni_src",
54+
],
55+
deps = [
56+
"@org_brotli//:brotli_inc",
57+
":jni_inc",
58+
],
59+
linkshared = 1,
60+
)
61+
62+
########################################################
63+
# WARNING: do not (transitively) depend on this target!
64+
########################################################
65+
cc_binary(
66+
name = "brotli_jni_no_dictionary_data.dll",
67+
srcs = [
68+
"@org_brotli//:common_headers",
69+
"@org_brotli//:common_sources",
70+
"@org_brotli//:dec_headers",
71+
"@org_brotli//:dec_sources",
72+
"@org_brotli//:enc_headers",
73+
"@org_brotli//:enc_sources",
74+
"//org/brotli/wrapper/common:jni_src",
75+
"//org/brotli/wrapper/dec:jni_src",
76+
"//org/brotli/wrapper/enc:jni_src",
77+
],
78+
defines = [
79+
"BROTLI_EXTERNAL_DICTIONARY_DATA=",
80+
],
81+
deps = [
82+
"@org_brotli//:brotli_inc",
83+
":jni_inc",
84+
],
85+
linkshared = 1,
86+
)

0 commit comments

Comments
 (0)