为 Fuchsia 添加 tree 命令


节约时间,修改后的tree版本传送门,GitHub - feilongfl/tree-for-fuchsia: fork from http://mama.indstate.edu/users/ice/tree/

高高兴兴的把tree下载下来发现根本不能用:)

http://mama.indstate.edu/users/ice/tree/ 下载最新(2019.3.4)版本1.8 放在//zircon/system/uapp/tree下,并在uapp下的BUILD.gn添加tree,在tree目录下建立编译文件,忽略各种warrning,然后改掉tree里面各种空括号函数()=>(void)

# Copyright 2019 The Fuchsia Authors. All rights reserved.# Use of this source code is governed by a BSD-style license that can be# found in the LICENSE file. config("tree_config") {  cflags = [    "-Wno-discarded-qualifiers",    "-Wno-implicit-fallthrough",    "-Wno-sign-compare",    "-Wno-unused-but-set-parameter",    "-Wno-incompatible-pointer-types"  ]} executable("tree") {  configs += [ ":tree_config" ]   sources = [    "color.c",    "hash.c",    "json.c",    "tree.c",    "unix.c",    "file.c",    "html.c",    "strverscmp.c",    "tree.h",    "xml.c",  ]}

开始编译…….顺利通过,高高兴兴在系统中打开tree命令,顺利的看到崩溃堆栈(手动滑稽),什么鬼…

今天(2019.3.4)太晚了,随手搞搞,先开个坑

开始查坑

首先早上(2019.3.5)起来先写了个helloworld试试水,毕竟这才是正路啊~~

image

# Copyright 2019 The Fuchsia Authors. All rights reserved.# Use of this source code is governed by a BSD-style license that can be# found in the LICENSE file. executable("i2c") {  sources = [    "i2c.c",  ]  deps = [    "$zx/system/fidl/fuchsia-hardware-i2c:c",    "$zx/system/ulib/fdio",    "$zx/system/ulib/zircon",  ]}


所以说c语言helloworld我还是能不调试一次写成功的(笑)

这样的话问题就比较清晰了,之前的tree命令没有依赖项。使用输入输出必须添加fdio依赖

google对fdio的说明

FDIO是一个客户端库,它通过紫红色系统接口中的底层fuchsia.io协议提供类似POSIX的抽象。FDIO is a client library that provides a POSIX-like abstraction over the underlying fuchsia.io protocol in the Fuchsia System Interface.

解决tree

添加fdio依赖即可运行(我已经修正github仓库)

# Copyright 2019 The Fuchsia Authors. All rights reserved.# Use of this source code is governed by a BSD-style license that can be# found in the LICENSE file. config("tree_config") {  cflags = [    "-Wno-discarded-qualifiers",    "-Wno-implicit-fallthrough",    "-Wno-sign-compare",    "-Wno-unused-but-set-parameter",    "-Wno-incompatible-pointer-types"  ]} executable("tree") {  configs += [ ":tree_config" ]   sources = [    "color.c",    "hash.c",    "json.c",    "tree.c",    "unix.c",    "file.c",    "html.c",    "strverscmp.c",    "tree.h",    "xml.c",  ]   deps = [    "$zx/system/ulib/fdio",  ]}

然后就可以查看fuchsia里面到底是什么目录结构了

想直接查看的朋友移步 fuchsia tree output · GitHub

Fuchsia OS 中文社区经授权转载,本文链接:这里;本文原作者:飞龙;原文链接:这里