Skip to content

Commit

Permalink
add deprecation warnings for command-line flags
Browse files Browse the repository at this point in the history
fix #16596
  • Loading branch information
vtjnash committed Jun 10, 2016
1 parent e02f85f commit a3fa745
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 39 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,16 @@ BASE_SRCS := $(shell find $(JULIAHOME)/base -name \*.jl)

$(build_private_libdir)/inference.ji: $(CORE_SRCS) | $(build_private_libdir)
@$(call PRINT_JULIA, cd $(JULIAHOME)/base && \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-ji $(call cygpath_w,$@) -f \
coreimg.jl)
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-ji $(call cygpath_w,$@) \
--startup-file=no coreimg.jl)

RELBUILDROOT := $(shell $(JULIAHOME)/contrib/relative_path.sh "$(JULIAHOME)/base" "$(BUILDROOT)/base/")
COMMA:=,
define sysimg_builder
$$(build_private_libdir)/sys$1.o: $$(build_private_libdir)/inference.ji $$(JULIAHOME)/VERSION $$(BASE_SRCS)
@$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \
$$(call spawn,$3) $2 -C $$(JULIA_CPU_TARGET) --output-o $$(call cygpath_w,$$@) $$(JULIA_SYSIMG_BUILD_FLAGS) -f \
-J $$(call cygpath_w,$$<) sysimg.jl $$(RELBUILDROOT) \
$$(call spawn,$3) $2 -C $$(JULIA_CPU_TARGET) --output-o $$(call cygpath_w,$$@) $$(JULIA_SYSIMG_BUILD_FLAGS) \
--startup-file=no --sysimage $$(call cygpath_w,$$<) sysimg.jl $$(RELBUILDROOT) \
|| { echo '*** This error is usually fixed by running `make clean`. If the error persists$$(COMMA) try `make cleanall`. ***' && false; } )
.SECONDARY: $(build_private_libdir)/sys$1.o
endef
Expand Down
4 changes: 0 additions & 4 deletions doc/man/julia.1
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ Evaluate <expr>
-E, --print <expr>
Evaluate and show <expr>

.TP
-P, --post-boot <expr>
Evaluate <expr>, but don't disable interactive mode

.TP
-L, --load <file>
Load <file> immediately on all processors
Expand Down
10 changes: 3 additions & 7 deletions doc/manual/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,10 @@ those available for the ``perl`` and ``ruby`` programs::
--compilecache={yes|no} Enable/disable incremental precompilation of modules
-H, --home <dir> Set location of julia executable
--startup-file={yes|no} Load ~/.juliarc.jl
-f, --no-startup Don't load ~/.juliarc (deprecated, use --startup-file=no)
-F Load ~/.juliarc (deprecated, use --startup-file=yes)
--handle-signals={yes|no} Enable or disable Julia's default signal handlers

-e, --eval <expr> Evaluate <expr>
-E, --print <expr> Evaluate and show <expr>
-P, --post-boot <expr> Evaluate <expr>, but don't disable interactive mode (deprecated, use -i -e instead)
-L, --load <file> Load <file> immediately on all processors

-p, --procs {N|auto} Integer value N launches N additional local worker processes
Expand All @@ -135,11 +132,10 @@ those available for the ``perl`` and ``ruby`` programs::
-q, --quiet Quiet startup (no banner)
--color={yes|no} Enable or disable color text
--history-file={yes|no} Load or save history
--no-history-file Don't load history file (deprecated, use --history-file=no)

--compile={yes|no|all} Enable or disable compiler, or request exhaustive compilation
--compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation
-C, --cpu-target <target> Limit usage of cpu features up to <target>
-O, --optimize Run time-intensive code optimizations
-O, --optimize={0,1,2,3} Set the optimization level (default 2 if unspecified or 3 if specified as -O)
--inline={yes|no} Control whether inlining is permitted (overrides functions declared as @inline)
--check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)
--math-mode={ieee,fast} Disallow or enable unsafe floating point optimizations (overrides @fastmath declaration)
Expand All @@ -149,14 +145,14 @@ those available for the ``perl`` and ``ruby`` programs::
--output-o name Generate an object file (including system image data)
--output-ji name Generate a system image data file (.ji)
--output-bc name Generate LLVM bitcode (.bc)

--output-incremental=no Generate an incremental output file (rather than complete)

--code-coverage={none|user|all}, --code-coverage
Count executions of source lines (omitting setting is equivalent to "user")
--track-allocation={none|user|all}, --track-allocation
Count bytes allocated by each source line


Resources
---------

Expand Down
21 changes: 7 additions & 14 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,22 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
@test !success(`$exename --eval="exit(1)"`)
@test !success(`$exename -e`)
@test !success(`$exename --eval`)
# --eval --interactive (replaced --post-boot)
@test success(`$exename -i -e "exit(0)"`)
@test !success(`$exename -i -e "exit(1)"`)

# --print
@test readstring(`$exename -E "1+1"`) == "2\n"
@test readstring(`$exename --print="1+1"`) == "2\n"
@test !success(`$exename -E`)
@test !success(`$exename --print`)

# --post-boot
@test success(`$exename -P "exit(0)"`)
@test !success(`$exename -P "exit(1)"`)
@test success(`$exename --post-boot="exit(0)"`)
@test !success(`$exename --post-boot="exit(1)"`)
@test !success(`$exename -P`)
@test !success(`$exename --post-boot`)

# --load
let testfile = tempname()
try
write(testfile, "testvar = :test\n")
@test split(readchomp(`$exename --load=$testfile -P "println(testvar)"`), '\n')[end] == "test"
@test split(readchomp(`$exename -P "println(testvar)" -L $testfile`), '\n')[end] == "test"
@test split(readchomp(`$exename -i --load=$testfile -e "println(testvar)"`), '\n')[end] == "test"
@test split(readchomp(`$exename -i -e "println(testvar)" -L $testfile`), '\n')[end] == "test"
finally
rm(testfile)
end
Expand All @@ -66,7 +61,7 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
end

# --procs
@test readchomp(`$exename -q -p 2 -P "println(nworkers()); exit(0)"`) == "2"
@test readchomp(`$exename -q -p 2 -e "println(nworkers())"`) == "2"
@test !success(`$exename -p 0`)
@test !success(`$exename --procs=1.0`)

Expand Down Expand Up @@ -95,8 +90,6 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
# --history-file
@test readchomp(`$exename -E "Bool(Base.JLOptions().historyfile)" --history-file=yes`) == "true"
@test readchomp(`$exename -E "Bool(Base.JLOptions().historyfile)" --history-file=no`) == "false"
# deprecated
@test readchomp(`$exename -E "Bool(Base.JLOptions().historyfile)" --no-history-file`) == "false"
@test !success(`$exename --history-file=false`)

# --startup-file
Expand Down Expand Up @@ -255,7 +248,7 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
# issue #12679
extrapath = is_windows() ? joinpath(JULIA_HOME, "..", "Git", "usr", "bin") * ";" : ""
withenv("PATH" => extrapath * ENV["PATH"]) do
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no --compile=yes -foo`),stderr=`cat`)) == "ERROR: unknown option `-o`"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no --compile=yes -ioo`),stderr=`cat`)) == "ERROR: unknown option `-o`"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no -p`),stderr=`cat`)) == "ERROR: option `-p/--procs` is missing an argument"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no --inline`),stderr=`cat`)) == "ERROR: option `--inline` is missing an argument"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no -e "@show ARGS" -now -- julia RUN.jl`),stderr=`cat`)) == "ERROR: unknown option `-n`"
Expand Down
27 changes: 17 additions & 10 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ static const char opts[] =
" --compilecache={yes|no} Enable/disable incremental precompilation of modules\n"
" -H, --home <dir> Set location of julia executable\n"
" --startup-file={yes|no} Load ~/.juliarc.jl\n"
" -f, --no-startup Don't load ~/.juliarc (deprecated, use --startup-file=no)\n"
" -F Load ~/.juliarc (deprecated, use --startup-file=yes)\n"
" --handle-signals={yes|no} Enable or disable Julia's default signal handlers\n\n"

// actions
" -e, --eval <expr> Evaluate <expr>\n"
" -E, --print <expr> Evaluate and show <expr>\n"
" -P, --post-boot <expr> Evaluate <expr>, but don't disable interactive mode (deprecated, use -i -e instead)\n"
" -L, --load <file> Load <file> immediately on all processors\n\n"

// parallel options
Expand All @@ -81,8 +78,7 @@ static const char opts[] =
" -i Interactive mode; REPL runs and isinteractive() is true\n"
" -q, --quiet Quiet startup (no banner)\n"
" --color={yes|no} Enable or disable color text\n"
" --history-file={yes|no} Load or save history\n"
" --no-history-file Don't load history file (deprecated, use --history-file=no)\n\n"
" --history-file={yes|no} Load or save history\n\n"

// code generation options
" --compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation\n"
Expand All @@ -98,14 +94,20 @@ static const char opts[] =
// compiler output options
" --output-o name Generate an object file (including system image data)\n"
" --output-ji name Generate a system image data file (.ji)\n"
" --output-bc name Generate LLVM bitcode (.bc)\n\n"
" --output-bc name Generate LLVM bitcode (.bc)\n"
" --output-incremental=no Generate an incremental output file (rather than complete)\n\n"

// instrumentation options
" --code-coverage={none|user|all}, --code-coverage\n"
" Count executions of source lines (omitting setting is equivalent to \"user\")\n"
" --track-allocation={none|user|all}, --track-allocation\n"
" Count bytes allocated by each source line\n";
" Count bytes allocated by each source line\n\n"

"Deprecated options:\n"
" -F Load ~/.juliarc (deprecated, use --startup-file=yes)\n"
" -f, --no-startup Don't load ~/.juliarc (deprecated, use --startup-file=no)\n"
" -P, --post-boot <expr> Evaluate <expr>, but don't disable interactive mode (deprecated, use -i -e instead)\n"
" --no-history-file Don't load history file (deprecated, use --history-file=no)\n";

void parse_opts(int *argcp, char ***argvp)
{
Expand Down Expand Up @@ -142,7 +144,6 @@ void parse_opts(int *argcp, char ***argvp)
{ "home", required_argument, 0, 'H' },
{ "eval", required_argument, 0, 'e' },
{ "print", required_argument, 0, 'E' },
{ "post-boot", required_argument, 0, 'P' },
{ "load", required_argument, 0, 'L' },
{ "sysimage", required_argument, 0, 'J' },
{ "precompiled", required_argument, 0, opt_use_precompiled },
Expand All @@ -152,9 +153,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "machinefile", required_argument, 0, opt_machinefile },
{ "color", required_argument, 0, opt_color },
{ "history-file", required_argument, 0, opt_history_file },
{ "no-history-file", no_argument, 0, opt_no_history_file }, // deprecated
{ "startup-file", required_argument, 0, opt_startup_file },
{ "no-startup", no_argument, 0, 'f' }, // deprecated
{ "compile", required_argument, 0, opt_compile },
{ "code-coverage", optional_argument, 0, opt_code_coverage },
{ "track-allocation",optional_argument, 0, opt_track_allocation },
Expand All @@ -172,6 +171,10 @@ void parse_opts(int *argcp, char ***argvp)
{ "worker", required_argument, 0, opt_worker },
{ "bind-to", required_argument, 0, opt_bind_to },
{ "lisp", no_argument, &lisp_prompt, 1 },
// deprecated options
{ "post-boot", required_argument, 0, 'P' },
{ "no-history-file", no_argument, 0, opt_no_history_file }, // deprecated
{ "no-startup", no_argument, 0, 'f' }, // deprecated
{ 0, 0, 0, 0 }
};
// getopt handles argument parsing up to -- delineator
Expand Down Expand Up @@ -236,6 +239,7 @@ void parse_opts(int *argcp, char ***argvp)
jl_options.print = strdup(optarg);
break;
case 'P': // post-boot
jl_printf(JL_STDOUT, "WARNING: julia -P/--post-boot option is deprecated, use -i -e instead.\n");
jl_options.postboot = strdup(optarg);
break;
case 'L': // load
Expand Down Expand Up @@ -296,6 +300,7 @@ void parse_opts(int *argcp, char ***argvp)
jl_errorf("julia: invalid argument to --history-file={yes|no} (%s)", optarg);
break;
case opt_no_history_file:
jl_printf(JL_STDOUT, "WARNING: julia --no-history-file option is deprecated, use --history-file=no instead.\n");
jl_options.historyfile = JL_OPTIONS_HISTORYFILE_OFF;
break;
case opt_startup_file:
Expand All @@ -307,9 +312,11 @@ void parse_opts(int *argcp, char ***argvp)
jl_errorf("julia: invalid argument to --startup-file={yes|no} (%s)", optarg);
break;
case 'f':
jl_printf(JL_STDOUT, "WARNING: julia -f/--no-startup option is deprecated, use --startup-file=no instead.\n");
jl_options.startupfile = JL_OPTIONS_STARTUPFILE_OFF;
break;
case 'F':
jl_printf(JL_STDOUT, "WARNING: julia -F option is deprecated, use --startup-file=yes instead.\n");
jl_options.startupfile = JL_OPTIONS_STARTUPFILE_ON;
break;
case opt_compile:
Expand Down

0 comments on commit a3fa745

Please sign in to comment.