首页 > 解决方案 > scons env.InstallAs() 似乎没有复制任何文件?

问题描述

例如,我有一个 .c 文件,如下所示:

$猫你好.c

int main(){
    return 0;
}

然后我使用 scons 构建并将其复制到某个地方:

$cat SConstruct

import os,sys
env = Environment()
hello = env.Program('hello.c')
env.InstallAs('/home/admin/hello-new', hello)

在名为“admin”的用户下运行 scons,它会打印:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o hello.o -c hello.c
gcc -o hello hello.o
scons: done building targets.

然后我尝试“ls /home/admin”,没有像“hello-new”这样的东西。所以我想知道为什么我的“env.InstallAs()”能正常工作?如何进行故障排除和修复?

谢谢。

标签: buildinstallationscons

解决方案


请阅读常见问题解答,这是对 SCons 的常见误解,因此在常见问题解答中:

https://scons.org/faq.html#How_do_I_install_files.3F_The_Install.28.29_method_doesn.27t_do_anything._In_general.2C_how_do_I_build_anything_outside_my_current_directory.3F

随着您的示例更改为此应该会导致它始终构建有问题的目标:

import os,sys
env = Environment()
hello = env.Program('hello.c')
install_target = env.InstallAs('/home/admin/hello-new', hello)

# Always build the install target by default
Default(install_target)

推荐阅读