Closure externs for APIs

8 views
Skip to first unread message

Michael Giuffrida

unread,
Jun 4, 2015, 10:22:17 PM6/4/15
to chromium...@chromium.org
How do you generate externs for APIs? For instance, the externs in third_party/closure_compiler/externs/{autofill_private,users_private}.js say they were generated, but I can't find documentation on how to trigger this.

And should these really be in separate files, or part of chrome_extensions.js?

Kyle Horimoto

unread,
Jun 5, 2015, 1:28:04 PM6/5/15
to Michael Giuffrida, chromium...@chromium.org
There's a script for this: python tools/json_schema_compiler/compiler.py

Just invoke the script and have it output to a file; for example:

python tools/json_schema_compiler/compiler.py chrome/common/extensions/api/autofill_private.idl --root=. --generator=externs > third_party/closure_compiler/externs/autofill_private.js

Regarding using these in separate files, I'm not really sure if that buys us anything. So far, they've all been their own files, and IMO this is easier to work with because you can just use the script to generate the whole file instead of using the script and copying the output to part of another file.

On Thu, Jun 4, 2015 at 7:21 PM, Michael Giuffrida <mich...@chromium.org> wrote:
How do you generate externs for APIs? For instance, the externs in third_party/closure_compiler/externs/{autofill_private,users_private}.js say they were generated, but I can't find documentation on how to trigger this.

And should these really be in separate files, or part of chrome_extensions.js?

--
You received this message because you are subscribed to the Google Groups "Chromium Settings" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-setti...@chromium.org.
To post to this group, send email to chromium...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-settings/CACi5S_26wPbKcD28nUSFraSJ1Qyp_8NyVsEbd2CCV-08O3fY9g%40mail.gmail.com.

James Hawkins

unread,
Jun 5, 2015, 1:30:28 PM6/5/15
to Michael Giuffrida, chromium...@chromium.org
I believe chrome_extensions.js is limited to the public extensions API, so we shouldn't 'pollute' it with Settings private APIs.

On Thu, Jun 4, 2015 at 7:21 PM, Michael Giuffrida <mich...@chromium.org> wrote:
How do you generate externs for APIs? For instance, the externs in third_party/closure_compiler/externs/{autofill_private,users_private}.js say they were generated, but I can't find documentation on how to trigger this.

And should these really be in separate files, or part of chrome_extensions.js?

Michael Giuffrida

unread,
Jun 5, 2015, 1:38:44 PM6/5/15
to James Hawkins, chromium...@chromium.org

I'm not sure. The file instructs that private APIs should go at the end of the file, and that even incomplete/in-progress APIs should be here as long as they're not in chrome.experimental:

https://code.google.com/p/chromium/codesearch#chromium/src/third_party/closure_compiler/externs/chrome_extensions.js&q=chrome_extensions.js&sq=package:chromium&type=cs&l=178

James Hawkins

unread,
Jun 5, 2015, 1:45:25 PM6/5/15
to Michael Giuffrida, chromium...@chromium.org
Talk to the authors listed at the bottom of the internal (google3) copy of this file for clarification.  I personally don't see the value in including our implementation-detail APIs in this file (and in fact see some cost that the authors may not be aware of).

Steven Bennetts

unread,
Jun 5, 2015, 1:45:34 PM6/5/15
to Michael Giuffrida, James Hawkins, chromium...@chromium.org
We include "private" APIs that are used by whitelisted Chrome apps/extensions that are developed internally at Google in chrome_extensions.js.

I believe that the long term goal should be to automate this process so that all APIs generate extern files which can be pulled from chrome into any repositories that require them. 

In other words, what James said - settings private APIs should be kept separate.

(I suspect that originally there was only chrome_extensions.js and some of the comments may be out of date).


On Fri, Jun 5, 2015 at 10:38 AM, Michael Giuffrida <mich...@chromium.org> wrote:

Dan Beam

unread,
Jun 5, 2015, 3:09:34 PM6/5/15
to Steven Bennetts, Michael Giuffrida, James Hawkins, chromium...@chromium.org, Tyler Breisacher, Evan Adams, Benjamin Kalman, Devlin Cronin
+ a lotta extension externs stakeholders

I think the eventual goal is to split up chrome_extensions.js.  Requiring an over nine thousand line externs file to use 1+ extension API[s] is kinda nuts (IMO) and probably makes everybody's compile slower.

Additionally, the current workflow is really indirect:
1) an extension API in chrome changes
2a) hand modify chrome_extensions.js
2b) poor ewa@ has to trudge through chrome code and tell you how you messed up
3) wait for that to be mirrored to github
4) pull the github mirror into chrome

I think it should be:
1) an extension API in chrome changes, automatically [tells you to] re-run extern generation script
2) sync generated externs to internal file (and later mirror to github)

tl;dr - we should be avoiding adding any new code to chrome_extensions.js, IMO

-- Dan

Reply all
Reply to author
Forward
0 new messages