@@ -227,13 +227,12 @@ end
227
227
incomplete_tag (exc:: Meta.ParseError ) = incomplete_tag (exc. detail)
228
228
229
229
cmd_suppresses_program (cmd) = cmd in (' e' , ' E' )
230
+
231
+ # Minimal exec_options for precompilation
230
232
function exec_options (opts)
231
233
quiet = (opts. quiet != 0 )
232
- startup = (opts. startupfile != 2 )
233
- history_file = (opts. historyfile != 0 )
234
- color_set = (opts. color != 0 ) # --color!=auto
235
- global have_color = color_set ? (opts. color == 1 ) : nothing # --color=on
236
- global is_interactive = (opts. isinteractive != 0 )
234
+ global have_color = false
235
+ global is_interactive = false
237
236
238
237
# pre-process command line argument list
239
238
arg_is_program = ! isempty (ARGS )
@@ -245,13 +244,6 @@ function exec_options(opts)
245
244
repl = false
246
245
elseif cmd == ' L'
247
246
# nothing
248
- elseif cmd == ' B' # --bug-report
249
- # If we're doing a bug report, don't load anything else. We will
250
- # spawn a child in which to execute these options.
251
- let InteractiveUtils = load_InteractiveUtils ()
252
- InteractiveUtils. report_bug (arg)
253
- end
254
- return nothing
255
247
else
256
248
@warn " Unexpected command -$cmd '$arg '"
257
249
end
@@ -260,30 +252,6 @@ function exec_options(opts)
260
252
# remove filename from ARGS
261
253
global PROGRAM_FILE = arg_is_program ? popfirst! (ARGS ) : " "
262
254
263
- # Load Distributed module only if any of the Distributed options have been specified.
264
- distributed_mode = (opts. worker == 1 ) || (opts. nprocs > 0 ) || (opts. machine_file != C_NULL )
265
- if distributed_mode
266
- let Distributed = require (PkgId (UUID ((0x8ba89e20_285c_5b6f , 0x9357_94700520ee1b )), " Distributed" ))
267
- Core. eval (Main, :(const Distributed = $ Distributed))
268
- Core. eval (Main, :(using . Distributed))
269
- end
270
-
271
- invokelatest (Main. Distributed. process_opts, opts)
272
- end
273
-
274
- interactiveinput = (repl || is_interactive:: Bool ) && isa (stdin , TTY)
275
- is_interactive:: Bool |= interactiveinput
276
-
277
- # load ~/.julia/config/startup.jl file
278
- if startup
279
- try
280
- load_julia_startup ()
281
- catch
282
- invokelatest (display_error, scrub_repl_backtrace (current_exceptions ()))
283
- ! (repl || is_interactive:: Bool ) && exit (1 )
284
- end
285
- end
286
-
287
255
# process cmds list
288
256
for (cmd, arg) in cmds
289
257
if cmd == ' e'
@@ -292,24 +260,13 @@ function exec_options(opts)
292
260
invokelatest (show, Core. eval (Main, parse_input_line (arg)))
293
261
println ()
294
262
elseif cmd == ' L'
295
- # load file immediately on all processors
296
- if ! distributed_mode
297
- include (Main, arg)
298
- else
299
- # TODO : Move this logic to Distributed and use a callback
300
- @sync for p in invokelatest (Main. procs)
301
- @async invokelatest (Main. remotecall_wait, include, p, Main, arg)
302
- end
303
- end
263
+ include (Main, arg)
304
264
end
305
265
end
306
266
307
267
# load file
308
268
if arg_is_program
309
- # program
310
- if ! is_interactive:: Bool
311
- exit_on_sigint (true )
312
- end
269
+ exit_on_sigint (true )
313
270
try
314
271
if PROGRAM_FILE == " -"
315
272
include_string (Main, read (stdin , String), " stdin" )
@@ -318,52 +275,12 @@ function exec_options(opts)
318
275
end
319
276
catch
320
277
invokelatest (display_error, scrub_repl_backtrace (current_exceptions ()))
321
- if ! is_interactive:: Bool
322
- exit (1 )
323
- end
278
+ exit (1 )
324
279
end
325
280
end
326
- if repl || is_interactive:: Bool
327
- b = opts. banner
328
- auto = b == - 1
329
- banner = b == 0 || (auto && ! interactiveinput) ? :no :
330
- b == 1 || (auto && interactiveinput) ? :yes :
331
- :short # b == 2
332
- run_main_repl (interactiveinput, quiet, banner, history_file, color_set)
333
- end
334
281
nothing
335
282
end
336
283
337
- function _global_julia_startup_file ()
338
- # If the user built us with a specific Base.SYSCONFDIR, check that location first for a startup.jl file
339
- # If it is not found, then continue on to the relative path based on Sys.BINDIR
340
- BINDIR = Sys. BINDIR
341
- SYSCONFDIR = Base. SYSCONFDIR
342
- if ! isempty (SYSCONFDIR)
343
- p1 = abspath (BINDIR, SYSCONFDIR, " julia" , " startup.jl" )
344
- isfile (p1) && return p1
345
- end
346
- p2 = abspath (BINDIR, " .." , " etc" , " julia" , " startup.jl" )
347
- isfile (p2) && return p2
348
- return nothing
349
- end
350
-
351
- function _local_julia_startup_file ()
352
- if ! isempty (DEPOT_PATH )
353
- path = abspath (DEPOT_PATH [1 ], " config" , " startup.jl" )
354
- isfile (path) && return path
355
- end
356
- return nothing
357
- end
358
-
359
- function load_julia_startup ()
360
- global_file = _global_julia_startup_file ()
361
- (global_file != = nothing ) && include (Main, global_file)
362
- local_file = _local_julia_startup_file ()
363
- (local_file != = nothing ) && include (Main, local_file)
364
- return nothing
365
- end
366
-
367
284
const repl_hooks = []
368
285
369
286
"""
@@ -388,96 +305,9 @@ function __atreplinit(repl)
388
305
end
389
306
_atreplinit (repl) = invokelatest (__atreplinit, repl)
390
307
391
- function load_InteractiveUtils (mod:: Module = Main)
392
- # load interactive-only libraries
393
- if ! isdefined (mod, :InteractiveUtils )
394
- try
395
- let InteractiveUtils = require (PkgId (UUID (0xb77e0a4c_d291_57a0_90e8_8db25a27a240 ), " InteractiveUtils" ))
396
- Core. eval (mod, :(const InteractiveUtils = $ InteractiveUtils))
397
- Core. eval (mod, :(using . InteractiveUtils))
398
- return InteractiveUtils
399
- end
400
- catch ex
401
- @warn " Failed to import InteractiveUtils into module $mod " exception= (ex, catch_backtrace ())
402
- end
403
- return nothing
404
- end
405
- return getfield (mod, :InteractiveUtils )
406
- end
407
-
308
+ # set by Client.jl
408
309
global active_repl
409
310
410
- # run the requested sort of evaluation loop on stdio
411
- function run_main_repl (interactive:: Bool , quiet:: Bool , banner:: Symbol , history_file:: Bool , color_set:: Bool )
412
- load_InteractiveUtils ()
413
-
414
- if interactive && isassigned (REPL_MODULE_REF)
415
- invokelatest (REPL_MODULE_REF[]) do REPL
416
- term_env = get (ENV , " TERM" , @static Sys. iswindows () ? " " : " dumb" )
417
- global current_terminfo = load_terminfo (term_env)
418
- term = REPL. Terminals. TTYTerminal (term_env, stdin , stdout , stderr )
419
- banner == :no || Base. banner (term, short= banner== :short )
420
- if term. term_type == " dumb"
421
- repl = REPL. BasicREPL (term)
422
- quiet || @warn " Terminal not fully functional"
423
- else
424
- repl = REPL. LineEditREPL (term, get (stdout , :color , false ), true )
425
- repl. history_file = history_file
426
- end
427
- global active_repl = repl
428
- # Make sure any displays pushed in .julia/config/startup.jl ends up above the
429
- # REPLDisplay
430
- pushdisplay (REPL. REPLDisplay (repl))
431
- _atreplinit (repl)
432
- REPL. run_repl (repl, backend-> (global active_repl_backend = backend))
433
- end
434
- else
435
- # otherwise provide a simple fallback
436
- if interactive && ! quiet
437
- @warn " REPL provider not available: using basic fallback"
438
- end
439
- banner == :no || Base. banner (short= banner== :short )
440
- let input = stdin
441
- if isa (input, File) || isa (input, IOStream)
442
- # for files, we can slurp in the whole thing at once
443
- ex = parse_input_line (read (input, String))
444
- if Meta. isexpr (ex, :toplevel )
445
- # if we get back a list of statements, eval them sequentially
446
- # as if we had parsed them sequentially
447
- for stmt in ex. args
448
- eval_user_input (stderr , stmt, true )
449
- end
450
- body = ex. args
451
- else
452
- eval_user_input (stderr , ex, true )
453
- end
454
- else
455
- while isopen (input) || ! eof (input)
456
- if interactive
457
- print (" julia> " )
458
- flush (stdout )
459
- end
460
- try
461
- line = " "
462
- ex = nothing
463
- while ! eof (input)
464
- line *= readline (input, keep= true )
465
- ex = parse_input_line (line)
466
- if ! (isa (ex, Expr) && ex. head === :incomplete )
467
- break
468
- end
469
- end
470
- eval_user_input (stderr , ex, true )
471
- catch err
472
- isa (err, InterruptException) ? print (" \n\n " ) : rethrow ()
473
- end
474
- end
475
- end
476
- end
477
- end
478
- nothing
479
- end
480
-
481
311
# MainInclude exists to hide Main.include and eval from `names(Main)`.
482
312
baremodule MainInclude
483
313
using .. Base
@@ -549,7 +379,14 @@ function _start()
549
379
# clear any postoutput hooks that were saved in the sysimage
550
380
empty! (Base. postoutput_hooks)
551
381
try
552
- exec_options (JLOptions ())
382
+ if Base. generating_output () || parse (Bool, get (ENV , " JULIA_MINIMAL_CLIENT" , " 0" ))
383
+ exec_options (JLOptions ())
384
+ else
385
+ let Client = require (PkgId (UUID ((0x22d9f1f7_1f08_4fdd , 0xa466_30825a29bd37 )), " Client" ))
386
+ Core. eval (Main, :(const Client = $ Client))
387
+ invokelatest (Client. exec_options, JLOptions ())
388
+ end
389
+ end
553
390
catch
554
391
invokelatest (display_error, scrub_repl_backtrace (current_exceptions ()))
555
392
exit (1 )
0 commit comments