Changeset 4448
- Timestamp:
- May 16, 2007, 11:46:47 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/compile.py
r4426 r4448 8 8 compile.compile(<filename>,..) 9 9 10 Ole Nielsen, Oct 200110 Ole Nielsen, Duncan Gray Oct 2001 11 11 """ 12 12 … … 25 25 26 26 27 ###########################jhdsgfjgdjfg28 27 29 28 import os, string, sys, types … … 119 118 compiler = CC 120 119 else: 121 compiler = 'gcc.exe' #Some systems require this (perhaps a security measure?)120 compiler = 'gcc.exe' #Some systems require this (a security measure?) 122 121 if LD: 123 122 loader = LD … … 222 221 open(FN, 'r') 223 222 except: 224 #print 'CWD:', os.getcwd()225 223 raise Exception, "Could not open: " + FN 226 224 … … 232 230 # 233 231 if utilities_include_dir is None: 234 s = '%s -c %s -I %s -o %s.o-Wall -O3'\232 s = '%s -c %s -I"%s" -o "%s.o" -Wall -O3'\ 235 233 %(compiler, FN, python_include, root) 236 234 else: 237 s = '%s -c %s -I%s -I%s -o %s.o -Wall -O3'\ 238 %(compiler, FN, python_include, utilities_include_dir, root) 235 if FN == "triangle.c" or FN == "mesh_engine_c_layer.c": 236 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -O3 -DTRILIBRARY=1 -DNO_TIMER=1'\ 237 %(compiler, FN, python_include, utilities_include_dir, root) 238 else: 239 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -Wall -O3'\ 240 %(compiler, FN, python_include, utilities_include_dir, root) 239 241 240 242 if os.name == 'posix' and os.uname()[4] == 'x86_64': … … 262 264 263 265 # Make shared library (*.so or *.dll) 264 265 s = "%s -%s %s -o %s.%s %s -lm" %(loader, sharedflag, object_files, root1, libext, libs) 266 if libs is "": 267 s = '%s -%s %s -o %s.%s -lm' %(loader, sharedflag, object_files, root1, libext) 268 else: 269 s = '%s -%s %s -o %s.%s "%s" -lm' %(loader, sharedflag, object_files, root1, libext, libs) 266 270 if verbose: 267 271 print s … … 282 286 """ 283 287 288 from anuga.config import use_extensions 284 289 285 290 from os.path import splitext … … 288 293 289 294 C=False 290 291 try: 292 s = 'import %s' %root 293 #print s 294 exec(s) 295 except: 295 if use_extensions: 296 296 try: 297 open(filename) 297 s = 'import %s' %root 298 #print s 299 exec(s) 298 300 except: 299 msg = 'C extension %s cannot be opened' %filename300 print msg301 else:302 print '------- Trying to compile c-extension %s' %filename303 304 compile(filename)305 301 try: 306 compile(filename)302 open(filename) 307 303 except: 308 print 'WARNING: Could not compile C-extension %s'\ 309 %filename 310 else: 304 msg = 'C extension %s cannot be opened' %filename 305 print msg 306 else: 307 print '------- Trying to compile c-extension %s' %filename 308 311 309 try: 312 exec('import %s' %root)310 compile(filename) 313 311 except: 314 msg = 'C extension %s seems to compile OK, ' 315 msg += 'but it can still not be imported.' 316 raise msg 312 print 'WARNING: Could not compile C-extension %s'\ 313 %filename 317 314 else: 318 C=True 319 else: 320 C=True 315 try: 316 exec('import %s' %root) 317 except: 318 msg = 'C extension %s seems to compile OK, ' 319 msg += 'but it can still not be imported.' 320 raise msg 321 else: 322 C=True 323 else: 324 C=True 321 325 322 326 if not C: … … 325 329 326 330 return C 327 328 329 331 330 332 … … 360 362 pass 361 363 362 print '------------------------------- -------'364 print '-------------------------------_-------' 363 365 print 'Trying to compile c-extension %s in %s'\ 364 366 %(filename, os.getcwd()) 365 366 compile(filename)367 367 try: 368 if filename == 'triang.c': 369 compile(['triang.c','triangle.c']) 370 elif filename == 'mesh_engine_c_layer.c': 371 compile(['mesh_engine_c_layer.c','triangle.c']) 372 else: 368 373 compile(filename) 369 374 except Exception, e:
Note: See TracChangeset
for help on using the changeset viewer.