Skip to content

Commit 99e466e

Browse files
authored
Merge pull request #17325 from JuliaLang/kf/moveargparse
Move option parsing to libjulia
2 parents 0d1cee7 + 914233e commit 99e466e

File tree

9 files changed

+474
-451
lines changed

9 files changed

+474
-451
lines changed

src/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ SRCS := \
3939
jltypes gf typemap ast builtins module interpreter \
4040
alloc dlload sys init task array dump toplevel jl_uv jlapi signal-handling \
4141
simplevector APInt-C runtime_intrinsics runtime_ccall \
42-
threadgroup threading stackwalk gc gc-debug gc-pages safepoint
42+
threadgroup threading stackwalk gc gc-debug gc-pages safepoint jloptions
43+
44+
ifeq ($(USEMSVC), 1)
45+
SRCS += getopt
46+
endif
4347

4448
LLVMLINK :=
4549

File renamed without changes.
File renamed without changes.

src/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jl_options_t jl_options = { 0, // quiet
8080
NULL, // outputo
8181
NULL, // outputji
8282
0, // incremental
83+
0 // image_file_specified
8384
};
8485

8586
int jl_boot_file_loaded = 0;

src/jloptions.c

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.

src/julia.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,10 +1673,19 @@ typedef struct {
16731673
const char *outputo;
16741674
const char *outputji;
16751675
int8_t incremental;
1676+
int8_t image_file_specified;
16761677
} jl_options_t;
16771678

16781679
extern JL_DLLEXPORT jl_options_t jl_options;
16791680

1681+
// Parse an argc/argv pair to extract general julia options, passing back out
1682+
// any arguments that should be passed on to the script.
1683+
JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp);
1684+
1685+
// Set julia-level ARGS array according to the arguments provided in
1686+
// argc/argv
1687+
JL_DLLEXPORT void jl_set_ARGS(int argc, char **argv);
1688+
16801689
JL_DLLEXPORT int jl_generating_output(void);
16811690

16821691
// Settings for code_coverage and malloc_log

test/cmdlineargs.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
273273
end
274274

275275
# Make sure `julia --lisp` doesn't break
276-
run(pipeline(DevNull, `$(Base.julia_cmd()) --lisp`, DevNull))
276+
run(pipeline(DevNull, `$(joinpath(JULIA_HOME, Base.julia_exename())) --lisp`, DevNull))
277+
278+
# Test that `julia [some other option] --lisp` is disallowed
279+
@test_throws ErrorException run(pipeline(DevNull, pipeline(`$(joinpath(JULIA_HOME, Base.julia_exename())) -Cnative --lisp`, stderr=DevNull), DevNull))
277280

278281
# --precompiled={yes|no}
279282
let exename = `$(Base.julia_cmd())`

ui/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ override CXXFLAGS += $(JCXXFLAGS)
1010
override CPPFLAGS += $(JCPPFLAGS)
1111

1212
SRCS := repl
13-
ifeq ($(USEMSVC), 1)
14-
SRCS += getopt
15-
endif
1613

1714
HEADERS := $(addprefix $(JULIAHOME)/src/,julia.h julia_threads.h julia_internal.h options.h) \
1815
$(BUILDDIR)/../src/julia_version.h $(wildcard $(JULIAHOME)/src/support/*.h) $(LIBUV_INC)/uv.h

0 commit comments

Comments
 (0)