• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15
16is_cross_platform_build = defined(is_arkui_x) && is_arkui_x
17
18# Lets callers do '#include <sqlite3.h>'
19config("sqlite_config") {
20  include_dirs = [
21    "include",
22    "//commonlibrary/c_utils/base/include",
23  ]
24}
25
26# This is the configuration used to build sqlite itself.
27# It should not be needed outside of this library.
28config("sqlite3_private_config") {
29  visibility = [ ":*" ]
30  include_dirs = [ "include" ]
31}
32
33group("libsqlite") {
34  public_deps = [ ":sqlite" ]
35}
36
37ohos_shared_library("sqlite") {
38  visibility = [ "//foundation/distributeddatamgr/*" ]
39  visibility += [ "//foundation/multimodalinput/*" ]
40  visibility +=
41      [ "//hit/fuzzing_test/projects/multimodal_InputService_fuzzer/*" ]
42  visibility += [ "//foundation/communication/*" ]
43  visibility += [ "//build/common/*" ]
44  visibility += [ ":*" ]
45  visibility += [ "//base/security/permission/*" ]
46  visibility += [ "//third_party/libsoup/*" ]
47  visibility += [ "//base/security/access_token/*" ]
48  visibility += [ "//foundation/resourceschedule/resource_schedule_service/*" ]
49
50  sources = [ "src/sqlite3.c" ]
51
52  defines = [
53    "NDEBUG=1",
54    "HAVE_USLEEP=1",
55    "SQLITE_HAVE_ISNAN",
56    "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
57    "SQLITE_THREADSAFE=2",
58    "SQLITE_TEMP_STORE=3",
59    "SQLITE_POWERSAFE_OVERWRITE=1",
60    "SQLITE_DEFAULT_FILE_FORMAT=4",
61    "SQLITE_DEFAULT_AUTOVACUUM=1",
62    "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
63    "SQLITE_ENABLE_FTS3",
64    "SQLITE_ENABLE_FTS4",
65    "SQLITE_ENABLE_FTS5",
66    "SQLITE_OMIT_COMPILEOPTION_DIAGS",
67    "SQLITE_OMIT_LOAD_EXTENSION",
68    "SQLITE_DEFAULT_FILE_PERMISSIONS=0660",
69    "SQLITE_SECURE_DELETE",
70    "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
71    "USE_PREAD64",
72    "fdatasync=fdatasync",
73    "HAVE_MALLOC_H=1",
74    "HAVE_MALLOC_USABLE_SIZE",
75    "SQLITE_DIRECT_OVERFLOW_READ",
76    "SQLITE_HAS_CODEC",
77    "SQLITE_EXPORT_SYMBOLS",
78    "SQLITE_SHARED_BLOCK_OPTIMIZATION",
79    "SQLITE_CODEC_ATTACH_CHANGED",
80    "SQLITE_ENABLE_DROPTABLE_CALLBACK",
81    "OPENSSL_SUPPRESS_DEPRECATED",
82  ]
83  cflags_c = [
84    "-fvisibility=hidden",
85    "-Wno-implicit-fallthrough",
86  ]
87  if (target_os != "ios") {
88    ldflags = [ "-Wl,--exclude-libs,ALL" ]
89  }
90  deps = [ "//third_party/openssl:libcrypto_shared" ]
91  public_configs = [ ":sqlite_config" ]
92  configs = [ ":sqlite3_private_config" ]
93  innerapi_tags = [ "platformsdk_indirect" ]
94  part_name = "sqlite"
95  subsystem_name = "thirdparty"
96  install_images = [ system_base_dir ]
97  relative_install_dir = "platformsdk"
98  if (is_cross_platform_build) {
99    if (target_os == "ios") {
100      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
101    } else {
102      deps += [ "//commonlibrary/c_utils/base:utils" ]
103    }
104  } else {
105    external_deps = [ "c_utils:utils" ]
106  }
107}
108
109ohos_executable("sqlite3") {
110  include_dirs = [ "include" ]
111  sources = [
112    "src/shell.c",
113    "src/sqlite3.c",
114  ]
115
116  defines = [
117    "NDEBUG=1",
118    "HAVE_USLEEP=1",
119    "SQLITE_HAVE_ISNAN",
120    "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
121    "SQLITE_THREADSAFE=2",
122    "SQLITE_TEMP_STORE=3",
123    "SQLITE_POWERSAFE_OVERWRITE=1",
124    "SQLITE_DEFAULT_FILE_FORMAT=4",
125    "SQLITE_DEFAULT_AUTOVACUUM=1",
126    "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
127    "SQLITE_ENABLE_FTS3",
128    "SQLITE_ENABLE_FTS4",
129    "SQLITE_OMIT_COMPILEOPTION_DIAGS",
130    "SQLITE_OMIT_LOAD_EXTENSION",
131    "SQLITE_DEFAULT_FILE_PERMISSIONS=0600",
132    "SQLITE_SECURE_DELETE",
133    "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
134    "USE_PREAD64",
135    "fdatasync=fdatasync",
136    "SQLITE_DIRECT_OVERFLOW_READ",
137    "SQLITE_SHARED_BLOCK_OPTIMIZATION",
138    "OPENSSL_SUPPRESS_DEPRECATED",
139  ]
140
141  cflags = [
142    "-Wno-error=implicit-function-declaration",
143    "-Wno-implicit-fallthrough",
144  ]
145}
146
147if (is_mingw || is_mac) {
148  ohos_shared_library("sqlite_sdk") {
149    include_dirs = [
150      "include",
151      "//third_party/bounds_checking_function/include",
152      "//third_party/openssl/include",
153    ]
154
155    sources = [ "src/sqlite3.c" ]
156
157    defines = [
158      "NDEBUG=1",
159      "HAVE_USLEEP=1",
160      "SQLITE_HAVE_ISNAN",
161      "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
162      "SQLITE_THREADSAFE=2",
163      "SQLITE_TEMP_STORE=3",
164      "SQLITE_POWERSAFE_OVERWRITE=1",
165      "SQLITE_DEFAULT_FILE_FORMAT=4",
166      "SQLITE_DEFAULT_AUTOVACUUM=1",
167      "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
168      "SQLITE_ENABLE_FTS3",
169      "SQLITE_ENABLE_FTS4",
170      "SQLITE_OMIT_COMPILEOPTION_DIAGS",
171      "SQLITE_OMIT_LOAD_EXTENSION",
172      "SQLITE_DEFAULT_FILE_PERMISSIONS=0600",
173      "SQLITE_SECURE_DELETE",
174      "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
175      "USE_PREAD64",
176      "fdatasync=fdatasync",
177      "SQLITE_DIRECT_OVERFLOW_READ",
178      "SQLITE_HAS_CODEC",
179      "SQLITE_EXPORT_SYMBOLS",
180      "SQLITE_SHARED_BLOCK_OPTIMIZATION",
181      "OPENSSL_SUPPRESS_DEPRECATED",
182    ]
183    remove_configs = [ "//build/config/compiler:chromium_code" ]
184    deps = [
185      "//third_party/bounds_checking_function:libsec_shared",
186      "//third_party/openssl:libcrypto_restool",
187    ]
188    if (is_mingw) {
189      libs = [ "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32/lib/libws2_32.a" ]
190    }
191    cflags = [
192      "-Wno-error=implicit-function-declaration",
193      "-Wno-implicit-fallthrough",
194    ]
195  }
196}
197
198if (is_cross_platform_build) {
199  ohos_static_library("sqlite_static") {
200    visibility = [ "//foundation/distributeddatamgr/*" ]
201    visibility += [ "//foundation/multimodalinput/*" ]
202    visibility +=
203        [ "//hit/fuzzing_test/projects/multimodal_InputService_fuzzer/*" ]
204    visibility += [ "//foundation/communication/*" ]
205    visibility += [ "//build/common/*" ]
206    visibility += [ ":*" ]
207    visibility += [ "//base/security/permission/*" ]
208    visibility += [ "//third_party/libsoup/*" ]
209    visibility += [ "//base/security/access_token/*" ]
210    visibility +=
211        [ "//foundation/resourceschedule/resource_schedule_service/*" ]
212
213    sources = [ "src/sqlite3.c" ]
214
215    defines = [
216      "NDEBUG=1",
217      "HAVE_USLEEP=1",
218      "SQLITE_HAVE_ISNAN",
219      "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
220      "SQLITE_THREADSAFE=2",
221      "SQLITE_TEMP_STORE=3",
222      "SQLITE_POWERSAFE_OVERWRITE=1",
223      "SQLITE_DEFAULT_FILE_FORMAT=4",
224      "SQLITE_DEFAULT_AUTOVACUUM=1",
225      "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
226      "SQLITE_ENABLE_FTS3",
227      "SQLITE_ENABLE_FTS4",
228      "SQLITE_ENABLE_FTS5",
229      "SQLITE_OMIT_COMPILEOPTION_DIAGS",
230      "SQLITE_OMIT_LOAD_EXTENSION",
231      "SQLITE_DEFAULT_FILE_PERMISSIONS=0660",
232      "SQLITE_SECURE_DELETE",
233      "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
234      "USE_PREAD64",
235      "fdatasync=fdatasync",
236      "HAVE_MALLOC_H=1",
237      "HAVE_MALLOC_USABLE_SIZE",
238      "SQLITE_DIRECT_OVERFLOW_READ",
239      "SQLITE_HAS_CODEC",
240      "SQLITE_EXPORT_SYMBOLS",
241      "SQLITE_SHARED_BLOCK_OPTIMIZATION",
242      "SQLITE_CODEC_ATTACH_CHANGED",
243      "SQLITE_ENABLE_DROPTABLE_CALLBACK",
244      "OPENSSL_SUPPRESS_DEPRECATED",
245    ]
246
247    cflags_c = [
248      "-fvisibility=hidden",
249      "-Wno-implicit-fallthrough",
250    ]
251
252    deps = [
253      "//third_party/bounds_checking_function:libsec_static",
254      "//third_party/openssl:libcrypto_static",
255    ]
256    public_configs = [ ":sqlite_config" ]
257    configs = [ ":sqlite3_private_config" ]
258    part_name = "sqlite"
259    subsystem_name = "thirdparty"
260  }
261}
262