Skip to content

Commit

Permalink
Remove configure-xcode-for-embedded-development
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=272053
rdar://125864015

Reviewed by Alexey Proskuryakov and Jonathan Bedard.

Since WebKit's move to additions SDKs last summer and changes to how
XCBuild loads specifications in 2022, we no longer need to modify Xcode
to build embedded platforms.

* ReadMe.md: Remove reference to the script and merge the Mac / embedded
  build sections, since there is less of a difference between them now.
* Tools/Scripts/configure-xcode-for-embedded-development: Replaced with
  an error message that the script is no longer needed.
* Websites/webkit.org/languages.md: Remove reference to the script.

Canonical link: https://commits.webkit.org/278218@main
  • Loading branch information
emw-apple committed May 1, 2024
1 parent 86923db commit 9c98cfb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 168 deletions.
36 changes: 19 additions & 17 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,28 @@ git clone https://github.com/WebKit/WebKit.git WebKit

## Building WebKit

### Building macOS Port
### Building for Apple platforms

Install Xcode and its command line tools if you haven't done so already:

1. **Install Xcode** Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
2. **Install the Xcode Command Line Tools** In Terminal, run the command: `xcode-select --install`

Run the following command to build a debug build with debugging symbols and assertions:
Run the following command to build a macOS debug build with debugging symbols and assertions:

```
Tools/Scripts/build-webkit --debug
```

For performance testing, and other purposes, use `--release` instead.

### Using Xcode
#### Embedded Builds

You can open `WebKit.xcworkspace` to build and debug WebKit within Xcode.

If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use `WebKitBuild` directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select "Custom", "Relative to Workspace", and enter `WebKitBuild` for both Products and Intermediates.

### Embedded Builds
To build for an embedded platform like iOS, tvOS, or watchOS, pass a platform
argument to `build-webkit`.

iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:

```
sudo Tools/Scripts/configure-xcode-for-embedded-development
```

Without this step, you will see the error message: "`target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.`" when building target `JSCLLIntOffsetsExtractor` of project `JavaScriptCore`.

Run the following command to build a debug build with debugging symbols and assertions for embedded simulators:
For example, to build a debug build with debugging symbols and assertions for
embedded simulators:

```
Tools/Scripts/build-webkit --debug --<platform>-simulator
Expand All @@ -68,6 +58,18 @@ Tools/Scripts/build-webkit --debug --<platform>-device

where `platform` is `ios`, `tvos` or `watchos`.

#### Using Xcode

You can open `WebKit.xcworkspace` to build and debug WebKit within Xcode.
Select the "Everything up to WebKit + Tools" scheme to build the entire
project.

If you don't use a custom build location in Xcode preferences, you have to
update the workspace settings to use `WebKitBuild` directory. In menu bar,
choose File > Workspace Settings, then click the Advanced button, select
"Custom", "Relative to Workspace", and enter `WebKitBuild` for both Products
and Intermediates.

### Building the GTK Port

For production builds:
Expand Down
152 changes: 2 additions & 150 deletions Tools/Scripts/configure-xcode-for-embedded-development
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2014-2020 Apple Inc. All rights reserved.
# Copyright (C) 2014-2024 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand All @@ -24,152 +24,4 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import errno
import os
import pathlib
import re
import shutil
import subprocess
import sys
import tempfile

from xml.etree import ElementTree as ET

# We always want the real system version
os.environ['SYSTEM_VERSION_COMPAT'] = '0'

xcode_version = subprocess.run(['/usr/bin/xcodebuild', '-version'], capture_output=True, encoding='ascii').stdout.splitlines()[0].split(' ')[1]
if tuple(int(n) for n in xcode_version.split('.')) >= (13, 3):
mac_xcspec_location = f'Platforms/MacOSX.platform/Developer/Library/Xcode/PrivatePlugIns/IDEOSXSupportCore.xcplugindata/Contents/Resources'
elif int(xcode_version.split('.')[0]) >= 12:
mac_xcspec_location = f'Platforms/MacOSX.platform/Developer/Library/Xcode/PrivatePlugIns/IDEOSXSupportCore.ideplugin/Contents/Resources'
else:
mac_xcspec_location = 'Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications'

ideplugin = 'XCBSpecifications' if tuple(int(n) for n in xcode_version.split('.')) >= (13, 3) else 'IDEiOSSupportCore'

XCSPEC_INFO = [dict(
id='com.apple.product-type.tool',
dest=f'Library/Xcode/Plug-ins/{ideplugin}.ideplugin/Contents/Resources/Embedded-Shared.xcspec' if tuple(int(n) for n in xcode_version.split('.')) >= (14, 3) else f'../PlugIns/{ideplugin}.ideplugin/Contents/Resources/Embedded-Shared.xcspec',
content='''
// Tool (normal Unix command-line executable)
{ Type = ProductType;
Identifier = com.apple.product-type.tool;
Class = PBXToolProductType;
Name = "Command-line Tool";
Description = "Standalone command-line tool";
IconNamePrefix = "TargetExecutable";
DefaultTargetName = "Command-line Tool";
DefaultBuildProperties = {
FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";
MACH_O_TYPE = "mh_execute";
EXECUTABLE_PREFIX = "";
EXECUTABLE_SUFFIX = "";
REZ_EXECUTABLE = YES;
INSTALL_PATH = "/usr/local/bin";
FRAMEWORK_FLAG_PREFIX = "-framework";
LIBRARY_FLAG_PREFIX = "-l";
LIBRARY_FLAG_NOSPACE = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
STRIP_STYLE = "all";
CODE_SIGNING_ALLOWED = YES;
};
PackageTypes = (
com.apple.package-type.mach-o-executable // default
);
WantsSigningEditing = YES;
WantsBundleIdentifierEditing = YES;
}
''',
), dict(
id='com.apple.package-type.mach-o-executable',
dest=f'Library/Xcode/Plug-ins/{ideplugin}.ideplugin/Contents/Resources/Embedded-Shared.xcspec' if tuple(int(n) for n in xcode_version.split('.')) >= (14, 3) else f'../PlugIns/{ideplugin}.ideplugin/Contents/Resources/Embedded-Shared.xcspec',
content='''
{ Type = PackageType;
Identifier = com.apple.package-type.mach-o-executable;
Name = "Mach-O Executable";
Description = "Mach-O executable";
DefaultBuildSettings = {
EXECUTABLE_PREFIX = "";
EXECUTABLE_SUFFIX = "";
EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
};
ProductReference = {
FileType = compiled.mach-o.executable;
Name = "$(EXECUTABLE_NAME)";
IsLaunchable = YES;
};
}
''',
)]

PLIST_BUDDY_PATH = pathlib.Path("/usr/libexec/PlistBuddy")


def xcode_developer_dir():
result = subprocess.run(
["xcode-select", "-p"],
capture_output=True, encoding="utf-8", check=True,
)
return pathlib.Path(result.stdout.strip())


# Xcode is driven by .xcspec files. These describe many aspects of the system,
# including what to build and how to build it. These .xcspec files can be
# global or they can be platform- or SDK-specific. In the case of building
# products for the embedded systems, there is some information in some macOS
# .xcspec files that need to be transferred to the embedded platforms. This
# function finds that information, extracts it from the macOS files, and copies
# it to the embedded files.

def update_xcspec_files():
for spec_info in XCSPEC_INFO:
dest_spec_path = xcode_developer_dir() / spec_info['dest']
if not dest_spec_path.exists():
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), dest_spec_path)

result = subprocess.run(
[PLIST_BUDDY_PATH, '-x', '-c', 'Print', dest_spec_path],
capture_output=True, encoding='utf-8', check=True,
)
if result.returncode != 0:
raise OSError(f'Failed to convert {dest_spec_path} to XML')

found = False
for topLevel in ET.fromstring(result.stdout.strip()):
for element in topLevel:
for key in element:
if key.tag == 'string' and key.text == spec_info['id']:
found = True
break
if found:
break
if found:
break
if found:
print(f'{spec_info["id"]} alread in {dest_spec_path}')
continue

with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as temp:
temp.write(spec_info['content'])
temp.flush()

print(f'Inserting: {spec_info["id"]}')
print(f'To: {dest_spec_path}')
subprocess.run([PLIST_BUDDY_PATH, '-c', 'add 0 dict', dest_spec_path], capture_output=True, check=True)
subprocess.run([PLIST_BUDDY_PATH, '-c', f'merge {temp.name} 0', dest_spec_path], capture_output=True, check=True)


def main():
if not os.geteuid() == 0 and not os.access(xcode_developer_dir(), os.R_OK | os.W_OK | os.X_OK, effective_ids=True):
raise RuntimeError(f"{__file__} must be run as root")

update_xcspec_files()
return 0


if __name__ == "__main__":
main()
raise SystemExit("configure-xcode-for-embedded-development is no longer needed. Embedded WebKit ports build in Xcode unmodified.")
2 changes: 1 addition & 1 deletion Websites/webkit.org/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ At some point in the future the Python 2 requirement will be relaxed.

#### Scripts used for developing WebKit

This includes scripts like `configure-xcode-for-embedded-development` and `lint-test-expectations`.
This includes scripts like `git-webkit` and `lint-test-expectations`.

These scripts must be compatible with Python 3,
and do not need to be compatible with Python 2.
Expand Down

0 comments on commit 9c98cfb

Please sign in to comment.