我正在尝试编写一个Sconscript文件,以便我可以使用SCONS构建GO代码。Sconscript文件非常简单;它只是一个入门文件:
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')
但我一直遇到此错误:
# scons
scons: Reading SConscript files ...
File "/root/repo/SConstruct", line 5
print(sources)
^
IndentationError: unexpected indent
我尝试在Python v2.7和3.7之间切换,以各种不同的方式重写代码,但是我一直遇到同一问题。我什至尝试在python解释器中写下上述代码的几个片段,语法和凹痕很好。
我从在线复制/粘贴了一些代码。原来有一些嵌入式选项卡,但我的编辑正在使用空格。因此,几条线不一致。我花了几个小时看这个,所以我想我会分享我的错误。