1 |
import os, os.path, platform, subprocess |
2 |
from SCons.Script import * |
3 |
|
4 |
munge = lambda s: s |
5 |
|
6 |
try: |
7 |
# if we have access to GetShortPathName, we'll use it... |
8 |
import win32api |
9 |
def munge1(s): |
10 |
s1 = s |
11 |
try: |
12 |
# we can only munge the path if it actually exists |
13 |
s1 = win32api.GetShortPathName(s) |
14 |
except: |
15 |
# if it doesn't exist, we just return the un-munged path |
16 |
pass |
17 |
return s1 |
18 |
munge = munge1 |
19 |
except: |
20 |
pass |
21 |
|
22 |
def generate(env): |
23 |
""" |
24 |
Detect IPOPT settings and add them to the environment. |
25 |
""" |
26 |
try: |
27 |
if platform.system()=="Windows": |
28 |
pkgconfig = ['c:\\MSYS\\1.0\\bin\\sh.exe','/MinGW/bin/pkg-config'] |
29 |
else: |
30 |
pkgconfig = ['/usr/bin/pkg-config'] |
31 |
|
32 |
cmd = pkgconfig + ['ipopt','--libs','--cflags'] |
33 |
env1 = env.Clone() |
34 |
env1['CPPPATH'] = None |
35 |
env1['LIBPATH'] = None |
36 |
env1['LIBS'] = None |
37 |
env1.ParseConfig(cmd) |
38 |
env['IPOPT_CPPPATH'] = env1.get('CPPPATH') |
39 |
env['IPOPT_LIBPATH'] = env1.get('LIBPATH') |
40 |
env['IPOPT_LIBS'] = env1.get('LIBS') |
41 |
env['HAVE_IPOPT'] = True |
42 |
|
43 |
print "IPOPT_LIBS =",env.get('IPOPT_LIBS') |
44 |
print "IPOPT_LIBPATH =",env.get('IPOPT_LIBPATH') |
45 |
print "IPOPT_CPPPATH =",env.get('IPOPT_CPPPATH') |
46 |
|
47 |
except Exception, e: |
48 |
print "FAILED IPOPT DETECTION:",e.__class__,str(e) |
49 |
env['HAVE_IPOPT'] = False |
50 |
|
51 |
def exists(env): |
52 |
""" |
53 |
Make sure this tool exists. |
54 |
""" |
55 |
if not subprocess.call('pkg-config --exists ipopt'): |
56 |
return True |
57 |
return False |
58 |
|