Commit b2f88fe4 authored by Ajay Patel's avatar Ajay Patel

Include test_windirent and fix PYTHONPATH bug on travis

parent 8093a464
Pipeline #36785990 passed with stages
in 110 minutes and 18 seconds
......@@ -24,7 +24,7 @@ script:
- /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- brew install [email protected] --without-multilib
- export CC="/usr/local/Cellar/gcc/8.2.0/bin/gcc-8"
- export PYTHONPATH=$(python3 -c "import site; print(site.getsitepackages())[0]")
- export PYTHONPATH=$(python3 -c "import site; print(site.getsitepackages()[0])")
- echo $PYTHONPATH
- $PIP install pip setuptools -U
- $PIP install cibuildwheel==0.10.0
......
......@@ -449,7 +449,8 @@ def get_modules(THIRD_PARTY, INTERNAL, PROJ_PATH,
library_dirs=libraries,
libraries=[
"user32",
"Advapi32"] if sys.platform == "win32" else [],
"Advapi32",
"Kernel32"] if sys.platform == "win32" else [],
extra_compile_args=compile_args,
extra_link_args=link_args)
......@@ -470,7 +471,7 @@ def get_modules(THIRD_PARTY, INTERNAL, PROJ_PATH,
extra_compile_args=["-O4"],
extra_link_args=link_args)
def sqlite_misc_extensions(skip=[], zlib=[]):
def sqlite_misc_extensions(skip=[], zlib=[], windirent=[]):
miscs = []
for source in glob(os.path.join(SQLITE_EXT, 'misc', '*.c')):
if os.path.basename(source) in skip:
......@@ -478,13 +479,25 @@ def get_modules(THIRD_PARTY, INTERNAL, PROJ_PATH,
module = os.path.basename(source)[:-2]
pyinit_source = source_for_module_with_pyinit(module)
z_sources = zlib_sources if os.path.basename(source) in zlib else []
windirent_sources = (
[
os.path.relpath(
os.path.join(
SQLITE3,
"test_windirent.c"),
PROJ_PATH)] if os.path.basename(source) in windirent else [])
miscs.append(
Extension(SO_PREFIX + module,
sources=[source] + z_sources + [pyinit_source],
include_dirs=includes,
library_dirs=libraries,
extra_compile_args=["-O4"],
extra_link_args=link_args))
Extension(
SO_PREFIX +
module,
sources=[source] +
z_sources +
windirent_sources +
[pyinit_source],
include_dirs=includes,
library_dirs=libraries,
extra_compile_args=["-O4"],
extra_link_args=link_args))
return miscs
lsm1 = sqlite_extension('lsm1')
......
......@@ -6,7 +6,7 @@ There are a few components that need updating when updating the version of `sqli
3. **Update SQLite3:** Download the latest SQLite Amalgamation package from the [SQLite website](https://www.sqlite.org/download.html). Update `third_party/sqlite3/sqlite3.c.pre.c` (with `sqlite3.c`) and update `third_party/sqlite3/sqlite3.h`, `third_party/sqlite3/sqlite3_ext.h`, and `third_party/sqlite3/shell.c` from the SQLite Amalgamation package.
3. **Update SQLite3 Extensions:** Download the latest SQLite source code package from the [SQLite website](https://www.sqlite.org/download.html). Update the `third_party/sqlite3/ext` with the `ext` filder from the SQLite Amalgamation package.
3. **Update SQLite3 Extensions:** Download the latest SQLite source code package from the [SQLite website](https://www.sqlite.org/download.html). Update the `third_party/sqlite3/ext` with the `ext` folder from the SQLite source code package. Also copy `test_windirent.h` and `test_windirent.c` from the `src` folder to `third_party/sqlite3/`.
4. **Copy `shell.c`:** Copy `shell.c` from the root of `third_party/_apsw` (which was updated in step #1) to `third_party/sqlite3/apsw_shell.c`.
......
......@@ -891,7 +891,7 @@ complete SQLite API into Python.""",
["src/apsw.c", "src/sqlite3.c", "src/icu.cpp"], # PLASTICITY
include_dirs=include_dirs + include_plasticity, # PLASTICITY
library_dirs=library_dirs,
libraries=libraries + (["user32", "Advapi32"] if sys.platform == "win32" else []), # PLASTICITY
libraries=libraries + (["user32", "Advapi32", "Kernel32"] if sys.platform == "win32" else []), # PLASTICITY
define_macros=define_macros,
extra_compile_args=["-O4", "-std=c++11"], # PLASTICITY
extra_link_args=["-flto"], # PLASTICITY
......
......@@ -291,7 +291,7 @@ def get_setup_args():
include_dirs=include_dirs + include_plasticity, # PLASTICITY
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
libraries=libraries + (["user32", "Advapi32"] if sys.platform == "win32" else []), # PLASTICITY
libraries=libraries + (["user32", "Advapi32", "Kernel32"] if sys.platform == "win32" else []), # PLASTICITY
extra_objects=extra_objects,
define_macros=define_macros,
extra_compile_args=["-O4", "-std=c++11"], # PLASTICITY
......
/*
** 2015 November 30
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement most of the opendir() family of
** POSIX functions on Win32 using the MSVCRT.
*/
#if defined(_WIN32) && defined(_MSC_VER)
#include "test_windirent.h"
/*
** Implementation of the POSIX getenv() function using the Win32 API.
** This function is not thread-safe.
*/
const char *windirent_getenv(
const char *name
){
static char value[32768]; /* Maximum length, per MSDN */
DWORD dwSize = sizeof(value) / sizeof(char); /* Size in chars */
DWORD dwRet; /* Value returned by GetEnvironmentVariableA() */
memset(value, 0, sizeof(value));
dwRet = GetEnvironmentVariableA(name, value, dwSize);
if( dwRet==0 || dwRet>dwSize ){
/*
** The function call to GetEnvironmentVariableA() failed -OR-
** the buffer is not large enough. Either way, return NULL.
*/
return 0;
}else{
/*
** The function call to GetEnvironmentVariableA() succeeded
** -AND- the buffer contains the entire value.
*/
return value;
}
}
/*
** Implementation of the POSIX opendir() function using the MSVCRT.
*/
LPDIR opendir(
const char *dirname
){
struct _finddata_t data;
LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));
SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);
if( dirp==NULL ) return NULL;
memset(dirp, 0, sizeof(DIR));
/* TODO: Remove this if Unix-style root paths are not used. */
if( sqlite3_stricmp(dirname, "/")==0 ){
dirname = windirent_getenv("SystemDrive");
}
memset(&data, 0, sizeof(struct _finddata_t));
_snprintf(data.name, namesize, "%s\\*", dirname);
dirp->d_handle = _findfirst(data.name, &data);
if( dirp->d_handle==BAD_INTPTR_T ){
closedir(dirp);
return NULL;
}
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ){
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ){
closedir(dirp);
return NULL;
}
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
}
dirp->d_first.d_attributes = data.attrib;
strncpy(dirp->d_first.d_name, data.name, NAME_MAX);
dirp->d_first.d_name[NAME_MAX] = '\0';
return dirp;
}
/*
** Implementation of the POSIX readdir() function using the MSVCRT.
*/
LPDIRENT readdir(
LPDIR dirp
){
struct _finddata_t data;
if( dirp==NULL ) return NULL;
if( dirp->d_first.d_ino==0 ){
dirp->d_first.d_ino++;
dirp->d_next.d_ino++;
return &dirp->d_first;
}
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ) return NULL;
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
dirp->d_next.d_ino++;
dirp->d_next.d_attributes = data.attrib;
strncpy(dirp->d_next.d_name, data.name, NAME_MAX);
dirp->d_next.d_name[NAME_MAX] = '\0';
return &dirp->d_next;
}
/*
** Implementation of the POSIX readdir_r() function using the MSVCRT.
*/
INT readdir_r(
LPDIR dirp,
LPDIRENT entry,
LPDIRENT *result
){
struct _finddata_t data;
if( dirp==NULL ) return EBADF;
if( dirp->d_first.d_ino==0 ){
dirp->d_first.d_ino++;
dirp->d_next.d_ino++;
entry->d_ino = dirp->d_first.d_ino;
entry->d_attributes = dirp->d_first.d_attributes;
strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX);
entry->d_name[NAME_MAX] = '\0';
*result = entry;
return 0;
}
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ){
*result = NULL;
return ENOENT;
}
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
entry->d_ino = (ino_t)-1; /* not available */
entry->d_attributes = data.attrib;
strncpy(entry->d_name, data.name, NAME_MAX);
entry->d_name[NAME_MAX] = '\0';
*result = entry;
return 0;
}
/*
** Implementation of the POSIX closedir() function using the MSVCRT.
*/
INT closedir(
LPDIR dirp
){
INT result = 0;
if( dirp==NULL ) return EINVAL;
if( dirp->d_handle!=NULL_INTPTR_T && dirp->d_handle!=BAD_INTPTR_T ){
result = _findclose(dirp->d_handle);
}
sqlite3_free(dirp);
return result;
}
#endif /* defined(WIN32) && defined(_MSC_VER) */
/*
** 2015 November 30
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains declarations for most of the opendir() family of
** POSIX functions on Win32 using the MSVCRT.
*/
#if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H)
#define SQLITE_WINDIRENT_H
/*
** We need several data types from the Windows SDK header.
*/
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include "windows.h"
/*
** We need several support functions from the SQLite core.
*/
#include "sqlite3.h"
/*
** We need several things from the ANSI and MSVCRT headers.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <io.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
/*
** We may need several defines that should have been in "sys/stat.h".
*/
#ifndef S_ISREG
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISLNK
#define S_ISLNK(mode) (0)
#endif
/*
** We may need to provide the "mode_t" type.
*/
#ifndef MODE_T_DEFINED
#define MODE_T_DEFINED
typedef unsigned short mode_t;
#endif
/*
** We may need to provide the "ino_t" type.
*/
#ifndef INO_T_DEFINED
#define INO_T_DEFINED
typedef unsigned short ino_t;
#endif
/*
** We need to define "NAME_MAX" if it was not present in "limits.h".
*/
#ifndef NAME_MAX
# ifdef FILENAME_MAX
# define NAME_MAX (FILENAME_MAX)
# else
# define NAME_MAX (260)
# endif
#endif
/*
** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
*/
#ifndef NULL_INTPTR_T
# define NULL_INTPTR_T ((intptr_t)(0))
#endif
#ifndef BAD_INTPTR_T
# define BAD_INTPTR_T ((intptr_t)(-1))
#endif
/*
** We need to provide the necessary structures and related types.
*/
#ifndef DIRENT_DEFINED
#define DIRENT_DEFINED
typedef struct DIRENT DIRENT;
typedef DIRENT *LPDIRENT;
struct DIRENT {
ino_t d_ino; /* Sequence number, do not use. */
unsigned d_attributes; /* Win32 file attributes. */
char d_name[NAME_MAX + 1]; /* Name within the directory. */
};
#endif
#ifndef DIR_DEFINED
#define DIR_DEFINED
typedef struct DIR DIR;
typedef DIR *LPDIR;
struct DIR {
intptr_t d_handle; /* Value returned by "_findfirst". */
DIRENT d_first; /* DIRENT constructed based on "_findfirst". */
DIRENT d_next; /* DIRENT constructed based on "_findnext". */
};
#endif
/*
** Provide a macro, for use by the implementation, to determine if a
** particular directory entry should be skipped over when searching for
** the next directory entry that should be returned by the readdir() or
** readdir_r() functions.
*/
#ifndef is_filtered
# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
#endif
/*
** Provide the function prototype for the POSIX compatiable getenv()
** function. This function is not thread-safe.
*/
extern const char *windirent_getenv(const char *name);
/*
** Finally, we can provide the function prototypes for the opendir(),
** readdir(), readdir_r(), and closedir() POSIX functions.
*/
extern LPDIR opendir(const char *dirname);
extern LPDIRENT readdir(LPDIR dirp);
extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
extern INT closedir(LPDIR dirp);
#endif /* defined(WIN32) && defined(_MSC_VER) */
__version_info__ = ('0', '0', '59')
__version_info__ = ('0', '0', '60')
__version__ = '.'.join(__version_info__)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment