There is two primary way to export symbols: export lists and inline annotations. Some ports use export lists. others use inline annotations, or even both.
An export list is a text file which contains the list of exporting symbols. Linkers refer these files to decide which symbols should be exported.
Ports have their own separate lists:
- Mac port uses this to build WebCore.framework.
- GTK port uses this to build libwebkitgtk.so
- Mac WebKi2 port uses this to build WebKit2.framework
- Will be used by Apple Win when switching to VS2010.
Inline annotations is compiler-specific qualifiers which are encapsulated by a set of macros. These macros are defined in following files:
- JS_EXPORT_PRIVATE, JS_EXPORTDATA
- (TODO: List port specific definitions for WebKit API layer here.)
Inline annotations are adopted as following:
- Mac port uses WTF_EXPORT, WTF_EXPORT_PRIVATE, JS_EXPORT, JS_EXPORT_PRIVATE, JS_EXPORTDATA to export WTF and JSC symbols.
- Win ports use it JS_EXPORTDATA for exporting JSC static variables.
- Many port have use their own inline annotations to export their WebKit API.
- You cannot export inline function.
- If you need to export C++ vtables (that rarely happens though), you need to add JS_EXPORT_PRIVATE or WTF_EXPORT_PRIVATE to the class definition.
How can I export my symbols?
Here are some typical scenarios when you need to care about symbol export:
Exporting WebCore symbols to use them from port WebKit implementations
- If you use it from Mac(WK1), you need to edit WebCore.exp.in.
- Otherwise you don't need to do anything about symbols.
- You need to add JS_EXPORT_PRIVATE or WTF_EXPORT_PRIVATE to the function.
Exporting WebCore symbols to use them from Internals object (WebCoreTestSupport)
- Only WebCore symbols need to be exported which are used in Internals (if not already exported. Check previous definitions first)
- Internals symbols need not be exported.
- You also need to add JS_EXPORT_PRIVATE or WTF_EXPORT_PRIVATE to exporting functions.
For WebCore symbols, you need to edit following files...
- WebCore.exp.in, symbols.filter, WebKit2.order
- You shouldn't do it.
- If you inevitably need to do it, it's same as the Internals appraoch noted above.
Exporting WebKit API symbols to applications
TODO: Write port specific way to do this.