I'm trying to write a SConscript file so that I can use scons to build Go code. The SConscript file is pretty simple; its just a starter file:
def gc(source, target, env, for_signature):
targets = target[0]
sources = " ".join(str(s) for s in source)
print(sources)
return 'go build {}'.format(sources)
go_compiler = Builder(
generator=gc,
src_suffix='.go',
)
# Create environment
env = Environment(
BUILDERS={'Go': go_compiler, }
)
# Build programs
main_package = env.Go(target='helloworld', source='helloworld.go')
But I keep getting this error:
# scons
scons: Reading SConscript files ...
File "/root/repo/SConstruct", line 5
print(sources)
^
IndentationError: unexpected indent
I tried switching between python v2.7 and 3.7, rewriting the code in various different ways, but I kept hitting the same issue. I even tried writing several fragments of the above code inside a python interpreter and the syntax and indentation were fine.