conan.io: 使用虚拟 运行 环境调用 exe
conan.io: call exe with virtual run environment
我有一个 hello 工具,它只包含 exe 文件(没有源代码)。
你好工具结构:
bin
helloBin.exe
helloRoot.exe
conanfile.py
conanfile.py
内容:
class ToolHelloConan(ConanFile):
name = "ToolHello"
version = "0.1"
settings = "os", "compiler", "build_type", "arch"
def package(self):
self.copy("*")
def package_info(self):
self.cpp_info.libs = self.collect_libs()
我已将 hello 工具导出到本地缓存:conan export-pkg . ToolHello/0.1@user/testing
。这复制了 local_cache/ToolHello/0.1/user/testing/package/hash/bin
中的所有 exe。本地缓存中的 bin 如下所示:
bin
helloBin.exe
helloRoot.exe
我定义了一个工具集成项目,它只包含 conanfile.txt
[requires]
ToolHello/0.1@user/testing
[generators]
virtualrunenv
在工具集成项目中 运行ning conan install .
并激活虚拟 运行 环境后,我只能调用 helloRoot.exe
因为它位于bin 目录,但我无法执行 bin/bin/helloBin.exe
问题:如何 运行 exe 文件不直接位于 local_cache/ToolHello/0.1/user/testing/package/hash/bin
,而是位于 local_cache/ToolHello/0.1/user/testing/package/hash/bin/directory
?
您需要定义非默认绑定 (bin
)。将此添加到您的 conanfile.py:
def package_info(self):
self.cpp_info.bindirs = ["bin", "bin/directory"]
如果您还需要包括包文件夹的根目录,您可能需要使用:
def package_info(self):
self.cpp_info.bindirs = ["", "bin", "bin/directory"]
我有一个 hello 工具,它只包含 exe 文件(没有源代码)。
你好工具结构:
bin
helloBin.exe
helloRoot.exe
conanfile.py
conanfile.py
内容:
class ToolHelloConan(ConanFile):
name = "ToolHello"
version = "0.1"
settings = "os", "compiler", "build_type", "arch"
def package(self):
self.copy("*")
def package_info(self):
self.cpp_info.libs = self.collect_libs()
我已将 hello 工具导出到本地缓存:conan export-pkg . ToolHello/0.1@user/testing
。这复制了 local_cache/ToolHello/0.1/user/testing/package/hash/bin
中的所有 exe。本地缓存中的 bin 如下所示:
bin
helloBin.exe
helloRoot.exe
我定义了一个工具集成项目,它只包含 conanfile.txt
[requires]
ToolHello/0.1@user/testing
[generators]
virtualrunenv
在工具集成项目中 运行ning conan install .
并激活虚拟 运行 环境后,我只能调用 helloRoot.exe
因为它位于bin 目录,但我无法执行 bin/bin/helloBin.exe
问题:如何 运行 exe 文件不直接位于 local_cache/ToolHello/0.1/user/testing/package/hash/bin
,而是位于 local_cache/ToolHello/0.1/user/testing/package/hash/bin/directory
?
您需要定义非默认绑定 (bin
)。将此添加到您的 conanfile.py:
def package_info(self):
self.cpp_info.bindirs = ["bin", "bin/directory"]
如果您还需要包括包文件夹的根目录,您可能需要使用:
def package_info(self):
self.cpp_info.bindirs = ["", "bin", "bin/directory"]