Improve resolution of relative includes #980
@ -99,7 +99,7 @@ add_include_path(File, Options) ->
|
|||||||
false ->
|
false ->
|
||||||
Dir = filename:dirname(File),
|
Dir = filename:dirname(File),
|
||||||
{ok, Cwd} = file:get_cwd(),
|
{ok, Cwd} = file:get_cwd(),
|
||||||
[{include, {file_system, [Cwd, Dir]}} | Options]
|
[{include, {file_system, [Cwd, aeso_utils:canonical_dir(Dir)]}} | Options]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec from_string(binary() | string(), options()) -> {ok, map()} | {error, [aeso_errors:error()]}.
|
-spec from_string(binary() | string(), options()) -> {ok, map()} | {error, [aeso_errors:error()]}.
|
||||||
|
@ -6,10 +6,22 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeso_utils).
|
-module(aeso_utils).
|
||||||
|
|
||||||
-export([scc/1]).
|
-export([scc/1, canonical_dir/1]).
|
||||||
|
|
||||||
-export_type([graph/1]).
|
-export_type([graph/1]).
|
||||||
|
|
||||||
|
%% -- Simplistic canonical directory
|
||||||
|
%% Note: no attempts to be 100% complete
|
||||||
|
|
||||||
|
canonical_dir(Dir) ->
|
||||||
|
{ok, Cwd} = file:get_cwd(),
|
||||||
|
AbsName = filename:absname(Dir),
|
||||||
|
RelAbsName = filename:join(tl(filename:split(AbsName))),
|
||||||
|
case filelib:safe_relative_path(RelAbsName, Cwd) of
|
||||||
|
unsafe -> AbsName;
|
||||||
|
Simplified -> filename:absname(Simplified, "")
|
||||||
|
end.
|
||||||
|
|
||||||
%% -- Topological sort
|
%% -- Topological sort
|
||||||
|
|
||||||
-type graph(Node) :: #{Node => [Node]}. %% List of incoming edges (dependencies).
|
-type graph(Node) :: #{Node => [Node]}. %% List of incoming edges (dependencies).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user