(Q1)我有一个 test.so 有一些我需要使用的功能。我已经调查了一段时间但没有答案。任何人都可以就如何在 Chromium 项目的 gn 文件中包含共享库提出一些建议吗?非常感谢。
以下是我的 gn 文件的内容:
import("//third_party/WebKit/Source/core/core.gni")
blink_core_sources("frame") {
sources = [
"csp/CSPSource.h",
"csp/ContentSecurityPolicy.cpp",
"csp/ContentSecurityPolicy.h",
"csp/MediaListDirective.cpp",
"csp/MediaListDirective.h",
"csp/SourceListDirective.cpp",
"csp/SourceListDirective.h",
// my created file
"HelloWorld.h",
"HelloWorld.cpp", // Will use the function of provided in add.so
"add.h"
]
deps = [ ":add.so" ]
}
(Q2)另一个问题是:如果我有add.so的源代码,我应该如何在gn中编写使用共享库的源代码?谢谢。
最佳答案
(Q1)Could anyone have some advise of how to include a shared library in gn file of chromium project?
通常,您可以使用
lib_dirs
指定库目录和图书馆 libs
.您的 BUILD.gn
文件可以是这样的:import("//third_party/WebKit/Source/core/core.gni")
blink_core_sources("frame") {
sources = [
"csp/CSPSource.h",
"csp/ContentSecurityPolicy.cpp",
"csp/ContentSecurityPolicy.h",
"csp/MediaListDirective.cpp",
"csp/MediaListDirective.h",
"csp/SourceListDirective.cpp",
"csp/SourceListDirective.h",
// my created file
"HelloWorld.h",
"HelloWorld.cpp", // Will use the function of provided in add.so
"add.h"
]
lib_dirs = [ "//path/to/add.so" ]
libs = [ "add" ]
}
(Q2)If I have source code of add.so, how should I write in gn to use the source code of the shared library?
如果你想从add.so的源代码中得到一个共享库,你可以写一个
BUILD.gn
像这样的文件:shared_library("libadd.so") {
include_dirs = []
sources = [
"/path/to/sources",
]
}
您可以使用
gn help shared_library
更多细节。然后你可以像 Q(1) 一样使用共享库。
最后,我建议您使用
gn help
查看有关 gn 构建系统的更多详细信息。
关于shared-libraries - 如何在chrome的gn文件中包含共享库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49102921/