Skip to content

Commit

Permalink
ENHANCED: file_autoload_directives/3: deal with library(main) hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Oct 15, 2024
1 parent 1a84824 commit 602df5c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions library/prolog_deps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
[ file_autoload_directives/3, % +File, -Directives, +Options
file_auto_import/2 % +File, +Options
]).
:- use_module(library(apply), [convlist/3, maplist/3]).
:- use_module(library(apply), [convlist/3, maplist/3, exclude/3]).
:- use_module(library(filesex), [copy_file/2]).
:- use_module(library(lists), [select/3, append/3, member/2]).
:- use_module(library(option), [option/2, option/3]).
Expand Down Expand Up @@ -117,7 +117,8 @@

file_autoload_directives(File, Directives, Options) :-
xref_source(File),
findall(Head, distinct(Head, undefined(File, Head, Options)), Missing),
findall(Head, distinct(Head, undefined(File, Head, Options)), Missing0),
clean_missing(Missing0, Missing),
option(update(Old), Options, []),
convlist(missing_autoload(File, Old), Missing, Pairs),
keysort(Pairs, Pairs1),
Expand Down Expand Up @@ -218,6 +219,23 @@
xref_defined(File, Callable, How),
How \= imported(_).

%! clean_missing(+Missing0, -Missing) is det.
%
% Hack to deal with library(main) and library(optparse) issues.
%
% @tbd Needs a more fundamental solution.

clean_missing(Missing0, Missing) :-
memberchk(main, Missing0),
memberchk(argv_options(_,_,_), Missing0),
!,
exclude(argv_option_hook, Missing0, Missing).
clean_missing(Missing, Missing).

argv_option_hook(opt_type(_,_,_)).
argv_option_hook(opt_help(_,_)).
argv_option_hook(opt_meta(_,_)).


/*******************************
* GENERATE OUTPUT *
Expand Down

0 comments on commit 602df5c

Please sign in to comment.