Fuchsia OS build command: fx set --with, produces: Include not allowed

﹥>﹥吖頭↗ 提交于 2020-05-16 05:54:07

问题


fuchsia/examples/intl/tz_version_parrot/main.cc uses fxl::CommandLineFromArgcArgv():

#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 show the use of fx set --with:

$ fx set workstation.x64 --with //bundles:tests

I modified the hello world example to use fxl::CommandLineFromArgcArgv():

~/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.

which produces errors. The original works fine:

~/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

What is missing?


回答1:


In ./examples/hello_world/cpp/BUILD.gn, extend the hello_world_cpp module declaration with the fxl dependency:

executable("bin") {
  output_name = "hello_world_cpp"

  sources = [ "hello_world.cc" ]

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

Reference: The same is done in other Fuchsia components that use fxl (link).



来源:https://stackoverflow.com/questions/60859528/fuchsia-os-build-command-fx-set-with-produces-include-not-allowed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!