How does Chromium automatically generate the corresponding Blink files?

158 views
Skip to first unread message

18楼梦想改造家

unread,
Jun 12, 2024, 11:10:48 PMJun 12
to Chromium-dev
Hi, anyone. I have a question.

When I read chromium source code, I noticed some file like this one.

-   v8_css_style_declaration.cc - Chromium Code Search

It seems like these documents were automatically generated. 

For example:
```
// Named interceptors
v8::Local<v8::Value>(),
static_cast<v8::PropertyHandlerFlags>(
```

I believe there is a source file here indicating that our flag is kOnlyInterceptStrings, and then the |chromium| generator program automatically generates such code.

So my questions are:

  1. What is the source file here?
  2. What is the generator program here? Where can I find them?

Thx.

Ian Clelland

unread,
Jun 17, 2024, 9:59:11 AMJun 17
to 18.flo...@gmail.com, Chromium-dev
The top of the file includes the comment:

// DO NOT EDIT: This file is auto-generated by 
// //third_party/blink/renderer/bindings/scripts/generate_bindings.py

This is the generator for v8_css_style_declaration.cc (among many others).

Chromium's build system is quite complex, but it is mostly expressed through the BUILD.gn and *.gni files in the source tree.

You can usually use code search to track down most of what you're looking for: if you search for "v8_css_style_declaration.cc", for instance, you can see that it's mentioned in the file third_party/blink/renderer/bindings/generated_in_core.gni, in a list named "generated_interface_sources_in_core". That can be traced back to third_party/blink/renderer/bindings/BUILD.gn, which includes the build steps that call generate_bindings.py.

As far as source files go, the bindings generator takes as its input all of the *.idl files in the source tree, and writes out the C++ code for these in .cc and .h files. In your case, the source file would have been third_party/blink/renderer/core/css/css_style_declaration.idl, and the code would have largely been written by third_party/blink/renderer/bindings/scripts/bind_gen/interface.py. (There are many other dependencies and files involved, but those two are the most directly related).

If you want to read up on how the bindings generation system works, https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/README.md is a good place to start.


Thx.

--
--
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 unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/a20b7fa3-40a7-46d2-a51f-11b9b07c4e8dn%40chromium.org.
Reply all
Reply to author
Forward
0 new messages