Skip to content

Instantly share code, notes, and snippets.

@FlandreDaisuki
Created February 19, 2016 07:14
Show Gist options
  • Save FlandreDaisuki/d80f6e3ed9402e6400ec to your computer and use it in GitHub Desktop.
Save FlandreDaisuki/d80f6e3ed9402e6400ec to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
import subprocess
import sys
import re
cflags = subprocess.getoutput('pkg-config --cflags --libs opencv')
# print(cflags)
cpp = sys.argv[1]
cmpl = 'g++ {} {}'.format(cpp, cflags)
print(cmpl)
cmpl_msg = subprocess.getoutput(cmpl)
if cmpl_msg:
m = re.search('cannot find\s*(\S+)', cmpl_msg)
if m:
cmpl_x = re.sub(m.group(1), '', cmpl)
subprocess.getoutput(cmpl_x)
else:
print(cmpl_msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment