OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [perl/] [software_editor.pl] - Blame information for rev 38

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 alirezamon
#!/usr/bin/perl
2
 
3
use strict;
4
use warnings;
5
 
6
use Glib qw(TRUE FALSE);
7
use Gtk2 '-init';
8
use Gtk2::SourceView2;
9
use Data::Dumper;
10
 
11
 
12
use base 'Class::Accessor::Fast';
13
require "widget.pl";
14
 
15
 
16
__PACKAGE__->mk_accessors(qw{
17
        window
18
        sourceview
19
        buffer
20
        filename
21
        search_regexp
22
        search_case
23
        search_entry
24
        regexp
25
        highlighted
26
});
27
 
28
my $NAME = 'Otec';
29
 
30
 
31
exit main() unless caller;
32
 
33
 
34
sub software_main {
35
        my ($sw,$file) = @_;
36
 
37
 
38
 
39
        my $app = __PACKAGE__->new();
40
        my ($table,$tview,$window)=$app->build_gui($sw);
41
        my $main_c=(defined $file)? "$sw/$file" : "$sw/main.c";
42
        $app->load_source($main_c) if (-f $main_c );
43
 
44
        #Gtk2->main();
45
 
46
        return ($app,$table,$tview,$window);
47
}
48
 
49
 
50
sub build_gui {
51
        my ($self,$sw) = @_;
52
 
53 35 alirezamon
        my $window = def_popwin_size (75,75,'Source Editor','percent');
54 34 alirezamon
        my $table= def_table(2,10,FALSE);
55
 
56
 
57
 
58
 
59
        my $hpaned = Gtk2::HPaned -> new;
60
        my $vpaned = Gtk2::VPaned -> new;
61
        $table->attach_defaults ($vpaned,0, 10, 0,1);
62
        #my $make = def_image_button('icons/run.png','Compile');
63
        #$table->attach ($make,9, 10, 1,2,'shrink','shrink',0,0);
64
        #$make -> signal_connect("clicked" => sub{
65
                #$self->do_save();
66
                #run_make_file($sw,$tview);     
67
 
68
        #});
69
 
70
        $window -> add ( $table);
71
 
72
        my($width,$hight)=max_win_size();
73
 
74
        my $scwin_dirs = Gtk2::ScrolledWindow -> new;
75
        $scwin_dirs -> set_policy ('automatic', 'automatic');
76
        $hpaned -> pack1 ($scwin_dirs, TRUE, TRUE);
77
        $hpaned ->set_position ($width*.15);
78
 
79
        my $scwin_text = Gtk2::ScrolledWindow -> new;
80
        $scwin_text -> set_policy ('automatic', 'automatic');
81
        $hpaned -> pack2 ($scwin_text, TRUE, TRUE);
82
 
83
 
84
        my ($scwin_info,$tview)= create_text();
85 38 alirezamon
        add_colors_to_textview($tview);
86 34 alirezamon
        $vpaned-> pack1 ($hpaned, TRUE, TRUE);
87
        $vpaned ->set_position ($hight*.5);
88
        $vpaned-> pack2 ($scwin_info, TRUE, TRUE);
89
 
90
 
91
 
92
 
93
# Directory name, full path
94
my $tree_store = Gtk2::TreeStore->new('Glib::String', 'Glib::String');
95
my $tree_view = Gtk2::TreeView->new($tree_store);
96
my $column = Gtk2::TreeViewColumn->new_with_attributes('', Gtk2::CellRendererText->new(), text => "0");
97
$tree_view->append_column($column);
98
$tree_view->set_headers_visible(FALSE);
99
$tree_view->signal_connect (button_release_event => sub{
100
        my $tree_model = $tree_view->get_model();
101
        my $selection = $tree_view->get_selection();
102
        my $iter = $selection->get_selected();
103
        if(defined $iter){
104
                my $path = $tree_model->get($iter, 1) ;
105
                $path= substr $path, 0, -1;
106
 
107
                 $self->load_source($path) if(-f $path);
108
        }
109
         return;
110
});
111
 
112
 
113
$tree_view->signal_connect ('row-expanded' => sub {
114
        my ($tree_view, $iter, $tree_path) = @_;
115
        my $tree_model = $tree_view->get_model();
116
        my ($dir, $path) = $tree_model->get($iter);
117
 
118
        # for each of $iter's children add any subdirectories
119
        my $child = $tree_model->iter_children ($iter);
120
        while ($child) {
121
                my ($dir, $path) = $tree_model->get($child, 0, 1);
122
                add_to_tree($tree_view,$tree_store, $child, $dir, $path);
123
                $child = $tree_model->iter_next ($child);
124
        }
125
         return;
126
});
127
 
128
 
129
$scwin_dirs -> add($tree_view);
130
 
131
 
132
 
133
my $child = $tree_store->append(undef);
134
$tree_store->set($child, 0, $sw, 1, '/');
135
add_to_tree($tree_view,$tree_store, $child, '/', "$sw/");
136
#print "$sw/\n";
137
 
138
        #my $window = Gtk2::Window->new();
139
        #$window->set_size_request(480, 360);
140
        #$window->set_title($NAME);
141
        $self->window($window);
142
 
143
        my $vbox = Gtk2::VBox->new(FALSE, 0);
144
        $scwin_text->add_with_viewport($vbox);
145
 
146
        $vbox->pack_start($self->build_menu, FALSE, FALSE, 0);
147
        $vbox->pack_start($self->build_search_box, FALSE, FALSE, 0);
148
 
149
        my $scroll = Gtk2::ScrolledWindow->new();
150
        $scroll->set_policy('automatic', 'automatic');
151
        $scroll->set_shadow_type('in');
152
        $vbox->pack_start($scroll, TRUE, TRUE, 0);
153
 
154
        my $buffer = $self->create_buffer();
155
        my $sourceview = Gtk2::SourceView2::View->new_with_buffer($buffer);
156
        $sourceview->set_show_line_numbers(TRUE);
157
        $sourceview->set_tab_width(2);
158
        $sourceview->set_indent_on_tab(TRUE);
159
        $sourceview->set_highlight_current_line(TRUE);
160
#       $sourceview->set_draw_spaces(['tab', 'newline']);
161
 
162
        #
163
        # Fix Gtk2::TextView's annoying paste behaviour when pasting with the mouse
164
        # (middle button click). By default gtk will scroll the text view to the
165
        # original place where the cursor is.
166
        #
167
        $sourceview->signal_connect(button_press_event => sub {
168
                my ($view, $event) = @_;
169
 
170
                # We're only interested on middle mouse clicks (mouse-paste)
171
                return FALSE unless $event->button == 2;
172
 
173
                # Remember the position of the paste
174
                my (@coords) = $sourceview->window_to_buffer_coords('text', $event->x, $event->y);
175
                my ($iter) = $sourceview->get_iter_at_position(@coords);
176
                $self->{paste_mark} = $buffer->create_mark('paste', $iter, FALSE);
177
 
178
                return FALSE;
179
        });
180
 
181
 
182
        #
183
        # If a paste is done through the middle click then place the cursor at the end
184
        # of the pasted text.
185
        #
186
        $buffer->signal_connect('paste-done' => sub {
187
                my $mark = delete $self->{paste_mark} or return;
188
 
189
                my $iter = $buffer->get_iter_at_mark($mark);
190
                $buffer->place_cursor($iter);
191
 
192
                $self->sourceview->scroll_to_mark(
193
                        $mark,
194
                        0.0,
195
                        FALSE,
196
                        0.0, 0.5
197
                );
198
                $buffer->delete_mark($mark);
199
        });
200
 
201
 
202
        $scroll->add($sourceview);
203
        $self->sourceview($sourceview);
204
        $self->buffer($sourceview->get_buffer);
205
 
206
        $window->signal_connect(delete_event => sub {
207
                Gtk2->main_quit();
208
                return TRUE;
209
        });
210
 
211
        $window->show_all();
212
        return ($table,$tview,$window);
213
}
214
 
215
 
216
sub build_search_box {
217
        my $self = shift;
218
 
219
        # Elements of the search box
220
        my $hbox = Gtk2::HBox->new(FALSE, 0);
221
 
222
        my $search_entry = Gtk2::Entry->new();
223
        $search_entry->signal_connect(activate => sub {$self->do_search()});
224
        $search_entry->signal_connect(icon_release => sub {$self->do_search()});
225
        $self->search_entry($search_entry);
226
 
227
        my $search_regexp = Gtk2::CheckButton->new('RegExp');
228
        $search_regexp->signal_connect(toggled => sub {
229
                $self->search_regexp($search_regexp->get_active);
230
        });
231
 
232
        my $search_case = Gtk2::CheckButton->new('Case');
233
        $search_case->signal_connect(toggled => sub {
234
                $self->search_case($search_case->get_active);
235
        });
236
 
237
        my $search_icon = Gtk2::Button->new_from_stock('gtk-find');
238
        $search_entry->set_icon_from_stock(primary => 'gtk-find');
239
 
240
        $hbox->pack_start($search_entry, TRUE, TRUE , 0);
241
        $hbox->pack_start($search_regexp, FALSE, FALSE, 0);
242
        $hbox->pack_start($search_case, FALSE, FALSE, 0);
243
 
244
        return $hbox;
245
}
246
 
247
 
248
sub create_buffer {
249
        my $self = shift;
250
        my $tags = Gtk2::TextTagTable->new();
251
 
252
        add_tag($tags, search => {
253
                        background => 'yellow',
254
        });
255
        add_tag($tags, goto_line => {
256
                        'paragraph-background' => 'orange',
257
        });
258
 
259
        my $buffer = Gtk2::SourceView2::Buffer->new($tags);
260
        $buffer->signal_connect('notify::cursor-position' => sub {
261
                $self->clear_highlighted();
262
        });
263
 
264
        return $buffer;
265
}
266
 
267
 
268
sub add_tag {
269
        my ($tags, $name, $properties) = @_;
270
 
271
        my $tag = Gtk2::TextTag->new($name);
272
        $tag->set(%{ $properties });
273
        $tags->add($tag);
274
}
275
 
276
 
277
sub detect_language {
278
        my $self = shift;
279
        my ($filename) = @_;
280
 
281
        # Guess the programming language of the file
282
        my $manager = Gtk2::SourceView2::LanguageManager->get_default;
283
        my $language = $manager->guess_language($filename);
284
        $self->buffer->set_language($language);
285
}
286
 
287
 
288
sub load_source {
289
        my $self = shift;
290
        my ($filename) = @_;
291
        my $buffer = $self->buffer;
292
 
293
        # Guess the programming language of the file
294
        $self->detect_language($filename);
295
 
296
        # Loading a file should not be undoable.
297
        my $content;
298
        do {
299
                open my $handle, $filename or die "Can't read file $filename because $!";
300
                local $/;
301
                $content = <$handle>;
302
                close $handle;
303
        };
304
        $buffer->begin_not_undoable_action();
305
        $buffer->set_text($content);
306
        $buffer->end_not_undoable_action();
307
 
308
        $buffer->set_modified(FALSE);
309
        $buffer->place_cursor($buffer->get_start_iter);
310
 
311
        $self->filename($filename);
312
        $self->window->set_title("$filename - $NAME");
313
}
314
 
315
 
316
sub clear_highlighted {
317
        my $self = shift;
318
 
319
        my $highlighted = delete $self->{highlighted} or return;
320
 
321
        my $buffer = $self->buffer;
322
 
323
        my @iters;
324
        foreach my $mark (@{ $highlighted->{marks} }) {
325
                my $iter = $buffer->get_iter_at_mark($mark);
326
                push @iters, $iter;
327
                $buffer->delete_mark($mark);
328
        }
329
 
330
        $buffer->remove_tag_by_name($highlighted->{name}, @iters);
331
}
332
 
333
 
334
sub get_text {
335
        my $self = shift;
336
        my $buffer = $self->buffer;
337
        return $buffer->get_text($buffer->get_start_iter, $buffer->get_end_iter, FALSE);
338
}
339
 
340
 
341
sub do_search {
342
        my $self = shift;
343
        my $criteria = $self->search_entry->get_text;
344
        if ($criteria eq '') {return;}
345
 
346
        my $case = $self->search_case;
347
        my $buffer = $self->buffer;
348
 
349
 
350
        # Start the search at the last search result or from the current cursor's
351
        # position. As a fall back we also add the beginning of the document. Once we
352
        # have the start position we can erase the previous search results.
353
        my @start;
354
        if (my $highlighted = $self->highlighted) {
355
                # Search from the last match
356
                push @start, $buffer->get_iter_at_mark($highlighted->{marks}[1]);
357
                $self->clear_highlighted();
358
        }
359
        else {
360
                # Search from the cursor
361
                push @start, $buffer->get_iter_at_offset(
362
                        $buffer->get_property('cursor-position')
363
                );
364
        }
365
        push @start, $buffer->get_start_iter;
366
 
367
        my @iters;
368
        if ($self->search_regexp) {
369
                # Gtk2::SourceView2 nor Gtk2::SourceView support regular expressions so we
370
                # have to do the search by hand!
371
 
372
                my $text = $self->get_text;
373
                my $regexp = $case ? qr/$criteria/m : qr/$criteria/im;
374
 
375
                foreach my $iter (@start) {
376
                        # Tell Perl where to start the regexp lookup
377
                        pos($text) = $iter->get_offset;
378
 
379
                        if ($text =~ /($regexp)/g) {
380
                                my $word = $1;
381
                                my $pos = pos($text);
382
                                @iters = (
383
                                        $buffer->get_iter_at_offset($pos - length($word)),
384
                                        $buffer->get_iter_at_offset($pos),
385
                                );
386
                                last;
387
                        }
388
                }
389
        }
390
        else {
391
                # Use the builtin search mechanism
392
                my $flags = $case ? [ ] : [ 'case-insensitive' ];
393
                foreach my $iter (@start) {
394
                        @iters = Gtk2::SourceView2::Iter->forward_search($iter, $criteria, $flags);
395
                        last if @iters;
396
                }
397
        }
398
 
399
        $self->show_highlighted(search => @iters) if @iters;
400
}
401
 
402
 
403
sub show_highlighted {
404
        my $self = shift;
405
        my ($tag_name, $start, $end) = @_;
406
        my $buffer = $self->buffer;
407
 
408
        # Highlight the region, remember it and scroll to it
409
        my $match_start = $buffer->create_mark('match-start', $start, TRUE);
410
        my $match_end = $buffer->create_mark('match-end', $end, FALSE);
411
 
412
        $buffer->apply_tag_by_name($tag_name, $start, $end);
413
 
414
        # We have a callback that listens to when the cursor is placed and we don't
415
        # want it to undo our work! So let's unhighlight the previous entry.
416
        delete $self->{highlighted};
417
        $buffer->place_cursor($end);
418
 
419
        $self->sourceview->scroll_to_mark(
420
                $match_start,
421
                0.2,
422
                FALSE,
423
                0.0, 0.5
424
        );
425
 
426
        # Keep a reference to the markers once they have been added to the buffer.
427
        # Using them before can be catastrophic (segmenation fault).
428
        #
429
        $self->highlighted({
430
                name  => $tag_name,
431
                marks => [$match_start, $match_end],
432
        });
433
}
434
 
435
 
436
sub do_file_new {
437
        my $self = shift;
438
        my $buffer = $self->buffer;
439
 
440
        # Set no language
441
        $buffer->set_language(undef);
442
 
443
        # Showing a blank editor should not be undoable.
444
        $buffer->begin_not_undoable_action();
445
        $buffer->set_text('');
446
        $buffer->end_not_undoable_action();
447
 
448
        $buffer->set_modified(FALSE);
449
        $buffer->place_cursor($buffer->get_start_iter);
450
 
451
        $self->filename('');
452
        $self->window->set_title("Untitled - $NAME");
453
}
454
 
455
 
456
sub do_file_open {
457
        my $self = shift;
458
        my ($window, $action, $menu_item) = @_;
459
 
460
        my $dialog = Gtk2::FileSelection->new("Open file...");
461
        $dialog->signal_connect(response => sub {
462
                my ($dialog, $response) = @_;
463
 
464
                if ($response eq 'ok') {
465
                        my $file = $dialog->get_filename;
466
                        return if -d $file;
467
                        $self->load_source($file);
468
                }
469
 
470
                $dialog->destroy();
471
        });
472
        $dialog->show();
473
}
474
 
475
 
476
sub do_show_about_dialog {
477
        my $self = shift;
478
 
479
        my $dialog = Gtk2::AboutDialog->new();
480
        $dialog->set_authors("Emmanuel Rodriguez");
481
        $dialog->set_comments("Gtk2::SourceView2 Demo");
482
        $dialog->signal_connect(response => sub {
483
                my ($dialog, $response) = @_;
484
                $dialog->destroy();
485
        });
486
        $dialog->show();
487
}
488
 
489
 
490
sub do_ask_goto_line {
491
        my $self = shift;
492
 
493
        my $dialog = Gtk2::Dialog->new_with_buttons(
494
                "Goto to line",
495
                $self->window,
496
                [ 'modal' ],
497
                'gtk-cancel' => 'cancel',
498
                'gtk-ok'     => 'ok',
499
        );
500
 
501
        my $hbox = Gtk2::HBox->new(FALSE, 0);
502
        $hbox->pack_start(
503
                Gtk2::Label->new("Line number: "),
504
                FALSE, FALSE, 0
505
        );
506
        my $entry = Gtk2::Entry->new();
507
        $hbox->pack_start($entry, TRUE, TRUE, 0);
508
 
509
        $dialog->get_content_area->add($hbox);
510
        $dialog->show_all();
511
 
512
 
513
        # Signal handlers
514
        $entry->signal_connect(activate => sub {
515
                if ($entry->get_text =~ /(\d+)/) {
516
                        $dialog->response('ok');
517
                }
518
        });
519
 
520
        # Run the dialog
521
        my $response = $dialog->run();
522
        $dialog->destroy();
523
        return unless $response eq 'ok';
524
 
525
        return unless my ($line) = ($entry->get_text =~ /(\d+)/);
526
        my $buffer = $self->buffer;
527
        my $start = $buffer->get_iter_at_line($line - 1);
528
        my $end = $start->copy;
529
        $end->forward_to_line_end;
530
 
531
        $self->clear_highlighted();
532
        $self->show_highlighted(goto_line => $start, $end);
533
}
534
 
535
 
536
sub do_quit {
537
        my $self = shift;
538
        Gtk2->main_quit();
539
}
540
 
541
 
542
sub do_save_as {
543
        my $self = shift;
544
 
545
        # If no file is associated with the editor then ask the user for a file where
546
        # to save the contents of the buffer.
547
        my $dialog = Gtk2::FileChooserDialog->new(
548
                "Save file", $self->window, 'save',
549
                'gtk-cancel' => 'cancel',
550
                'gtk-save'   => 'ok',
551
        );
552
 
553
        my $response = $dialog->run();
554
        if ($response eq 'ok') {
555
                $self->filename($dialog->get_filename);
556
                $self->do_save();
557
        }
558
        $dialog->destroy();
559
}
560
 
561
 
562
sub do_save {
563
        my $self = shift;
564
 
565
        my $filename = $self->filename;
566
 
567
        # If there's no file then do a save as...
568
        if (! $filename) {
569
                $self->do_save_as();
570
                return;
571
        }
572
 
573
        my $buffer = $self->buffer;
574
        open my $handle, '>:encoding(UTF-8)', $filename or die "Can't write to $filename: $!";
575
        print $handle $self->get_text;
576
        close $handle;
577
 
578
        if (! $buffer->get_language) {
579
                $self->detect_language($filename);
580
        }
581
}
582
 
583
 
584
sub build_menu {
585
        my $self = shift;
586
 
587
        my $entries = [
588
                # name, stock id, label
589
                [ "FileMenu",  undef, "_File" ],
590
                [ "SearchMenu",  undef, "_Search" ],
591
                [ "HelpMenu",  undef, "_Help" ],
592
 
593
                # name, stock id, label, accelerator, tooltip, method
594
                [
595
                        "New",
596
                        'gtk-new',
597
                        "_New",
598
                        "<control>N",
599
                        "Create a new file",
600
                        sub { $self->do_file_new(@_) }
601
                ],
602
                [
603
                        "Open",
604
                        'gtk-open',
605
                        "_Open",
606
                        "<control>O",
607
                        "Open a file",
608
                        sub { $self->do_file_open(@_) }
609
                ],
610
                [
611
                        "Save",
612
                        'gtk-save',
613
                        "_Save",
614
                        "<control>S",
615
                        "Save current file",
616
                        sub { $self->do_save(@_) }
617
                ],
618
                [
619
                        "SaveAs",
620
                        'gtk-save',
621
                        "Save _As...",
622
                        "<control><shift>S",
623
                        "Save to a file",
624
                        sub { $self->do_save_as(@_) }
625
                ],
626
                [
627
                        "Quit",
628
                        'gtk-quit',
629
                        "_Quit",
630
                        "<control>Q",
631
                        "Quit",
632
                        sub { $self->do_quit() }
633
                ],
634
                [
635
                        "About",
636
                        'gtk-about',
637
                        "_About",
638
                        undef,
639
                        "About",
640
                        sub { $self->do_show_about_dialog(@_) }
641
                ],
642
                [
643
                        "GotoLine",
644
                        undef,
645
                        "Goto to _Line",
646
                        "<control>L",
647
                        "Go to line",
648
                        sub { $self->do_ask_goto_line(@_) }
649
                ],
650
        ];
651
 
652
        my $actions = Gtk2::ActionGroup->new("Actions");
653
        $actions->add_actions($entries, undef);
654
 
655
        my $ui = Gtk2::UIManager->new();
656
        $ui->insert_action_group($actions, 0);
657
        $ui->add_ui_from_string(<<'__UI__');
658
<ui>
659
        <menubar name='MenuBar'>
660
                <menu action='FileMenu'>
661
                        <menuitem action='New'/>
662
                        <menuitem action='Open'/>
663
                        <separator/>
664
                        <menuitem action='Save'/>
665
                        <menuitem action='SaveAs'/>
666
                        <separator/>
667
                        <menuitem action='Quit'/>
668
                </menu>
669
                <menu action='SearchMenu'>
670
                        <menuitem action='GotoLine'/>
671
                </menu>
672
                <menu action='HelpMenu'>
673
                        <menuitem action='About'/>
674
                </menu>
675
        </menubar>
676
</ui>
677
__UI__
678
 
679
        $self->window->add_accel_group($ui->get_accel_group);
680
 
681
        return $ui->get_widget('/MenuBar');
682
}
683
 
684
 
685
 
686
sub add_to_tree {
687
 my ($tree_view,$tree_store, $parent, $dir, $path) = @_;
688
my $tree_model = $tree_view->get_model();
689
 
690
# If $parent already has children, then remove them first
691
 my $child = $tree_model->iter_children ($parent);
692
 while ($child) {
693
  $tree_store->remove ($child);
694
  $child = $tree_model->iter_children ($parent);
695
 }
696
 
697
# Add children from directory listing
698
 opendir(DIRHANDLE, $path) || return ; #die "Cannot open directory:$path $!\n";
699
 foreach my $subdir (sort readdir(DIRHANDLE)) {
700
  if ($subdir ne '.' and $subdir ne '..'
701
                                   # and -d $path.$subdir and -r $path.$subdir
702
) {
703
   my $child = $tree_store->append($parent);
704
   $tree_store->set($child, 0, $subdir, 1, "$path$subdir/");
705
  }
706
 }
707
 closedir(DIRHANDLE);
708
}
709
 
710
 
711
# Directory expanded. Populate subdirectories in readiness.
712
 
713
sub populate_tree {
714
 
715
# $iter has been expanded
716
 my ($tree_view,$tree_store, $iter, $tree_path) = @_;
717
 my $tree_model = $tree_view->get_model();
718
 my ($dir, $path) = $tree_model->get($iter);
719
 
720
# for each of $iter's children add any subdirectories
721
 my $child = $tree_model->iter_children ($iter);
722
 while ($child) {
723
  my ($dir, $path) = $tree_model->get($child, 0, 1);
724
  add_to_tree($tree_view,$tree_store, $child, $dir, $path);
725
  $child = $tree_model->iter_next ($child);
726
 }
727
 return;
728
}
729
 
730
 
731
sub run_make_file {
732 38 alirezamon
        my ($dir,$outtext, $args)=@_;
733
        my $cmd =       (defined $args) ? "cd \"$dir/\" \n  make $args" :  "cd \"$dir/\" \n  make ";
734 34 alirezamon
        my $error=0;
735 38 alirezamon
        add_info(\$outtext,"$cmd\n");
736 34 alirezamon
 
737
        my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout( $cmd);
738 38 alirezamon
        #($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout( $cmd);
739 34 alirezamon
 
740
 
741 38 alirezamon
        if($exit){
742
                if($stderr){
743
                        $stderr=~ s/[‘,’]//g;
744
                        add_info(\$outtext,"$stdout\n");
745
                        add_colored_info(\$outtext,"$stderr\n","red");
746
                }
747 34 alirezamon
                add_colored_info(\$outtext,"Compilation failed.\n",'red');
748 38 alirezamon
                return 0;
749 34 alirezamon
 
750
        }else{
751
                add_info(\$outtext,"$stdout\n");
752 38 alirezamon
                if($stderr){ #probebly had warning
753
                        $stderr=~ s/[‘,’]//g;
754
                        #add_info(\$outtext,"$stdout\n"); 
755
                        add_colored_info(\$outtext,"$stderr\n","green");
756
                }
757
 
758 34 alirezamon
                add_colored_info(\$outtext,"Compilation finished successfully.\n",'blue');
759 38 alirezamon
                return 1;
760 34 alirezamon
        }
761
 
762
        #add_info(\$outtext,"**********Quartus compilation is done successfully in $target_dir!*************\n") if($error==0);
763
 
764
 
765
 
766
}
767
 
768
 
769
 
770
 
771
1;
772
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.