我正在测试DUB,我想安装derelcitsdl2
"dependencies": {
"derelict-sdl2": ">=1.2.10"
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时会立即抛出运行时错误.它告诉我它找不到*.so文件.
当我构建一个跨平台项目时,我不希望依赖于这样的全局系统包,这很可能是Windows上的一个问题.
是否可以使用DUB运行buildscripts?
可能看起来像这样的东西
"dependencies": {
"derelict-sdl2": ">=1.2.10"
}
"c-dependency-sdl":{
git clone sdllink && cd sdl && cmake . && make && make install clib
}
Run Code Online (Sandbox Code Playgroud)
我没有在DUB网站上找到有关告诉我很可能无法获得的信息.
您如何为不同平台构建项目?
我需要为此编写.sh/.bat脚本吗?我如何指定本地搜索路径?
据我所知,dub不处理非dub依赖项的安装.您可以使用systemDependencies条目描述系统库要求,该条目将"在注册表中可见,并将在链接器错误的情况下显示",但不会自动安装.
您可以使用preGenerateCommands或preBuildCommands执行上述shell命令.我会将安装脚本放在上面描述的.sh/.bat脚本中(因此它们可用于非配音用户),然后将这样的内容放在dub.json:
"preGenerateCommands-posix": [ "./setup.sh" ],
"preGenerateCommands-windows": [ "./setup.bat" ]
Run Code Online (Sandbox Code Playgroud)
在linux上,我通常会假设必要的.so文件在标准搜索路径上可用(或者可以通过包管理器安装),特别是对于像sdl这样常见的东西.
至于指定搜索路径,我只使用lflags:
"lflags": [ "-L./ext/sdl/lib" ] (or wherever the local libs are)
Run Code Online (Sandbox Code Playgroud)
来源:DUB包格式
完全披露:我实际上没有尝试使用preGenerateCommands,但它听起来像你需要的.