public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andrea Arteaga" <andyspiros@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: /
Date: Mon, 13 Jun 2011 14:12:35 +0000 (UTC)	[thread overview]
Message-ID: <3ce46646c899b4a452a8dff930f39b6e7d898bd2.spiros@gentoo> (raw)

commit:     3ce46646c899b4a452a8dff930f39b6e7d898bd2
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Mon Jun 13 14:11:53 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Mon Jun 13 14:11:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=3ce46646

Starting code cleanup. Created btlutils.

---
 blasbase.py |   36 +++++++++++++++---------------------
 btlutils.py |   30 ++++++++++++++++++++++++++++++
 main.py     |    6 ++++++
 3 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/blasbase.py b/blasbase.py
index 3335000..b9be2cd 100644
--- a/blasbase.py
+++ b/blasbase.py
@@ -3,6 +3,7 @@ import commands as cmd
 import subprocess as sp
 import matplotlib.pyplot as plt
 import numpy as np
+import btlutils as btl
 
 run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
 
@@ -85,29 +86,22 @@ class ModuleBase:
             os.environ['LD_LIBRARY_PATH'] = root + libdir
         
         # Compile
-        exe = testdir + "/test"
-        inc = """
-        -Ibtl/actions
-        -Ibtl/generic_bench
-        -Ibtl/generic_bench/utils
-        -Ibtl/libs/BLAS
-        -Ibtl/libs/STL
-        """.replace('\n', '')
-        libs = "-lrt -L" + root+libdir
-        cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
-        defines = "-DCBLASNAME=" + name
-        implflags = self._get_flags(root, impl, libdir)
-        cl = "g++ %s %s %s %s %s btl/libs/BLAS/main.cpp -o %s" \
-            % (inc, libs, cxxflags, defines, implflags, exe)
-        cl = shlex.split(cl)
-        cp = sp.Popen(cl, stdout=sp.PIPE, stderr=sp.PIPE)
-        cp.communicate()
-        if cp.returncode != 0:
-            raise Exception("Compilation failed: " + " ".join(cl))
-        Print("Compilation successful")
+        returncode, compilecl = btl.btlcompile(
+          exe = testdir + "/test",
+          source = "btl/libs/BLAS/main.cpp",
+          btldir = 'btl/',
+          includes = ['btl/libs/BLAS'],
+          defines = ["CBLASNAME=" + name],
+          libs = [],
+          libdirs = [root+libdir],
+          other = [self._get_flags(root, impl, libdir)]
+        )
+        if returncode != 0:
+            raise Exception("Compilation failed: " + compilecl)
+        Print("Compilation successful: " + compilecl)
         
         # Run test
-        args = [exe] + self.tests
+        args = [testdir + "/test"] + self.tests
         proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
           cwd = testdir)
         results = {}

diff --git a/btlutils.py b/btlutils.py
new file mode 100644
index 0000000..3da5b0c
--- /dev/null
+++ b/btlutils.py
@@ -0,0 +1,30 @@
+import subprocess as sp
+import shlex
+
+run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
+
+def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other):
+    incs = (
+      "%s/actions" % btldir,
+      "%s/generic_bench" % btldir,
+      "%s/generic_bench/utils" % btldir,
+      "%s/libs/STL" % btldir
+    ) + tuple(includes)
+    incs = ' '.join(['-I'+i for i in incs])
+    
+    defs = ' '.join(['-D'+d for d in ["NDEBUG"] + defines])
+    
+    libs = ' '.join(['-l'+l for l in ["rt"] + libs])
+    
+    libdirs = ' '.join(['-L'+L for L in libdirs])
+    
+    cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
+    
+    otherflags = ' '.join(other)
+    
+    cl = "g++ -o %s %s %s %s %s %s %s %s" \
+        % (exe, source, incs, defs, libs, libdirs, cxxflags, otherflags)
+    cl = shlex.split(cl)
+    cp = sp.Popen(cl, stdout=sp.PIPE, stderr=sp.PIPE)
+    cp.communicate()
+    return (cp.returncode, ' '.join(cl))

diff --git a/main.py b/main.py
index ee17fed..a992e58 100644
--- a/main.py
+++ b/main.py
@@ -1,6 +1,7 @@
 import os, sys, shlex
 from PortageUtils import *
 import subprocess as sp
+import time
   
 class _Print:
     def __init__(self, maxlevel=10):
@@ -78,6 +79,11 @@ try:
 except ImportError, IndexError:
     print_usage()
     exit(1)
+    
+#tmp = __import__(sys.argv[1], fromlist = ['Module'])
+#mod = tmp.Module(Print, libdir, sys.argv[3:])
+#del tmp
+#testsfname = sys.argv[2]
 
 
 """



             reply	other threads:[~2011-06-13 14:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 14:12 Andrea Arteaga [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-09-02 11:41 [gentoo-commits] proj/auto-numerical-bench:master commit in: / Andrea Arteaga
2012-08-11 18:00 Andrea Arteaga
2012-08-04  1:11 Andrea Arteaga
2012-04-09 22:58 Andrea Arteaga
2012-03-05 15:48 Andrea Arteaga
2012-02-28 19:20 Andrea Arteaga
2012-02-24 17:22 Andrea Arteaga
2011-08-22 18:15 Andrea Arteaga
2011-08-16 23:38 Andrea Arteaga
2011-08-15 21:57 Andrea Arteaga
2011-08-14 12:59 Andrea Arteaga
2011-08-14 12:35 Andrea Arteaga
2011-08-12 22:56 Andrea Arteaga
2011-08-09  0:00 Andrea Arteaga
2011-08-09  0:00 Andrea Arteaga
2011-07-17  0:21 Andrea Arteaga
2011-07-13 21:48 Andrea Arteaga
2011-06-15 23:25 Andrea Arteaga
2011-06-15 12:56 Andrea Arteaga
2011-06-13 23:53 Andrea Arteaga
2011-06-10  1:02 Andrea Arteaga
2011-06-10  0:52 Andrea Arteaga
2011-06-06 20:05 Andrea Arteaga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ce46646c899b4a452a8dff930f39b6e7d898bd2.spiros@gentoo \
    --to=andyspiros@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox