conan.io:使用虚拟运行环境调用exe



我有一个hello工具,它只包含exe文件(没有源代码(
Hello工具结构:

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

在工具集成项目中运行conan install .并激活虚拟运行环境后,我只能调用helloRoot.exe,因为它位于bin目录中,但我无法执行bin/bin/helloBin.exe

问题:如何运行不是直接位于local_cache/ToolHello/0.1/user/testing/package/hash/bin而是位于local_cache/ToolHello/0.1/user/testing/package/hash/bin/directory中的exe文件?

您需要定义不是默认的bindir(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"]

最新更新