1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Useful environment variables that can be set on the mmma command line, as
16# <key>=<value> pairs:
17#
18# LIBTEXTCLASSIFIER_STRIP_OPTS: (optional) value for LOCAL_STRIP_MODULE (for all
19#   modules we build).  NOT for prod builds.  Can be set to keep_symbols for
20#   debug / treemap purposes.
21
22
23LOCAL_PATH := $(call my-dir)
24
25# Custom C/C++ compilation flags:
26MY_LIBTEXTCLASSIFIER_CFLAGS := \
27    -Wno-unused-parameter \
28    -Wno-sign-compare \
29    -Wno-missing-field-initializers \
30    -Wno-ignored-qualifiers \
31    -Wno-undefined-var-template \
32    -fvisibility=hidden
33
34# Only enable debug logging in userdebug/eng builds.
35ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
36  MY_LIBTEXTCLASSIFIER_CFLAGS += -DTC_DEBUG_LOGGING=1
37endif
38
39# ------------------------
40# libtextclassifier_protos
41# ------------------------
42
43include $(CLEAR_VARS)
44
45LOCAL_MODULE := libtextclassifier_protos
46
47LOCAL_STRIP_MODULE := $(LIBTEXTCLASSIFIER_STRIP_OPTS)
48
49LOCAL_SRC_FILES := $(call all-proto-files-under, .)
50LOCAL_SHARED_LIBRARIES := libprotobuf-cpp-lite
51
52include $(BUILD_STATIC_LIBRARY)
53
54# -----------------
55# libtextclassifier
56# -----------------
57
58include $(CLEAR_VARS)
59LOCAL_MODULE := libtextclassifier
60
61proto_sources_dir := $(generated_sources_dir)
62
63LOCAL_CPP_EXTENSION := .cc
64LOCAL_CFLAGS += $(MY_LIBTEXTCLASSIFIER_CFLAGS)
65LOCAL_STRIP_MODULE := $(LIBTEXTCLASSIFIER_STRIP_OPTS)
66
67LOCAL_SRC_FILES := $(filter-out tests/%,$(call all-subdir-cpp-files))
68LOCAL_C_INCLUDES += $(proto_sources_dir)/proto/external/libtextclassifier
69
70LOCAL_STATIC_LIBRARIES += libtextclassifier_protos
71LOCAL_SHARED_LIBRARIES += libprotobuf-cpp-lite
72LOCAL_SHARED_LIBRARIES += liblog
73LOCAL_SHARED_LIBRARIES += libicuuc libicui18n
74LOCAL_REQUIRED_MODULES := textclassifier.langid.model
75LOCAL_REQUIRED_MODULES += textclassifier.smartselection.en.model
76
77LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/jni.lds
78LOCAL_LDFLAGS += -Wl,-version-script=$(LOCAL_PATH)/jni.lds
79
80include $(BUILD_SHARED_LIBRARY)
81
82# -----------------------
83# libtextclassifier_tests
84# -----------------------
85
86include $(CLEAR_VARS)
87
88LOCAL_MODULE := libtextclassifier_tests
89LOCAL_MODULE_TAGS := tests
90
91LOCAL_CPP_EXTENSION := .cc
92LOCAL_CFLAGS += $(MY_LIBTEXTCLASSIFIER_CFLAGS)
93LOCAL_STRIP_MODULE := $(LIBTEXTCLASSIFIER_STRIP_OPTS)
94
95LOCAL_TEST_DATA := $(call find-test-data-in-subdirs, $(LOCAL_PATH), *, tests/testdata)
96
97LOCAL_CPPFLAGS_32 += -DTEST_DATA_DIR="\"/data/nativetest/libtextclassifier_tests/tests/testdata/\""
98LOCAL_CPPFLAGS_64 += -DTEST_DATA_DIR="\"/data/nativetest64/libtextclassifier_tests/tests/testdata/\""
99
100LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
101LOCAL_C_INCLUDES += $(proto_sources_dir)/proto/external/libtextclassifier
102
103LOCAL_STATIC_LIBRARIES += libtextclassifier_protos libgmock
104LOCAL_SHARED_LIBRARIES += libprotobuf-cpp-lite
105LOCAL_SHARED_LIBRARIES += liblog
106LOCAL_SHARED_LIBRARIES += libicuuc libicui18n
107
108include $(BUILD_NATIVE_TEST)
109
110# ------------
111# LangId model
112# ------------
113
114include $(CLEAR_VARS)
115LOCAL_MODULE        := textclassifier.langid.model
116LOCAL_MODULE_CLASS  := ETC
117LOCAL_MODULE_OWNER := google
118LOCAL_SRC_FILES     := ./models/textclassifier.langid.model
119LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
120include $(BUILD_PREBUILT)
121
122# ----------------------
123# Smart Selection models
124# ----------------------
125
126include $(CLEAR_VARS)
127LOCAL_MODULE        := textclassifier.smartselection.ar.model
128LOCAL_MODULE_CLASS  := ETC
129LOCAL_MODULE_OWNER  := google
130LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.ar.model
131LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
132include $(BUILD_PREBUILT)
133
134include $(CLEAR_VARS)
135LOCAL_MODULE        := textclassifier.smartselection.de.model
136LOCAL_MODULE_CLASS  := ETC
137LOCAL_MODULE_OWNER  := google
138LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.de.model
139LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
140include $(BUILD_PREBUILT)
141
142include $(CLEAR_VARS)
143LOCAL_MODULE        := textclassifier.smartselection.en.model
144LOCAL_MODULE_CLASS  := ETC
145LOCAL_MODULE_OWNER  := google
146LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.en.model
147LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
148include $(BUILD_PREBUILT)
149
150include $(CLEAR_VARS)
151LOCAL_MODULE        := textclassifier.smartselection.es.model
152LOCAL_MODULE_CLASS  := ETC
153LOCAL_MODULE_OWNER  := google
154LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.es.model
155LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
156include $(BUILD_PREBUILT)
157
158include $(CLEAR_VARS)
159LOCAL_MODULE        := textclassifier.smartselection.fr.model
160LOCAL_MODULE_CLASS  := ETC
161LOCAL_MODULE_OWNER  := google
162LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.fr.model
163LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
164include $(BUILD_PREBUILT)
165
166include $(CLEAR_VARS)
167LOCAL_MODULE        := textclassifier.smartselection.it.model
168LOCAL_MODULE_CLASS  := ETC
169LOCAL_MODULE_OWNER  := google
170LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.it.model
171LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
172include $(BUILD_PREBUILT)
173
174include $(CLEAR_VARS)
175LOCAL_MODULE        := textclassifier.smartselection.ja.model
176LOCAL_MODULE_CLASS  := ETC
177LOCAL_MODULE_OWNER  := google
178LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.ja.model
179LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
180include $(BUILD_PREBUILT)
181
182include $(CLEAR_VARS)
183LOCAL_MODULE        := textclassifier.smartselection.ko.model
184LOCAL_MODULE_CLASS  := ETC
185LOCAL_MODULE_OWNER  := google
186LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.ko.model
187LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
188include $(BUILD_PREBUILT)
189
190include $(CLEAR_VARS)
191LOCAL_MODULE        := textclassifier.smartselection.nl.model
192LOCAL_MODULE_CLASS  := ETC
193LOCAL_MODULE_OWNER  := google
194LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.nl.model
195LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
196include $(BUILD_PREBUILT)
197
198include $(CLEAR_VARS)
199LOCAL_MODULE        := textclassifier.smartselection.pl.model
200LOCAL_MODULE_CLASS  := ETC
201LOCAL_MODULE_OWNER  := google
202LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.pl.model
203LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
204include $(BUILD_PREBUILT)
205
206include $(CLEAR_VARS)
207LOCAL_MODULE        := textclassifier.smartselection.pt-PT.model
208LOCAL_MODULE_CLASS  := ETC
209LOCAL_MODULE_OWNER  := google
210LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.pt-PT.model
211LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
212include $(BUILD_PREBUILT)
213
214include $(CLEAR_VARS)
215LOCAL_MODULE        := textclassifier.smartselection.ru.model
216LOCAL_MODULE_CLASS  := ETC
217LOCAL_MODULE_OWNER  := google
218LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.ru.model
219LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
220include $(BUILD_PREBUILT)
221
222include $(CLEAR_VARS)
223LOCAL_MODULE        := textclassifier.smartselection.th.model
224LOCAL_MODULE_CLASS  := ETC
225LOCAL_MODULE_OWNER  := google
226LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.th.model
227LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
228include $(BUILD_PREBUILT)
229
230include $(CLEAR_VARS)
231LOCAL_MODULE        := textclassifier.smartselection.tr.model
232LOCAL_MODULE_CLASS  := ETC
233LOCAL_MODULE_OWNER  := google
234LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.tr.model
235LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
236include $(BUILD_PREBUILT)
237
238include $(CLEAR_VARS)
239LOCAL_MODULE        := textclassifier.smartselection.zh-Hant.model
240LOCAL_MODULE_CLASS  := ETC
241LOCAL_MODULE_OWNER  := google
242LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.zh-Hant.model
243LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
244include $(BUILD_PREBUILT)
245
246include $(CLEAR_VARS)
247LOCAL_MODULE        := textclassifier.smartselection.zh.model
248LOCAL_MODULE_CLASS  := ETC
249LOCAL_MODULE_OWNER  := google
250LOCAL_SRC_FILES     := ./models/textclassifier.smartselection.zh.model
251LOCAL_MODULE_PATH   := $(TARGET_OUT_ETC)/textclassifier
252include $(BUILD_PREBUILT)
253
254# -----------------------
255# Smart Selection bundles
256# -----------------------
257
258include $(CLEAR_VARS)
259LOCAL_MODULE           := textclassifier.smartselection.bundle1
260LOCAL_REQUIRED_MODULES := textclassifier.smartselection.en.model
261LOCAL_REQUIRED_MODULES += textclassifier.smartselection.es.model
262LOCAL_REQUIRED_MODULES += textclassifier.smartselection.de.model
263LOCAL_REQUIRED_MODULES += textclassifier.smartselection.fr.model
264include $(BUILD_STATIC_LIBRARY)
265