[Numpy-svn] r4222 - branches/numpy.scons/numpy/core/code_generators

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Oct 18 01:15:25 EDT 2007


Author: cdavid
Date: 2007-10-18 00:15:15 -0500 (Thu, 18 Oct 2007)
New Revision: 4222

Modified:
   branches/numpy.scons/numpy/core/code_generators/generate_array_api.py
   branches/numpy.scons/numpy/core/code_generators/generate_ufunc_api.py
Log:
Merge back cleanconfig modifications for reuse of code generators

Modified: branches/numpy.scons/numpy/core/code_generators/generate_array_api.py
===================================================================
--- branches/numpy.scons/numpy/core/code_generators/generate_array_api.py	2007-10-18 05:02:14 UTC (rev 4221)
+++ branches/numpy.scons/numpy/core/code_generators/generate_array_api.py	2007-10-18 05:15:15 UTC (rev 4222)
@@ -1,9 +1,6 @@
 import os
 import genapi
 
-OBJECT_API_ORDER = 'array_api_order.txt'
-MULTIARRAY_API_ORDER = 'multiarray_api_order.txt'
-
 types = ['Generic','Number','Integer','SignedInteger','UnsignedInteger',
          'Inexact',
          'Floating', 'ComplexFloating', 'Flexible', 'Character',
@@ -122,22 +119,30 @@
 """
 
 def generate_api(output_dir, force=False):
-    header_file = os.path.join(output_dir, '__multiarray_api.h')
-    c_file = os.path.join(output_dir,'__multiarray_api.c')
-    doc_file = os.path.join(output_dir, 'multiarray_api.txt')
+    basename = 'multiarray_api'
 
-    targets = (header_file, c_file, doc_file)
-    if (not force
-            and not genapi.should_rebuild(targets,
-                                          [OBJECT_API_ORDER,
-                                           MULTIARRAY_API_ORDER,
-                                           __file__])):
+    h_file = os.path.join(output_dir, '__%s.h' % basename)
+    c_file = os.path.join(output_dir, '__%s.c' % basename)
+    d_file = os.path.join(output_dir, '%s.txt' % basename)
+    targets = (h_file, c_file, d_file)
+    sources = ['array_api_order.txt',  'multiarray_api_order.txt']
+
+    if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
         return targets
+    else:
+        do_generate_api(targets, sources)
 
+    return targets
+
+def do_generate_api(targets, sources):
+    header_file = targets[0]
+    c_file = targets[1]
+    doc_file = targets[2]
+
     objectapi_list = genapi.get_api_functions('OBJECT_API',
-                                              OBJECT_API_ORDER)
+                                              sources[0])
     multiapi_list = genapi.get_api_functions('MULTIARRAY_API',
-                                             MULTIARRAY_API_ORDER)
+                                             sources[1])
     # API fixes for __arrayobject_api.h
 
     fixed = 10

Modified: branches/numpy.scons/numpy/core/code_generators/generate_ufunc_api.py
===================================================================
--- branches/numpy.scons/numpy/core/code_generators/generate_ufunc_api.py	2007-10-18 05:02:14 UTC (rev 4221)
+++ branches/numpy.scons/numpy/core/code_generators/generate_ufunc_api.py	2007-10-18 05:15:15 UTC (rev 4222)
@@ -1,8 +1,6 @@
 import os
 import genapi
 
-UFUNC_API_ORDER = 'ufunc_api_order.txt'
-
 h_template = r"""
 #ifdef _UMATHMODULE
 
@@ -72,18 +70,29 @@
 """
 
 def generate_api(output_dir, force=False):
-    header_file = os.path.join(output_dir, '__ufunc_api.h')
-    c_file = os.path.join(output_dir, '__ufunc_api.c')
-    doc_file = os.path.join(output_dir, 'ufunc_api.txt')
+    basename = 'ufunc_api'
+    
+    h_file = os.path.join(output_dir, '__%s.h' % basename)
+    c_file = os.path.join(output_dir, '__%s.c' % basename)
+    d_file = os.path.join(output_dir, '%s.txt' % basename)
+    targets = (h_file, c_file, d_file)
 
-    targets = (header_file, c_file, doc_file)
-    if (not force
-            and not genapi.should_rebuild(targets,
-                                          [UFUNC_API_ORDER, __file__])):
+    sources = ['ufunc_api_order.txt']
+
+    if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
         return targets
+    else:
+        do_generate_api(targets, sources)
 
-    ufunc_api_list = genapi.get_api_functions('UFUNC_API', UFUNC_API_ORDER)
+    return targets
 
+def do_generate_api(targets, sources):
+    header_file = targets[0]
+    c_file = targets[1]
+    doc_file = targets[2]
+
+    ufunc_api_list = genapi.get_api_functions('UFUNC_API', sources[0])
+
     # API fixes for __arrayobject_api.h
 
     fixed = 1




More information about the Numpy-svn mailing list