Skip to content

Commit c8e0d7a

Browse files
Gary-Hobsonacassis
authored andcommitted
database: add sqlite support
enable UTILS_SQLITE configuration, use the sqlite3 command line tool Signed-off-by: yinshengkai <[email protected]>
1 parent 110fa82 commit c8e0d7a

File tree

7 files changed

+309
-0
lines changed

7 files changed

+309
-0
lines changed

database/Make.defs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
############################################################################
2+
# apps/database/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(wildcard $(APPDIR)/database/*/Make.defs)

database/Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
############################################################################
2+
# apps/database/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
MENUDESC = "Database"
22+
23+
include $(APPDIR)/Directory.mk

database/sqlite/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/sqlite
3+
*.zip

database/sqlite/Kconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config LIB_SQLITE
7+
bool "SQLITE library"
8+
depends on CONFIG_FS_LOCK_BUCKET_SIZE > 0
9+
default n
10+
11+
if LIB_SQLITE
12+
13+
config LIB_SQLITE_VERSION
14+
string "SQLITE version"
15+
default "3.45.1"
16+
17+
config UTILS_SQLITE
18+
tristate "SQLite cmd line tool"
19+
default n
20+
21+
config UTILS_SQLITE_STACKSIZE
22+
int "SQLite3 cmd line tool stack size"
23+
default 8192
24+
depends on UTILS_SQLITE
25+
26+
endif

database/sqlite/Make.defs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
############################################################################
2+
# apps/database/sqlite/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
ifneq ($(CONFIG_LIB_SQLITE),)
22+
CONFIGURED_APPS += $(APPDIR)/database/sqlite
23+
endif

database/sqlite/Makefile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
############################################################################
2+
# apps/database/sqlite/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
23+
SQLITEDIR=$(APPDIR)/database/sqlite
24+
BUILDDIR=$(SQLITEDIR)/build
25+
26+
CSRCS += ${BUILDDIR}/sqlite3.c
27+
28+
CFLAGS += ${INCDIR_PREFIX}$(SQLITEDIR)
29+
CFLAGS += ${DEFINE_PREFIX}_HAVE_SQLITE_CONFIG_H
30+
CFLAGS += ${DEFINE_PREFIX}NDEBUG
31+
CFLAGS += -Wno-unused-variable -Wno-undef -Wno-unused-function -Wno-shadow
32+
33+
ifneq ($(CONFIG_UTILS_SQLITE),)
34+
PROGNAME = sqlite3
35+
PRIORITY = 100
36+
STACKSIZE = ${CONFIG_UTILS_SQLITE_STACKSIZE}
37+
MAINSRC = ${BUILDDIR}/shell.c
38+
endif
39+
40+
41+
# Download and unpack tarball if no git repo found
42+
43+
sqlite.zip:
44+
ifeq ($(wildcard sqlite/.git),)
45+
$(Q) curl -L https://codeload.github.com/sqlite/sqlite/zip/refs/tags/vesion-${CONFIG_LIB_SQLITE_VERSION} -o sqlite.zip
46+
$(Q) unzip -q -o sqlite.zip
47+
$(Q) mv sqlite-vesion-* sqlite
48+
$(call DELFILE, sqlite.zip)
49+
endif
50+
51+
context:: sqlite.zip
52+
$(Q) mkdir -p ${BUILDDIR} && \
53+
cd ${BUILDDIR} && \
54+
echo "Generate SQLite amalgamation version" && \
55+
${SQLITEDIR}/sqlite/configure 1> /dev/null && \
56+
make sqlite3.c -j 1> /dev/null
57+
58+
clean::
59+
$(call DELFILE, ${BUILDDIR}/*.o)
60+
61+
distclean::
62+
$(call DELDIR, ${BUILDDIR})
63+
ifeq ($(wildcard sqlite/.git),)
64+
$(call DELDIR, sqlite)
65+
endif
66+
67+
include $(APPDIR)/Application.mk
68+

database/sqlite/sqlite_cfg.h

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/* sqlite_cfg.h. Generated from sqlite_cfg.h.in by configure. */
2+
/* sqlite_cfg.h.in. Generated from configure.ac by autoheader. */
3+
4+
/* Define to 1 if you have the <dlfcn.h> header file. */
5+
#define HAVE_DLFCN_H 1
6+
7+
/* Define to 1 if you have the `fdatasync' function. */
8+
#define HAVE_FDATASYNC 1
9+
10+
/* Define to 1 if you have the `gmtime_r' function. */
11+
#define HAVE_GMTIME_R 1
12+
13+
/* Define to 1 if the system has the type `int16_t'. */
14+
#define HAVE_INT16_T 1
15+
16+
/* Define to 1 if the system has the type `int32_t'. */
17+
#define HAVE_INT32_T 1
18+
19+
/* Define to 1 if the system has the type `int64_t'. */
20+
#define HAVE_INT64_T 1
21+
22+
/* Define to 1 if the system has the type `int8_t'. */
23+
#define HAVE_INT8_T 1
24+
25+
/* Define to 1 if the system has the type `intptr_t'. */
26+
#define HAVE_INTPTR_T 1
27+
28+
/* Define to 1 if you have the <inttypes.h> header file. */
29+
#define HAVE_INTTYPES_H 1
30+
31+
/* Define to 1 if you have the `isnan' function. */
32+
#define HAVE_ISNAN 1
33+
34+
/* Define to 1 if you have the `localtime_r' function. */
35+
#define HAVE_LOCALTIME_R 1
36+
37+
/* Define to 1 if you have the `localtime_s' function. */
38+
/* #undef HAVE_LOCALTIME_S */
39+
40+
/* Define to 1 if you have the <malloc.h> header file. */
41+
#define HAVE_MALLOC_H 1
42+
43+
/* Define to 1 if you have the `malloc_usable_size' function. */
44+
#define HAVE_MALLOC_USABLE_SIZE 1
45+
46+
/* Define to 1 if you have the <memory.h> header file. */
47+
#define HAVE_MEMORY_H 1
48+
49+
/* Define to 1 if you have the `pread' function. */
50+
#define HAVE_PREAD 1
51+
52+
/* Define to 1 if you have the `pread64' function. */
53+
#define HAVE_PREAD64 1
54+
55+
/* Define to 1 if you have the `pwrite' function. */
56+
#define HAVE_PWRITE 1
57+
58+
/* Define to 1 if you have the `pwrite64' function. */
59+
#define HAVE_PWRITE64 1
60+
61+
/* Define to 1 if you have the <stdint.h> header file. */
62+
#define HAVE_STDINT_H 1
63+
64+
/* Define to 1 if you have the <stdlib.h> header file. */
65+
#define HAVE_STDLIB_H 1
66+
67+
/* Define to 1 if you have the `strchrnul' function. */
68+
#define HAVE_STRCHRNUL 1
69+
70+
/* Define to 1 if you have the <strings.h> header file. */
71+
#define HAVE_STRINGS_H 1
72+
73+
/* Define to 1 if you have the <string.h> header file. */
74+
#define HAVE_STRING_H 1
75+
76+
/* Define to 1 if you have the <sys/stat.h> header file. */
77+
#define HAVE_SYS_STAT_H 1
78+
79+
/* Define to 1 if you have the <sys/types.h> header file. */
80+
#define HAVE_SYS_TYPES_H 1
81+
82+
/* Define to 1 if the system has the type `uint16_t'. */
83+
#define HAVE_UINT16_T 1
84+
85+
/* Define to 1 if the system has the type `uint32_t'. */
86+
#define HAVE_UINT32_T 1
87+
88+
/* Define to 1 if the system has the type `uint64_t'. */
89+
#define HAVE_UINT64_T 1
90+
91+
/* Define to 1 if the system has the type `uint8_t'. */
92+
#define HAVE_UINT8_T 1
93+
94+
/* Define to 1 if the system has the type `uintptr_t'. */
95+
#define HAVE_UINTPTR_T 1
96+
97+
/* Define to 1 if you have the <unistd.h> header file. */
98+
#define HAVE_UNISTD_H 1
99+
100+
/* Define to 1 if you have the `usleep' function. */
101+
#define HAVE_USLEEP 1
102+
103+
/* Define to 1 if you have the `utime' function. */
104+
#define HAVE_UTIME 1
105+
106+
/* Define to 1 if you have the <zlib.h> header file. */
107+
#ifdef CONFIG_LIB_ZLIB
108+
# define HAVE_ZLIB_H 1
109+
#endif
110+
111+
/* Define to the sub-directory in which libtool stores uninstalled libraries.
112+
*/
113+
#define LT_OBJDIR ".libs/"
114+
115+
/* Define to the address where bug reports for this package should be sent. */
116+
#define PACKAGE_BUGREPORT ""
117+
118+
/* Define to the full name of this package. */
119+
#define PACKAGE_NAME "sqlite"
120+
121+
/* Define to the full name and version of this package. */
122+
#define PACKAGE_STRING "sqlite 3.45.1"
123+
124+
/* Define to the one symbol short name of this package. */
125+
#define PACKAGE_TARNAME "sqlite"
126+
127+
/* Define to the home page for this package. */
128+
#define PACKAGE_URL ""
129+
130+
/* Define to the version of this package. */
131+
#define PACKAGE_VERSION "3.45.1"
132+
133+
/* Define to 1 if you have the ANSI C header files. */
134+
#define STDC_HEADERS 1
135+
136+
/* Enable large inode numbers on Mac OS X 10.5. */
137+
#ifndef _DARWIN_USE_64_BIT_INODE
138+
# define _DARWIN_USE_64_BIT_INODE 1
139+
#endif
140+
141+
/* Number of bits in a file offset, on hosts where this is settable. */
142+
/* #undef _FILE_OFFSET_BITS */
143+
144+
/* Define for large files, on AIX-style hosts. */
145+
/* #undef _LARGE_FILES */

0 commit comments

Comments
 (0)