forked from Anniepoo/strangeloop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_start.pl
102 lines (80 loc) · 2.9 KB
/
debug_start.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
:- module(debug_start, []).
/** <module> Dev mode starter file
Consult this file to start the system in dev mode
*/
% Make sure we're on a reasonable version
%
%% reasonable_version is nondet
%
% succeeds if our version is 6.4.1 or better
%
reasonable_version :-
current_prolog_flag(version_data, swi(Major, _, _, _)),
Major > 6.
reasonable_version :-
current_prolog_flag(version_data, swi(6, Minor, _, _)),
Minor > 3.
reasonable_version :-
current_prolog_flag(version_data, swi(6, 3, Patch, _)),
Patch > 18.
check_version :- reasonable_version, !.
check_version :-
current_prolog_flag(version_data, swi(Major, Minor, Patch, _)),
format('OOOPS - you need swipl version 6.4.1 or better, you are on ~w.~w.~w~n',
[Major, Minor, Patch]).
:- check_version.
%% force_right_directory
%
% Change the working directory to the directory this file
% loaded from so we don't have weird relative path issues
%
force_right_directory :-
source_file(check_version, File),
file_directory_name(File, Dir),
working_directory(_, Dir).
:- force_right_directory.
% Make it easier to read 'codes' style strings
:- portray_text(true).
% pldoc is SWI-Prolog's equivilent of doxygen
% pldoc is served at / by default. We need to
% move pldoc's URI path so it doesn't interfere with the main
% application. Each SWI-Prolog process has a single global
% URI space for dispatch.
% abstract URI paths allow us to disconnect the served URI path
% from the name we refer to it by. By default, pldoc('foo/bar') maps
% to /foo/bar. We'll move pldoc to /help/source, so pldoc('foo/bar')
% will serve from /help/source/foo/bar
% First we import the abstract path stuff
:- use_module(library(http/http_path)).
% Now we define a new clause for the *multifile* predicate
% http:location/3. Default priority is 0, we use a higher
% priority to override pldoc's default location
% We define pldoc in terms of [system defined] root.
%
http:location(pldoc, root('help/source'), [priority(10)]).
% load our application server
% We start it first
% so it doesn't collide with pldoc
:-ensure_loaded(load).
% we don't actually start the server ourselves, in dev mode
% we piggyback on the pldoc server
%
% :- strangeloop_server.
% Now we can start pldoc. This starts our application server
% as well, a workaround for one server per process
:- doc_server(7777).
% Nice thing about SWI-Prolog, the interface to most
% development environment is fairly simple, so it's practical
% to set your environment for your own convenience. Here, we
% launch our first handler
:-www_open_url('http://localhost:7777/').
% and our pldoc home page
:-www_open_url('http://localhost:7777/help/source/').
% and the workshop page
:-www_open_url('http://localhost:7777/workshop').
% and bring up a module in the editor
:- edit('debug_start.pl').
% open the navigator
% put it in module user so programmer doesn't have to
% use a module name
user:open_tools :- prolog_ide(open_navigator).