Add --config option printing ./configure options used
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Nicolas Williams · committed by Nico Williams · parent 7d64381 · Browse files · 4 files·+56 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+56 added−4 removed
- other:+56 added−4 removed
Provenance
- Commit
583e4a2- Tree
fba0bc0- Author
Nicolas Williams <nico@cryptonector.com>- Committer
Nico Williams <nico@cryptonector.com>- Parent
7d64381
4 files changed+56 added−4 removed
modified:docs/content/manual/manual.yml+19 added
299 unmodified lines300 * `--version` / `-V`:301 302 Output the jq version and exit with zero.303 304+ * `--build-configuration`:305+306+ Output the build configuration of jq and exit with zero.307+ This output has no supported format or structure and may change308+ without notice in future releases.309+310 * `--help` / `-h`:311 312 Output the jq help and exit with zero.313 1659 unmodified lines1973 input: '[ { "_a": { "__b": 2 } } ]'1974 output:1975 - '[{"a":{"b":2}}]'1976 1977+ - title: "`$JQ_BUILD_CONFIGURATION`"1978+ body: |1979+1980+ This builtin binding shows the jq executable's build1981+ configuration. Its value has no particular format, but1982+ it can be expected to be at least the `./configure`1983+ command-line arguments, and may be enriched in the1984+ future to include the version strings for the build1985+ tooling used.1986+1987+ Note that this can be overriden in the command-line1988+ with `--arg` and related options.1989+1990 - title: "`$ENV`, `env`"1991 body: |1992 1993 `$ENV` is an object representing the environment variables as1709 unmodified linesmodified:src/main.c+15 added
31 unmodified lines32 #include "jq.h"33 #include "jv_alloc.h"34 #include "util.h"35 #include "src/version.h"36+#include "src/config_opts.inc"37 38 int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);39 40 static const char* progname;65 unmodified lines106 #ifdef WIN32107 " -b, --binary open input/output streams in binary mode;\n"108 #endif109 " -V, --version show the version;\n"110+ " --build-configuration show jq's build configuration;\n"111 " -h, --help show the help;\n"112 " -- terminates argument processing;\n\n"113 "Named arguments are also available as $ARGS.named[], while\n"114 "positional arguments are available as $ARGS.positional[].\n");466 unmodified lines581 printf("jq-%s\n", JQ_VERSION);582 ret = JQ_OK;583 goto out;584 }585+ if (isoption(argv[i], 0, "build-configuration", &short_opts)) {586+ printf("%s\n", JQ_CONFIG);587+ ret = JQ_OK;588+ goto out;589+ }590 if (isoption(argv[i], 0, "run-tests", &short_opts)) {591 i++;592 // XXX Pass program_arguments, even a whole jq_state *, through;593 // could be useful for testing89 unmodified lines683 jq_set_attr(jq, jv_string("PROGRAM_ORIGIN"), jq_realpath(jv_string(dirname(program_origin))));684 ARGS = JV_OBJECT(jv_string("positional"), ARGS,685 jv_string("named"), jv_copy(program_arguments));686 program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));687+ if (!jv_object_has(jv_copy(program_arguments), jv_string("JQ_BUILD_CONFIGURATION")))688+ program_arguments = jv_object_set(program_arguments,689+ jv_string("JQ_BUILD_CONFIGURATION"),690+ jv_string(JQ_CONFIG)); /* named arguments */691 compiled = jq_compile_args(jq, skip_shebang(jv_string_value(data)), jv_copy(program_arguments));692 free(program_origin);693 jv_free(data);694 } else {695 jq_set_attr(jq, jv_string("PROGRAM_ORIGIN"), jq_realpath(jv_string("."))); // XXX is this good?696 ARGS = JV_OBJECT(jv_string("positional"), ARGS,697 jv_string("named"), jv_copy(program_arguments));698 program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));699+ if (!jv_object_has(jv_copy(program_arguments), jv_string("JQ_BUILD_CONFIGURATION")))700+ program_arguments = jv_object_set(program_arguments,701+ jv_string("JQ_BUILD_CONFIGURATION"),702+ jv_string(JQ_CONFIG)); /* named arguments */703 compiled = jq_compile_args(jq, program, jv_copy(program_arguments));704 }705 if (!compiled){706 ret = JQ_ERROR_COMPILE;84 unmodified linesmodified:jq.1.prebuilt+12 added
233 unmodified lines234 .IP235 Output the jq version and exit with zero\.236 .237 .TP238+\fB\-\-build\-configuration\fR:239+.240+.IP241+Output the build configuration of jq and exit with zero\. This output has no supported format or structure and may change without notice in future releases\.242+.243+.TP244 \fB\-\-help\fR / \fB\-h\fR:245 .246 .IP247 Output the jq help and exit with zero\.1903 unmodified lines2151 .fi2152 .2153 .IP "" 02154 .2155+.SS "$JQ_BUILD_CONFIGURATION"2156+This builtin binding shows the jq executable\'s build configuration\. Its value has no particular format, but it can be expected to be at least the \fB\./configure\fR command\-line arguments, and may be enriched in the future to include the version strings for the build tooling used\.2157+.2158+.P2159+Note that this can be overriden in the command\-line with \fB\-\-arg\fR and related options\.2160+.2161 .SS "$ENV, env"2162 \fB$ENV\fR is an object representing the environment variables as set when the jq program started\.2163 .2164 .P1965 unmodified linesmodified:Makefile.am+10 added-4 removed
31 unmodified lines32 # While there is some autoconf macro support for lex/flex, it doesn't support33 # header file creation so we'll use good old make34 if MAINTAINER_MODE35 BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \36- src/builtin.inc src/version.h36+ src/builtin.inc src/config_opts.inc src/version.h37 src/lexer.c: src/lexer.l38 $(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<39 src/lexer.h: src/lexer.c40 else41-BUILT_SOURCES = src/builtin.inc src/version.h41+BUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h42 .y.c:43 $(AM_V_YACC) echo "NOT building parser.c!"44 .l.c:45 $(AM_V_LEX) echo "NOT building lexer.c!"62 unmodified lines108 @ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h109 src/version.h: .remake-version-h110 mkdir -p src111 $(AM_V_GEN) $(generate_ver); echo "$$ver" > $@112-src/main.c: src/version.h112+src/config_opts.inc:113+ mkdir -p src114+ $(AM_V_GEN) if test -x ./config.status; then \115+ ./config.status --config; \116+ else echo "(unknown)"; \117+ fi | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' -e 's/^/#define JQ_CONFIG /' > $@118+src/main.c: src/version.h src/config_opts.inc119 120 src/builtin.inc: $(srcdir)/src/builtin.jq121 mkdir -p src122 $(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $(srcdir)/src/builtin.jq > $@123 src/builtin.o: src/builtin.inc124 119-CLEANFILES = src/version.h .remake-version-h src/builtin.inc125+CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc126 127 bin_PROGRAMS = jq128 jq_SOURCES = src/main.c src/version.h129 jq_LDFLAGS = -static-libtool-libs124 unmodified lines