Skip to content

Commit

Permalink
Revert "rename JULIA_HOME/JULIA_HOME => JULIA_BINDIR/Sys.BINDIR [#20899
Browse files Browse the repository at this point in the history
…]"

This reverts commit 6885af8.
  • Loading branch information
StefanKarpinski committed Dec 15, 2017
1 parent 6885af8 commit 5e1418b
Show file tree
Hide file tree
Showing 38 changed files with 90 additions and 93 deletions.
7 changes: 2 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,6 @@ Compiler/Runtime improvements
Deprecated or removed
---------------------

* The `JULIA_HOME` environment variable has been renamed to `JULIA_BINDIR` and
`Base.JULIA_HOME` has been moved to `Sys.BINDIR` ([#20899]).

* The keyword `immutable` is fully deprecated to `struct`, and
`type` is fully deprecated to `mutable struct` ([#19157], [#20418]).

Expand Down Expand Up @@ -616,8 +613,8 @@ Deprecated or removed
`serialize` ([#6466]).

* The default `juliarc.jl` file on Windows has been removed. Now must explicitly include the
full path if you need access to executables or libraries in the `Sys.BINDIR` directory, e.g.
`joinpath(Sys.BINDIR, "7z.exe")` for `7z.exe` ([#21540]).
full path if you need access to executables or libraries in the `JULIA_HOME` directory, e.g.
`joinpath(JULIA_HOME, "7z.exe")` for `7z.exe` ([#21540]).

* `sqrtm` has been deprecated in favor of `sqrt` ([#23504]).

Expand Down
8 changes: 4 additions & 4 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ end

function load_juliarc()
# If the user built us with a specific Base.SYSCONFDIR, check that location first for a juliarc.jl file
# If it is not found, then continue on to the relative path based on Sys.BINDIR
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
include(Main, abspath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
# If it is not found, then continue on to the relative path based on JULIA_HOME
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(JULIA_HOME, Base.SYSCONFDIR, "julia", "juliarc.jl"))
include(Main, abspath(JULIA_HOME, Base.SYSCONFDIR, "julia", "juliarc.jl"))
else
try_include(Main, abspath(Sys.BINDIR, "..", "etc", "julia", "juliarc.jl"))
try_include(Main, abspath(JULIA_HOME, "..", "etc", "julia", "juliarc.jl"))
end
try_include(Main, abspath(homedir(), ".juliarc.jl"))
nothing
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export
C_NULL,
ENDIAN_BOM,
ENV,
JULIA_HOME,
LOAD_PATH,
PROGRAM_FILE,
STDERR,
Expand Down
17 changes: 12 additions & 5 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ code.
const LOAD_PATH = String[]
const LOAD_CACHE_PATH = String[]

function init_load_path(BINDIR = Sys.BINDIR)
function init_load_path(JULIA_HOME = JULIA_HOME)
vers = "v$(VERSION.major).$(VERSION.minor)"
if haskey(ENV, "JULIA_LOAD_PATH")
prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @static Sys.iswindows() ? ';' : ':'))
end
push!(LOAD_PATH, abspath(BINDIR, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(BINDIR, "..", "share", "julia", "site", vers))
#push!(LOAD_CACHE_PATH, abspath(BINDIR, "..", "lib", "julia")) #TODO: add a builtin location?
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "share", "julia", "site", vers))
#push!(LOAD_CACHE_PATH, abspath(JULIA_HOME, "..", "lib", "julia")) #TODO: add a builtin location?
end

function early_init()
eval(Sys, :(const BINDIR = ccall(:jl_get_julia_bindir, Any, ())))
global const JULIA_HOME = ccall(:jl_get_julia_home, Any, ())
# make sure OpenBLAS does not set CPU affinity (#1070, #9639)
ENV["OPENBLAS_MAIN_FREE"] = get(ENV, "OPENBLAS_MAIN_FREE",
get(ENV, "GOTOBLAS_MAIN_FREE", "1"))
Expand All @@ -80,6 +80,13 @@ function early_init()
end
end

"""
JULIA_HOME
A string containing the full path to the directory containing the `julia` executable.
"""
:JULIA_HOME

const atexit_hooks = []

"""
Expand Down
2 changes: 1 addition & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ function runtests(tests = ["all"], numcores = ceil(Int, Sys.CPU_CORES / 2);
ENV2 = copy(ENV)
ENV2["JULIA_CPU_CORES"] = "$numcores"
try
run(setenv(`$(julia_cmd()) $(joinpath(Sys.BINDIR,
run(setenv(`$(julia_cmd()) $(joinpath(JULIA_HOME,
Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2))
catch
buf = PipeBuffer()
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ function __init__()
ENV["SSL_CERT_FILE"]
else
# If we have a bundled ca cert file, point libgit2 at that so SSL connections work.
abspath(ccall(:jl_get_julia_bindir, Any, ()), Base.DATAROOTDIR, "julia", "cert.pem")
abspath(ccall(:jl_get_julia_home, Any, ()), Base.DATAROOTDIR, "julia", "cert.pem")
end
set_ssl_cert_locations(cert_loc)
end
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ end

function find_source_file(path::String)
(isabspath(path) || isfile(path)) && return path
base_path = joinpath(Sys.BINDIR, DATAROOTDIR, "julia", "base", path)
base_path = joinpath(JULIA_HOME, DATAROOTDIR, "julia", "base", path)
return isfile(base_path) ? base_path : nothing
end

Expand Down
2 changes: 1 addition & 1 deletion base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
struct JLOptions
quiet::Int8
banner::Int8
julia_bindir::Ptr{UInt8}
julia_home::Ptr{UInt8}
julia_bin::Ptr{UInt8}
commands::Ptr{Ptr{UInt8}} # (e)eval, (E)print, (L)load
image_file::Ptr{UInt8}
Expand Down
2 changes: 1 addition & 1 deletion base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ include("threadcall.jl")
include("loading.jl")

# set up load path to be able to find stdlib packages
init_load_path(ccall(:jl_get_julia_bindir, Any, ()))
init_load_path(ccall(:jl_get_julia_home, Any, ()))

INCLUDE_STATE = 3 # include = include_relative

Expand Down
10 changes: 1 addition & 9 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module Sys
Provide methods for retrieving information about hardware and the operating system.
""" -> Sys

export BINDIR,
CPU_CORES,
export CPU_CORES,
WORD_SIZE,
ARCH,
MACHINE,
Expand All @@ -27,13 +26,6 @@ export BINDIR,

import ..Base: show

"""
Sys.BINDIR
A string containing the full path to the directory containing the `julia` executable.
"""
:BINDIR

global CPU_CORES
"""
Sys.CPU_CORES
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ println_with_color(color::Union{Int, Symbol}, io::IO, msg...; bold::Bool = false
println_with_color(color::Union{Int, Symbol}, msg...; bold::Bool = false) =
println_with_color(color, STDOUT, msg...; bold = bold)

function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename()))
function julia_cmd(julia=joinpath(JULIA_HOME, julia_exename()))
opts = JLOptions()
cpu_target = unsafe_string(opts.cpu_target)
image_file = unsafe_string(opts.image_file)
Expand Down
6 changes: 3 additions & 3 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function default_sysimg_path(debug=false)
if Sys.isunix()
splitext(Libdl.dlpath(debug ? "sys-debug" : "sys"))[1]
else
joinpath(dirname(Sys.BINDIR), "lib", "julia", debug ? "sys-debug" : "sys")
joinpath(dirname(JULIA_HOME), "lib", "julia", debug ? "sys-debug" : "sys")
end
end

Expand All @@ -17,7 +17,7 @@ end
Rebuild the system image. Store it in `sysimg_path`, which defaults to a file named `sys.ji`
that sits in the same folder as `libjulia.{so,dylib}`, except on Windows where it defaults
to `Sys.BINDIR/../lib/julia/sys.ji`. Use the cpu instruction set given by `cpu_target`.
to `JULIA_HOME/../lib/julia/sys.ji`. Use the cpu instruction set given by `cpu_target`.
Valid CPU targets are the same as for the `-C` option to `julia`, or the `-march` option to
`gcc`. Defaults to `native`, which means to use all CPU instructions available on the
current processor. Include the user image file given by `userimg_path`, which should contain
Expand Down Expand Up @@ -46,7 +46,7 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
# Enter base and setup some useful paths
base_dir = dirname(Base.find_source_file("sysimg.jl"))
cd(base_dir) do
julia = joinpath(Sys.BINDIR, debug ? "julia-debug" : "julia")
julia = joinpath(JULIA_HOME, debug ? "julia-debug" : "julia")
cc, warn_msg = find_system_compiler()

# Ensure we have write-permissions to wherever we're trying to write to
Expand Down
4 changes: 2 additions & 2 deletions contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function libDir()
end
end

private_libDir() = abspath(Sys.BINDIR, Base.PRIVATE_LIBDIR)
private_libDir() = abspath(JULIA_HOME, Base.PRIVATE_LIBDIR)

function includeDir()
return abspath(Sys.BINDIR, Base.INCLUDEDIR, "julia")
return abspath(JULIA_HOME, Base.INCLUDEDIR, "julia")
end

function ldflags()
Expand Down
4 changes: 2 additions & 2 deletions contrib/mac/juliarc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Set up environment for Julia OSX binary distribution
let
ROOT = abspath(Sys.BINDIR,"..")
ENV["PATH"]="$Sys.BINDIR:$(ENV["PATH"])"
ROOT = abspath(JULIA_HOME,"..")
ENV["PATH"]="$JULIA_HOME:$(ENV["PATH"])"
ENV["FONTCONFIG_PATH"] = joinpath(ROOT, "etc", "fonts")
ENV["TK_LIBRARY"] = "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts"
end
2 changes: 1 addition & 1 deletion doc/src/devdocs/sysimg.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ named `build_sysimg.jl` that lives in `DATAROOTDIR/julia/`. That is, to include
Julia session, type:

```julia
include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
```

This will include a `build_sysimg` function:
Expand Down
4 changes: 2 additions & 2 deletions doc/src/manual/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ the above test program `test.c` with `gcc` using:
gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib test.c -ljulia $JULIA_DIR/lib/julia/libstdc++.so.6
```
Then if the environment variable `JULIA_BINDIR` is set to `$JULIA_DIR/bin`, the output `test` program
Then if the environment variable `JULIA_HOME` is set to `$JULIA_DIR/bin`, the output `test` program
can be executed.
Alternatively, look at the `embedding.c` program in the Julia source tree in the `examples/` folder.
Expand Down Expand Up @@ -125,7 +125,7 @@ too, and the makefile can be used to take advantage of that. The above example
use a Makefile:
```
JL_SHARE = $(shell julia -e 'print(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia"))')
JL_SHARE = $(shell julia -e 'print(joinpath(JULIA_HOME,Base.DATAROOTDIR,"julia"))')
CFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
CXXFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
LDFLAGS += $(shell $(JL_SHARE)/julia-config.jl --ldflags)
Expand Down
20 changes: 10 additions & 10 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ those for which `JULIA` appears in the name.

## File locations

### `JULIA_BINDIR`
### `JULIA_HOME`

The absolute path of the directory containing the Julia executable, which sets
the global variable [`Sys.BINDIR`](@ref). If `$JULIA_BINDIR` is not set, then
Julia determines the value `Sys.BINDIR` at run-time.
the global variable [`Base.JULIA_HOME`](@ref). If `$JULIA_HOME` is not set, then
Julia determines the value `Base.JULIA_HOME` at run-time.

The executable itself is one of

```
$JULIA_BINDIR/julia
$JULIA_BINDIR/julia-debug
$JULIA_HOME/julia
$JULIA_HOME/julia-debug
```

by default.

The global variable `Base.DATAROOTDIR` determines a relative path from
`Sys.BINDIR` to the data directory associated with Julia. Then the path
`Base.JULIA_HOME` to the data directory associated with Julia. Then the path

```
$JULIA_BINDIR/$DATAROOTDIR/julia/base
$JULIA_HOME/$DATAROOTDIR/julia/base
```

determines the directory in which Julia initially searches for source files (via
Expand All @@ -45,15 +45,15 @@ Likewise, the global variable `Base.SYSCONFDIR` determines a relative path to th
configuration file directory. Then Julia searches for a `juliarc.jl` file at

```
$JULIA_BINDIR/$SYSCONFDIR/julia/juliarc.jl
$JULIA_BINDIR/../etc/julia/juliarc.jl
$JULIA_HOME/$SYSCONFDIR/julia/juliarc.jl
$JULIA_HOME/../etc/julia/juliarc.jl
```

by default (via `Base.load_juliarc()`).

For example, a Linux installation with a Julia executable located at
`/bin/julia`, a `DATAROOTDIR` of `../share`, and a `SYSCONFDIR` of `../etc` will
have `JULIA_BINDIR` set to `/bin`, a source-file search path of
have `JULIA_HOME` set to `/bin`, a source-file search path of

```
/share/julia/base
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/unicode-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function tab_completions(symbols...)
end
function unicode_data()
file = normpath(Sys.BINDIR, "..", "..", "doc", "UnicodeData.txt")
file = normpath(JULIA_HOME, "..", "..", "doc", "UnicodeData.txt")
names = Dict{UInt32, String}()
open(file) do unidata
for line in readlines(unidata)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/stdlib/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Base.ARGS
Base.C_NULL
Base.VERSION
Base.LOAD_PATH
Base.Sys.BINDIR
Base.JULIA_HOME
Base.Sys.CPU_CORES
Base.Sys.WORD_SIZE
Base.Sys.KERNEL
Expand Down
2 changes: 1 addition & 1 deletion examples/embedding/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
EXE := $(suffix $(abspath $(JULIA)))

# get compiler and linker flags. (see: `contrib/julia-config.jl`)
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
CPPFLAGS_ADD :=
CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags)
LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs)
Expand Down
2 changes: 1 addition & 1 deletion examples/embedding/embedding-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Test

if Sys.iswindows()
# libjulia needs to be in the same directory as the embedding executable or in path
ENV["PATH"] = string(Sys.BINDIR, ";", ENV["PATH"])
ENV["PATH"] = string(JULIA_HOME, ";", ENV["PATH"])
end

@test length(ARGS) == 1
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ extern "C" int isabspath(const char *in);

static void write_log_data(logdata_t &logData, const char *extension)
{
std::string base = std::string(jl_options.julia_bindir);
std::string base = std::string(jl_options.julia_home);
base = base + "/../share/julia/base/";
logdata_t::iterator it = logData.begin();
for (; it != logData.end(); it++) {
Expand Down
2 changes: 1 addition & 1 deletion src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int endswith_extension(const char *path)

#define PATHBUF 512

extern char *julia_bindir;
extern char *julia_home;

#define JL_RTLD(flags, FLAG) (flags & JL_RTLD_ ## FLAG ? RTLD_ ## FLAG : 0)

Expand Down
18 changes: 9 additions & 9 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static char *abspath(const char *in, int nprefix)

static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
{ // this function resolves the paths in jl_options to absolute file locations as needed
// and it replaces the pointers to `julia_bindir`, `julia_bin`, `image_file`, and output file paths
// and it replaces the pointers to `julia_home`, `julia_bin`, `image_file`, and output file paths
// it may fail, print an error, and exit(1) if any of these paths are longer than PATH_MAX
//
// note: if you care about lost memory, you should call the appropriate `free()` function
Expand All @@ -508,22 +508,22 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
jl_options.julia_bin = (char*)malloc(path_size+1);
memcpy((char*)jl_options.julia_bin, free_path, path_size);
((char*)jl_options.julia_bin)[path_size] = '\0';
if (!jl_options.julia_bindir) {
jl_options.julia_bindir = getenv("JULIA_BINDIR");
if (!jl_options.julia_bindir) {
jl_options.julia_bindir = dirname(free_path);
if (!jl_options.julia_home) {
jl_options.julia_home = getenv("JULIA_HOME");
if (!jl_options.julia_home) {
jl_options.julia_home = dirname(free_path);
}
}
if (jl_options.julia_bindir)
jl_options.julia_bindir = abspath(jl_options.julia_bindir, 0);
if (jl_options.julia_home)
jl_options.julia_home = abspath(jl_options.julia_home, 0);
free(free_path);
free_path = NULL;
if (jl_options.image_file) {
if (rel == JL_IMAGE_JULIA_HOME && !isabspath(jl_options.image_file)) {
// build time path, relative to JULIA_BINDIR
// build time path, relative to JULIA_HOME
free_path = (char*)malloc(PATH_MAX);
int n = snprintf(free_path, PATH_MAX, "%s" PATHSEPSTRING "%s",
jl_options.julia_bindir, jl_options.image_file);
jl_options.julia_home, jl_options.image_file);
if (n >= PATH_MAX || n < 0) {
jl_error("fatal error: jl_options.image_file path too long");
}
Expand Down
Loading

0 comments on commit 5e1418b

Please sign in to comment.