似乎-u不适合我(我使用秒2.3.6)。
为了简化上下文,您可以将我的项目结构想象为:
+root
+project
- bar.vcxproj (generated vs project)
-SConstruct
-bar.c
在SConstruct中,我放置了如下代码:
env_base = Environment()
...
env_base.StaticLibrary(target = 'bar', source = ['bar.c'])
...
如果我在根文件夹中执行命令"scons",一切都运行良好。
但是如果我在项目文件夹中执行命令"scons -u", scons可以在根文件夹中找到我的SConstruct,但没有文件被编译。
BTW:我在project文件夹中执行"scons -u"的原因是因为我想把生成的vsproj放在project文件夹中,并使用BuildCommandLine来编译项目。
我想我没有正确地使用"-u",对于我的情况,什么是优雅的解决方案?
编辑1:
正如bdbaddog所问的,我把SConstruct放在这里:
def BuildConfig(env, config):
env.Append(CCFLAGS = '/W 4')
env.Append(CCFLAGS = '/WX')
if config == "debug":
env.Append(CCFLAGS = '/DEBUG')
#env.Append(CCFLAGS = '-Zi /Fd${TARGET}.pdb')
env.Append(CCFLAGS = '/Z7')
elif config == "release":
pass
env_base = Environment()
lib = env_base.StaticLibrary(target = 'bar', source = ['bar.c'])
opts=Variables()
opts.Add('target', 'Compile Target (debug/release).', "debug")
# there is more in my project....
opts.Update(env_base) # update environment
# here I want to use my own command to build the project, so it can support different build option that is defined by me.
env_base['MSVSBUILDCOM'] = "scons -u target=$(Configuration)"
target = env_base["target"]
BuildConfig(env_base, env_base['target'])
env_base.MSVSProject(target = "project\bar" + env_base['MSVSPROJECTSUFFIX'],
srcs = ["..\bar.c"],
incs = [],
localincs = "",
resources = "",
misc = "",
buildtarget = lib,
variant = ['debug'],
auto_build_solution=0)
默认情况下,SCons只在当前目录下构建文件。
如果您只想在某个目录中构建文件(有在那里构建目标的规则),您可以像下面这样调用SCons:
您the_target_directory_I_want_to_build