Skip to content

Commit

Permalink
update for unix-based cross compiling e.g. w musl (#200)
Browse files Browse the repository at this point in the history
* minor cleanup for code scan

* clang-format app/select.c,select-pull.c

* change .clang-format to explicitly set PointerAlignment to Right

* Use clang-format-15

* Create symlink of clang-format-15

* Cleanup of format script

* Add missing declaration

* Fix "Invalid column index" issue

* Add some CodeQL fixes

* Apply code scanning fix for potential use after free

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Add missing brace

* further minor updates to silence compiler warnings and revert malloc to calloc

* minor format change due to differences in CI clang-format vs mac clang-format 18.1.8

* app/Makefile update for unix-based cross-compilers e.g. musl and to add memmem to zsvutil lib

---------

Co-authored-by: Azeem Sajid <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 78413b8 commit 21a0232
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ ifeq ($(NO_STDIN),1)
endif

CFLAGS+= ${CFLAGS_PIC}

CONFIGURE_HOST=
ifneq ($(HOST),)
CONFIGURE_HOST=$(HOST)
endif
ifeq ($(WIN),0)
BUILD_SUBDIR=$(shell uname)/${DBG_SUBDIR}
EXE=
Expand All @@ -96,17 +101,21 @@ ifeq ($(WIN),0)
CFLAGS_EXE+= -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s PTHREAD_POOL_SIZE=8
endif
endif
CONFIGURE_HOST=
CFLAGS_SETENV=
else
BUILD_SUBDIR=win/${DBG_SUBDIR}
EXE=.exe
CFLAGS+= -D__USE_MINGW_ANSI_STDIO -D_ISOC99_SOURCE
CFLAGS+= -Wl,--strip-all
CONFIGURE_HOST=--host=x86_64-w64-mingw32
CONFIGURE_HOST=x86_64-w64-mingw32
CFLAGS_SETENV=-Dsetenv\(a,b,c\)=_putenv_s\(a,b\)
endif

JQ_CONFIGURE_HOST=
ifneq ($(CONFIGURE_HOST),)
JQ_CONFIGURE_HOST=--host=$(CONFIGURE_HOST)
endif

CFLAGS+=-std=gnu11
CFLAGS+=-Wunused
CFLAGS_O ?=
Expand Down Expand Up @@ -171,6 +180,7 @@ OBJECTS=${UTILS}
ifeq ($(NO_MEMMEM),1)
OBJECTS+= ${BUILD_DIR}/objs/utils/memmem.o
CFLAGS+=-DNO_MEMMEM
UTIL_A_OBJ_WIN=memmem
endif

ZSV=$(BINDIR)/zsv${EXE}
Expand Down Expand Up @@ -284,7 +294,7 @@ ${ZSV_UTIL_A}: ${BUILD_DIR}/objs/utils/util.a
@mkdir -p `dirname $@`
cp -p $< $@

UTIL_A_OBJ:=writer file dirs-no-jq os
UTIL_A_OBJ:=writer file dirs-no-jq os ${UTIL_A_OBJ_WIN}
UTIL_A_OBJ:=$(addprefix ${BUILD_DIR}/objs/utils/,$(addsuffix .o,${UTIL_A_OBJ}))

${BUILD_DIR}/objs/utils/util.a: ${UTIL_A_OBJ}
Expand Down Expand Up @@ -396,7 +406,7 @@ ${JQ_BUNDLE_LIB}: ${JQ_SRC} # -D_REENTRANT needed for clang to not break
--disable-docs \
--disable-shared \
--enable-static \
${CONFIGURE_HOST} \
${JQ_CONFIGURE_HOST} \
&& (${MAKE} install -k)

${JSONWRITER_OBJECT}: ${JSONWRITER_SRC}/jsonwriter.c
Expand Down
1 change: 1 addition & 0 deletions app/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
return zsv_status_ok;
}

int err = 0;
char fixed_auto = 0;
struct zsv_select_data data = {0};
data.opts = opts;
Expand Down

0 comments on commit 21a0232

Please sign in to comment.