wat
This commit is contained in:
parent
c9ff381f39
commit
921890e0b2
8 changed files with 95 additions and 10 deletions
9
site_scons/dirs.py
Normal file
9
site_scons/dirs.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# dirs.py
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
from SCons.Script import Dir
|
||||
|
||||
BUILD_DIR = Dir('#build')
|
||||
LIB_DIR = Dir('#lib')
|
||||
SRC_DIR = Dir('#src')
|
||||
TEST_DIR = Dir('#test')
|
||||
|
|
@ -7,14 +7,9 @@
|
|||
|
||||
import os.path
|
||||
import SCons.Defaults
|
||||
import binaries
|
||||
from dirs import *
|
||||
|
||||
|
||||
BUILD_DIR = Dir('#build')
|
||||
LIB_DIR = Dir('#lib')
|
||||
SRC_DIR = Dir('#src')
|
||||
TEST_DIR = Dir('#test')
|
||||
|
||||
#
|
||||
# Environment Configuration
|
||||
#
|
||||
|
|
@ -22,11 +17,15 @@ TEST_DIR = Dir('#test')
|
|||
def has_clang(env):
|
||||
_, cc_tail = os.path.split(env['CC'])
|
||||
_, cxx_tail = os.path.split(env['CXX'])
|
||||
return any([cc_tail.startswith('clang'), cxx_tail.startswith('clang')])
|
||||
return all([cc_tail.startswith('clang'), cxx_tail.startswith('clang')])
|
||||
|
||||
default_env = SCons.Defaults.DefaultEnvironment()
|
||||
default_env.Replace(CC=binaries.first(['clang', 'gcc']),
|
||||
CXX=binaries.first(['clang++', 'g++']))
|
||||
default_env.Append(TOOLS=['gtest'])
|
||||
print default_env.Dump()
|
||||
|
||||
default_env.Replace(
|
||||
CC=default_env.WhereIs('clang') or default_env.WhereIs('gcc'),
|
||||
CXX=default_env.WhereIs('clang++') or default_env.WhereIs('gcc++'))
|
||||
|
||||
default_env.Append(CCFLAGS=['-Wall', '-Wextra', '-pedantic'],
|
||||
CFLAGS=['-std=c99'],
|
||||
|
|
|
|||
28
site_scons/site_tools/gtest/__init__.py
Normal file
28
site_scons/site_tools/gtest/__init__.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# gtestprogram.py
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
import SCons.Util
|
||||
import dirs
|
||||
|
||||
|
||||
def build_gtest_program(env, target, source=None, *args, **kwargs):
|
||||
if not SCons.Util.is_List(source):
|
||||
source = [source]
|
||||
source.insert(0, dirs.LIB_DIR.Dir('gtest').File('gtest_main.cc'))
|
||||
source.append(env['LIBS']['gtest']['static'])
|
||||
return env.Program(target, source, *args, **kwargs)
|
||||
|
||||
|
||||
def generate(env):
|
||||
print 'gtestprogram generate()'
|
||||
try:
|
||||
env.AddMethod(build_gtest_program, 'GTestProgram')
|
||||
except AttributeError:
|
||||
# Old version of SCons
|
||||
from SCons.Script.SConscript import SConsEnvironment
|
||||
SConsEnvironment.GTestProgram = build_gtest_program
|
||||
|
||||
|
||||
def exists(env):
|
||||
print 'gtestprogram exists()'
|
||||
return 'gtest' in env['LIBS']
|
||||
Loading…
Add table
Add a link
Reference in a new issue