Skip to content
Snippets Groups Projects
Commit ec926152 authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

decide to compile based on actual dependency list

parent 98d5afab
Branches
Tags
1 merge request!23WIP: Feature/use cmake
Pipeline #36539 passed
...@@ -65,6 +65,15 @@ src_file_list = ['hdf5_tools', ...@@ -65,6 +65,15 @@ src_file_list = ['hdf5_tools',
'Lagrange_polys', 'Lagrange_polys',
'scope_timer'] 'scope_timer']
def get_file_dependency_list(src_file):
p = subprocess.Popen(
['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
deps = str(out, 'ASCII').replace('\\\n', '')
return deps
def get_dependency_list(): def get_dependency_list():
ofile = open('dependencies.txt', 'w') ofile = open('dependencies.txt', 'w')
for src_file in src_file_list: for src_file in src_file_list:
......
...@@ -215,13 +215,10 @@ class CompileLibCommand(distutils.cmd.Command): ...@@ -215,13 +215,10 @@ class CompileLibCommand(distutils.cmd.Command):
if not os.path.isfile('bfps/libbfps.a'): if not os.path.isfile('bfps/libbfps.a'):
need_to_compile = True need_to_compile = True
else: else:
need_to_compile = False
ofile = 'bfps/libbfps.a' ofile = 'bfps/libbfps.a'
libtime = datetime.datetime.fromtimestamp(os.path.getctime(ofile)) libtime = datetime.datetime.fromtimestamp(os.path.getctime(ofile))
latest = libtime latest = libtime
for fname in header_list:
latest = max(latest,
datetime.datetime.fromtimestamp(os.path.getctime('bfps/' + fname)))
need_to_compile = (latest > libtime)
eca = extra_compile_args eca = extra_compile_args
eca += ['-fPIC'] eca += ['-fPIC']
if self.timing_output: if self.timing_output:
...@@ -238,9 +235,14 @@ class CompileLibCommand(distutils.cmd.Command): ...@@ -238,9 +235,14 @@ class CompileLibCommand(distutils.cmd.Command):
if not os.path.exists(ofile): if not os.path.exists(ofile):
need_to_compile_file = True need_to_compile_file = True
else: else:
need_to_compile_file = (need_to_compile or need_to_compile_file = False
(datetime.datetime.fromtimestamp(os.path.getctime(ofile)) < if not need_to_compile:
datetime.datetime.fromtimestamp(os.path.getctime(ifile)))) latest = libtime
dependency_list = get_file_dependency_list(fname)
for depname in dependency_list.split()[1:]:
latest = max(latest,
datetime.datetime.fromtimestamp(os.path.getctime(depname)))
need_to_compile_file = (latest > libtime)
if need_to_compile_file: if need_to_compile_file:
command_strings = [compiler, '-c'] command_strings = [compiler, '-c']
command_strings += ['bfps/cpp/' + fname + '.cpp'] command_strings += ['bfps/cpp/' + fname + '.cpp']
...@@ -269,6 +271,15 @@ class CompileLibCommand(distutils.cmd.Command): ...@@ -269,6 +271,15 @@ class CompileLibCommand(distutils.cmd.Command):
protocol = 2) protocol = 2)
return None return None
def get_file_dependency_list(src_file):
p = subprocess.Popen(
['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
deps = str(out, 'ASCII').replace('\\\n', '')
return deps
from setuptools import setup from setuptools import setup
setup( setup(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment