Skip to content

Instantly share code, notes, and snippets.

@egregius313
Created February 16, 2018 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egregius313/c4875e744f72326bfbcd94c38b1cca9e to your computer and use it in GitHub Desktop.
Save egregius313/c4875e744f72326bfbcd94c38b1cca9e to your computer and use it in GitHub Desktop.
check_cflags - guarantees that -Wall -Werror --pedantic flags are set in $CFLAGS
#!/usr/bin/env python
# check_cflags.py
"""
check_cflags - guarantees that -Wall -Werror --pedantic flags are set in $CFLAGS
Exits with 0 if proper CFLAGS is used, otherwise returns with 1
Usage:
./check_cflags.py FILE
"""
import distutils.sysconfig
import sys
def check_cflags(filename):
args = distutils.sysconfig.parse_makefile(filename)
if 'CFLAGS' not in args:
return 1
flags = args['CFLAGS']
return not all(flag in flags for flag in ['-Wall', '-Werror', '--pedantic'])
if __name__ == '__main__':
filename = sys.argv[1]
exitcode = check_cflags(filename)
if exitcode:
print('$(CFLAGS) does not contain -Wall -Werror and --pedantic')
else:
print('Makefile looks good')
exit(exitcode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment