setup.py: Make sure CFLAGS has at least one -O

This commit is contained in:
Yury Selivanov 2016-05-17 18:34:01 -04:00
parent dc8aefb67a
commit 7d78e505f2
1 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import os
import re
import subprocess
import sys
import unittest
@ -39,10 +40,11 @@ class libuv_build_ext(build_ext):
def build_libuv(self):
env = os.environ.copy()
env['CFLAGS'] = ('-fPIC ' +
env.get('CFLAGS', '-O2') +
' ' +
env.get('ARCHFLAGS', ''))
cur_cflags = env.get('CFLAGS', '')
if not re.search('-O\d', cur_cflags):
cur_cflags += ' -O2'
env['CFLAGS'] = (cur_cflags + ' -fPIC' + env.get('ARCHFLAGS', ''))
j_flag = '-j{}'.format(os.cpu_count() or 1)