Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
Added debug build. Modify pkg config script according to build type.
Browse files Browse the repository at this point in the history
  • Loading branch information
juvinious committed May 8, 2015
1 parent 2ccd2ab commit b7a7e4c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
35 changes: 22 additions & 13 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SetOption('num_jobs', scons.utils.detectCPUs())
includedir = '{0}/include'.format(os.getcwd())

env = Environment(ENV = os.environ, CPPPATH=includedir, tools=['textfile', 'default'])
config = env.Configure(custom_tests = {'CheckAllegro5': scons.checks.checkAllegro5(False),
config = env.Configure(custom_tests = {'CheckAllegro5': scons.checks.checkAllegro5(scons.checks.debug()),
'CheckFreetype': scons.checks.checkFreetype,
'ConfigChecks': scons.checks.configChecks})
config.CheckAllegro5()
Expand All @@ -20,14 +20,19 @@ env = scons.utils.less_verbose(env)
if not env['HAVE_ALLEGRO5']:
Exit(1)

build_dir = 'build'
if scons.checks.debug():
env.Append(CXXFLAGS = ['-g3','-ggdb', '-Werror'])

build_dir = 'build/release' if not scons.checks.debug() else 'build/debug'
options = {'networking': False,
'allegro5': True
}

libname = 'lib/r-tech1' if not scons.checks.debug() else 'lib/r-tech1-debug'

env.VariantDir(build_dir, 'src')
libs = env.SConscript('src/SConscript', variant_dir=build_dir, exports=['env', 'options'])
rtech1 = env.StaticLibrary('lib/r-tech1', libs)
rtech1 = env.StaticLibrary(libname, libs)
Alias('rtech1', rtech1)

tests_build_dir = os.path.join(build_dir, 'tests')
Expand All @@ -51,21 +56,25 @@ if os.access(env.installPrefix, os.W_OK):

# PC script
replacelist = {
'%lib%': 'r-tech1' if not scons.checks.debug() else 'r-tech1-debug',
'%prefix%': env.installPrefix,
'%rtech1_version%': '1',
'%flags%': pcflags,
'%libs%': pclibs,
'%libpaths%': pclibpaths
}

pc_install = '{0}/lib/pkgconfig/r-tech1.pc'.format(env.installPrefix)

pc_copied = Command(build_dir + '/temp.pc.in', 'misc/r-tech1.pc.in', Copy('$TARGET', '$SOURCE'))
pc_script = env.Substfile(build_dir + '/temp.pc.in', SUBST_DICT = replacelist)
env.Depends(pc_script, pc_copied)
pc_mod = Command(build_dir + '/r-tech1.pc', build_dir + '/temp.pc', Copy('$TARGET', '$SOURCE'))
env.Depends(pc_mod, pc_script)
env.InstallAs(pc_install, pc_mod)

def script(name):
pc_install = '{0}/lib/pkgconfig/{1}.pc'.format(env.installPrefix, name)
pc_copied = Command(build_dir + '/temp.pc.in', 'misc/r-tech1.pc.in'.format(name), Copy('$TARGET', '$SOURCE'))
pc_script = env.Substfile(build_dir + '/temp.pc.in', SUBST_DICT = replacelist)
env.Depends(pc_script, pc_copied)
pc_mod = Command(build_dir + '/{0}.pc'.format(name), build_dir + '/temp.pc', Copy('$TARGET', '$SOURCE'))
env.Depends(pc_mod, pc_script)
env.InstallAs(pc_install, pc_mod)
return pc_mod, pc_install

pc_mod, pc_install = script('r-tech1') if not scons.checks.debug() else script('r-tech1-debug')

# Install
env.Alias('install', [env.installPrefix, pc_install])
Expand All @@ -86,7 +95,7 @@ env.Default(unit_tests)

for test in unit_tests:
orig = str(test).translate(None,'[]\'')
to = orig.replace('build/tests/', '')
to = orig.replace('{0}/tests/'.format(build_dir), '')
print orig, to
copy = Command('bin/{0}'.format(to), orig, Copy('$TARGET', '$SOURCE'))
env.Depends(copy, test)
Expand Down
5 changes: 3 additions & 2 deletions misc/r-tech1.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ libdir=${prefix}/lib
includedir=${prefix}/include
version=%rtech1_version%
flags=%flags%
lib=%lib%
libs=%libs%
paths=%libpaths%

Name: r-tech1
Name: ${lib}
Description: R-Tech1 Library Wrapper Utility
Version: ${version}
Libs: -L${libdir} ${paths} -lr-tech1 ${libs}
Libs: -L${libdir} ${paths} -l${lib} ${libs}
Cflags: -I${includedir} -I${includedir}/r-tech1 ${flags}
7 changes: 7 additions & 0 deletions scons/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ def checkFreetype(context):
context.Message('Not found, install libfreetype2')
context.Result(utils.colorResult(ok))
return ok

def debug():
try:
import os
return int(os.environ[ 'DEBUG' ])
except KeyError:
return 0

def configChecks(context):
def prefix(env):
Expand Down

0 comments on commit b7a7e4c

Please sign in to comment.