首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fuchsia OS构建命令: fx set --使用,产生:包含不允许的

Fuchsia OS构建命令: fx set --使用,产生:包含不允许的
EN

Stack Overflow用户
提问于 2020-03-26 00:53:00
回答 1查看 162关注 0票数 1

鹦鹉/main.cc使用fxl::CommandLineFromArgcArgv()

代码语言:javascript
复制
#include "src/lib/fxl/command_line.h"
...
int main(int argc, const char** argv) {
  const auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);

Fuchsia > Guides > fx workflows展示了fx set --with的使用

代码语言:javascript
复制
$ fx set workstation.x64 --with //bundles:tests

我修改了hello示例以使用fxl::CommandLineFromArgcArgv()

代码语言:javascript
复制
~/fuchsia$ cat examples/hello_world/cpp/hello_world.cc 
#include <iostream>
#include "src/lib/fxl/command_line.h"

int main(int argc_a, char** argv_a) {
    auto command_line = fxl::CommandLineFromArgcArgv(argc_a, argv_a);
    std::cout << "hello has_argv0():" << command_line.has_argv0() << "\n";
    return 0;
}
~/fuchsia$ fx set bringup.x64 --with //examples/hello_world
ERROR at //examples/hello_world/cpp/hello_world.cc:2:11: Include not allowed.
#include "src/lib/fxl/command_line.h"
          ^-------------------------
It is not in any dependency of                                                                                           
  //examples/hello_world/cpp:bin
The include file is in the target(s):
  //src/lib/fxl:fxl
which should somehow be reachable.

会产生错误。原来的作品很好:

代码语言:javascript
复制
~/fuchsia$ cat examples/hello_world/cpp/hello_world.cc 
#include <iostream>
//#include "src/lib/fxl/command_line.h"

int main(int argc_a, char** argv_a) {
//    auto command_line = fxl::CommandLineFromArgcArgv(argc_a, argv_a);
//    std::cout << "hello has_argv0():" << command_line.has_argv0() << "\n";
    return 0;
}
~/fuchsia$ fx set bringup.x64 --with //examples/hello_world
Generating JSON projects took 3090ms
Generating compile_commands took 219ms
Done. Made 26946 targets from 2635 files in 16354ms

少了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-19 14:16:41

./examples/hello_world/cpp/BUILD.gn中,用fxl依赖项扩展hello_world_cpp模块声明:

代码语言:javascript
复制
executable("bin") {
  output_name = "hello_world_cpp"

  sources = [ "hello_world.cc" ]

  deps = [ "//src/lib/fxl" ] # Add this line
}
代码语言:javascript
复制
cd fuchsia
fx set bringup.x64 --with //examples/hello_world
fx build; fx qemu
...
hello_world_cpp
hello has_argv0():1

参考:在使用fxl (链接)的其他Fuchsia组件中也是如此。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60859528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档