Yocto
Yocto系列讲解[入门篇] 1 - 快速入门熟悉Yocto的构建
Yocto系列讲解[入门篇] 2 - 演示运行qemux86-64虚拟机
Yocto系列讲解[理论篇] 3 - meta layer recipe class概念介绍
Yocto系列讲解[入门篇] 4 - 创建自己的meta layer
Yocto系列讲解[入门篇] 5 - 在meta-mylayer中添加helloworld recipe
Yocto系列讲解[理论篇] 6 - yocto是什么,学习它不难
Yocto系列讲解[实战篇] 7 - 开发工具devtool实操(创建新项目helloyocto)
Yocto系列讲解[实战篇] 8 - 开发工具devtool实操(添加git项目learnyocto)
Yocto系列讲解[实战篇] 9 - devtool验证并将learnyocto添加到meta-mylayer中
Yocto系列讲解[实战篇] 10 - 在qemux86机器运行时安装程序
Yocto系列讲解[实战篇] 11 - 在qemux86机器运行时卸载删除程序
Yocto系列讲解[实战篇]12 - 修改开源项目的代码(1)
Yocto系列讲解[技巧篇]13 - devtool修改workspace目录位置
Yocto系列讲解[技巧篇]14 - devtool edit-recipe命令(编辑bb文件命令)
本文档使用 MrDoc 发布
-
+
首页
Yocto系列讲解[实战篇] 8 - 开发工具devtool实操(添加git项目learnyocto)
### 在gitee创建简单项目 在讲述devtool新知识前,我们现在gitee创建一个新项目,如下图:  点击创建后就会有这个项目: https://gitee.com/fulinux/learnyocto ### git命令简单实用 在自己的ubuntu系统中下载下来: ~]$ cd code/ #记得吗?这个目录下面有个helloyocto项目 code]$ git clone https://gitee.com/fulinux/learnyocto 正克隆到 'learnyocto'... remote: Enumerating objects: 8, done. remote: Counting objects: 100% (8/8), done. remote: Compressing objects: 100% (8/8), done. remote: Total 8 (delta 0), reused 0 (delta 0), pack-reused 0 展开对象中: 100% (8/8), 完成. 检查连接... 完成。 code]$ cd learnyocto/ learnyocto]$ git branch -a #查看分支 * master #当前在master分支 remotes/origin/HEAD -> origin/master remotes/origin/develop #开发分支 remotes/origin/master 我们粗略可以这么认为develop用来日常的开发,代码测试和稳定后可以合并到master分支,由管理员维护master分支。这样我们先切换到develop分支进行开发: learnyocto]$ git checkout develop 分支 develop 设置为跟踪来自 origin 的远程分支 develop。 切换到一个新分支 'develop' learnyocto]$ cp ../helloyocto/* . #将之前的项目拷贝一份过来,图省事 cp: 略过目录'../helloyocto/build' cp: 略过目录'../helloyocto/oe-logs' cp: 略过目录'../helloyocto/oe-workdir' learnyocto]$ ls CMakeLists.txt LICENSE main.c README.en.md README.md ### 修改项目 修改CMakeLists.txt和main.c文件: learnyocto]$ vim CMakeLists.txt project(learnyocto C) cmake_minimum_required(VERSION 2.6.3) add_executable (learnyocto main.c) install(TARGETS learnyocto DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) learnyocto]$ vim main.c #include <stdio.h> int main (int argc, char **argv) { printf ("[develop branch]Hello Yocto!\n"); return 0; } /* ----- End of main() ----- */ ### 项目提交到gitee learnyocto]$ git status 位于分支 develop 您的分支与上游分支 'origin/develop' 一致。 未跟踪的文件: (使用 "git add <文件>..." 以包含要提交的内容) CMakeLists.txt main.c 提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪) learnyocto]$ git add CMakeLists.txt main.c learnyocto]$ git commit -m "第一次代码" #可惜了少了‘添加’两个字 learnyocto]$ git push origin develop Username for 'https://gitee.com': **** #输入你自己的用户名 Password for 'https://fulinux@gitee.com': 对象计数中: 4, 完成. Delta compression using up to 12 threads. 压缩对象中: 100% (4/4), 完成. 写入对象中: 100% (4/4), 599 bytes | 0 bytes/s, 完成. Total 4 (delta 1), reused 0 (delta 0) remote: Powered by GITEE.COM [GNK-5.0] To https://gitee.com/fulinux/learnyocto 83f1936..351e99f develop -> develop 在网页上就可以看到自己提交的内容了:  ### 切换到master分支 learnyocto]$ git checkout master 切换到分支 'master' 您的分支与上游分支 'origin/master' 一致。 ### 合并develop改动到master分支 learnyocto]$ git merge develop 更新 83f1936..351e99f Fast-forward CMakeLists.txt | 6 ++++++ main.c | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 main.c 修改main.c,用以后续区分不同分支项目: learnyocto]$ vim main.c #不会用vim的就用其他编辑器 #include <stdio.h> int main (int argc, char **argv) { printf ("[master branch]Hello Yocto!\n");//change develop to master return 0; } /* ----- End of main() ----- */ ### 提交改动到gitee上 learnyocto]$ git add main.c learnyocto]$ git commit -m "修改main.c" learnyocto]$ git push origin master ### 给项目打个tag learnyocto]$ git tag -a v1.0 -m "add my 1.0 version" #给自己的项目打个tag learnyocto]$ git tag -l v1.0 learnyocto]$ git push origin v1.0 ### 将learnyocto添加到[yocto](https://so.csdn.net/so/search?q=yocto&spm=1001.2101.3001.7020)上 默认情况下,devtool add从远程URI获取到的内容就是master分支中的最新版本。在某些情况下,您可能希望通过branch,tag或commit-id来指定版本。下面我们尝试使用develop分支的内容 参考上片中内容,将learnyocto添加到yocto中: learnyocto]$ cd ~]$ cd poky/ poky]$ source oe-init-build-env 要指定源分支,请使用–srcbranch选项: build]$ devtool add --srcbranch develop learnyocto https://gitee.com/fulinux/learnyocto.git NOTE: Starting bitbake server... NOTE: Starting bitbake server... INFO: Fetching git://gitee.com/fulinux/learnyocto.git;protocol=https;branch=develop... Loading cache: 100% |########################################################################################################################################################| Time: 0:00:02 Loaded 1321 entries from dependency cache. Parsing recipes: 100% |######################################################################################################################################################| Time: 0:00:00 Parsing of 782 .bb files complete (779 cached, 3 parsed). 1323 targets, 46 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Build Configuration: BB_VERSION = "1.46.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "x86_64-poky-linux" MACHINE = "qemux86-64" DISTRO = "poky" DISTRO_VERSION = "3.1.2" TUNE_FEATURES = "m64 core2" TARGET_FPU = "" meta meta-poky meta-yocto-bsp = "my-yocto-3.1.2:569b1f5d67c57de957e243997c53ec2f81dc8dfe" meta-altera = "master:aa24dfcb39fce3619a87ee6eef6e4296e66d2099" meta-mylayer workspace = "my-yocto-3.1.2:569b1f5d67c57de957e243997c53ec2f81dc8dfe" Initialising tasks: 100% |###################################################################################################################################################| Time: 0:00:00 Sstate summary: Wanted 0 Found 0 Missed 0 Current 0 (0% match, 0% complete) NOTE: No setscene tasks NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 2 tasks of which 0 didn't need to be rerun and all succeeded. INFO: Using default source tree path /home/peeta/poky/build/workspace/sources/learnyocto NOTE: Starting bitbake server... INFO: Recipe /home/peeta/poky/build/workspace/recipes/learnyocto/learnyocto_git.bb has been automatically created; further editing may be required to make it fully functional ### learnyocto的bb文件 build]$ cat workspace/recipes/learnyocto/learnyocto_git.bb # Recipe created by recipetool # This is the basis of a recipe and may need further editing in order to be fully functional. # (Feel free to remove these comments when editing.) # WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is # your responsibility to verify that the values are complete and correct. LICENSE = "LGPLv3" LIC_FILES_CHKSUM = "file://LICENSE;md5=e6a600fd5e1d9cbde2d983680233ad02" SRC_URI = "git://gitee.com/fulinux/learnyocto.git;protocol=https;branch=develop" # Modify these as desired PV = "1.0+git${SRCPV}" SRCREV = "351e99f4d4f6045771a920a33ab178b55a8ff829" S = "${WORKDIR}/git" inherit cmake # Specify any options you want to pass to cmake using EXTRA_OECMAKE: EXTRA_OECMAKE = "" ### learnyocto源码的位置 build]$ ls workspace/sources/learnyocto/ CMakeLists.txt LICENSE main.c oe-logs oe-workdir README.en.md README.md build]$ cd workspace/sources/learnyocto/ learnyocto]$ git branch develop * devtool #当前分支,会创建一个devtool分支,不过它是从develop分支切出来的 master learnyocto]$ git log 351e99f 第一次代码 (Peeta Chen, 51 分钟前) 83f1936 Initial commit (fulinux, 70 分钟前) ### 编译learnyocto build]$ devtool build learnyocto 编译成功。 ### 指定tag和commit-id的方法 本节是一个小知识点,用不上可以忽略。 要指定特定tag或commit hash值,请使用–srcrev选项,可以先记着下面的例子: devtool add --srcrev v1.0 learnyocto https://gitee.com/fulinux/learnyocto.git devtool add --srcrev [commit id] learnyocto https://gitee.com/fulinux/learnyocto.git > 注意:如果您希望每次构建配方时都使用最新版本,请使用–autorev或-a选项。 下篇继续`learnyocto`项目更新~
admin
2024年2月5日 15:24
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码