1/* Part of LogicMOO Base Logicmoo Path Setups
    2% ===================================================================
    3    File:         'logicmoo_util_library.pl'
    4    Purpose:       To load the logicmoo libraries as needed
    5    Contact:       $Author: dmiles $@users.sourceforge.net ;
    6    Version:       'logicmoo_util_library.pl' 1.0.0
    7    Revision:      $Revision: 1.7 $
    8    Revised At:    $Date: 2002/07/11 21:57:28 $
    9    Author:        Douglas R. Miles
   10    Maintainers:   TeamSPoon
   11    E-mail:        logicmoo@gmail.com
   12    WWW:           http://www.prologmoo.com
   13    SCM:           https://github.com/TeamSPoon/PrologMUD/tree/master/pack/logicmoo_base
   14    Copyleft:      1999-2015, LogicMOO Prolog Extensions
   15    License:       Lesser GNU Public License
   16% ===================================================================
   17*/
   18
   19:- module(logicmoo_utils_all,[]).   20
   21
   22
   23
   24:- if(gethostname(gitlab)).                                            
   25
   26:- set_prolog_flag(runtime_debug,3).   27:- set_prolog_flag(runtime_safety,3).   28:- set_prolog_flag(runtime_speed,0).   29
   30:- else.   31
   32:- set_prolog_flag(runtime_debug,1).   33:- set_prolog_flag(runtime_safety,1).   34:- set_prolog_flag(runtime_speed,1).   35
   36:- endif.   37
   38
   39:- set_prolog_flag(lm_no_autoload,false).   40:- set_prolog_flag(lm_pfc_lean,false).   41
   42
   43/*
   44:- set_prolog_flag(stack_limit, 32 000 000 000).
   45:- set_prolog_stack(global, limit(32*10**9)).
   46:- set_prolog_stack(local, limit(32*10**9)).
   47:- set_prolog_stack(trail, limit(32*10**9)).
   48*/
   49
   50
   51%:- setenv('DISPLAY', '').
   52:- use_module(library(plunit)).   53
   54
   55% ==============================================
   56% Enable History
   57% ==============================================
   58:- if(\+ current_predicate(setup_hist0/0)).   59:- if(exists_source(library(editline))). 
   60:- if(\+ current_prolog_flag(windows,true)).   61:- use_module(library(editline)).   62:- endif.   63:- else.   64:- if(exists_source(library(readline))).   65:- use_module(library(readline)).   66:- endif.   67:- endif.   68setup_hist0:-  '$toplevel':setup_history.
   69:- setup_hist0.   70:- endif.   71   
   72% ==============================================
   73% Add Pack Directories
   74% ==============================================
   75:- use_module(library(prolog_pack)).   76:- multifile(user:file_search_path/2).   77:-   dynamic(user:file_search_path/2).   78
   79dir_from(Rel,Y):-
   80    ((getenv('LOGICMOO_WS',Dir);
   81      prolog_load_context(directory,Dir);
   82      'w:/opt/logicmoo_workspace/'=Dir;      
   83      '~/logicmoo_workspace'=Dir;
   84      '/opt/logicmoo_workspace/'=Dir;
   85      fail)),
   86    absolute_file_name(Rel,Y,[relative_to(Dir),file_type(directory),file_errors(fail)]),
   87    exists_directory(Y),!.
   88
   89:- export(add_pack_path/1).   90add_pack_path(packs_xtra):-pack_property(logicmoo_nlu,_),!.
   91add_pack_path(packs_sys):-pack_property(logicmoo_base,_),!.
   92add_pack_path(Rel):- 
   93   dir_from(Rel,Y),
   94   (( \+ user:file_search_path(pack,Y)) ->asserta(user:file_search_path(pack,Y));true).
   95
   96
   97
   98:- if( \+ exists_source(library(logicmoo_common))).   99:- add_pack_path(packs_sys).  100:- endif.  101
  102:- if( \+ exists_source(library(logicmoo_hyhtn))).  103:- add_pack_path(packs_xtra).  104:- endif.  105
  106%:- ignore(add_pack_path(packs_usr)).
  107%:- add_pack_path(packs_web).
  108%:- add_pack_path(packs_xtra).
  109%:- add_pack_path(packs_lib).
  110
  111:- initialization(attach_packs,now).  112
  113update_packs:- !.
  114update_packs:-    
  115   use_module(library(prolog_pack)),
  116   (pack_property(prologmud_samples,version(Version));
  117    pack_property(pfc,version(Version))),!,
  118   use_module(library(git)),
  119   forall(
  120   (pack_property(Pack,version(Version)), pack_property(Pack,directory(Dir)),
  121      directory_file_path(Dir, '.git', GitDir),
  122      %(exists_file(GitDir);exists_directory(GitDir)),
  123       access_file(GitDir,read),
  124       access_file(GitDir,write)),
  125     ( print_message(informational, pack(git_fetch(Dir))),
  126     git([fetch], [ directory(Dir) ]),
  127     git_describe(V0, [ directory(Dir) ]),
  128     git_describe(V1, [ directory(Dir), commit('origin/master') ]),
  129     (   V0 == V1
  130     ->  print_message(informational, pack(up_to_date(Pack)))
  131     ;   true,
  132         git([merge, 'origin/master'], [ directory(Dir) ]),
  133         pack_rebuild(Pack)
  134     ))),
  135   initialization(attach_packs,now).
  136
  137:- update_packs.  138
  139:- discontiguous logicmoo_utils_all:'$exported_op'/3.  140:- system:reexport(library(logicmoo_common)).  141
  142:- pack_list_installed.  143
  144
  145% :- predicate_inheritance:kb_global(plunit:loading_unit/4).