【问题标题】:scons env.InstallAs() doesn't seem to copy any file?scons env.InstallAs() 似乎没有复制任何文件?
【发布时间】:2019-01-24 02:59:49
【问题描述】:

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

$cat hello.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()”能正常工作?如何进行故障排除和修复?

谢谢。

【问题讨论】:

  • 这个问题的答案在 scons.org 网站上的常见问题解答中。请考虑加入用户邮件列表和/或向 IRC 频道提出问题。

标签: build installation scons


【解决方案1】:

请阅读常见问题解答,这是对 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)

【讨论】:

  • 谢谢,但实际上它并没有回答我的问题。
  • 从未评估过目标的原因是默认情况下 scons 仅在当前目录下构建目标。由于您试图在其他地方安装 scons 并不认为您在请求它。最简单的解决方法是(见上面的补充)。
  • 很确定这确实是你的问题,但也许你不明白为什么
猜你喜欢
  • 2016-10-15
  • 1970-01-01
  • 1970-01-01
  • 2019-09-16
  • 1970-01-01
  • 1970-01-01
  • 2010-12-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多