| # Copyright 2023 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//third_party/protobuf/proto_library.gni") |
| |
| config("sentencepiece_config") { |
| include_dirs = [ |
| "src/src", |
| "src", |
| "shims", |
| "$root_gen_dir/third_party/sentencepiece/src", |
| "$root_gen_dir/third_party/sentencepiece/src/src", |
| ] |
| |
| defines = [ |
| "DARTS_DISABLE_EXCEPTIONS=1", |
| "SENTENCEPIECE_DISABLE_EXCEPTIONS=1", |
| ] |
| } |
| |
| config("sentencepiece_flags") { |
| cflags = [ |
| "-Wno-deprecated-anon-enum-enum-conversion", |
| "-Wno-macro-redefined", |
| ] |
| } |
| |
| proto_library("sentencepiece_proto") { |
| proto_in_dir = "src/src" |
| cc_generator_options = "lite=true:" |
| sources = [ |
| "src/src/sentencepiece.proto", |
| "src/src/sentencepiece_model.proto", |
| ] |
| } |
| |
| static_library("sentencepiece") { |
| sources = [ |
| "src/src/bpe_model.cc", |
| "src/src/bpe_model.h", |
| "src/src/builder.cc", |
| "src/src/builder.h", |
| "src/src/char_model.cc", |
| "src/src/char_model.h", |
| "src/src/common.h", |
| "src/src/error.cc", |
| "src/src/filesystem.cc", |
| "src/src/filesystem.h", |
| "src/src/freelist.h", |
| "src/src/init.h", |
| "src/src/model_factory.cc", |
| "src/src/model_factory.h", |
| "src/src/model_interface.cc", |
| "src/src/model_interface.h", |
| "src/src/normalization_rule.h", |
| "src/src/normalizer.cc", |
| "src/src/normalizer.h", |
| "src/src/sentencepiece_processor.cc", |
| "src/src/sentencepiece_processor.h", |
| "src/src/spec_parser.h", |
| "src/src/unicode_script.cc", |
| "src/src/unicode_script.h", |
| "src/src/unicode_script_map.h", |
| "src/src/unigram_model.cc", |
| "src/src/unigram_model.h", |
| "src/src/util.cc", |
| "src/src/util.h", |
| "src/src/word_model.cc", |
| "src/src/word_model.h", |
| ] |
| |
| deps = [ |
| ":sentencepiece_proto", |
| "//third_party/abseil-cpp:absl", |
| "//third_party/protobuf:protobuf_lite", |
| ] |
| |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| |
| public_configs = [ ":sentencepiece_config" ] |
| |
| configs += [ ":sentencepiece_flags" ] |
| } |