How to add new component to chromium build system

535 views
Skip to first unread message

Derek Lee

unread,
Jan 15, 2016, 2:09:51 AM1/15/16
to blink-dev
Hi everybody,

I want to add new component (new "feature" directory in "src" directory) to chromium source but I don't know how to build them.
Actually, no existing component depends on my new component so I don't need to touch 'dependencies' field of other gyp files.

What I tried to build them was
1. Add some cc and h files to my new directory (src/feature directory).
2. Create new feature.gyp file for building them.
{
  'targets': [
    {   
      'target_name': 'myfeature',
      'type': '<(component)',
      'dependencies': [
        '<(DEPTH)/ui/aura/aura.gyp:aura',
      ],  
      'include_dirs': [
        '..',
      ],  
      'includes': [
        '../build/common.gypi',
      ],  
      'sources': [
        'main_feature.h',
        'main_feature.cc',
        'sub_feature.h'
        'sub_feature.cc',
      ],  
    },  
  ]
}
3. Add "../feature/feature.gyp" dependency to src/build/all.gyp file.
4. Clean and re-build chromium.

I could see feature.ninja file but there is no object files from main_feature.cc and sub_feature.cc files.

Do I need to do something else?

Thanks in advance.
Derek

Peter Kasting

unread,
Jan 15, 2016, 4:49:03 AM1/15/16
to Derek Lee, blink-dev
On Thu, Jan 14, 2016 at 11:09 PM, Derek Lee <coo...@gmail.com> wrote:
4. Clean and re-build chromium.

What target did you build, precisely, chrome or all?  Because it sounds as if you built the former, and you'd expect that to only build targets that chromium actually depends on.

Also, you might want to ask this on chromium-dev instead of blink-dev since this doesn't seem to be Blink-specific, though I'd imagine people here would know the answers too.

PK

Nico Weber

unread,
Jan 15, 2016, 3:48:18 PM1/15/16
to Derek Lee, blink-dev
How did you "re-build chromium"? If you just did `ninja -C out/Release chrome` but didn't make chrome depend on myfeature, it won't be built. Try `ninja -C out/Release myfeature`. What you did looks correct (except that common.gypi is included automatically everywhere, you don't need an explicit include for that.)

Nico

Derek Lee

unread,
Jan 15, 2016, 10:52:17 PM1/15/16
to blink-dev, coo...@gmail.com
I tried to build chrome but I am not sure it is related to what I want to do. Is this?
Adding new component that needs to use blink web engine is what I am trying now so I asked this on blink-dev.

2016년 1월 15일 금요일 오후 6시 49분 3초 UTC+9, Peter Kasting 님의 말:

Derek Lee

unread,
Jan 15, 2016, 10:58:00 PM1/15/16
to blink-dev, coo...@gmail.com
I didn't do 'ninja' command for rebuilding but removed all of them and started to build from scratch since I wanted to make sure I did the right re-build.
You are saying myfeature won't be built even if I did the correct things?
The only solution is 'ninja -C out/Release myfeature'?

2016년 1월 16일 토요일 오전 5시 48분 18초 UTC+9, Nico Weber 님의 말:

Peter Kasting

unread,
Jan 16, 2016, 1:18:53 AM1/16/16
to Derek Lee, blink-dev
On Fri, Jan 15, 2016 at 7:58 PM, Derek Lee <coo...@gmail.com> wrote:
I didn't do 'ninja' command for rebuilding but removed all of them and started to build from scratch since I wanted to make sure I did the right re-build.
You are saying myfeature won't be built even if I did the correct things?
The only solution is 'ninja -C out/Release myfeature'?

Your feature will be built if you build it directly (as Nico suggests) or if you build something that depends on it.  From your description, the only thing that you made depend on this is the "all" target, which is why I suggested building that.

PK

Thiago Farina

unread,
Jan 20, 2016, 8:21:01 AM1/20/16
to Derek Lee, blink-dev
On Sat, Jan 16, 2016 at 1:58 AM, Derek Lee <coo...@gmail.com> wrote:
I didn't do 'ninja' command for rebuilding but removed all of them and started to build from scratch since I wanted to make sure I did the right re-build.
You are saying myfeature won't be built even if I did the correct things?
The only solution is 'ninja -C out/Release myfeature'?
You feature component will be built as a shared library if you set component=shared_library in your GYP_DEFINES (there are other ways to do this in gyp though). That said, either static (.a) or shared library (.so), you will want to have it linked to another library or executable, add to do that you add feature/feature.gyp:myfeature in some other dependencies list.

If you just want to build your myfeature the following should be enough:

$ ./build/gyp_chromium feature/feature.gyp
$ ninja -C out/Release myfeature

--
Thiago Farina
Reply all
Reply to author
Forward
0 new messages