似乎 CPPPATH 不起作用
env = Environment()
target = 'app'
sources = ['app.d']
libs = ['phobos2', 'pthread', 'm', 'rt']
includes = ['/home/supertool/devel/d/vibe.d/source/vibe']
env.Program(target = target,
source = sources,
LIBS = libs,
CPPPATH = includes);
Run Code Online (Sandbox Code Playgroud)
当我运行 scons 时,它会生成编译命令:
dmd -I. -c -ofapp.o app.d
Run Code Online (Sandbox Code Playgroud)
includes未添加到-I部分
那么我该如何配置呢?有 INCLUDEPATH 吗?
我正在编写一个 python 程序,它使用 scons 来构建一个.exe,然后检查它是 64 位还是 32 位。我试过了platform.architecture(test1.exe),但问题是当我提供 32 位 exe 时,它说它是 64 位。
我尝试使用dumpbin但输出很大,所以我使用了这个dumpin /HEADERS test.exe |find "machine". 问题是我不能使用 python 来执行这个命令。当我使用时subprocess.call(['dumpbin /HEADERS test2.exe |find "machine"']),出现以下错误
Traceback (most recent call last):
File "test_scons.py", line 66, in <module>
print "Architecture of the compiled program is ",subprocess.call(["dumpbin /HEADERS test2.exe |find ""machine" ])
File "C:\Python27\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", …Run Code Online (Sandbox Code Playgroud) 我正在使用 SCONS 构建工具。
我无法使用在 python 脚本中初始化的环境变量。
在我的项目中,用户可以更改一些变量以与编译器一起使用。
为此,我们有 2 个文件。
Config.py 具有所有变量,例如包含目录、 CFLAGS 、 CPPDEFINES 等。因此,在这里我们可以设置一些变量。我需要在 Sconstruct 文件中使用这些变量。在 config.py 中我设置了一个变量,如下所示
SCONS_INC = "Include files"
os.environ["SCONS_INC"] = SCONS_INC
Run Code Online (Sandbox Code Playgroud)
我需要在 Sconstruct 文件中使用这些变量。代码是
env["CPPPATH"] = os.environ["SCONS_INC"]
Run Code Online (Sandbox Code Playgroud)
但我收到类似未定义变量 SCONS_INC 的错误。
这个怎么做?
我想要基于 SConstruct 文件中分配的变量构建文件。如本例所示:
import os
env = Environment(ENV = os.environ)
def text_file_maker(target, source, env):
with open(str(target[0]), "w") as text_file:
text_file.write(env['my_text'])
return 0
env.Append( BUILDERS = {'Make_text' : Builder(action = text_file_maker)})
env.Make_text(target = 'sour.txt',
source = None,
my_text = 'lemon')
env.Make_text(target = 'sweet.txt',
source = None,
my_text = 'apple')
Run Code Online (Sandbox Code Playgroud)
运行此脚本会生成两个文本文件,内容分别为“lemon”和“apple”。如果我再次运行该脚本,SCons 会正确检测到目标存在:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
Run Code Online (Sandbox Code Playgroud)
现在,如果我要改变一个目标,例如:
env.Make_text(target = 'sweet.txt',
source = …Run Code Online (Sandbox Code Playgroud) 如何从C程序调用C++函数,是否可能?,如果是,我该怎么办呢?谢谢.
我从github下载了钛移动sdk的源代码.我在windows 7中安装了python,scons,jdk和android sdk.我在环境变量中为java,android sdk等设置了路径.但在使用scons进行编译时,会出现以下错误.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Shihab>cd C:\Project\titanium_mobile
C:\Project\titanium_mobile>scons
scons: Reading SConscript files ...
Building MobileSDK version 3.1.0, githash 2d79a72
KeyError: 14:
File "C:\Project\titanium_mobile\SConstruct", line 115:
sdk = AndroidSDK(ARGUMENTS.get("android_sdk", None), 14)
File "C:\Project\titanium_mobile\support\android\androidsdk.py", line 49:
self.set_api_level(api_level)
File "C:\Project\titanium_mobile\support\android\androidsdk.py", line 53:
self.find_platform_dir()
File "C:\Project\titanium_mobile\support\android\androidsdk.py", line 127:
old_style_dir = os.path.join(self.android_sdk, 'platforms', android_api_leve
ls[api_level])
C:\Project\titanium_mobile>
Run Code Online (Sandbox Code Playgroud)
如何解决此错误?
我一直在玩OSX上的Scons,我正在尝试创建一个共享库(.dll,.so,.dylib).
这一切都完美无缺,除了一件让我烦恼的事情,它在图书馆名称前添加了"lib".例如,我选择名称WL,它变成libWL.dylib.我无法弄清楚为什么Scons这样做,这让我很生气.

我使用的代码是:
# -*- coding: utf-8 -*-
import os
SourceList = ['Window.cpp']
env = Environment(ENV = os.environ)
#Libraries we are using
Targets = 'WL'
libraries = ['SDL2']
#Paths to the libraries and include paths
Paths = ['/usr/local/lib', '/usr/local/include']
Export('SourceList env libraries Paths Targets')
SConscript('src/SConscript', variant_dir='bin', duplicate=0)
Run Code Online (Sandbox Code Playgroud)
和
Import('SourceList env libraries Paths Targets')
SharedLibrary(target = Targets,source = SourceList,LIBS = libraries, LIBPATH=Paths)
Run Code Online (Sandbox Code Playgroud)
我不太了解共享库的工作方式,所以我不知道在编译后是否可以更改名称.但我希望它不要添加字母
我正在使用 vim 编辑 scons 的 SConstruct 文件,我想让 vim 自动突出显示为 python 语法。怎么做?
如何在vimrc中将'SConstruct'的文件名与'Python'相关联?
谢谢
我正在关注有关设置 gdnative 的本教程。
我已经通过 Visual Studio、python 3.2 和 scons 4.1.0 安装了 C++ 工具
我一直试图让 scons 来构建这个gdnative 示例。我遇到的问题似乎是 scons 无法找到 #include 文件。我曾尝试使用子目录的相对文件路径godot-cpp/、同级目录的相对路径以及同级目录../godot-cpp/的完整路径,E:/Projects/Godot Projects/Units/godot-cpp/但我每次都遇到相同的错误。我提供了一个屏幕截图来显示文件结构。我正在运行 sconsX64 Native Tools Command Prompt for VS 2019
编辑 - 现在也尝试以管理员身份运行,同样的错误
左上角:我正在尝试构建的项目以及我需要包含在同级目录中的 cpp 文件。
右上角:项目文件夹的内容。该godot-cpp/子目录是从左上方的同名文件夹的副本。
左下:内容 godot-cpp/
右下: 的内容godot-cpp/godot-headers。突出显示的文件是它似乎找不到的文件。
子目录的相对路径:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo …Run Code Online (Sandbox Code Playgroud) 我需要能够调整构造环境,以便我可以在较低级别构建静态或共享对象.目前,我想出了以下方法:
顶级SConstruct:
if build_shared:
env.Replace(ObjectBuilder = env.SharedObject)
env.Replace(LibraryBuilder = env.SharedLibrary)
else:
env.Replace(ObjectBuilder = env.StaticObject)
env.Replace(LibraryBuilder = env.StaticLibrary)
Run Code Online (Sandbox Code Playgroud)
在较低级别的SConstructs中,我按名称调用它们:
env['ObjectBuilder']('foo.c')
env['LibraryBuilder']('lib', objects)
Run Code Online (Sandbox Code Playgroud)
但是,我不确定这个解决方案有多健全.是否有更简单/正确的方法来实现相同的功能?
提前致谢.
我无法在Mac OS X 10.7.2上构建libjingle.当我$path_to_swtoolkit/hammer.sh按照libjingle的自述文件运行时输出如下 .
MBP17:talk rei25$ ~/Desktop/swtoolkit/hammer.sh
scons: Reading SConscript files ...
scons: warning: The build_dir keyword has been deprecated; use the variant_dir keyword instead.
File "/Users/rei25/Desktop/swtoolkit/site_scons/site_init.py", line 203, in BuildEnvironmentSConscripts
scons: done reading SConscript files.
scons: Building targets ...
________Compiling build/dbg/obj/third_party/expat-2.0.1/lib/xmlparse.o
third_party/expat-2.0.1/lib/xmlparse.c:6:48: error: string.h: No such file or directory
third_party/expat-2.0.1/lib/xmlparse.c:7:20: error: assert.h: No such file or directory
In file included from third_party/expat-2.0.1/lib/xmlparse.c:24:
third_party/expat-2.0.1/lib/expat.h:17:20: error: stdlib.h: No such file or directory
cc1: warnings being treated as errors …Run Code Online (Sandbox Code Playgroud) 我根据https://github.com/TideSDK/TideSDK/wiki/Windows7-x86-2005上的说明设置了所有内容
但是,scons不会从PATH中获取"rc":
> scons -s debug=1 sdkinstaller run=1
...
runs fine for a while, until:
...
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release
boot_win32.cpp
'rc' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [build\win32\objs\boot\support\winboot.res] Error 1
> …Run Code Online (Sandbox Code Playgroud) 据说scons使用MD5签名作为默认决策来确定源文件是否需要重新编译.例如,我有SConstruct如下:
Library('o.c')
Run Code Online (Sandbox Code Playgroud)
我的oc是:
$ cat o.c
/*commented*/
#include<stdio.h>
int f(){
printf("hello\n");
return 2;
}
Run Code Online (Sandbox Code Playgroud)
运行scons并删除注释行,再次运行scons.我希望scons不应该再次编译它,但实际上它是:
gcc -o o.o -c o.c
scons: done building targets.
Run Code Online (Sandbox Code Playgroud)
如果我更改SConstruct文件添加一行:
Decider('MD5').
Run Code Online (Sandbox Code Playgroud)
还是一样的结果.
我的问题是:如何确保对于scons,在更改源文件注释时,它们不会重新构建?
谢谢!