Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
erlang
2854-kernel-Add-erts-to-code-lib_dir-lookup.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2854-kernel-Add-erts-to-code-lib_dir-lookup.patch of Package erlang
From 7c94901057d205509e1e15ed702cea9b8a816946 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Fri, 31 Jan 2020 16:49:46 +0100 Subject: [PATCH 04/27] kernel: Add erts to code:lib_dir lookup --- erts/test/otp_SUITE.erl | 10 ++++++++-- lib/dialyzer/src/dialyzer_cl_parse.erl | 16 ++++++++++------ lib/kernel/src/code_server.erl | 33 ++++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl index c5e0dfe649..b5f15ebb10 100644 --- a/erts/test/otp_SUITE.erl +++ b/erts/test/otp_SUITE.erl @@ -57,8 +57,14 @@ init_per_suite(Config) -> {error,bad_name} -> Erts = filename:join([code:root_dir(),"erts","preloaded","ebin"]), {ok,_} = xref:add_directory(Server, Erts, []); - _ -> - ok + LibDir -> + case file:read_file_info(filename:join([LibDir,"ebin"])) of + {error,enoent} -> + Erts = filename:join([LibDir, "preloaded","ebin"]), + {ok,_} = xref:add_directory(Server, Erts, []); + _ -> + ok + end end, [{xref_server,Server}|Config]. diff --git a/lib/dialyzer/src/dialyzer_cl_parse.erl b/lib/dialyzer/src/dialyzer_cl_parse.erl index cadc2116b0..a3ec1b92f1 100644 --- a/lib/dialyzer/src/dialyzer_cl_parse.erl +++ b/lib/dialyzer/src/dialyzer_cl_parse.erl @@ -330,12 +330,16 @@ get_lib_dir(Apps) -> get_lib_dir([H|T], Acc) -> NewElem = case code:lib_dir(list_to_atom(H)) of - {error, bad_name} -> - case H =:= "erts" of % hack for including erts in an un-installed system - true -> filename:join(code:root_dir(), "erts/preloaded/ebin"); - false -> H - end; - LibDir -> LibDir ++ "/ebin" + {error, bad_name} -> H; + LibDir when H =:= "erts" -> % hack for including erts in an un-installed system + EbinDir = filename:join([LibDir,"ebin"]), + case file:read_file_info(EbinDir) of + {error,enoent} -> + filename:join([LibDir,"preloaded","ebin"]); + _ -> + EbinDir + end; + LibDir -> filename:join(LibDir,"ebin") end, get_lib_dir(T, [NewElem|Acc]); get_lib_dir([], Acc) -> diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl index 5469d8694c..8ef54dd0e1 100644 --- a/lib/kernel/src/code_server.erl +++ b/lib/kernel/src/code_server.erl @@ -93,7 +93,7 @@ init(Ref, Parent, [Root,Mode]) -> root = Root, path = Path, moddb = Db, - namedb = init_namedb(Path), + namedb = create_namedb(Path, Root), mode = Mode}, Parent ! {Ref,{ok,self()}}, @@ -265,8 +265,8 @@ handle_call({add_paths,Where,Dirs0}, _From, {reply,Resp,S#state{path=Path}}; handle_call({set_path,PathList}, _From, - #state{path=Path0,namedb=Namedb}=S) -> - {Resp,Path,NewDb} = set_path(PathList, Path0, Namedb), + #state{root=Root,path=Path0,namedb=Namedb}=S) -> + {Resp,Path,NewDb} = set_path(PathList, Path0, Namedb, Root), {reply,Resp,S#state{path=Path,namedb=NewDb}}; handle_call({del_path,Name}, _From, @@ -755,12 +755,12 @@ update(Dir, NameDb) -> %% %% Set a completely new path. %% -set_path(NewPath0, OldPath, NameDb) -> +set_path(NewPath0, OldPath, NameDb, Root) -> NewPath = normalize(NewPath0), case check_path(NewPath) of {ok, NewPath2} -> ets:delete(NameDb), - NewDb = init_namedb(NewPath2), + NewDb = create_namedb(NewPath2, Root), {true, NewPath2, NewDb}; Error -> {Error, OldPath, NameDb} @@ -788,11 +788,27 @@ normalize(Other) -> %% Handle a table of name-directory pairs. %% The priv_dir/1 and lib_dir/1 functions will have %% an O(1) lookup. -init_namedb(Path) -> - Db = ets:new(code_names,[private]), +create_namedb(Path, Root) -> + Db = ets:new(code_names,[named_table, public]), init_namedb(lists:reverse(Path), Db), + + case lookup_name("erts", Db) of + {ok, _, _, _} -> + %% erts is part of code path + ok; + false -> + %% No erts in code path, check if this is a source + %% repo and if so use that. + ErtsDir = filename:join(Root, "erts"), + case erl_prim_loader:read_file_info(ErtsDir) of + error -> + ok; + _ -> + do_insert_name("erts", ErtsDir, Db) + end + end, Db. - + init_namedb([P|Path], Db) -> insert_dir(P, Db), init_namedb(Path, Db); @@ -997,7 +1013,6 @@ lookup_name(Name, Db) -> _ -> false end. - %% %% Fetch a directory. %% -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor