4 A Programmer's Text Editor
6 A simple IDE-like build system.
8 Copyright (C) 1991-2008 Angel Ortega <angel@triptico.com>
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 http://www.triptico.com
28 /** editor actions **/
30 mp.actions['build'] = sub(doc) {
34 if ((t = mp.build_get_targets()) == NULL) {
35 mp.alert(L("No Makefile targets found."));
39 /* more than one target? ask user to pick one */
42 { 'label' => L("Makefile target") ~ ':',
56 mp.long_op(mp.build_execute, target);
60 /** Default key bindings **/
62 mp.keycodes['f2'] = "build";
64 /** action descriptions **/
66 mp.actdesc['build'] = LL("Build project...");
70 sub mp.build_get_targets
74 if ((f = open('Makefile', 'r')) != NULL) {
82 if (t = regex('/^[A-Za-z0-9_\.-]+:/', l))
83 push(r, sregex('/:/', t, ''));
93 sub mp.build_execute(target)
95 local log = mp.open('<make output>');
100 /* pipe through make */
102 if ((p = popen('make ' ~ target, 'r')) != NULL) {
113 log.syntax = mp.syntax.make_output;
117 /* set the last search regex to match file:line strings,
118 so that calling seek-next and seek-prev moves there */
119 mp.last_search = '/^[a-z\.\_0-9\/-]+:[0-9]+:/m';