diff --git a/base/Makefile b/base/Makefile index 34791f7b4b0d4..7301ebbd268c7 100644 --- a/base/Makefile +++ b/base/Makefile @@ -71,6 +71,7 @@ endif @printf "%s\n" "const PRIVATE_LIBDIR = "$(call shell_escape,$(call julia_escape,$(call normalize_path,$(private_libdir_rel)))) >> $@ @printf "%s\n" "const PRIVATE_LIBEXECDIR = "$(call shell_escape,$(call julia_escape,$(call normalize_path,$(private_libexecdir_rel)))) >> $@ @printf "%s\n" "const INCLUDEDIR = "$(call shell_escape,$(call julia_escape,$(call normalize_path,$(includedir_rel)))) >> $@ + @printf "%s\n" "const SOURCEDIR = "$(call shell_escape,$(call julia_escape,$(call normalize_path,$(shell echo $(call cygpath_w,$(JULIAHOME)))))) >> $@ ifeq ($(DARWIN_FRAMEWORK), 1) @printf "%s\n" "const DARWIN_FRAMEWORK = true" >> $@ @printf "%s\n" "const DARWIN_FRAMEWORK_NAME = \"$(FRAMEWORK_NAME)\"" >> $@ diff --git a/base/initdefs.jl b/base/initdefs.jl index 2c9ded9c4033e..d17c7e9e1e02b 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -97,7 +97,7 @@ const DEPOT_PATH = String[] function append_bundled_depot_path!(DEPOT_PATH) path = abspath(Sys.BINDIR, "..", "local", "share", "julia") path in DEPOT_PATH || push!(DEPOT_PATH, path) - path = abspath(Sys.BINDIR, "..", "share", "julia") + path = abspath(Sys.BINDIR, Base.DATAROOTDIR, "julia") path in DEPOT_PATH || push!(DEPOT_PATH, path) return DEPOT_PATH end diff --git a/base/methodshow.jl b/base/methodshow.jl index 075fcb2e891b6..1cf9195ddfebb 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -140,7 +140,7 @@ function fixup_stdlib_path(path::String) if isdefined(@__MODULE__, :Core) && isdefined(Core, :Compiler) compiler_folder = dirname(String(Base.moduleloc(Core.Compiler).file)) if dirname(path) == compiler_folder - return abspath(Sys.STDLIB, "..", "..", "Compiler", "src", basename(path)) + return abspath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "Compiler", "src", basename(path)) end end end diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 5b0d60a406b2f..b77c312e3f2c9 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -42,7 +42,7 @@ export BINDIR, which, detectwsl -import ..Base: show +import ..Base: DATAROOTDIR, show """ Sys.BINDIR::String @@ -56,12 +56,10 @@ global BINDIR::String = ccall(:jl_get_julia_bindir, Any, ())::String A string containing the full path to the directory containing the `stdlib` packages. """ -global STDLIB::String = "$BINDIR/../share/julia/stdlib/v$(VERSION.major).$(VERSION.minor)" # for bootstrap +global STDLIB::String = "$BINDIR/$DATAROOTDIR/julia/stdlib/v$(VERSION.major).$(VERSION.minor)" # for bootstrap # In case STDLIB change after julia is built, the variable below can be used # to update cached method locations to updated ones. const BUILD_STDLIB_PATH = STDLIB -# Similarly, this is the root of the julia repo directory that julia was built from -const BUILD_ROOT_PATH = "$BINDIR/../.." # helper to avoid triggering precompile warnings @@ -200,7 +198,7 @@ end function __init_build() global BINDIR = ccall(:jl_get_julia_bindir, Any, ())::String vers = "v$(string(VERSION.major)).$(string(VERSION.minor))" - global STDLIB = abspath(BINDIR, "..", "share", "julia", "stdlib", vers) + global STDLIB = abspath(BINDIR, DATAROOTDIR, "julia", "stdlib", vers) nothing end diff --git a/doc/make.jl b/doc/make.jl index 2604c801f19aa..9a2c2146b3d1b 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -25,7 +25,7 @@ end documenter_project_dir = joinpath(@__DIR__, "..", "deps", "jlutilities", "documenter") empty!(DEPOT_PATH) push!(DEPOT_PATH, joinpath(buildroot, "deps", "jlutilities", "depot")) -push!(DEPOT_PATH, abspath(Sys.BINDIR, "..", "share", "julia")) +push!(DEPOT_PATH, abspath(Sys.BINDIR, Base.DATAROOTDIR, "julia")) using Pkg Pkg.activate(documenter_project_dir) Pkg.instantiate() diff --git a/doc/src/devdocs/EscapeAnalysis.md b/doc/src/devdocs/EscapeAnalysis.md index d8efd759fa131..9c568541ab7c0 100644 --- a/doc/src/devdocs/EscapeAnalysis.md +++ b/doc/src/devdocs/EscapeAnalysis.md @@ -22,7 +22,7 @@ defines the convenience entries `code_escapes` and `@code_escapes` for testing a ```@repl EAUtils # InteractiveUtils.@activate Compiler # to use the stdlib version of the Compiler -let JULIA_DIR = normpath(Sys.BINDIR, "..", "share", "julia") +let JULIA_DIR = normpath(Sys.BINDIR, Base.DATAROOTDIR, "julia") include(normpath(JULIA_DIR, "Compiler", "test", "EAUtils.jl")) using .EAUtils end diff --git a/stdlib/CRC32c/test/runtests.jl b/stdlib/CRC32c/test/runtests.jl index 37b447e6d999a..f4097a919c7bb 100644 --- a/stdlib/CRC32c/test/runtests.jl +++ b/stdlib/CRC32c/test/runtests.jl @@ -3,7 +3,7 @@ using Test, Random using CRC32c -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl")) using .Main.OffsetArrays: Origin diff --git a/stdlib/Dates/test/io.jl b/stdlib/Dates/test/io.jl index 98bc610784477..8159b33574bd5 100644 --- a/stdlib/Dates/test/io.jl +++ b/stdlib/Dates/test/io.jl @@ -5,7 +5,7 @@ module IOTests using Test using Dates -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") include(joinpath(BASE_TEST_PATH, "testhelpers", "withlocales.jl")) @testset "string/show representation of Date" begin diff --git a/stdlib/LibGit2/test/libgit2-tests.jl b/stdlib/LibGit2/test/libgit2-tests.jl index af551552bd43f..4e56280024547 100644 --- a/stdlib/LibGit2/test/libgit2-tests.jl +++ b/stdlib/LibGit2/test/libgit2-tests.jl @@ -7,7 +7,7 @@ using LibGit2_jll using Test using Random, Serialization, Sockets -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :ChallengePrompts) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ChallengePrompts.jl")) using .Main.ChallengePrompts: challenge_prompt as basic_challenge_prompt diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 3054c9778e68d..7c7e220a6c5bc 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -538,8 +538,7 @@ function flatten(data::Vector, lidict::LineInfoDict) return (newdata, newdict) end -const SRC_DIR = normpath(joinpath(Sys.BUILD_ROOT_PATH, "src")) -const COMPILER_DIR = "../usr/share/julia/Compiler/" +const SRC_DIR = normpath(Base.SOURCEDIR, "src") # Take a file-system path and try to form a concise representation of it # based on the package ecosystem @@ -548,17 +547,18 @@ function short_path(spath::Symbol, filenamecache::Dict{Symbol, Tuple{String,Stri return get!(filenamecache, spath) do path = Base.fixup_stdlib_path(string(spath)) path_norm = normpath(path) - possible_base_path = normpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base", path)) + possible_base_path = normpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base", path) lib_dir = abspath(Sys.BINDIR, Base.LIBDIR) + compiler_dir = normpath(Base.DATAROOT, "julia", "Compiler/") if startswith(path_norm, SRC_DIR) remainder = only(split(path_norm, SRC_DIR, keepempty=false)) return (isfile(path_norm) ? path_norm : ""), "@juliasrc", remainder elseif startswith(path_norm, lib_dir) remainder = only(split(path_norm, lib_dir, keepempty=false)) return (isfile(path_norm) ? path_norm : ""), "@julialib", remainder - elseif contains(path, COMPILER_DIR) - remainder = split(path, COMPILER_DIR, keepempty=false)[end] - possible_compiler_path = normpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "Compiler", remainder)) + elseif startswith(path_norm, compiler_dir) + remainder = split(path_norm, compiler_dir, keepempty=false)[end] + possible_compiler_path = normpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "Compiler", remainder) return (isfile(possible_compiler_path) ? possible_compiler_path : ""), "@Compiler", remainder elseif isabspath(path) if ispath(path) @@ -586,11 +586,10 @@ function short_path(spath::Symbol, filenamecache::Dict{Symbol, Tuple{String,Stri elseif isfile(possible_base_path) # do the same mechanic for Base (or Core/Compiler) files as above, # but they start from a relative path - return possible_base_path, "@Base", normpath(path) + return possible_base_path, "@Base", path_norm else # for non-existent relative paths (such as "REPL[1]"), just consider simplifying them - path = normpath(path) - return "", "", path # drop leading "./" + return "", "", path_norm # drop leading "./" end end end diff --git a/stdlib/REPL/src/precompile.jl b/stdlib/REPL/src/precompile.jl index 84e533b94cb19..9d925a7c3a0f9 100644 --- a/stdlib/REPL/src/precompile.jl +++ b/stdlib/REPL/src/precompile.jl @@ -7,7 +7,7 @@ import ..REPL # Ugly hack for our cache file to not have a dependency edge on the FakePTYs file. Base._track_dependencies[] = false try - Base.include(@__MODULE__, joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testhelpers", "FakePTYs.jl")) + Base.include(@__MODULE__, joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "testhelpers", "FakePTYs.jl")) @Core.latestworld import .FakePTYs: open_fake_pty finally diff --git a/stdlib/REPL/test/bad_history_startup.jl b/stdlib/REPL/test/bad_history_startup.jl index 54ec779a9f39f..27e03cdc2da74 100644 --- a/stdlib/REPL/test/bad_history_startup.jl +++ b/stdlib/REPL/test/bad_history_startup.jl @@ -4,7 +4,7 @@ using Test -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl")) import .Main.FakePTYs: with_fake_pty diff --git a/stdlib/REPL/test/precompilation.jl b/stdlib/REPL/test/precompilation.jl index bc3eda15eae61..57b6b27be6e7c 100644 --- a/stdlib/REPL/test/precompilation.jl +++ b/stdlib/REPL/test/precompilation.jl @@ -2,7 +2,7 @@ ## Tests that compilation in the interactive session startup are as expected using Test -Base.include(@__MODULE__, joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testhelpers", "FakePTYs.jl")) +Base.include(@__MODULE__, joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "testhelpers", "FakePTYs.jl")) import .FakePTYs: open_fake_pty if !Sys.iswindows() diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 699e6e6bec420..b93c3371306b6 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -11,7 +11,7 @@ empty!(Base.Experimental._hint_handlers) # unregister error hints so they can be @test Base.REPL_MODULE_REF[] === REPL -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl")) import .Main.FakePTYs: with_fake_pty diff --git a/stdlib/Random/test/runtests.jl b/stdlib/Random/test/runtests.jl index 6403fbfe958c3..55cbf02f6ad9d 100644 --- a/stdlib/Random/test/runtests.jl +++ b/stdlib/Random/test/runtests.jl @@ -3,7 +3,7 @@ using Test, SparseArrays using Test: guardseed -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl")) using .Main.OffsetArrays diff --git a/stdlib/SharedArrays/test/runtests.jl b/stdlib/SharedArrays/test/runtests.jl index 84dffafb3d92a..1d4bd81e4b75f 100644 --- a/stdlib/SharedArrays/test/runtests.jl +++ b/stdlib/SharedArrays/test/runtests.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license using Test, Distributed, SharedArrays, Random -include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) +include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "testenv.jl")) # These processes explicitly want to share memory, we can't have # them in separate rr sessions diff --git a/test/buildkitetestjson.jl b/test/buildkitetestjson.jl index f0771e9c005d0..48a4144a3dc53 100644 --- a/test/buildkitetestjson.jl +++ b/test/buildkitetestjson.jl @@ -88,14 +88,14 @@ end # to be able to identify the file. Also convert Windows-style paths to Unix-style paths so tests can # be grouped by file. const generalize_file_paths_cache = Dict{AbstractString,AbstractString}() -const norm_build_root_path = normpath(Sys.BUILD_ROOT_PATH) +const norm_sourcedir = normpath(Base.SOURCEDIR) const bindir_dir = dirname(Sys.BINDIR) const pathsep = Sys.iswindows() ? '\\' : '/' function generalize_file_paths(path::AbstractString) return get!(generalize_file_paths_cache, path) do path = replace(path, Sys.STDLIB => "stdlib", - string(norm_build_root_path, pathsep) => "", + string(norm_sourcedir, pathsep) => "", string(bindir_dir, pathsep) => "" ) @static if Sys.iswindows() diff --git a/test/secretbuffer.jl b/test/secretbuffer.jl index 703552570745c..996471c5b3830 100644 --- a/test/secretbuffer.jl +++ b/test/secretbuffer.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") +const BASE_TEST_PATH = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test") isdefined(Main, :ChallengePrompts) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ChallengePrompts.jl")) using .Main.ChallengePrompts: challenge_prompt