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/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/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/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()