mirror of https://github.com/mattn/go-sqlite3.git
Merge pull request #339 from brauner/2016-10-17/fix_libsqlite3_build
actually link to <sqlite3.h> when -tags libsqlite3
This commit is contained in:
commit
dbe15b0408
|
@ -17,6 +17,7 @@
|
||||||
** language. The code for the "sqlite3" command-line shell is also in a
|
** language. The code for the "sqlite3" command-line shell is also in a
|
||||||
** separate file. This file contains only code for the core SQLite library.
|
** separate file. This file contains only code for the core SQLite library.
|
||||||
*/
|
*/
|
||||||
|
#ifndef USE_LIBSQLITE3
|
||||||
#define SQLITE_CORE 1
|
#define SQLITE_CORE 1
|
||||||
#define SQLITE_AMALGAMATION 1
|
#define SQLITE_AMALGAMATION 1
|
||||||
#ifndef SQLITE_PRIVATE
|
#ifndef SQLITE_PRIVATE
|
||||||
|
@ -197846,5 +197847,9 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
|
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
|
||||||
|
#else // USE_LIBSQLITE3
|
||||||
|
// If users really want to link against the system sqlite3 we
|
||||||
|
// need to make this file a noop.
|
||||||
|
#endif
|
||||||
|
|
||||||
/************** End of fts5.c ************************************************/
|
/************** End of fts5.c ************************************************/
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
** the version number) and changes its name to "sqlite3.h" as
|
** the version number) and changes its name to "sqlite3.h" as
|
||||||
** part of the build process.
|
** part of the build process.
|
||||||
*/
|
*/
|
||||||
|
#ifndef USE_LIBSQLITE3
|
||||||
#ifndef SQLITE3_H
|
#ifndef SQLITE3_H
|
||||||
#define SQLITE3_H
|
#define SQLITE3_H
|
||||||
#include <stdarg.h> /* Needed for the definition of va_list */
|
#include <stdarg.h> /* Needed for the definition of va_list */
|
||||||
|
@ -10338,5 +10339,9 @@ struct fts5_api {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _FTS5_H */
|
#endif /* _FTS5_H */
|
||||||
|
#else // USE_LIBSQLITE3
|
||||||
|
// If users really want to link against the system sqlite3 we
|
||||||
|
// need to make this file a noop.
|
||||||
|
#endif
|
||||||
|
|
||||||
/******** End of fts5.h *********/
|
/******** End of fts5.h *********/
|
||||||
|
|
11
sqlite3ext.h
11
sqlite3ext.h
|
@ -1,3 +1,4 @@
|
||||||
|
#ifndef USE_LIBSQLITE3
|
||||||
/*
|
/*
|
||||||
** 2006 June 7
|
** 2006 June 7
|
||||||
**
|
**
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
** This header file defines the SQLite interface for use by
|
** This header file defines the SQLite interface for use by
|
||||||
** shared libraries that want to be imported as extensions into
|
** shared libraries that want to be imported as extensions into
|
||||||
** an SQLite instance. Shared libraries that intend to be loaded
|
** an SQLite instance. Shared libraries that intend to be loaded
|
||||||
** as extensions by SQLite should #include this file instead of
|
** as extensions by SQLite should #include this file instead of
|
||||||
** sqlite3.h.
|
** sqlite3.h.
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE3EXT_H
|
#ifndef SQLITE3EXT_H
|
||||||
|
@ -543,14 +544,14 @@ typedef int (*sqlite3_loadext_entry)(
|
||||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||||
|
|
||||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||||
/* This case when the file really is being compiled as a loadable
|
/* This case when the file really is being compiled as a loadable
|
||||||
** extension */
|
** extension */
|
||||||
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
||||||
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
||||||
# define SQLITE_EXTENSION_INIT3 \
|
# define SQLITE_EXTENSION_INIT3 \
|
||||||
extern const sqlite3_api_routines *sqlite3_api;
|
extern const sqlite3_api_routines *sqlite3_api;
|
||||||
#else
|
#else
|
||||||
/* This case when the file is being statically linked into the
|
/* This case when the file is being statically linked into the
|
||||||
** application */
|
** application */
|
||||||
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||||
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||||
|
@ -558,3 +559,7 @@ typedef int (*sqlite3_loadext_entry)(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* SQLITE3EXT_H */
|
#endif /* SQLITE3EXT_H */
|
||||||
|
#else // USE_LIBSQLITE3
|
||||||
|
// If users really want to link against the system sqlite3 we
|
||||||
|
// need to make this file a noop.
|
||||||
|
#endif
|
||||||
|
|
|
@ -37,18 +37,21 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
b, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
resp.Body.Close()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("extracting %v\n", path.Base(url))
|
fmt.Printf("extracting %v\n", path.Base(url))
|
||||||
r, err := zip.NewReader(bytes.NewReader(b), resp.ContentLength)
|
r, err := zip.NewReader(bytes.NewReader(b), resp.ContentLength)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
resp.Body.Close()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
for _, zf := range r.File {
|
for _, zf := range r.File {
|
||||||
var f *os.File
|
var f *os.File
|
||||||
switch path.Base(zf.Name) {
|
switch path.Base(zf.Name) {
|
||||||
|
@ -68,11 +71,27 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
_, err = io.Copy(f, zr)
|
|
||||||
f.Close()
|
_, err = io.WriteString(f, "#ifndef USE_LIBSQLITE3\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
zr.Close()
|
||||||
|
f.Close()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
_, err = io.Copy(f, zr)
|
||||||
|
if err != nil {
|
||||||
|
zr.Close()
|
||||||
|
f.Close()
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
_, err = io.WriteString(f, "#else // USE_LIBSQLITE3\n // If users really want to link against the system sqlite3 we\n// need to make this file a noop.\n #endif")
|
||||||
|
if err != nil {
|
||||||
|
zr.Close()
|
||||||
|
f.Close()
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
zr.Close()
|
||||||
|
f.Close()
|
||||||
fmt.Printf("extracted %v\n", filepath.Base(f.Name()))
|
fmt.Printf("extracted %v\n", filepath.Base(f.Name()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue