forked from unicode-org/icu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ICU-21117 Use Bazel to automate generation of Unicode data files
- Loading branch information
Showing
18 changed files
with
663 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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,9 @@ | ||
# © 2021 and later: Unicode, Inc. and others. | ||
# License & terms of use: http://www.unicode.org/copyright.html | ||
|
||
# .bazeliskrc is the configuration file for the wrapper program for the Bazel | ||
# build system, called Bazelisk. Bazelisk can be used as a drop-in replacement | ||
# for running Bazel commands while ensuring, through configuration, that only a | ||
# specific version of Bazel is executed. | ||
|
||
USE_BAZEL_VERSION=3.7.1 |
This file contains 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 |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
*.vcxproj.user | ||
*_debug | ||
*_release | ||
bazel-* | ||
cygicudata* | ||
libicu* | ||
libicutest* | ||
|
This file contains 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,5 @@ | ||
# © 2021 and later: Unicode, Inc. and others. | ||
# License & terms of use: http://www.unicode.org/copyright.html | ||
|
||
# This file tells Bazel where the root directory of the project is. | ||
# "Target" and file paths in Bazel BUILD files are relative to this root directory. |
This file contains 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,356 @@ | ||
# © 2021 and later: Unicode, Inc. and others. | ||
# License & terms of use: http://www.unicode.org/copyright.html | ||
|
||
# This file defines Bazel targets for a subset of ICU4C "common" library header and source files. | ||
# The configuration of dependencies among targets is strongly assisted by the | ||
# file in depstest that maintains such information, at | ||
# icu4c/source/test/depstest/dependencies.txt . | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
# When compiling code in the `common` dir, the constant | ||
# `U_COMMON_IMPLEMENTATION` needs to be defined. See | ||
# https://unicode-org.github.io/icu/userguide/howtouseicu#c-with-your-own-build-system . | ||
|
||
# If linker errors occur, then this may be a sign that the dependencies were | ||
# not specified correctly. Use dependencies.txt in depstest for assistance. See | ||
# https://stackoverflow.com/q/66111709/2077918 . | ||
|
||
cc_library( | ||
name = "headers", | ||
hdrs = glob([ | ||
"unicode/*.h", # public | ||
"*.h", # internal | ||
], | ||
# Instead of using this checked-in file, our Bazel build process | ||
# regenerates this file and then uses the new version. | ||
exclude = ["norm2_nfc_data.h"], | ||
), | ||
# We need to add includes in order to preserve existing source files' | ||
# include directives that use traditional paths, not paths relative to | ||
# Bazel workspace: | ||
# https://stackoverflow.com/a/65635893/2077918 | ||
includes = ["."], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "platform", | ||
srcs = [ | ||
"cmemory.cpp", | ||
"uobject.cpp", | ||
"cstring.cpp", | ||
"cwchar.cpp", | ||
"uinvchar.cpp", | ||
"charstr.cpp", | ||
"unistr.cpp", | ||
"appendable.cpp", | ||
"stringpiece.cpp", | ||
"ustrtrns.cpp", | ||
"ustring.cpp", | ||
"ustrfmt.cpp", | ||
"utf_impl.cpp", | ||
"putil.cpp", | ||
"ucln_cmn.cpp", | ||
"udataswp.cpp", | ||
"umath.cpp", | ||
"umutex.cpp", | ||
"sharedobject.cpp", | ||
"utrace.cpp", | ||
], | ||
deps = [ | ||
":headers", | ||
# omit other deps b/c they are sys symbols | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
linkopts = ["-ldl"], | ||
) | ||
|
||
cc_library( | ||
name = "utrie", | ||
srcs = ["utrie.cpp"], | ||
deps = [":platform"], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "utrie2", | ||
srcs = ["utrie2.cpp"], | ||
deps = [":platform"], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "utrie2_builder", | ||
srcs = ["utrie2_builder.cpp"], | ||
deps = [ | ||
":utrie", | ||
":utrie2", | ||
":platform", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "ucptrie", | ||
srcs = ["ucptrie.cpp"], | ||
deps = [":platform"], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "umutablecptrie", | ||
srcs = ["umutablecptrie.cpp"], | ||
deps = [":ucptrie"], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "bytestrie", | ||
srcs = ["bytestrie.cpp"], | ||
deps = [":platform"], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "bytestriebuilder", | ||
srcs = ["bytestriebuilder.cpp"], | ||
deps = [ | ||
":bytestrie", | ||
":stringtriebuilder", | ||
":sort", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "stringtriebuilder", | ||
srcs = ["stringtriebuilder.cpp"], | ||
deps = [ | ||
":uhash", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "uhash", | ||
hdrs = [ | ||
"uhash.h", | ||
], | ||
srcs = [ | ||
"uhash.cpp", | ||
], | ||
deps = [ | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "errorcode", | ||
hdrs = [ | ||
], | ||
srcs = [ | ||
"errorcode.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":platform", | ||
":utypes", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "utypes", | ||
srcs = [ | ||
"utypes.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "uniset", | ||
srcs = [ | ||
"uniset.cpp", | ||
"unifilt.cpp", | ||
"unisetspan.cpp", | ||
"bmpset.cpp", | ||
"util.cpp", | ||
"unifunct.cpp", | ||
"usetiter.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":patternprops", | ||
":uvector", | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "patternprops", | ||
srcs = [ | ||
"patternprops.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "propsvec", | ||
srcs = [ | ||
"propsvec.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":sort", | ||
":utrie2_builder", | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "propname", | ||
srcs = [ | ||
"propname.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":bytestrie", | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
# Note: cc_library target name "uvector32" matches dependencies.txt group name, | ||
# but filename "uvectr32.*" differs in spelling. | ||
cc_library( | ||
name = "uvector32", | ||
srcs = [ | ||
"uvectr32.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":platform", | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "sort", | ||
srcs = [ | ||
"uarrsort.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "uvector", | ||
srcs = [ | ||
"uvector.cpp", | ||
], | ||
includes = ["."], | ||
deps = [ | ||
":platform", | ||
":sort", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
|
||
# Building this target will indirectly cause the creation of a header file that | ||
# integrates normalization data. This header file is generated by a genrule | ||
# target that invokes the gennorm2 binary. | ||
cc_library( | ||
name = "normalizer2", | ||
srcs = [ | ||
"normalizer2.cpp", | ||
"normalizer2impl.cpp", | ||
], | ||
includes = ["."], | ||
hdrs = [ | ||
"normalizer2impl.h", | ||
"norm2_nfc_data.h", # generated by gennorm2 | ||
], | ||
deps = [ | ||
":headers", | ||
], | ||
local_defines = [ | ||
"U_COMMON_IMPLEMENTATION", | ||
], | ||
) | ||
|
||
|
||
|
||
# Note: Bazel has chosen specifically to disallow any official support for breaking | ||
# through constraints that would allow copying to or generating to source | ||
# directories: https://stackoverflow.com/questions/51283183/how-to-generate-files-in-source-folder-using-bazel | ||
|
||
genrule( | ||
name = "gen_norm2_nfc_data_h", | ||
srcs = [ | ||
"//icu4c/source/data/unidata/norm2:nfc.txt", | ||
], | ||
outs = ["norm2_nfc_data.h"], | ||
cmd = "./$(location //icu4c/source/tools/gennorm2) -o $@ $(location //icu4c/source/data/unidata/norm2:nfc.txt) --csource && cp $@ /tmp", | ||
tools = ["//icu4c/source/tools/gennorm2"], | ||
) |
This file contains 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.