Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update configure, extension.c, app/Makefile #205

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ endif
CFLAGS+= -DUSE_JQ

STATIC_LIB_FLAGS=
ifneq ($(STATIC_LIBS),)
ifeq ($(STATIC_BUILD),1)
STATIC_LIB_FLAGS=${LDFLAGS_STATIC}
else
ifneq ($(STATIC_LIBS),)
STATIC_LIB_FLAGS=${LDFLAGS_STATIC}
endif
endif

STANDALONE_PFX=${BUILD_DIR}/bin/zsv_
Expand Down Expand Up @@ -277,9 +281,10 @@ MORE_SOURCE+= ${YAJL_INCLUDE} ${YAJL_HELPER_INCLUDE} -I${JQ_INCLUDE_DIR}
MORE_LIBS+=${JQ_LIB} ${LDFLAGS_JQ}

help:
@echo "To build: ${MAKE} [DEBUG=1] [clean] [clean-all] [BINDIR=${BINDIR}] [JQ_PREFIX=/usr/local] <install|all|install-util-lib|test>"
@echo "To build: ${MAKE} [DEBUG=1] [STATIC_BUILD=1] [clean] [clean-all] [BINDIR=${BINDIR}] [JQ_PREFIX=/usr/local] <install|all|install-util-lib|test>"
@echo
@echo "If JQ_PREFIX is not defined, libjq will be built in the build dir"
@echo "If STATIC_BUILD is set to 1, will build with -static flag, if the compiler supports it"
@echo
@echo "To build and test individual apps, run:"
@echo " ${MAKE} test"
Expand Down
16 changes: 12 additions & 4 deletions app/ext_example/my_extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ static struct zsv_ext_callbacks zsv_cb;
* but with an additional preceding zsv_execution_context parameter.
* Here, we just declare the functions; we fully define them further below
*/
enum zsv_ext_status count_main(zsv_execution_context ctx, int argc, const char *argv[]);
static enum zsv_ext_status echo_main(zsv_execution_context ctx, int argc, const char *argv[]);
enum zsv_ext_status count_main(zsv_execution_context ctx, int argc, const char *argv[], struct zsv_opts *opts,
const char *opts_used);
static enum zsv_ext_status echo_main(zsv_execution_context ctx, int argc, const char *argv[], struct zsv_opts *opts,
const char *opts_used);

/**
* *Required*. Initialization is called when our extension is loaded. Our
Expand Down Expand Up @@ -166,9 +168,12 @@ static void echo_rowhandler(void *ctx) {
* `ext_xxx` functions. All we do here is initialize our data, call the parser, and
* perform any final steps after all data has been processed
*/
static enum zsv_ext_status echo_main(zsv_execution_context ctx, int argc, const char *argv[]) {
static enum zsv_ext_status echo_main(zsv_execution_context ctx, int argc, const char *argv[], struct zsv_opts *optsp,
const char *opts_used) {
(void)(argc);
(void)(argv);
(void)(optsp);
(void)(opts_used);
/* initialize private data */
struct my_data data;
memset(&data, 0, sizeof(data));
Expand Down Expand Up @@ -236,7 +241,10 @@ static const char *count_help = "count: print the number of rows in a CSV data f
"\n"
"usage: count [-h,--help] [filename]\n";

enum zsv_ext_status count_main(zsv_execution_context ctx, int argc, const char *argv[]) {
enum zsv_ext_status count_main(zsv_execution_context ctx, int argc, const char *argv[], struct zsv_opts *optsp,
const char *opts_used) {
(void)(optsp);
(void)(opts_used);
/* help */
if (argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
printf("%s", count_help);
Expand Down
2 changes: 1 addition & 1 deletion app/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
}

if (argc < 2) {
fprintf(stderr, "TO DO! work with no input file\n");
fprintf(stderr, "Please specify an input file\n");
return 1;
}

Expand Down
14 changes: 10 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ trysharedldflag () {
}

# Beginning of actual script
CROSS_COMPILING=no
if [ "$CROSS_COMPILING" = "" ]; then
CROSS_COMPILING=no
fi
CFLAGS_AUTO=
CFLAGS_TRY=
LDFLAGS_AUTO=
Expand All @@ -261,8 +263,12 @@ if [ "$CONFIGFILE" = "" ]; then
CONFIGFILE=config.mk
fi

if [ "$ARCH" = "" ] && [ "$CROSS_COMPILING" = "no" ]; then
ARCH=native
if [ "$ARCH" = "" ] ; then
if [ "$CROSS_COMPILING" = "no" ]; then
ARCH=native
else
ARCH=none
fi
fi

# check prefixes first, since others may be derived from it unless overridden
Expand Down Expand Up @@ -697,7 +703,7 @@ if [ "$JQ_PREFIX" != "" ] && [ "$CROSS_COMPILING" = "no" ] ; then
if ! tryldflag LDFLAGS_JQ -ljq -L${JQ_PREFIX}/lib ; then
echo "Error: Failed to compile with -ljq and -L${JQ_PREFIX}/lib"
exit 1
else
elif [ "$JQ_PREFIX" != "$PREFIX" ]; then
LDFLAGS_JQ="$LDFLAGS_JQ -L$JQ_PREFIX/lib"
fi
fi
Expand Down