【问题标题】:Bitbake recipe copy local sources in sub foldersBitbake 配方复制子文件夹中的本地源
【发布时间】:2021-03-12 16:13:09
【问题描述】:

我正在学习 yocto 和 bitbake,但我对一些事情感到困惑。

当我开发 C 项目时,我的树文件如下所示:

myproject
├── commons
│   ├── commons.c
│   ├── commons.h
│   └── path.h
├── config
│   ├── config.c
│   └── config.h
├── errors
│   ├── error.c
│   └── error.h
├── files
│   ├── COPYING
│   ├── ...
├── jimini
│   ├── jimini.c        # source including the main()
│   └── jimini.h
├── Doxyfile
├── CMakeLists.txt
└── jimini-collector_0.3.bb

我的 CMakeLists.txt 看起来像:

cmake_minimum_required(VERSION 3.0.0)

if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

project(myproject VERSION 0.3.0)

find_library(LIBCONFIG config)
message(STATUS "libconfig path :  ${LIBCONFIG}")

find_library(CURL curl)
message("CURL path : ${CURL}")

find_library(JSON json-c)
message("JSON path : ${JSON}")

find_library(RT rt)
message("RT path : ${RT}")

include(CTest)
enable_testing()

aux_source_directory(../commons SOURCES)
aux_source_directory(../config SOURCES)
aux_source_directory(../errors SOURCES)
aux_source_directory(../jimini SOURCES)

message(STATUS "project folder : " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "My sources: " ${SOURCES})

add_executable(${PROJECT_NAME} ${SOURCES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE RelWithDebInfo)

target_link_libraries(${PROJECT_NAME} config)
target_link_libraries(${PROJECT_NAME} m)
target_link_libraries(${PROJECT_NAME} pthread)
target_link_libraries(${PROJECT_NAME} curl)
target_link_libraries(${PROJECT_NAME} json-c)
target_link_libraries(${PROJECT_NAME} rt)

# install the executable in /usr/bin
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

我的食谱看起来像:

DESCRIPTION="This is my recipe to my super package"
MAINTAINER="Me <me@me.com>"

# Define license file and file checksum verification
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0"

DEPENDS += "libconfig"
DEPENDS += "json-c"

FILESEXTRAPATHS_prepend := "${THISDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
FILESEXTRAPATHS_prepend := "${THISDIR}/commons:"
FILESEXTRAPATHS_prepend := "${THISDIR}/config:"
FILESEXTRAPATHS_prepend := "${THISDIR}/errors:"
FILESEXTRAPATHS_prepend := "${THISDIR}/jimini:"

# include license and cmake config files
SRC_URI+="file://COPYING file://CMakeLists.txt"

# include sources files
SRC_URI+= " file://jimini.c file://commons.c file://config.c file://error.c"
SRC_URI+= " file://jimini.h file://commons.h file://path.h file://config.h file://error.h"

# where to copy sources and headers files
S="${WORKDIR}"

# define dependencies to build and package
inherit pkgconfig cmake 

我不明白如何设置配方以复制子文件夹中的本地源。 Bitbake 将各个源码复制到同一个文件夹中,无法编译代码。

我尝试设置不同的 S="${WORKDIR}" 但没有结果。

你能给我解释一下吗?

谢谢。

编辑: 我已经更正了我的文件,现在它可以工作了。

我的 CMakeLists.txt,现在看起来像:

cmake_minimum_required(VERSION 3.0.0)

if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

project(myproject VERSION 0.3.0)

find_library(LIBCONFIG config)
message(STATUS "libconfig path :  ${LIBCONFIG}")

find_library(CURL curl)
message("CURL path : ${CURL}")

find_library(JSON json-c)
message("JSON path : ${JSON}")

find_library(RT rt)
message("RT path : ${RT}")

include(CTest)
enable_testing()

aux_source_directory(commons SOURCES)    # removed the ../
aux_source_directory(config SOURCES)     # removed the ../
aux_source_directory(errors SOURCES)     # removed the ../
aux_source_directory(jimini SOURCES)     # removed the ../

message(STATUS "project folder : " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "My sources: " ${SOURCES})

add_executable(${PROJECT_NAME} ${SOURCES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE RelWithDebInfo)

target_link_libraries(${PROJECT_NAME} config)
target_link_libraries(${PROJECT_NAME} m)
target_link_libraries(${PROJECT_NAME} pthread)
target_link_libraries(${PROJECT_NAME} curl)
target_link_libraries(${PROJECT_NAME} json-c)
target_link_libraries(${PROJECT_NAME} rt)

# install the executable in /usr/bin
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

我的食谱,现在看起来像:

DESCRIPTION="This is my recipe to my super package"
MAINTAINER="Me <me@me.com>"

# Define license file and file checksum verification
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0"

DEPENDS += "libconfig"
DEPENDS += "json-c"

SCR_URI+= "file://files/"
SCR_URI+= "file://commons/"
SCR_URI+= "file://config/"
SCR_URI+= "file://errors/"
SCR_URI+= "file://jimini/"

# include license and cmake config files
SRC_URI+="file://COPYING file://CMakeLists.txt"

# include sources files
SRC_URI+= " file://*.c"
SRC_URI+= "file://*.h"

# where to copy sources and headers files
S="${WORKDIR}"

# define dependencies to build and package
inherit pkgconfig cmake 

我还按照答案中的建议修改了我的树文件。

【问题讨论】:

    标签: c cmake embedded yocto bitbake


    【解决方案1】:

    FILESEXTRAPATHS 只是添加路径以查找SRC_URI 中声明的文件。您只需执行以下操作:

    SRC_URI += "file://files/"
    SRC_URI += "file://commons/"
    SRC_URI += "file://config/"
    SRC_URI += "file://errors/"
    SRC_URI += "file://jimini/"
    
    # include license and cmake config files
    SRC_URI+="file://COPYING file://CMakeLists.txt"
    

    此外,您的树形布局应如下所示:

    myproject
    ├── jimini-collector-0.3 # or files, or jimini-collector
    │   ├──commons
    |   │   ├── commons.c
    |   │   ├── commons.h
    |   │   └── path.h
    |   ├── config
    |   │   ├── config.c
    |   │   └── config.h
    |   ├── errors
    |   │   ├── error.c
    |   │   └── error.h
    |   ├── files
    |   │   ├── COPYING
    |   │   ├── ...
    |   ├── jimini
    |   │   ├── jimini.c        # source including the main()
    |   │   └── jimini.h
    |   ├── Doxyfile
    |   ├── CMakeLists.txt
    └── jimini-collector_0.3.bb
    

    【讨论】:

    • 感谢您的回复。我重新排列了我的项目文件夹并修改了我的配方,但是如果我对我的配方执行 bitbake unpack 命令,则不会复制任何源文件。你知道为什么吗?
    猜你喜欢
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 2013-05-10
    • 1970-01-01
    • 2023-01-11
    • 2017-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多