forked from marcjoos-phd/dumses-hybrid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.py
executable file
·48 lines (45 loc) · 1.35 KB
/
make.py
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
#!/usr/bin/env python
#===============================================================================
# DUMSES-Hybrid:
# DUMSES make script.
#
# author:
# Marc Joos <marc.joos@cea.fr>, Sebastien Fromang, Romain Teyssier,
# Patrick Hennebelle
# copyright:
# Copyrights 2013-2015, CEA
# This file is distributed under the CeCILL-A & GNU/GPL licenses, see
# <http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.html> and
# <http://www.gnu.org/licenses/>
# date:
# created: 12-15-2014
# last modified: 06-25-2015
#===============================================================================
import os, sys, re, shutil
sys.path.append('utils/pyutils/')
from preproc import FileTree
if sys.version_info[0] <= 2:
from commands import getstatusoutput as cmd
else:
from subprocess import getstatusoutput as cmd
def editMakefile(fname='Makefile'):
tname = fname + '.temp'
tmpdir = re.compile('^TMPDIR')
with open(fname, 'r') as f, open(tname, 'w') as t:
for line in f:
if tmpdir.match(line):
line = "TMPDIR = tmp\n"
t.write(line)
shutil.move(tname, fname)
def main():
try:
os.makedirs('./bin')
except OSError:
pass
tree = FileTree('./src')
tree.processAllFiles()
editMakefile()
st, out = cmd('make')
print out
if __name__ == "__main__":
main()