在安装和构建Fuchsia之后,我可以将示例hello world程序中的字符串从"Hello,World!\n“修改为"Hello,Fuchsia!\n”。然后,我执行build并执行生成预期字符串"Hello,Fuchsia!“的代码。使用:
cd fuchsia
fx set bringup.x64 --with //examples/hello_world
fx build; fx qemu
hello_world_cpp这对于理解如何改变Fuchsia“分布”的一部分是很好的。我如何在紫红色树之外创建我自己的程序?我假设当创建在Fuchsia上运行的程序时,人们通常会这样做,以便可以干净地管理源代码。
发布于 2020-04-21 03:49:28
回答
third_party目录用于在Fuchsia树之外管理的模块。在顶级.gitignore中,目录被排除(link):
/third_party/*您可以看到这个文件夹在git (link)中几乎是空的。它首先在引导程序(link)期间填充,引导程序在内部使用jiri update来获取集成清单中指定的repos (例如,用于third_party)。
您将在单独的git存储库中维护您的模块。对于开发,您可以将此存储库克隆到third-party中的一个子目录中。由于.gitignore条目,它将不会被Fuchsia git跟踪。
示例
文件:
third_party/hello_world/BUILD.gn
third_party/hello_world/hello_world.ccBUILD.gn
import("//build/package.gni")
group("hello_world") {
deps = [ ":hello-world-cpp" ]
}
executable("bin") {
output_name = "my_hello_world_cpp"
sources = [ "hello_world.cc" ]
}
package("hello-world-cpp") {
deps = [ ":bin" ]
binaries = [
{
name = "my_hello_world_cpp"
},
]
}hello_world.cc
#include <iostream>
int main(int argc, char** argv) {
std::cout << "Hello, World (out-of-tree)!" << std::endl;
return 0;
}构建并运行:
$ fx set bringup.x64 --with //third_party/hello_world
$ fx build
$ fx qemu
$ my_hello_world_cpp
Hello, World (out-of-tree)!https://stackoverflow.com/questions/60896095
复制相似问题