1 | import os |
---|
2 | import re |
---|
3 | |
---|
4 | def generate(env): |
---|
5 | def CheckCasaLib(context, lib): |
---|
6 | context.Message("Checking casa library '%s'..."%lib) |
---|
7 | |
---|
8 | context.Result(r) |
---|
9 | return r |
---|
10 | |
---|
11 | def CheckCasa(context, path=None): |
---|
12 | ''' look for casa libraries''' |
---|
13 | def addCasa(env): |
---|
14 | casalibs = "casav atnf images ms components coordinates \ |
---|
15 | lattices fits measures measures_f \ |
---|
16 | tables scimath scimath_f casa wcs".split() |
---|
17 | #env.Prepend( LIBS = casalibs ) |
---|
18 | casaincd = [os.path.join(env['CASAROOT'], 'code/include'), \ |
---|
19 | os.path.join(env['CASAROOT'], 'code/casa')] |
---|
20 | env.Append( CPPPATH = casaincd ) |
---|
21 | casalibd = os.path.join(env['CASAROOT'], env['CASAARCH'], 'lib') |
---|
22 | env.Append( LIBPATH = [ casalibd ] ) |
---|
23 | # Explicit templates in casa |
---|
24 | env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] ) |
---|
25 | context.Message('Checking for casa libraries...') |
---|
26 | casaarch = None |
---|
27 | if os.environ.has_key('AIPSPATH'): |
---|
28 | casa = os.environ.get('AIPSPATH').split() |
---|
29 | context.env.Append(CASAARCH = casa[1]) |
---|
30 | context.env.Append(CASAROOT = casa[0]) |
---|
31 | addCasa(context.env) |
---|
32 | context.Result('yes') |
---|
33 | return True |
---|
34 | casaarch = 'linux_gnu' |
---|
35 | if sys.platform == 'darwin': |
---|
36 | casaarch = 'darwin' |
---|
37 | elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit': |
---|
38 | casaarch = 'linux_64b' |
---|
39 | paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split() |
---|
40 | if path is not None and len(path): |
---|
41 | paths = [path] |
---|
42 | # @todo poor mans detection, do autocontext later |
---|
43 | for p in paths: |
---|
44 | if os.path.isfile(os.path.join(p, casaarch, "lib/libcasa.a")): |
---|
45 | context.env.Append(CASAARCH = casaarch) |
---|
46 | context.env.Append(CASAROOT = os.path.abspath(p)) |
---|
47 | addCasa(context.env) |
---|
48 | context.Result('yes') |
---|
49 | return True |
---|
50 | context.Result('no') |
---|
51 | return False |
---|
52 | |
---|
53 | |
---|
54 | def AddCustomTests(conf): |
---|
55 | conf.AddTests({ |
---|
56 | 'CheckCasa' : CheckCasa, |
---|
57 | }) |
---|
58 | |
---|
59 | env.AddCustomTests = AddCustomTests |
---|
60 | |
---|
61 | def AddCustomPath(path=""): |
---|
62 | if not len(path) or not os.path.exists(path): |
---|
63 | return |
---|
64 | env.PrependUnique(CPPPATH = [os.path.join(path, "include")]) |
---|
65 | env.PrependUnique(LIBPATH = [os.path.join(path, "lib")]) |
---|
66 | env.AddCustomPath = AddCustomPath |
---|
67 | |
---|
68 | def exists(env): |
---|
69 | return true |
---|