-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSConscript
More file actions
67 lines (47 loc) · 1.83 KB
/
SConscript
File metadata and controls
67 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!python
import os
# The cleaning code was borrowed from https://bitbucket.org/scons/scons/wiki/CustomCleanActions
def TestClean(env, targets):
if not env.GetOption('clean'):
return False
# Normalize targets to absolute paths
targets = env.subst('${TARGETS.abspath}', target=targets).split()
launchDir = env.GetLaunchDir()
topDir = env.Dir("#").abspath
clTargets = COMMAND_LINE_TARGETS
if len(clTargets) == 0:
clTargets.append(".")
for i in range(len(clTargets)):
fullTarget = ""
if clTargets[i][0] == '#':
fullTarget = os.path.join(topDir,clTargets[i][1:0])
else:
fullTarget = os.path.join(launchDir,clTargets[i])
fullTarget = os.path.normpath(fullTarget)
for target in targets:
if target.startswith(fullTarget):
return True
return False
def CleanActionFunc(env, targets, action):
if TestClean(env, targets):
env.Execute(action)
# The name of our program
TARGET='wgrib2'
# This is the way to make sure that environment variables are passed
# to the "make" command that is called downstream
env = Environment( ENV = { 'CC': 'gcc', 'FC': 'gfortran', 'PATH': os.environ['PATH'] } )
# Add the cleaner to the environment
env.AddMethod(CleanActionFunc, 'CleanAction')
# Get the commmand line prefix and add it to the environment
vars = Variables()
vars.Add( PathVariable( 'PREFIX', 'Installation Prefix', '/usr/local', PathVariable.PathIsDirCreate ) )
vars.Update(env)
installDir = env['PREFIX']
t = env.Command( "wgrib2/" + TARGET, "", "make" )
Default( t )
# Override the default clean to redirect it to call "make clean"
env.CleanAction( t, Action(['make clean']) )
# Add an installer
binTarget = os.path.join( installDir, 'bin' )
env.Install( binTarget, t )
env.Alias( 'install', binTarget )