Changes between Version 8 and Version 9 of AddingFiles


Ignore:
Timestamp:
Oct 23, 2017 4:03:45 PM (6 years ago)
Author:
keith_miller@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AddingFiles

    v8 v9  
    11WebKit has several different build systems; which is used depends on the platform and port. When adding files used by more than one port, its tricky to remember all the different build system files that the file must be added. This page documents how to do so, and common gotchas.
    22
     3
    34= How to add a file
     5
     6== Adding Source Files (.cpp/.mm)
     7
     8Due to the size of WebKit the WebKit project uses a system called unified sources to build files. This means that we pass multiple source files to the compiler to treat as a single source file. The bundling of source files is done automatically in the build system. Sources are passed to the bundling code via source list files and a particular port might use more than one source list file. e.g. The iOS port uses the `Sources.txt`, `SourcesCocoa.txt`, and the `SourcesIOS.txt` files. Both the Xcode and CMake build systems use unified sources but the way the sources are bundled should be the same across both build systems.
     9
     10Choosing the right source list file depends on what ports the file is built on. If the source should be compiled on every port then add it to `Sources.txt`. If it's on Mac and iOS add it to `SourcesCocoa.txt`. Otherwise, add it to the appropriate `Sources<Port>.txt` file for that port.
    411
    512== Xcode (for Mac, iOS)
     
    1724If adding a header file that should be accessible from other frameworks (say, using a WebCore framework from WebKit2), then you must alter the file's target membership from "Project" to "Private" in the "Target Membership" details sidebar, using the drop-down next to the framework. If using headers from JavaScriptCore inside WebCore, you must also add a forwarding header in `Source/WebCore/ForwardingHeaders` in the appropriate mirrored directory structure.
    1825
     26It is important to make sure that any source file added is not compiled by Xcode if it is in a source file list. If this happens it's likely that there will be an error in the linker that complains about duplicate symbols.
     27
    1928=== Adding code generators / generated files
    2029
     
    2433 * If the rules added to `DerivedSources.make` rely on environment variables, you need to set those in `make-generated-sources.sh`.
    2534
    26 == Visual Studio (Windows)
    27 
    28 Visual Studio-based builds use XML files named after the respective WebKit components. One file (e.g., `Source/WebCore/WebCore.vcxproj.filters`) describes the tree structure of the project that should be displayed in Visual Studio. The other file (e.g., `Source/WebCore/WebCore.vcxproj`) contains the actual build rules and dependencies.
    29 
    30 === Adding a directory
    31 
    32  * Make a stub in `Project.vcxproj.filters` at the top.
    33  * If the directory has headers used outside the current project (i.e., a WebCore directory's headers are used by WebKit), then you must tell the build system to copy the directory's headers to the shared include dir. This is configured in `Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd`.
    34 
    35 === Adding a file
    36 
    37  * Add a `CLInclude` command for a header file and `CLCompile` command for an implementation file.
    38  * When adding .cpp files to WebCore, you may need to add a #include of the cpp file to the appropriate *AllInOne.cpp file in the same directory. (Without this hack, template bloat in Windows release builds can cause machines to run out of memory.)
    39  * It's recommended that you consult a build expert for anything more complicated, such as adding a new code generator (especially if you can't run Visual Studio yourself).
    40 
    41 === Adding code generators / generated files
    42 
    43  * Make sure that the rules in `copy-files.cmd` will properly copy any generated files you want to use from other frameworks.
    44  * If you rely on environment variables inside `DerivedSources.make`, you will need to export them in `build-generated-files.sh`.
    45 
    46 == CMake (EFL, GTK)
     35== CMake (EFL, GTK, Win, Mac)
    4736
    4837Find the relevant `CMakeLists.txt` file in the project directory (WebCore, WebKit2, DumpRenderTree, etc). Then, add entries to various lists in the files depending on what is being added. Platform-specific rules and dependencies are located in files like `PlatformGTK.cmake` and `PlatformEFL.cmake`.
     
    5241 * If the directory contains header or implementation files, add it to `Project_INCLUDE_DIRECTORIES`.
    5342 * If the directory contains IDL files, add it to `Project_IDL_INCLUDES`.
    54  * If the directory has headers used outside the current project (i.e., a WebCore directory's headers are used by WebKit2), then you must add the referenced directory to referencing project's `CMakeLists.txt` (i.e., WebKit2).
     43 * If the directory has headers used outside the current project (i.e., a WebCore directory's headers are used by WebKit2), then you must add the referenced directory to referencing project's `CMakeLists.txt` (e.g., WebKit2).
    5544
    5645=== Adding a file
     
    6554You'll need to add a custom command, and append the generated files to `Project_SOURCES` or some other list. This adds the generated file as a build dependency, and the custom rule tells CMake how to derive the generated files. See existing files for examples.
    6655
     56= How Source Files are bundled.
     57
     58TODO - Be more specific about how this works
     59
     60It's mostly based on the directory of the source file. Although, there is also a limit of 8 sources per bundle to provide a balance between incremental and clean builds
    6761
    6862= Tips