Skip to content

Commit

Permalink
Add in PREFIX/etc/julia/juliarc.jl file for site-specific commands to…
Browse files Browse the repository at this point in the history
… be run at startup

Lays the groundwork for addressing JuliaLang#4222
  • Loading branch information
staticfloat committed Sep 23, 2013
1 parent 47e9815 commit 7f2c743
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VERSDIR = v`cut -d. -f1-2 < VERSION`
all: default
default: release

DIRS = $(BUILD)/bin $(BUILD)/lib $(BUILD)/share/julia $(BUILD)/share/julia/man/man1
DIRS = $(BUILD)/bin $(BUILD)/etc/julia $(BUILD)/lib $(BUILD)/share/julia $(BUILD)/share/julia/man/man1
ifneq ($(JL_LIBDIR),bin)
ifneq ($(JL_LIBDIR),lib)
DIRS += $(BUILD)/$(JL_LIBDIR)
Expand All @@ -30,7 +30,7 @@ endif
$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,base test doc examples,$(eval $(call symlink_target,$(link),$(BUILD)/share/julia)))

debug release: | $(DIRS) $(BUILD)/share/julia/base $(BUILD)/share/julia/test $(BUILD)/share/julia/doc $(BUILD)/share/julia/examples
debug release: | $(DIRS) $(BUILD)/share/julia/base $(BUILD)/share/julia/test $(BUILD)/share/julia/doc $(BUILD)/share/julia/examples $(BUILD)/etc/julia/juliarc.jl
@$(MAKE) $(QUIET_MAKE) julia-$@
@export JL_PRIVATE_LIBDIR=$(JL_PRIVATE_LIBDIR) && \
$(MAKE) $(QUIET_MAKE) LD_LIBRARY_PATH=$(BUILD)/lib:$(LD_LIBRARY_PATH) JULIA_EXECUTABLE="$(JULIA_EXECUTABLE_$@)" $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji
Expand Down Expand Up @@ -61,6 +61,9 @@ $(BUILD)/share/man/man1/julia.1: doc/man/julia.1 | $(BUILD)/share/julia
@mkdir -p $(BUILD)/share/man/man1
@cp $< $@

$(BUILD)/etc/julia/juliarc.jl: etc/juliarc.jl | $(BUILD)/etc/julia
@cp $< $@

# use sys.ji if it exists, otherwise run two stages
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys0.ji:
@$(QUIET_JULIA) cd base && \
Expand Down Expand Up @@ -156,7 +159,7 @@ PREFIX ?= julia-$(JULIA_COMMIT)
install:
@$(MAKE) $(QUIET_MAKE) debug
@$(MAKE) $(QUIET_MAKE) release
@for subdir in "bin" "libexec" $(JL_LIBDIR) $(JL_PRIVATE_LIBDIR) "share/julia" "share/man/man1" "include/julia" "share/julia/site/"$(VERSDIR) ; do \
@for subdir in "bin" "libexec" $(JL_LIBDIR) $(JL_PRIVATE_LIBDIR) "share/julia" "share/man/man1" "include/julia" "share/julia/site/"$(VERSDIR) "etc/julia" ; do \
mkdir -p $(PREFIX)/$$subdir ; \
done
cp -a $(BUILD)/bin $(PREFIX)
Expand Down Expand Up @@ -187,6 +190,8 @@ ifeq ($(OS), WINNT)
endif
# Copy in beautiful new man page!
cp $(BUILD)/share/man/man1/julia.1 $(PREFIX)/share/man/man1/
# Copy in etc/julia directory for things like juliarc.jl
cp -R $(BUILD)/etc/julia $(PREFIX)/etc/


dist:
Expand Down
9 changes: 7 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function process_options(args::Array{Any,1})
startup = false
elseif args[i] == "-F"
# load juliarc now before processing any more options
try_include(abspath(user_prefdir(),".juliarc.jl"))
load_juliarc()
startup = false
elseif beginswith(args[i], "--color")
if args[i] == "--color"
Expand Down Expand Up @@ -317,6 +317,11 @@ function init_profiler()
Profile.init(1_000_000, 0.001)
end

function load_juliarc()
try_include(abspath(JULIA_HOME,"..","etc","julia","juliarc.jl"))
try_include(abspath(user_prefdir(),".juliarc.jl"))
end


function _start()
# set up standard streams
Expand Down Expand Up @@ -348,7 +353,7 @@ function _start()
any(a->(a=="--worker"), ARGS) || init_head_sched()
init_load_path()
(quiet,repl,startup,color_set) = process_options(ARGS)
repl && startup && try_include(abspath(user_prefdir(),".juliarc.jl"))
repl && startup && load_juliarc()

if repl
if isa(STDIN,File)
Expand Down
3 changes: 3 additions & 0 deletions etc/juliarc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file should contain site-specific commands to be executed on Julia startup
# Users should store their own personal commands in user_prefdir(), in a file named .juliarc.jl

0 comments on commit 7f2c743

Please sign in to comment.