Version 3 (modified by BJ Burg, 10 years ago) (diff)

add instructions for windoze and Gmake

WebKit 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.

How to add a file

Xcode (for Mac, iOS)

Xcode-based builds use Xcode projects named after the respective WebKit components. For example, the Xcode project directory for WebCore is at Source/WebCore/WebCore.xcproj/ and the actual project file in called project.pbxproj. To add a file, you'll need to open the appropriate project in Xcode.

Adding a directory

Usually, file system directories are mapped one-to-one to Xcode project groups (which have folder icons). To add a directory, right-click in the navigation sidebar and "Add Group". Name and alphabetize the group, and then open the item details sidebar by selecting the group. If the group corresponds to a filesystem directory, ensure that location is set to "Relative to Group", and just below, select the directory. (By doing this, Xcode knows to look in the filesystem directory when adding new files to the group.)

Adding a file

Find the group that corresponds to the file's directory, then right-click and select "Add Files to ProjectName..." and select the files in the file chooser dialog. Ensure that the file is added to correct target. The correct target is almost always the framework named after the project, not the "All" target. Lastly, alphabetize the file within its group in the navigation sidebar.

If 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.

Visual Studio (Windows)

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.

Adding a directory

  • Make a stub in Project.vcxproj.filters at the top.

Adding a file

  • Add a CLInclude command for a header file and CLCompile command for an implementation file.
  • 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).

CMake (EFL)

Find 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.

Adding a directory

  • If the directory contains header or implementation files, add it to Project_INCLUDE_DIRECTORIES.
  • If the directory contains IDL files, add it to Project_IDL_INCLUDES.

Adding a file

  • If it's an IDL file, add to the section Project_IDL_FILES.
  • If it's a new Inspector domain, add to Project_INSPECTOR_DOMAINS.
  • If it's a CPP file, add it to Project_SOURCES.
  • If the file depends on a feature flag, then wrap it in a conditional that appends extra values to the main lists if the feature is enabled. See existing CMakeLists.txt for examples of how to do this.

Adding code generators / generated files

You'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.

GMake (GTK)

Build rules and paths are in a per-project file. Lists of files to build go in a per-project

Adding a directory

  • If the directory contains headers, add it to project_cppflags.
  • (WebCore only) If the directory contains IDL flies, add it to IDL_PATH and EXTRA_DIST.

Adding a file

  • If it's a new Inspector domain, add it to project_INSPECTOR_DOMAINS in
  • Otherwise, add it to the correct section in This includes generated sources (inside DerivedSources/).


TODO - feel free to add your hard-won lessons here.