Skip to content

Commit 05088d5

Browse files
committed
Fix minor issues for SQLite shell application
- fix function prototypes for sqlite3mc_version in shell source - adjust patch script for shell source - adjust amalgamation script to support shell source amalgamation
1 parent 0e4224d commit 05088d5

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

scripts/amalgamate.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ def find_included_file(self, file_path, source_dir):
6464

6565
return None
6666

67+
def add_excluded_files(self):
68+
search_files = self.exclude_files[:]
69+
for search_file in search_files:
70+
found_excluded_path = self.find_included_file(search_file, None)
71+
if found_excluded_path:
72+
norm_excluded_path = os.path.normpath(found_excluded_path)
73+
self.excluded_files.append(os.path.normpath(norm_excluded_path))
74+
6775
def __init__(self, args):
6876
with open(args.config, 'r') as f:
6977
config = json.loads(f.read())
@@ -74,6 +82,8 @@ def __init__(self, args):
7482
self.prologue = args.prologue
7583
self.source_path = args.source_path
7684
self.included_files = []
85+
self.excluded_files = []
86+
self.add_excluded_files()
7787

7888
# Generate the amalgamation and write it to the target file.
7989
def generate(self):
@@ -89,6 +99,7 @@ def generate(self):
8999
print(" working_dir = {0}".format(os.getcwd()))
90100
print(" include_paths = {0}".format(self.include_paths))
91101
print(" force_include = {0}".format(self.force_include))
102+
print(" exclude_files = {0}".format(self.exclude_files))
92103
print("Creating amalgamation:")
93104
for file_path in self.sources:
94105
# Do not check the include paths while processing the source
@@ -239,9 +250,10 @@ def _process_includes(self):
239250
found_included_path = self.amalgamation.find_included_file(
240251
include_path, self.file_dir if search_same_dir else None)
241252
if found_included_path:
242-
includes.append((include_match, found_included_path))
243-
#if self.amalgamation.verbose:
244-
# print(" #include = {0}".format(include_path))
253+
if not os.path.normpath(found_included_path) in self.amalgamation.excluded_files:
254+
includes.append((include_match, found_included_path))
255+
#if self.amalgamation.verbose:
256+
# print(" #include = {0}".format(include_path))
245257
include_match = self.include_pattern.search(self.content,
246258
include_match.end())
247259

scripts/patchshell.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ die() {
1717
sed -e '/^ sputf(stdout, "SQLite version/{n;N;d}' "$INPUT" \
1818
| sed '/#ifdef SQLITE_CUSTOM_INCLUDE/!{p;d;};n;n;n;a #if SQLITE3MC_USE_MINIZ != 0 && !defined(SQLITE_ENABLE_COMPRESS)\n#include "miniz.c"\n#ifdef SQLITE_HAVE_ZLIB\n#undef SQLITE_HAVE_ZLIB\n#endif\n#define SQLITE_HAVE_ZLIB 1\n#endif\n' \
1919
| sed '/#include <zlib.h>/c #include "zlibwrap.h"' \
20-
| sed '/^ sqlite3_fprintf(stdout,$/c \ extern char* sqlite3mc_version();\n sqlite3_fprintf(stdout,' \
20+
| sed '/^ sqlite3_fprintf(stdout,$/c \ extern const char* sqlite3mc_version();\n sqlite3_fprintf(stdout,' \
2121
| sed '/^ "SQLite version/c \ "SQLite version \%s \%.19s" \/\*extra-version-info\*\/\n " (\%s)\\n" \/\*SQLite3-Multiple-Ciphers-version-info\*\/' \
2222
| sed '/^ sqlite3_libversion(), sqlite3_sourceid());/c \ sqlite3_libversion(), sqlite3_sourceid(), sqlite3mc_version());' \
23-
| sed '/^ sqlite3_libversion(), sqlite3_sourceid());/a \ extern char* sqlite3mc_version();\n sqlite3_fprintf(p->out, "\%s\\n", sqlite3mc_version());'
23+
| sed '/^ sqlite3_libversion(), sqlite3_sourceid());/a \ extern const char* sqlite3mc_version();\n sqlite3_fprintf(p->out, "\%s\\n", sqlite3mc_version());'

scripts/shell3mc.c.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"project": "shell3mc.c",
3+
"target": "shell3mc_amalgamation.c",
4+
"sources": [
5+
"shell.c"
6+
],
7+
"include_paths": [
8+
"src", "."
9+
],
10+
"force_include": [
11+
],
12+
"exclude_files": [
13+
"test_windirent.c",
14+
"test_windirent.h",
15+
"sqlite3.h"
16+
]
17+
}
18+

scripts/sqlite3mc.c.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"aegis/aegis256/aegis256_common.h",
1919
"aegis/aegis256x2/aegis256x2_common.h",
2020
"aegis/aegis256x4/aegis256x4_common.h"
21+
],
22+
"exclude_files": [
2123
]
2224
}
2325

scripts/sqlite3mc.h.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"src", "."
99
],
1010
"force_include": [
11+
],
12+
"exclude_files": [
1113
]
1214
}
1315

src/shell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32358,7 +32358,7 @@ static int do_meta_command(char *zLine, ShellState *p){
3235832358
char *zPtrSz = sizeof(void*)==8 ? "64-bit" : "32-bit";
3235932359
sqlite3_fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
3236032360
sqlite3_libversion(), sqlite3_sourceid());
32361-
extern char* sqlite3mc_version();
32361+
extern const char* sqlite3mc_version();
3236232362
sqlite3_fprintf(p->out, "%s\n", sqlite3mc_version());
3236332363
#if SQLITE_HAVE_ZLIB
3236432364
sqlite3_fprintf(p->out, "zlib version %s\n", zlibVersion());
@@ -33803,7 +33803,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
3380333803
char *zHome;
3380433804
char *zHistory;
3380533805
int nHistory;
33806-
extern char* sqlite3mc_version();
33806+
extern const char* sqlite3mc_version();
3380733807
sqlite3_fprintf(stdout,
3380833808
"SQLite version %s %.19s" /*extra-version-info*/
3380933809
" (%s)\n" /*SQLite3-Multiple-Ciphers-version-info*/

0 commit comments

Comments
 (0)