Skip to content

Commit

Permalink
Build windows 64bit binary using UCRT64 (#2832)
Browse files Browse the repository at this point in the history
* Build windows 64bit binary using UCRT64

Is the default and recommended msystem setting. Will produce
binaries that are compatible with windows 10 and later.

Also run tests for 32bit build.

Related to #2831

* Use jq -b in tests/shtest

* Add Windows strptime

* Make Windows-optional tests not run on Windows again

---------

Co-authored-by: Nicolas Williams <[email protected]>
  • Loading branch information
wader and nicowilliams authored Aug 12, 2023
1 parent 5a52553 commit fdab39b
Show file tree
Hide file tree
Showing 6 changed files with 876 additions and 39 deletions.
21 changes: 7 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,16 @@ jobs:
- i386
include:
- arch: amd64
CC: x86_64-pc-msys
toolchain: gcc
msystem: msys
msystem: UCRT64
- arch: i386
CC: i686-w64-mingw32
toolchain: mingw-w64-i686-toolchain
msystem: mingw32
msystem: MINGW32
runs-on: windows-2022
env:
CHOST: ${{ matrix.CC }}
CC: ${{ matrix.CC }}-gcc
LDFLAGS: -s
SUFFIX: windows-${{ matrix.arch }}
defaults:
run:
shell: msys2 {0}
steps:
- name: Clone repository
uses: actions/checkout@v3
Expand All @@ -224,13 +221,12 @@ jobs:
autoconf
automake
libtool
${{ matrix.toolchain }}
pacboy: >-
toolchain:p
- name: Build
shell: msys2 {0}
run: |
autoreconf -i
./configure \
--host=${{ matrix.CC }} \
--disable-docs \
--disable-valgrind \
--with-oniguruma=builtin \
Expand All @@ -242,9 +238,6 @@ jobs:
file ./jq.exe
cp ./jq.exe jq-${{ env.SUFFIX }}.exe
- name: Test
# Only run tests for amd64 matching the CI machine arch
if: ${{ matrix.arch == 'amd64' }}
shell: msys2 {0}
run: |
make check VERBOSE=yes
git diff --exit-code --ignore-submodules
Expand Down
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ endif

### Tests (make check)

TESTS = tests/optionaltest tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test
TESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test
if !WIN32
TESTS += tests/optionaltest
endif
AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq NO_VALGRIND=$(NO_VALGRIND)

# This is a magic make variable that causes it to treat tests/man.test as a
Expand Down
22 changes: 3 additions & 19 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void *alloca (size_t);
#include "locfile.h"
#include "jv_unicode.h"
#include "jv_alloc.h"
#include "util.h"


#define BINOP(name) \
Expand Down Expand Up @@ -1417,25 +1418,6 @@ static void set_tm_yday(struct tm *tm) {
tm->tm_yday = yday;
}

#ifndef HAVE_STRPTIME
static char *strptime(const char *s, const char *format, struct tm *tm) {
if (strcmp(format, "%Y-%m-%dT%H:%M:%SZ"))
return NULL;

int count, end;
count = sscanf(s, "%d-%d-%dT%d:%d:%d%n",
&tm->tm_year, &tm->tm_mon, &tm->tm_mday,
&tm->tm_hour, &tm->tm_min, &tm->tm_sec,
&end );
if (count == 6 && s[end] == 'Z') {
tm->tm_year -= 1900;
tm->tm_mon--;
return (char*)s + end + 1;
}
return NULL;
}
#endif

static jv f_strptime(jq_state *jq, jv a, jv b) {
if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING) {
return ret_error2(a, b, jv_string("strptime/1 requires string inputs and arguments"));
Expand Down Expand Up @@ -1478,6 +1460,8 @@ static jv f_strptime(jq_state *jq, jv a, jv b) {
*/
set_tm_wday(&tm);
set_tm_yday(&tm);
#elif defined(WIN32)
set_tm_wday(&tm);
#else
if (tm.tm_wday == 8 && tm.tm_mday != 0 && tm.tm_mon >= 0 && tm.tm_mon <= 11)
set_tm_wday(&tm);
Expand Down
Loading

0 comments on commit fdab39b

Please sign in to comment.