Adding third party library

351 views
Skip to first unread message

sepehr abdous

unread,
Aug 15, 2018, 2:30:59 PM8/15/18
to Chromium-dev
Hello all,

I want to add a third party library to the chromium and form what I got from the link below:


what is needed is solely to copy the whole file to the third-party directory of is there any other steps required?

The library I want to add is ndn-rtc and is written in cpp:

Best,
Sepehr

Dirk Pranke

unread,
Aug 15, 2018, 3:12:20 PM8/15/18
to sepehrab...@gmail.com, Chromium-dev
You have to copy the file in and then make sure something references the library from the appropriate build targets, but that shouldn't be too hard.

-- Dirk

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKaOriipJtCrJqXDVaWHDZJYJpngMj8ZaejD4SPsr%2B1MqDVaKg%40mail.gmail.com.

sepehr abdous

unread,
Aug 15, 2018, 3:26:04 PM8/15/18
to Dirk Pranke, Chromium-dev
Oh so I should look for someway to reference the library from a build target.

Thank you
--
Sepehr Abdous
Faculty: abd...@ce.sharif.edu
Cellphone:+989129751873
School of computer engineering
Sharif University of Technology
Tehran, Iran

sepehr abdous

unread,
Aug 17, 2018, 5:27:38 PM8/17/18
to Dirk Pranke, Chromium-dev
Hello all,
how can we reference a third party library from an appropriate build target?
In other words how can we find out which build target is appropriate for the library?
An example from an existing library in chromium would be sufficient as well.

thanks

Dirk Pranke

unread,
Aug 17, 2018, 5:43:47 PM8/17/18
to sepehr abdous, Chromium-dev
Find the build file for the source files that reference (call) the third party code, and then look into adding a 'libs' variable to that build target in GN.

In general, we don't link directly against third-party libs in chromium builds, we prefer to build things from source code. On the linux builds, though,
you can look at where we link against the system libraries through the pkg_config() templates.

-- Dirk

sepehr abdous

unread,
Aug 17, 2018, 5:56:10 PM8/17/18
to Dirk Pranke, Chromium-dev
Actually the library that I am using is open source and I can build it from source code as well.
you suggest building it from source code rather than link it?

Dirk Pranke

unread,
Aug 17, 2018, 5:58:52 PM8/17/18
to sepehr abdous, Chromium-dev
When I say "build it from source", that means that you'd need to write a GN file for it and integrate it into the normal build. If you can do that, that's the best long term option. But, if you're just experimenting with something, that's probably overkill. It's certainly possible to just link against a .a file, I'm just not sure that we have any examples in the current build I could really point at.

-- Dirk

sepehr abdous

unread,
Aug 20, 2018, 2:19:59 PM8/20/18
to Dirk Pranke, Chromium-dev
What about the ones in the third_party directory? aren't those the examples? for instance webrtc?

Dirk Pranke

unread,
Aug 20, 2018, 4:04:14 PM8/20/18
to sepehr abdous, Chromium-dev
webrtc, like most (all?) things in third_party is built from src using GN, so it's not an example of what I'm talking about.

-- Dirk

sepehr abdous

unread,
Aug 20, 2018, 4:11:09 PM8/20/18
to Dirk Pranke, Chromium-dev
Oh I see. and if I want to build a library from source using GN what should I do?
I saw than there is a build.gn file in the webrtc directory but is that file all that is needed or additional steps are required as well?


Dirk Pranke

unread,
Aug 20, 2018, 5:01:46 PM8/20/18
to sepehr abdous, Chromium-dev
You can either add a build target for your library to an existing file, or add a new build file, and then reference the targets in your new file from an existing file.

-- Dirk

sepehr abdous

unread,
Aug 20, 2018, 5:22:43 PM8/20/18
to Dirk Pranke, Chromium-dev
from the existing file do you mean a .gn file?
There are a lot of .gn files which one you mean?

Dirk Pranke

unread,
Aug 20, 2018, 6:06:46 PM8/20/18
to sepehr abdous, Chromium-dev
Yes, I mean a .gn file. Which .gn file depends on what you're adding and who needs to call it.

For example, if you wanted to add the ability to use OpenSSL instead of BoringSSL, you'd need to (a) write a build file for OpenSSL, (b) find all of the places in the current build files that reference targets in //third_party/boringssl, and change them to refer to your new OpenSSL targets in your new file.

On the other hand, if you wanted to do something like replace our use of //third_party/modp_b64 with a new library that has a Base64 implementation, modp_b64 is *only* referenced from //base/BUILD.gn, so you could probably just modify the //base/BUILD.gn library to link in your new .a (if you had it prebuilt), or you could write a target to build your new library from scratch and just put it in //base/BUILD.gn rather than creating a new file.

-- Dirk

sepehr abdous

unread,
Aug 20, 2018, 6:50:33 PM8/20/18
to Dirk Pranke, Chromium-dev
what about the libraries with functionalities that do not exist currently in chromium. for example WebAROnARCore is extended from the chromium and added some functionalities, I want to do the exact same thing about another library.
There is a library named NDN-RTC(https://github.com/remap/ndnrtc) I want to add it to chromium and expose its functionalities through chromium to my js files.

But I guess NDN-RTC would act as a substitute of webrtc.

Dirk Pranke

unread,
Aug 20, 2018, 8:14:29 PM8/20/18
to sepehr abdous, Chromium-dev
We don't have a guide to explain how to add a feature to Chromium that is exposed through JavaScript and the DOM. I'm willing to bet that others have written such things, though.

In short, you'll need to add code into the web bindings for the API you want, and then plumb those bindings through C++ into the library that you want to expose. This likely means you'll need to add a few files to some existing targets (for the bindings), register those, and then have those targets call into your library.

That's about the level of detail I have the time to offer at this point, I'm afraid. Maybe others can take it from here, or point at tutorials for this sort of thing.

I hope I've been able to help at least some,

-- Dirk

sepehr abdous

unread,
Aug 24, 2018, 2:09:28 PM8/24/18
to Dirk Pranke, Chromium-dev
Thank you very much 
Reply all
Reply to author
Forward
0 new messages