Commit c2939bca authored by Roman Yurchak's avatar Roman Yurchak

Skip building C extensions for the target

(except for numpy)
parent 34384953
......@@ -59,10 +59,43 @@ def collect_args(basename):
path = path.replace(str(ROOTDIR) + ':', '')
env['PATH'] = path
# determine the package name from the current directory
re_res = re.match('.*packages/(?P<name>[\w\-]+)/build.*',
env['PWD'])
if re_res:
package_name = re_res.group('name')
else:
package_name = None
# Skip compilations of C/Fortran extensions for the target environement.
# We still need to generate the output files for distutils to continue
# the build.
# TODO: This may need slight tuning for new projects. In particular,
# currently ar is not skipped, so a known failure would happen when
# we create some object files (that are empty as gcc is skipped), on
# which we run the actual ar command.
skip = False
if (basename in ['gcc', 'cc', 'c++', 'gfortran', 'ld']
and '-o' in sys.argv[1:]
# do not skip numpy as it is needed as build time
# dependency by other packages (e.g. matplotlib)
and package_name != 'numpy'):
out_idx = sys.argv.index('-o')
if (out_idx + 1) < len(sys.argv):
# get the index of the output file path
out_idx += 1
with open(sys.argv[out_idx], 'wb') as fh:
fh.write(b'')
skip = True
with open('build.log', 'a') as fd:
if skip:
fd.write('SKIP\n')
json.dump([basename] + sys.argv[1:], fd)
fd.write('\n')
if skip:
sys.exit(0)
sys.exit(
subprocess.run(
[basename] + sys.argv[1:],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment