Created
July 23, 2010 17:45
-
-
Save hank/487779 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from SCons.Script import * | |
archs = {'amd64': '6', '386': '8', 'arm': '5',} | |
def gc(source, target, env, for_signature): | |
targets = target[0] | |
sources = ' '.join(str(s) for s in source) | |
flags = '' | |
for include in env.get('GOINCLUDE', []): | |
flags += '-I %s ' % (include) | |
return '%s -o %s %s %s' % (env['GOCOMPILER'], targets, flags, sources) | |
def ld(source, target, env, for_signature): | |
targets = target[0] | |
sources = ' '.join(str(s) for s in source) | |
return '%s -o %s %s' % (env['GOLINKER'], targets, sources) | |
def _go_object_suffix(env, sources): | |
return "." + archs[env['ENV']['GOARCH']] | |
def _go_program_prefix(env, sources): | |
return env['PROGPREFIX'] | |
def _go_program_suffix(env, sources): | |
return env['PROGSUFFIX'] | |
go_compiler = Builder(generator=gc, | |
suffix=_go_object_suffix, | |
src_suffix='.go',) | |
go_linker = Builder(generator=ld, | |
prefix=_go_program_prefix, | |
suffix=_go_program_suffix,) | |
# Create environment | |
go_env = Environment(BUILDERS={'Go': go_compiler, 'GoProgram': go_linker}, | |
ENV=os.environ,) | |
arch_prefix = archs[os.environ['GOARCH']] | |
go_env.SetDefault(GOCOMPILER=arch_prefix + 'g') | |
go_env.SetDefault(GOLINKER=arch_prefix + 'l') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scons_go_support import * | |
import os | |
# Build programs | |
# Modify this to suit your program | |
main_package = go_env.Go(target='echo.out', source='echo.go') | |
program = go_env.GoProgram(target='echo', source=[main_package]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment