• 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
16# Lets callers do '#include <sqlite3.h>'
17config("sqlite_config") {
18  include_dirs = [
19    "include",
20    "//commonlibrary/c_utils/base/include",
21  ]
22}
23
24# This is the configuration used to build sqlite itself.
25# It should not be needed outside of this library.
26config("sqlite3_private_config") {
27  visibility = [ ":*" ]
28  include_dirs = [ "include" ]
29}
30
31group("libsqlite") {
32  public_deps = [ ":sqlite" ]
33}
34
35ohos_shared_library("sqlite") {
36  visibility = [ "//foundation/distributeddatamgr/*" ]
37  visibility += [ "//foundation/multimodalinput/*" ]
38  visibility +=
39      [ "//hit/fuzzing_test/projects/multimodal_InputService_fuzzer/*" ]
40  visibility += [ "//foundation/communication/*" ]
41  visibility += [ "//build/common/*" ]
42  visibility += [ ":*" ]
43  visibility += [ "//base/security/permission/*" ]
44  visibility += [ "//third_party/libsoup/*" ]
45  visibility += [ "//base/security/access_token/*" ]
46  visibility += [ "//foundation/resourceschedule/resource_schedule_service/*" ]
47  visibility += [ "//base/update/dupdate_engine/services/engine/*" ]
48
49  sources = [ "src/sqlite3.c" ]
50
51  defines = [
52    "NDEBUG=1",
53    "HAVE_USLEEP=1",
54    "SQLITE_HAVE_ISNAN",
55    "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
56    "SQLITE_THREADSAFE=2",
57    "SQLITE_TEMP_STORE=3",
58    "SQLITE_POWERSAFE_OVERWRITE=1",
59    "SQLITE_DEFAULT_FILE_FORMAT=4",
60    "SQLITE_DEFAULT_AUTOVACUUM=1",
61    "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
62    "SQLITE_ENABLE_FTS3",
63    "SQLITE_ENABLE_FTS4",
64    "SQLITE_ENABLE_FTS5",
65    "SQLITE_OMIT_COMPILEOPTION_DIAGS",
66    "SQLITE_OMIT_LOAD_EXTENSION",
67    "SQLITE_DEFAULT_FILE_PERMISSIONS=0660",
68    "SQLITE_SECURE_DELETE",
69    "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
70    "USE_PREAD64",
71    "fdatasync=fdatasync",
72    "HAVE_MALLOC_H=1",
73    "HAVE_MALLOC_USABLE_SIZE",
74    "SQLITE_DIRECT_OVERFLOW_READ",
75    "SQLITE_HAS_CODEC",
76    "SQLITE_EXPORT_SYMBOLS",
77    "SQLITE_SHARED_BLOCK_OPTIMIZATION",
78    "SQLITE_CODEC_ATTACH_CHANGED",
79  ]
80  cflags_c = [
81    "-fvisibility=hidden",
82    "-Wno-implicit-fallthrough",
83  ]
84  ldflags = [ "-Wl,--exclude-libs,ALL" ]
85  deps = [ "//third_party/openssl:libcrypto_shared" ]
86  public_configs = [ ":sqlite_config" ]
87  configs = [ ":sqlite3_private_config" ]
88  part_name = "common"
89  install_images = [ system_base_dir ]
90  relative_install_dir = "platformsdk"
91  external_deps = [ "c_utils:utils" ]
92}
93
94ohos_executable("sqlite3") {
95  include_dirs = [ "include" ]
96  sources = [
97    "src/shell.c",
98    "src/sqlite3.c",
99  ]
100
101  defines = [
102    "NDEBUG=1",
103    "HAVE_USLEEP=1",
104    "SQLITE_HAVE_ISNAN",
105    "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
106    "SQLITE_THREADSAFE=2",
107    "SQLITE_TEMP_STORE=3",
108    "SQLITE_POWERSAFE_OVERWRITE=1",
109    "SQLITE_DEFAULT_FILE_FORMAT=4",
110    "SQLITE_DEFAULT_AUTOVACUUM=1",
111    "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
112    "SQLITE_ENABLE_FTS3",
113    "SQLITE_ENABLE_FTS4",
114    "SQLITE_OMIT_COMPILEOPTION_DIAGS",
115    "SQLITE_OMIT_LOAD_EXTENSION",
116    "SQLITE_DEFAULT_FILE_PERMISSIONS=0600",
117    "SQLITE_SECURE_DELETE",
118    "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
119    "USE_PREAD64",
120    "fdatasync=fdatasync",
121    "SQLITE_DIRECT_OVERFLOW_READ",
122    "SQLITE_SHARED_BLOCK_OPTIMIZATION",
123  ]
124
125  cflags = [
126    "-Wno-error=implicit-function-declaration",
127    "-Wno-implicit-fallthrough",
128  ]
129}
130
131if (is_mingw || is_mac) {
132  ohos_shared_library("sqlite_sdk") {
133    include_dirs = [
134      "include",
135      "//third_party/bounds_checking_function/include",
136      "//third_party/openssl/include",
137    ]
138
139    sources = [ "src/sqlite3.c" ]
140
141    defines = [
142      "NDEBUG=1",
143      "HAVE_USLEEP=1",
144      "SQLITE_HAVE_ISNAN",
145      "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
146      "SQLITE_THREADSAFE=2",
147      "SQLITE_TEMP_STORE=3",
148      "SQLITE_POWERSAFE_OVERWRITE=1",
149      "SQLITE_DEFAULT_FILE_FORMAT=4",
150      "SQLITE_DEFAULT_AUTOVACUUM=1",
151      "SQLITE_ENABLE_MEMORY_MANAGEMENT=1",
152      "SQLITE_ENABLE_FTS3",
153      "SQLITE_ENABLE_FTS4",
154      "SQLITE_OMIT_COMPILEOPTION_DIAGS",
155      "SQLITE_OMIT_LOAD_EXTENSION",
156      "SQLITE_DEFAULT_FILE_PERMISSIONS=0600",
157      "SQLITE_SECURE_DELETE",
158      "SQLITE_ENABLE_BATCH_ATOMIC_WRITE",
159      "USE_PREAD64",
160      "fdatasync=fdatasync",
161      "SQLITE_DIRECT_OVERFLOW_READ",
162      "SQLITE_HAS_CODEC",
163      "SQLITE_EXPORT_SYMBOLS",
164      "SQLITE_SHARED_BLOCK_OPTIMIZATION",
165    ]
166    remove_configs = [ "//build/config/compiler:chromium_code" ]
167    deps = [
168      "//third_party/bounds_checking_function:libsec_shared",
169      "//third_party/openssl:libcrypto_restool",
170    ]
171    if (is_mingw) {
172      libs = [ "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32/lib/libws2_32.a" ]
173    }
174    cflags = [
175      "-Wno-error=implicit-function-declaration",
176      "-Wno-implicit-fallthrough",
177    ]
178  }
179}
180