Skip to content

Commit

Permalink
build: uuid - disable uuidv7 for 32-bit windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Jun 12, 2024
1 parent 130ec1d commit 9cacec1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ jobs:
make compile-linux
make test-all
- name: Install MSYS2 and 'mingw-w64-i686-toolchain'
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
cache: true
install: mingw-w64-i686-toolchain
update: true

- name: Build for Windows
if: matrix.os == 'windows-latest'
shell: bash
run: make compile-windows
run: |
$RUNNER_TEMP/msys64/msys2_shell.cmd -defterm -no-start -mingw32 -lc "mingw32-make compile-windows-x86"
make compile-windows
- name: Build for macOS
if: matrix.os == 'macos-latest'
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ compile-windows-x86:
gcc -O3 $(WINDO_FLAGS) src/sqlite3-stats.c src/stats/*.c -o dist/x86/stats.dll -lm
gcc -O3 $(WINDO_FLAGS) src/sqlite3-text.c src/text/*.c -o dist/x86/text.dll
gcc -O3 $(WINDO_FLAGS) src/sqlite3-unicode.c src/unicode/*.c -o dist/x86/unicode.dll
gcc -O3 $(WINDO_FLAGS) src/sqlite3-uuid.c src/uuid/*.c -o dist/x86/uuid.dll
gcc -O3 $(WINDO_FLAGS) src/sqlite3-vsv.c src/vsv/*.c -o dist/x86/vsv.dll -lm
gcc -O1 $(WINDO_FLAGS) -include src/regexp/constants.h src/sqlite3-sqlean.c src/crypto/*.c src/define/*.c src/fileio/*.c src/fuzzy/*.c src/math/*.c src/regexp/*.c src/regexp/pcre2/*.c src/stats/*.c src/text/*.c src/unicode/*.c src/vsv/*.c -o dist/x86/sqlean.dll -lm
gcc -O1 $(WINDO_FLAGS) -include src/regexp/constants.h src/sqlite3-sqlean.c src/crypto/*.c src/define/*.c src/fileio/*.c src/fuzzy/*.c src/math/*.c src/regexp/*.c src/regexp/pcre2/*.c src/stats/*.c src/text/*.c src/unicode/*.c src/uuid/*.c src/vsv/*.c -o dist/x86/sqlean.dll -lm

pack-windows:
7z a -tzip dist/sqlean-win-x86.zip ./dist/x86/*.dll
Expand Down
9 changes: 8 additions & 1 deletion src/uuid/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ static void uuid_v4_generate(sqlite3_context* context, int argc, sqlite3_value**
sqlite3_result_text(context, (char*)zStr, 36, SQLITE_TRANSIENT);
}

// Time functions are not available on Windows 32-bit.
#if !defined(_WIN32) || defined(_WIN64)
/*
* uuid_v7_generate generates a version 7 UUID as a string
*/
Expand Down Expand Up @@ -226,6 +228,8 @@ static void uuid_v7_extract_timestamp_ms(sqlite3_context* context, int argc, sql
sqlite3_result_int64(context, timestampMs);
}

#endif

/*
* uuid_str converts a UUID X into a well-formed UUID string.
* X can be either a string or a blob.
Expand Down Expand Up @@ -260,8 +264,11 @@ int uuid_init(sqlite3* db) {
static const int flags = SQLITE_UTF8 | SQLITE_INNOCUOUS;
static const int det_flags = SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC;
sqlite3_create_function(db, "uuid4", 0, flags, 0, uuid_v4_generate, 0, 0);
#if !defined(_WIN32) || defined(_WIN64)
sqlite3_create_function(db, "uuid7", 0, flags, 0, uuid_v7_generate, 0, 0);
sqlite3_create_function(db, "uuid7_timestamp_ms", 1, det_flags, 0, uuid_v7_extract_timestamp_ms, 0, 0);
sqlite3_create_function(db, "uuid7_timestamp_ms", 1, det_flags, 0, uuid_v7_extract_timestamp_ms,
0, 0);
#endif
/* for postgresql compatibility */
sqlite3_create_function(db, "gen_random_uuid", 0, flags, 0, uuid_v4_generate, 0, 0);
sqlite3_create_function(db, "uuid_str", 1, det_flags, 0, uuid_str, 0, 0);
Expand Down

0 comments on commit 9cacec1

Please sign in to comment.