Filter header files from built sources.

pull/15/head
Jussi Pakkanen 12 years ago
parent 5c0d1cc7c0
commit 2af66e5478
  1. 6
      environment.py
  2. 6
      interpreter.py
  3. 4
      test cases/22 header in file list/builder.txt
  4. 1
      test cases/22 header in file list/header.h
  5. 1
      test cases/22 header in file list/prog.c

@ -152,6 +152,8 @@ class ArLinker():
def get_output_flags(self):
return []
header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H']
class Environment():
def __init__(self, source_dir, build_dir, options):
self.source_dir = source_dir
@ -177,6 +179,10 @@ class Environment():
return os.environ[evar].split()
return self.default_c
def is_header(self, fname):
suffix = fname.split('.')[-1]
return suffix in header_suffixes
def detect_c_compiler(self):
exelist = self.get_c_compiler_exelist()
p = subprocess.Popen(exelist + ['--version'], stdout=subprocess.PIPE)

@ -443,7 +443,11 @@ class Interpreter():
if not isinstance(a, str):
raise InvalidArguments('Line %d: Argument %s is not a string.' % (node.lineno(), str(a)))
name = args[0]
sources = args[1:]
sources = []
for s in args[1:]:
print(s)
if not self.environment.is_header(s):
sources.append(s)
if len(sources) == 0:
raise InvalidArguments('Line %d: target has no source files.' % node.lineno())
if name in self.build.targets:

@ -0,0 +1,4 @@
project('header in file list', 'c')
exe = executable('prog', 'prog.c', 'header.h')
add_test('basic', exe)

@ -0,0 +1 @@
int main(int argc, char **argv) { return 0; }
Loading…
Cancel
Save