Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
50177d96b8 | |||
146b177ca9 | |||
84b5595490 | |||
2ab67a8138 | |||
517a083694 | |||
fd2e6ae699 | |||
c669ad98f1 |
5 changed files with 53 additions and 49 deletions
|
@ -1,11 +1,12 @@
|
|||
# SConstruct
|
||||
# vim: set ft=python:
|
||||
#
|
||||
# Toplevel Scons build script. This should be mostly complete and generic enough
|
||||
# for most builds.
|
||||
#
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
'''
|
||||
Toplevel Scons build script. This should be mostly complete and generic enough
|
||||
for most builds.
|
||||
'''
|
||||
|
||||
import logging
|
||||
|
||||
setup_logging()
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# paths.py
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
|
||||
def is_executable(path):
|
||||
return os.path.exists(path) and os.access(path, os.X_OK)
|
||||
|
||||
|
||||
def which(program):
|
||||
'''
|
||||
Look for `program` in system path and return the full path to that binary if
|
||||
it is found. Otherwise, return `None`.
|
||||
'''
|
||||
path, name = os.path.split(program)
|
||||
if path:
|
||||
if is_executable(program):
|
||||
return program
|
||||
else:
|
||||
pathext = [''] + os.environ.get('PATHEXT', '').split(os.pathsep)
|
||||
for path in os.environ.get('PATH', '').split(os.pathsep):
|
||||
exe = os.path.join(path, program)
|
||||
for ext in pathext:
|
||||
candidate = exe + ext
|
||||
if is_executable(candidate):
|
||||
return candidate
|
||||
return None
|
||||
|
|
@ -3,12 +3,9 @@
|
|||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import SCons.Environment
|
||||
import SCons.Errors
|
||||
|
||||
import paths
|
||||
|
||||
|
||||
def setup_logging(level=logging.DEBUG):
|
||||
'''Configure global logging for the SCons system.'''
|
||||
|
@ -105,6 +102,9 @@ class Environment(SCons.Environment.Environment):
|
|||
if colorful and sys.stdout.isatty():
|
||||
if 'clang' in self['CC'] or 'clang' in self['CXX']:
|
||||
self.AppendUnique(CCFLAGS=['-fcolor-diagnostics'])
|
||||
elif 'gcc' in self['CC'] or 'g++' in self['CXX']:
|
||||
# TODO: Also set a GCC_COLORS variable in the system environment?
|
||||
self.AppendUnique(CCFLAGS=['-fdiagnostics-color=always'])
|
||||
|
||||
# Pretty printing
|
||||
self.SetDefault(ARCOMSTR=Environment._comstr('Archiving', succinct))
|
||||
|
@ -135,8 +135,6 @@ class Environment(SCons.Environment.Environment):
|
|||
|
||||
def process_src(self):
|
||||
out_dir = self.build_root.Dir('src')
|
||||
# TODO: Do the thing.
|
||||
# do_sconscript(env, env.source_root, src_out_dir)
|
||||
self.SConscript(self.src_root.File('SConscript'),
|
||||
variant_dir=out_dir)
|
||||
self.Append(CPPPATH=[self.src_root])
|
||||
|
@ -184,7 +182,7 @@ class Environment(SCons.Environment.Environment):
|
|||
def _append_custom_tools(self, kwargs):
|
||||
'''Add custom tools to the `kwargs`.'''
|
||||
tools = kwargs.setdefault('tools', ['default'])
|
||||
for tool in ['lib', 'test', 'program', 'sconscript']:
|
||||
for tool in ['lib', 'test', 'program', 'sconscript', 'swiftc']:
|
||||
if tool in tools:
|
||||
continue
|
||||
tools.append(tool)
|
||||
|
|
|
@ -9,18 +9,20 @@ import SCons.Script
|
|||
|
||||
def _do_sconscript(env):
|
||||
original_sconscript = env.SConscript
|
||||
|
||||
|
||||
def sconscript(env, sconscript, clone=False, *args, **kwargs):
|
||||
exports = {'Library': env.Library,
|
||||
'StaticLibrary': env.StaticLibrary,
|
||||
'SharedLibrary': env.SharedLibrary,
|
||||
'Program': env.Program}
|
||||
exports = {
|
||||
'Library': env.Library,
|
||||
'Object': env.Object,
|
||||
'SharedObject': env.SharedObject,
|
||||
'StaticLibrary': env.StaticLibrary,
|
||||
'SharedLibrary': env.SharedLibrary,
|
||||
'Program': env.Program,
|
||||
'env': env.Clone() if clone else env,
|
||||
}
|
||||
SCons.Script._SConscript.GlobalDict.update(exports)
|
||||
env.log('Reading {}'.format(sconscript))
|
||||
return original_sconscript(sconscript,
|
||||
{'env': env.Clone() if clone else env},
|
||||
*args,
|
||||
**kwargs)
|
||||
return original_sconscript(sconscript, {}, *args, **kwargs)
|
||||
|
||||
return sconscript
|
||||
|
||||
|
|
33
site_scons/site_tools/swiftc.py
Normal file
33
site_scons/site_tools/swiftc.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# swiftc.py
|
||||
# vim: set ft=python:
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
'''
|
||||
SCons plugin for building Swift files with swiftc.
|
||||
'''
|
||||
|
||||
import SCons.Action
|
||||
import SCons.Tool
|
||||
import SCons.Util
|
||||
|
||||
SwiftSuffix = '.swift'
|
||||
SwiftAction = SCons.Action.Action("$SWIFTCCOM", "$SWIFTCCOMSTR")
|
||||
|
||||
compilers = ['swiftc']
|
||||
|
||||
def generate(env):
|
||||
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
|
||||
static_obj.add_action(SwiftSuffix, SwiftAction)
|
||||
static_obj.add_emitter(SwiftSuffix, SCons.Defaults.SharedObjectEmitter)
|
||||
shared_obj.add_action(SwiftSuffix, SwiftAction)
|
||||
shared_obj.add_emitter(SwiftSuffix, SCons.Defaults.SharedObjectEmitter)
|
||||
|
||||
if 'SWIFTC' not in env:
|
||||
compiler = env.Detect(compilers)
|
||||
env['SWIFTC'] = compiler if compiler else compilers[0]
|
||||
env['SWIFTFLAGS'] = SCons.Util.CLVar('')
|
||||
env['SWIFTCCOM'] = '$SWIFTC -o $TARGET -c $SWIFTFLAGS $SOURCES'
|
||||
env['SWIFTFILESUFFIX'] = SwiftSuffix
|
||||
|
||||
def exists(env):
|
||||
return env.Detect(compilers)
|
Loading…
Add table
Add a link
Reference in a new issue