[svn:parrot] r41746 - in branches/detect_llvm: . config/auto lib/Parrot/Configure/Step t/steps/auto

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Wed Oct 7 01:45:11 UTC 2009


Author: jkeenan
Date: Wed Oct  7 01:45:09 2009
New Revision: 41746
URL: https://trac.parrot.org/parrot/changeset/41746

Log:
Rough first draft of code to detect LLVM.

Added:
   branches/detect_llvm/config/auto/llvm.pm   (contents, props changed)
   branches/detect_llvm/t/steps/auto/llvm-01.t   (contents, props changed)
Modified:
   branches/detect_llvm/MANIFEST
   branches/detect_llvm/lib/Parrot/Configure/Step/List.pm

Modified: branches/detect_llvm/MANIFEST
==============================================================================
--- branches/detect_llvm/MANIFEST	Wed Oct  7 01:37:28 2009	(r41745)
+++ branches/detect_llvm/MANIFEST	Wed Oct  7 01:45:09 2009	(r41746)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 30 22:16:16 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct  7 01:41:24 2009 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -257,6 +257,7 @@
 config/auto/isreg.pm                                        []
 config/auto/isreg/test_c.in                                 []
 config/auto/jit.pm                                          []
+config/auto/llvm.pm                                         []
 config/auto/memalign.pm                                     []
 config/auto/memalign/test2_c.in                             []
 config/auto/memalign/test_c.in                              []
@@ -1931,6 +1932,7 @@
 t/steps/auto/inline-01.t                                    [test]
 t/steps/auto/isreg-01.t                                     [test]
 t/steps/auto/jit-01.t                                       [test]
+t/steps/auto/llvm-01.t                                      [test]
 t/steps/auto/memalign-01.t                                  [test]
 t/steps/auto/msvc-01.t                                      [test]
 t/steps/auto/neg_0-01.t                                     [test]

Added: branches/detect_llvm/config/auto/llvm.pm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/detect_llvm/config/auto/llvm.pm	Wed Oct  7 01:45:09 2009	(r41746)
@@ -0,0 +1,114 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+config/auto/llvm - Check whether the Low Level Virtual Machine is present
+
+=head1 DESCRIPTION
+
+Determines whether the Low Level Virtual Machine (LLVM) is installed and
+functional on the system.  It is OK when it
+doesn't exist.
+
+=cut
+
+package auto::llvm;
+
+use strict;
+use warnings;
+
+use base qw(Parrot::Configure::Step);
+
+use Parrot::Configure::Utils ':auto';
+
+sub _init {
+    my $self = shift;
+    my %data;
+    $data{description} = q{Is LLVM installed};
+    $data{result}      = q{};
+    return \%data;
+}
+
+sub runstep {
+    my ( $self, $conf ) = @_;
+
+    my $verbose = $conf->options->get( 'verbose' );
+
+    my @llvm_components = (
+        [ 'llvm-gcc'    => 'llvm-gcc' ],
+        [ 'lli'         => 'Low Level Virtual Machine' ],
+        [ 'llc'         => 'Low Level Virtual Machine' ],
+    );
+    my $sanity_check = 0;
+    foreach my $prog (@llvm_components) {
+        my $output = capture_output( $prog->[0], '--version' );
+        print $output, "\n" if $verbose;
+        my $exp = $prog->[1];
+        unless ( $output =~ m/$exp/s ) {
+            $sanity_check++;
+            print "Could not get expected '--version' output for $prog->[0]\n"
+                if $verbose;
+        }
+    }
+    if ( $sanity_check ) {
+        $self->set_result('no');
+        $conf->data->set( has_llvm => '' );
+    }
+    else {
+        $self->set_result('yes');
+        $conf->data->set( has_llvm => 1 );
+    }
+
+    return 1;
+}
+
+#sub _probe_for_llvm {
+#    my $conf = shift;
+#    my $variations_ref = shift;
+#    my $verbose = shift;
+#    my ($llvm, $has_llvm);
+#    while (defined (my $t = shift(@$variations_ref))) {
+#        my $output = capture_output( $t, '--version' ) || '';
+#        print $output, "\n" if $verbose;
+#        $has_llvm = _probe_for_llvm_output($output, $verbose);
+#        $llvm = $t if $has_llvm;
+#        last if $has_llvm;
+#    }
+#    return ($llvm, $has_llvm);
+#}
+#
+#sub _probe_for_llvm_output {
+#    my ($output, $verbose) = @_;
+#    my $has_llvm = ( $output =~ m/Exuberant Ctags/ ) ? 1 : 0;
+#    print $has_llvm, "\n" if $verbose;
+#    return $has_llvm;
+#}
+#
+#sub _evaluate_llvm {
+#    my ($self, $conf, $llvm, $has_llvm) = @_;
+#    if ($has_llvm) {
+#        $conf->data->set( llvm => $llvm );
+#        $self->set_result( 'yes' );
+#    }
+#    else {
+#        $conf->data->set( llvm => 'llvm' );
+#        $self->set_result( 'no' );
+#    }
+#}
+
+1;
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+

Modified: branches/detect_llvm/lib/Parrot/Configure/Step/List.pm
==============================================================================
--- branches/detect_llvm/lib/Parrot/Configure/Step/List.pm	Wed Oct  7 01:37:28 2009	(r41745)
+++ branches/detect_llvm/lib/Parrot/Configure/Step/List.pm	Wed Oct  7 01:45:09 2009	(r41746)
@@ -41,6 +41,7 @@
     auto::arch
     auto::jit
     auto::frames
+    auto::llvm
     auto::cpu
     auto::cgoto
     auto::inline

Added: branches/detect_llvm/t/steps/auto/llvm-01.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/detect_llvm/t/steps/auto/llvm-01.t	Wed Oct  7 01:45:09 2009	(r41746)
@@ -0,0 +1,149 @@
+#!perl
+# Copyright (C) 2001-2007, Parrot Foundation.
+# $Id$
+# auto/llvm-01.t
+
+use strict;
+use warnings;
+use Test::More qw(no_plan); # tests =>  28;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::auto::llvm');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw(
+    test_step_thru_runstep
+    test_step_constructor_and_description
+);
+use IO::CaptureOutput qw( capture );
+
+########## regular ##########
+
+my ($args, $step_list_ref) = process_options( {
+    argv => [ ],
+    mode => q{configure},
+} );
+
+my $conf = Parrot::Configure->new;
+
+my $pkg = q{auto::llvm};
+
+$conf->add_steps($pkg);
+
+my $serialized = $conf->pcfreeze();
+
+$conf->options->set( %{$args} );
+my $step = test_step_constructor_and_description($conf);
+my $ret = $step->runstep($conf);
+ok( $ret, "runstep() returned true value" );
+ok(defined($step->result()), "Result was defined");
+#ok($possible_llvm{$conf->data->get('llvm')},
+#    "Acceptable value for 'llvm' attribute was set");
+#
+#$conf->replenish($serialized);
+#
+########### --verbose ##########
+#
+#($args, $step_list_ref) = process_options( {
+#    argv => [ q{--verbose} ],
+#    mode => q{configure},
+#} );
+#$conf->options->set( %{$args} );
+#$step = test_step_constructor_and_description($conf);
+#{
+#    my $stdout;
+#    my $ret = capture(
+#        sub { $step->runstep($conf) },
+#        \$stdout
+#    );
+#    ok( $ret, "runstep() returned true value" );
+#    ok( defined $step->result(), "Result was defined");
+#    ok($possible_llvm{$conf->data->get('llvm')},
+#        "Acceptable value for 'llvm' attribute was set");
+#}
+#
+#$conf->replenish($serialized);
+#
+########### _evaluate_llvm() ##########
+#
+#($args, $step_list_ref) = process_options( {
+#    argv => [ ],
+#    mode => q{configure},
+#} );
+#$conf->options->set( %{$args} );
+#$step = test_step_constructor_and_description($conf);
+#
+#$conf->replenish($serialized);
+#
+#my $pseudo_llvm;
+#$pseudo_llvm = q{alpha};
+#$step->_evaluate_llvm($conf, $pseudo_llvm, 1);
+#is($conf->data->get('llvm'), $pseudo_llvm,
+#    "'llvm' attribute was set as expected");
+#is($step->result(), q{yes}, "Got expected result");
+#
+#$pseudo_llvm = q{alpha};
+#$step->_evaluate_llvm($conf, $pseudo_llvm, 0);
+#is($conf->data->get('llvm'), 'llvm',
+#    "'llvm' attribute was set as expected");
+#is($step->result(), q{no}, "Got expected result");
+#
+#$conf->replenish($serialized);
+#
+########### _probe_for_llvm_output() ##########
+#
+#($args, $step_list_ref) = process_options( {
+#    argv => [ ],
+#    mode => q{configure},
+#} );
+#$conf->options->set( %{$args} );
+#$step = test_step_constructor_and_description($conf);
+#ok(auto::llvm::_probe_for_llvm_output('Exuberant Ctags', 0),
+#    "Probe returned true when output matched");
+#ok(! auto::llvm::_probe_for_llvm_output('alpha', 0),
+#    "Probe returned false when output matched");
+#{
+#    my $stdout;
+#    my $rv = capture(
+#        sub { auto::llvm::_probe_for_llvm_output('Exuberant Ctags', 1) },
+#        \$stdout
+#    );
+#    ok($rv, "Probe returned true when output matched");
+#}
+#{
+#    my $stdout;
+#    my $rv = capture(
+#        sub { auto::llvm::_probe_for_llvm_output('alpha', 1) },
+#        \$stdout
+#    );
+#    ok(! $rv, "Probe returned false when output matched");
+#}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+t/steps/auto/llvm-01.t - tests Parrot::Configure step auto::llvm
+
+=head1 SYNOPSIS
+
+    prove t/steps/auto/llvm-01.t
+
+=head1 DESCRIPTION
+
+This file holds tests for auto::llvm.
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:


More information about the parrot-commits mailing list