2

我有一个只包含 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. 这复制了所有 exe 文件local_cache/ToolHello/0.1/user/testing/package/hash/bin。本地缓存中的 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,而是位于的 exe 文件local_cache/ToolHello/0.1/user/testing/package/hash/bin/directory

4

1 回答 1

1

您需要定义非默认绑定器 ( 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"]
于 2018-07-11T10:44:07.313 回答