工作区在yaml文件中定义,并使用任何用户定义的名称。其结构为:
editables:
say/0.1@user/testing:
path: say
hello/0.1@user/testing:
path: hello
chat/0.1@user/testing:
path: chat
layout: layout_gcc
workspace_generator: cmake
root: chat/0.1@user/testing
第一部分 “可编辑” 定义了包引用和相对路径之间的映射。每一个都相当于一个柯南可编辑的add命令 (不要这样做 — 这不是必须的。稍后会自动完成。只是为了了解行为):
$ conan editable add say say/0.1@user/testing --layout=layout_gcc
$ conan editable add hello hello/0.1@user/testing --layout=layout_gcc
$ conan editable add chat chat/0.1@user/testing --layout=layout_gcc
主要区别在于,此可编辑状态仅是此工作区的临时状态。它不会影响其他项目或包,这些项目或包仍然可以使用本地缓存中的这些聊天包。
请注意,工作区中的布局: 布局 _ gcc声明会影响所有包。还可以为每个包定义不同的布局,如下所示:
editables:
say/0.1@user/testing:
path: say
layout: custom_say_layout
布局文件在可编辑布局文件和 “可编辑模式” 部分中的包中进行了说明。
Workspace_生成器定义将为top项目生成的文件。到目前为止,唯一支持的值是cmake,它将生成一个conanworkspace.cmake文件,如下所示:
set(PACKAGE_say_SRC "<path>/examples/workspace/cmake/say/src")
set(PACKAGE_say_BUILD "<path>/examples/workspace/cmake/say/build/Debug")
set(PACKAGE_hello_SRC "<path>/examples/workspace/cmake/hello/src")
set(PACKAGE_hello_BUILD "<path>/examples/workspace/cmake/hello/build/Debug")
set(PACKAGE_chat_SRC "<path>/examples/workspace/cmake/chat/src")
set(PACKAGE_chat_BUILD "<path>/examples/workspace/cmake/chat/build/Debug")
macro(conan_workspace_subdirectories)
add_subdirectory(${PACKAGE_say_SRC} ${PACKAGE_say_BUILD})
add_subdirectory(${PACKAGE_hello_SRC} ${PACKAGE_hello_BUILD})
add_subdirectory(${PACKAGE_chat_SRC} ${PACKAGE_chat_BUILD})
endmacro()
此文件可以包含在用户定义的CMakeLists.txt中 (此文件不会生成)。在此,您可以看到此项目中使用的CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(WorkspaceProject)
include(${CMAKE_BINARY_DIR}/conanworkspace.cmake)
conan_workspace_subdirectories()
根: chat/0.1 @ user/test定义图形的使用者节点,通常是某种可执行文件。您可以提供以逗号分隔的引用列表 (以字符串形式) 或yaml列表 (以yaml项缩写或完整)。所有根节点都在同一个依赖关系图中,如果它们依赖于同一个库的不同版本,就会导致冲突,就像在任何其他Conan命令中一样。
editables:
say/0.1@user/testing:
path: say
hello/0.1@user/testing:
path: hello
chat/0.1@user/testing:
path: chat
root: chat/0.1@user/testing, say/0.1@user/testing
# or
root: ["helloa/0.1@lasote/stable", "hellob/0.1@lasote/stable"]
# or
root:
- helloa/0.1@lasote/stable
- hellob/0.1@lasote/stable