Skip to content

Commit

Permalink
setting the home project: --project command-line option
Browse files Browse the repository at this point in the history
modified version of #27798
  • Loading branch information
fredrikekre authored and StefanKarpinski committed Jun 29, 2018
1 parent 2549e22 commit 955a950
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ function init_load_path()
paths = filter!(env -> env !== nothing,
[env == "@" ? current_project() : env for env in DEFAULT_LOAD_PATH])
end
project = get(ENV, "JULIA_PROJECT", nothing)
project = (JLOptions().project != C_NULL ?
unsafe_string(Base.JLOptions().project) :
get(ENV, "JULIA_PROJECT", nothing))
HOME_PROJECT[] =
project == "" ? nothing :
project == "@" ? current_project() : project
Expand Down
1 change: 1 addition & 0 deletions base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct JLOptions
cpu_target::Ptr{UInt8}
nprocs::Int32
machine_file::Ptr{UInt8}
project::Ptr{UInt8}
isinteractive::Int8
color::Int8
historyfile::Int8
Expand Down
6 changes: 6 additions & 0 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jl_options_t jl_options = { 0, // quiet
-1, // banner
NULL, // julia_bindir
NULL, // julia_bin
NULL, // project

This comment has been minimized.

Copy link
@Keno

Keno Jun 30, 2018

Member

This seems to be in the wrong place. cc @StefanKarpinski @fredrikekre

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Jul 1, 2018

Member

Sorry, I should have checked before cherry-picking!

NULL, // cmds
NULL, // image_file (will be filled in below)
NULL, // cpu_target ("native", "core2", etc...)
Expand Down Expand Up @@ -171,6 +172,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_sysimage_native_code,
opt_compiled_modules,
opt_machine_file,
opt_project,
};
static const char* const shortopts = "+vhqH:e:E:L:J:C:ip:O:g:";
static const struct option longopts[] = {
Expand All @@ -194,6 +196,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
{ "procs", required_argument, 0, 'p' },
{ "machinefile", required_argument, 0, opt_machinefile }, // deprecated
{ "machine-file", required_argument, 0, opt_machine_file },
{ "project", optional_argument, 0, opt_project },
{ "color", required_argument, 0, opt_color },
{ "history-file", required_argument, 0, opt_history_file },
{ "startup-file", required_argument, 0, opt_startup_file },
Expand Down Expand Up @@ -399,6 +402,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
if (!jl_options.machine_file)
jl_error("julia: failed to allocate memory");
break;
case opt_project:
jl_options.project = optarg ? strdup(optarg) : "@";
break;
case opt_color:
if (!strcmp(optarg, "yes"))
jl_options.color = JL_OPTIONS_COLOR_ON;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,7 @@ typedef struct {
const char *cpu_target;
int32_t nprocs;
const char *machine_file;
const char *project;
int8_t isinteractive;
int8_t color;
int8_t historyfile;
Expand Down

0 comments on commit 955a950

Please sign in to comment.