Fix building libservo with cargo build -p libservo (#35116)

* Fix building libservo with `cargo build -p libservo`

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Test the libservo build in CI

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Work around build issue on macOS (#34517)

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Delan Azabani 2025-01-23 17:05:10 +08:00 committed by GitHub
parent 935364b7bc
commit 0af1204aa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 74 additions and 14 deletions

View file

@ -17,6 +17,9 @@ on:
unit-tests: unit-tests:
required: true required: true
type: boolean type: boolean
build-libservo:
required: true
type: boolean
bencher: bencher:
required: true required: true
type: boolean type: boolean
@ -30,6 +33,7 @@ jobs:
with: with:
profile: ${{ inputs.profile }} profile: ${{ inputs.profile }}
unit-tests: ${{ inputs.unit-tests }} unit-tests: ${{ inputs.unit-tests }}
build-libservo: ${{ inputs.build-libservo }}
bencher: ${{ inputs.bencher }} bencher: ${{ inputs.bencher }}
macos: macos:
@ -41,6 +45,7 @@ jobs:
profile: ${{ inputs.profile }} profile: ${{ inputs.profile }}
wpt-layout: ${{ inputs.wpt-layout }} wpt-layout: ${{ inputs.wpt-layout }}
unit-tests: ${{ inputs.unit-tests }} unit-tests: ${{ inputs.unit-tests }}
build-libservo: ${{ inputs.build-libservo }}
wpt-args: ${{ inputs.wpt-args }} wpt-args: ${{ inputs.wpt-args }}
bencher: ${{ inputs.bencher }} bencher: ${{ inputs.bencher }}
@ -53,6 +58,7 @@ jobs:
profile: ${{ inputs.profile }} profile: ${{ inputs.profile }}
wpt-layout: ${{ inputs.wpt-layout }} wpt-layout: ${{ inputs.wpt-layout }}
unit-tests: ${{ inputs.unit-tests }} unit-tests: ${{ inputs.unit-tests }}
build-libservo: ${{ inputs.build-libservo }}
wpt-args: ${{ inputs.wpt-args }} wpt-args: ${{ inputs.wpt-args }}
bencher: ${{ inputs.bencher }} bencher: ${{ inputs.bencher }}

View file

@ -21,6 +21,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -59,6 +63,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -165,6 +173,9 @@ jobs:
timeout_minutes: 20 timeout_minutes: 20
max_attempts: 2 # https://github.com/servo/servo/issues/30683 max_attempts: 2 # https://github.com/servo/servo/issues/30683
command: ./mach test-unit --${{ inputs.profile }} command: ./mach test-unit --${{ inputs.profile }}
- name: Build libservo
if: ${{ inputs.build-libservo }}
run: cargo build -p libservo
- name: Archive build timing - name: Archive build timing
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View file

@ -18,6 +18,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -52,6 +56,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -152,6 +160,9 @@ jobs:
timeout_minutes: 40 # https://github.com/servo/servo/issues/30275 timeout_minutes: 40 # https://github.com/servo/servo/issues/30275
max_attempts: 3 # https://github.com/servo/servo/issues/30683 max_attempts: 3 # https://github.com/servo/servo/issues/30683
command: ./mach test-unit --${{ inputs.profile }} command: ./mach test-unit --${{ inputs.profile }}
- name: Build libservo
if: ${{ inputs.build-libservo }}
run: cargo build -p libservo
- name: Build mach package - name: Build mach package
run: ./mach package --${{ inputs.profile }} run: ./mach package --${{ inputs.profile }}
- name: Run DMG smoketest - name: Run DMG smoketest

View file

@ -35,7 +35,7 @@ jobs:
run: | run: |
{ {
echo 'result<<EOF' echo 'result<<EOF'
python ./python/servo/try_parser.py ${{ github.event_name == 'pull_request' && 'linux-unit-tests lint' || github.event_name == 'push' && 'fail-fast full bencher production-bencher' || 'fail-fast full' }} python ./python/servo/try_parser.py ${{ github.event_name == 'pull_request' && 'linux-unit-tests linux-build-libservo lint' || github.event_name == 'push' && 'fail-fast full bencher production-bencher' || 'fail-fast full' }}
echo EOF echo EOF
} >> $GITHUB_OUTPUT } >> $GITHUB_OUTPUT
@ -54,6 +54,7 @@ jobs:
wpt-layout: ${{ matrix.wpt_layout }} wpt-layout: ${{ matrix.wpt_layout }}
profile: ${{ matrix.profile }} profile: ${{ matrix.profile }}
unit-tests: ${{ matrix.unit_tests }} unit-tests: ${{ matrix.unit_tests }}
build-libservo: ${{ matrix.build_libservo }}
wpt-args: ${{ matrix.wpt_args }} wpt-args: ${{ matrix.wpt_args }}
bencher: ${{ matrix.bencher }} bencher: ${{ matrix.bencher }}

View file

@ -137,6 +137,7 @@ jobs:
wpt-layout: ${{ matrix.wpt_layout }} wpt-layout: ${{ matrix.wpt_layout }}
profile: ${{ matrix.profile }} profile: ${{ matrix.profile }}
unit-tests: ${{ matrix.unit_tests }} unit-tests: ${{ matrix.unit_tests }}
build-libservo: ${{ matrix.build_libservo }}
wpt-args: ${{ matrix.wpt_args }} wpt-args: ${{ matrix.wpt_args }}
bencher: ${{ matrix.bencher }} bencher: ${{ matrix.bencher }}

View file

@ -107,6 +107,7 @@ jobs:
wpt-layout: ${{ matrix.wpt_layout }} wpt-layout: ${{ matrix.wpt_layout }}
profile: ${{ matrix.profile }} profile: ${{ matrix.profile }}
unit-tests: ${{ matrix.unit_tests }} unit-tests: ${{ matrix.unit_tests }}
build-libservo: ${{ matrix.build_libservo }}
wpt-args: ${{ matrix.wpt_args }} wpt-args: ${{ matrix.wpt_args }}
bencher: ${{ matrix.bencher }} bencher: ${{ matrix.bencher }}

View file

@ -11,6 +11,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -37,6 +41,10 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
build-libservo:
required: false
default: false
type: boolean
upload: upload:
required: false required: false
default: false default: false
@ -168,6 +176,9 @@ jobs:
timeout_minutes: 30 timeout_minutes: 30
max_attempts: 3 # https://github.com/servo/servo/issues/30683 max_attempts: 3 # https://github.com/servo/servo/issues/30683
command: .\mach test-unit --${{ inputs.profile }} -- -- --test-threads=1 command: .\mach test-unit --${{ inputs.profile }} -- -- --test-threads=1
- name: Build libservo
if: ${{ inputs.build-libservo }}
run: cargo build -p libservo
- name: Archive build timing - name: Archive build timing
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View file

@ -64,6 +64,7 @@ gstreamer-gl = "0.23"
gstreamer-gl-sys = "0.23" gstreamer-gl-sys = "0.23"
gstreamer-sys = "0.23" gstreamer-sys = "0.23"
gstreamer-video = "0.23" gstreamer-video = "0.23"
harfbuzz-sys = "0.6.1"
headers = "0.4" headers = "0.4"
hitrace = "0.1.4" hitrace = "0.1.4"
html5ever = "0.29" html5ever = "0.29"

View file

@ -26,7 +26,8 @@ euclid = { workspace = true }
fnv = { workspace = true } fnv = { workspace = true }
fontsan = { git = "https://github.com/servo/fontsan" } fontsan = { git = "https://github.com/servo/fontsan" }
fonts_traits = { workspace = true } fonts_traits = { workspace = true }
harfbuzz-sys = "0.6.1" # FIXME (#34517): macOS only needs this when building libservo without `--features media-gstreamer`
harfbuzz-sys = { workspace = true, features = ["bundled"] }
ipc-channel = { workspace = true } ipc-channel = { workspace = true }
itertools = { workspace = true } itertools = { workspace = true }
libc = { workspace = true } libc = { workspace = true }
@ -62,7 +63,6 @@ core-graphics = "0.23"
core-text = "20.1" core-text = "20.1"
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
harfbuzz-sys = { version = "0.6", features = ["bundled"] }
freetype-sys = { workspace = true } freetype-sys = { workspace = true }
servo_allocator = { path = "../allocator" } servo_allocator = { path = "../allocator" }
@ -72,11 +72,6 @@ fontconfig_sys = { package = "yeslogic-fontconfig-sys", version = "6" }
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
xml-rs = "0.8" xml-rs = "0.8"
[target.'cfg(target_env = "ohos")'.dependencies]
harfbuzz-sys = { version = "0.6.1", features = ["bundled"] }
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
harfbuzz-sys = { version = "0.6", features = ["bundled"] }
dwrote = "0.11.2" dwrote = "0.11.2"
truetype = { version = "0.47.3", features = ["ignore-invalid-language-ids"] } truetype = { version = "0.47.3", features = ["ignore-invalid-language-ids"] }

View file

@ -88,7 +88,6 @@ servo_geometry = { path = "../geometry" }
servo_url = { path = "../url" } servo_url = { path = "../url" }
style = { workspace = true } style = { workspace = true }
style_traits = { workspace = true } style_traits = { workspace = true }
surfman = { workspace = true }
tracing = { workspace = true, optional = true } tracing = { workspace = true, optional = true }
webdriver_server = { path = "../webdriver_server", optional = true } webdriver_server = { path = "../webdriver_server", optional = true }
webgpu = { path = "../webgpu" } webgpu = { path = "../webgpu" }
@ -98,5 +97,11 @@ webrender_traits = { workspace = true }
webxr = { workspace = true, optional = true } webxr = { workspace = true, optional = true }
webxr-api = { workspace = true, optional = true } webxr-api = { workspace = true, optional = true }
[target.'cfg(any(target_os = "android", target_env = "ohos"))'.dependencies]
surfman = { workspace = true, features = ["sm-angle-default"] }
[target.'cfg(not(any(target_os = "android", target_env = "ohos")))'.dependencies]
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
[target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os = "android"), not(target_env = "ohos"), not(target_arch = "arm"), not(target_arch = "aarch64")))'.dependencies] [target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os = "android"), not(target_env = "ohos"), not(target_arch = "arm"), not(target_arch = "aarch64")))'.dependencies]
gaol = "0.2.1" gaol = "0.2.1"

View file

@ -57,6 +57,7 @@ class JobConfig(object):
wpt_layout: Layout = Layout.none wpt_layout: Layout = Layout.none
profile: str = "release" profile: str = "release"
unit_tests: bool = False unit_tests: bool = False
build_libservo: bool = False
bencher: bool = False bencher: bool = False
wpt_args: str = "" wpt_args: str = ""
# These are the fields that must match in between two JobConfigs for them to be able to be # These are the fields that must match in between two JobConfigs for them to be able to be
@ -72,6 +73,7 @@ class JobConfig(object):
self.wpt_layout |= other.wpt_layout self.wpt_layout |= other.wpt_layout
self.unit_tests |= other.unit_tests self.unit_tests |= other.unit_tests
self.build_libservo |= other.build_libservo
self.bencher |= other.bencher self.bencher |= other.bencher
self.update_name() self.update_name()
return True return True
@ -92,6 +94,8 @@ class JobConfig(object):
modifier.append(self.profile.title()) modifier.append(self.profile.title())
if self.unit_tests: if self.unit_tests:
modifier.append("Unit Tests") modifier.append("Unit Tests")
if self.build_libservo:
modifier.append("Build libservo")
if self.wpt_layout != Layout.none: if self.wpt_layout != Layout.none:
modifier.append("WPT") modifier.append("WPT")
if self.bencher: if self.bencher:
@ -131,6 +135,8 @@ def handle_modifier(config: JobConfig, s: str) -> Optional[JobConfig]:
s = s.lower() s = s.lower()
if "unit-tests" in s: if "unit-tests" in s:
config.unit_tests = True config.unit_tests = True
if "build-libservo" in s:
config.build_libservo = True
if "production" in s: if "production" in s:
config.profile = "production" config.profile = "production"
if "bencher" in s: if "bencher" in s:
@ -175,8 +181,11 @@ class Config(object):
self.fail_fast = True self.fail_fast = True
continue # skip over keyword continue # skip over keyword
if word == "full": if word == "full":
words.extend(["linux-unit-tests", "linux-wpt-2020", "linux-bencher"]) words.extend(["linux-unit-tests", "linux-build-libservo", "linux-wpt-2020", "linux-bencher"])
words.extend(["macos-unit-tests", "windows-unit-tests", "android", "ohos", "lint"]) words.extend([
"macos-unit-tests", "macos-build-libservo", "windows-unit-tests", "windows-build-libservo",
"android", "ohos", "lint",
])
continue # skip over keyword continue # skip over keyword
if word == "bencher": if word == "bencher":
words.extend(["linux-bencher", "macos-bencher", "windows-bencher", "android-bencher", "ohos-bencher"]) words.extend(["linux-bencher", "macos-bencher", "windows-bencher", "android-bencher", "ohos-bencher"])
@ -220,6 +229,7 @@ class TestParser(unittest.TestCase):
'name': 'Linux (Unit Tests)', 'name': 'Linux (Unit Tests)',
'profile': 'release', 'profile': 'release',
'unit_tests': True, 'unit_tests': True,
'build_libservo': False,
'workflow': 'linux', 'workflow': 'linux',
'wpt_layout': 'none', 'wpt_layout': 'none',
'wpt_args': '' 'wpt_args': ''
@ -230,29 +240,32 @@ class TestParser(unittest.TestCase):
self.assertDictEqual(json.loads(Config("").to_json()), self.assertDictEqual(json.loads(Config("").to_json()),
{"fail_fast": False, "matrix": [ {"fail_fast": False, "matrix": [
{ {
"name": "Linux (Unit Tests, WPT, Bencher)", "name": "Linux (Unit Tests, Build libservo, WPT, Bencher)",
"workflow": "linux", "workflow": "linux",
"wpt_layout": "2020", "wpt_layout": "2020",
"profile": "release", "profile": "release",
"unit_tests": True, "unit_tests": True,
'build_libservo': True,
'bencher': True, 'bencher': True,
"wpt_args": "" "wpt_args": ""
}, },
{ {
"name": "MacOS (Unit Tests)", "name": "MacOS (Unit Tests, Build libservo)",
"workflow": "macos", "workflow": "macos",
"wpt_layout": "none", "wpt_layout": "none",
"profile": "release", "profile": "release",
"unit_tests": True, "unit_tests": True,
'build_libservo': True,
'bencher': False, 'bencher': False,
"wpt_args": "" "wpt_args": ""
}, },
{ {
"name": "Windows (Unit Tests)", "name": "Windows (Unit Tests, Build libservo)",
"workflow": "windows", "workflow": "windows",
"wpt_layout": "none", "wpt_layout": "none",
"profile": "release", "profile": "release",
"unit_tests": True, "unit_tests": True,
'build_libservo': True,
'bencher': False, 'bencher': False,
"wpt_args": "" "wpt_args": ""
}, },
@ -262,6 +275,7 @@ class TestParser(unittest.TestCase):
"wpt_layout": "none", "wpt_layout": "none",
"profile": "release", "profile": "release",
"unit_tests": False, "unit_tests": False,
'build_libservo': False,
'bencher': False, 'bencher': False,
"wpt_args": "" "wpt_args": ""
}, },
@ -271,6 +285,7 @@ class TestParser(unittest.TestCase):
"wpt_layout": "none", "wpt_layout": "none",
"profile": "release", "profile": "release",
"unit_tests": False, "unit_tests": False,
'build_libservo': False,
'bencher': False, 'bencher': False,
"wpt_args": "" "wpt_args": ""
}, },
@ -280,6 +295,7 @@ class TestParser(unittest.TestCase):
"wpt_layout": "none", "wpt_layout": "none",
"profile": "release", "profile": "release",
"unit_tests": False, "unit_tests": False,
'build_libservo': False,
'bencher': False, 'bencher': False,
"wpt_args": ""} "wpt_args": ""}
]}) ]})
@ -292,6 +308,7 @@ class TestParser(unittest.TestCase):
'name': 'Linux (WPT)', 'name': 'Linux (WPT)',
'profile': 'release', 'profile': 'release',
'unit_tests': False, 'unit_tests': False,
'build_libservo': False,
'workflow': 'linux', 'workflow': 'linux',
'wpt_layout': 'all', 'wpt_layout': 'all',
'wpt_args': '' 'wpt_args': ''