]> granicus.if.org Git - graphviz/commitdiff
support receiving C compiler flags in the test suite from the environment
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Apr 2021 04:07:09 +0000 (21:07 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 23:49:01 +0000 (16:49 -0700)
The environment variables CFLAGS and LDFLAGS now also effect the flags used with
the C compiler in the test suite, in addition to the build system. Related to
#1881.

rtest/gvtest.py

index fd41c38a24fbad90747949ecf2ff30e3c6565702..06ca30952cd9ca80087d5fe0702848e762e3a57a 100644 (file)
@@ -13,6 +13,10 @@ def compile_c(src: Path, cflags: List[str] = [], link: List[str] = [],
     compile a C program
     '''
 
+    # include compiler flags from both the caller and the environment
+    cflags = os.environ.get('CFLAGS', '').split() + cflags
+    ldflags = os.environ.get('LDFLAGS', '').split()
+
     # if the user did not give us destination, use a temporary path
     if dst is None:
         _, dst = tempfile.mkstemp('.exe')
@@ -24,14 +28,14 @@ def compile_c(src: Path, cflags: List[str] = [], link: List[str] = [],
         # construct an invocation of MSVC
         args = ['cl', src, '-Fe:', dst, '-nologo', rtflag] + cflags
         if len(link) > 0:
-            args += ['-link'] + [f'{l}.lib' for l in link]
+            args += ['-link'] + [f'{l}.lib' for l in link] + ldflags
 
     else:
         # construct an invocation of the default C compiler
         cc = os.environ.get('CC', 'cc')
         args = [cc, '-std=c99', src, '-o', dst] + cflags
         if len(link) > 0:
-            args += [f'-l{l}' for l in link]
+            args += [f'-l{l}' for l in link] + ldflags
 
     # compile the program
     try: