I am trying to add a functionality to the chromium that requires the third party library tpm2-tss. This library has a makefile to build it.
I have added a folder tpm
in the third_party
directory and added a BUILD.gn
file. Also the library is added as a subdirectory in this folder.
thirdparty
...other third-party folders
tpm
BUILD.gn
tmp2-tss/
Makefile
...
I tried adding the library by using
config("tpm_config"){
include_dirs = ["tpm2-tss"]
}
in the BUILD.gn and then using configs += ["//thirdparty/tpm:tpm_config"]
where I want to use the library. This of course does not work as the tpm2-tss library is not header-only. However, I can't find a way to tell the GN Build system to build/link this library using the Makefile it provides.
Is there a way to use the makefile inside GN or do I need to rewrite the Makefile into a BUILD.gn?
This is just for a proof of concept so I don't need a proper solution that would satisfy the usual standards of the chromium repository.
GN doesn't know anything about other build systems, and requires you to build out actions (or template) for anything more than compiling / archiving / linking.
So, in your case, you might want to place a BUILD.gn file in the root directory of your third-party thing that looks like this:
If tpm doesn't change frequently, or if you always clean your build before you change it, you can skip the
sources
section; that's just there for GN to emit source-file dependencies on the target.Or if this is something you do often, you could wrap it up in a template:
And then use it in your BUILD.gn file:
Your
make.py
might look like this: