mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
build(mach): generate webrender revision via cargo lockfile
This commit is contained in:
parent
e9fdcdc785
commit
6b16e712e7
2 changed files with 33 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,6 +23,7 @@ Servo.app
|
||||||
.config.mk.last
|
.config.mk.last
|
||||||
/glfw
|
/glfw
|
||||||
capture_webrender/
|
capture_webrender/
|
||||||
|
/components/compositing/webrender_revision.rs
|
||||||
|
|
||||||
# Editors
|
# Editors
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,36 @@ def set_osmesa_env(bin_path, env):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
def generate_webrender_revision():
|
||||||
|
"""Read current package id of web render to generate revision"""
|
||||||
|
|
||||||
|
lockfile_path = path.join(os.getcwd(), "Cargo.lock")
|
||||||
|
if not os.path.isfile(lockfile_path):
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(lockfile_path) as f:
|
||||||
|
lockfile = toml.loads(f.read())
|
||||||
|
|
||||||
|
webrender_revision = ""
|
||||||
|
for package in lockfile.get("package", []):
|
||||||
|
pkgName = package.get("name")
|
||||||
|
if ("webrender" == pkgName):
|
||||||
|
webrender_revision = package.get("source")
|
||||||
|
|
||||||
|
revision = '''/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
/// auto-generated by mach. do not manually modify.
|
||||||
|
pub const REVISION: &'static str = \"%s\";''' % webrender_revision
|
||||||
|
|
||||||
|
compositor_path = os.path.join(os.getcwd(), "components", "compositing", "webrender_revision.rs")
|
||||||
|
|
||||||
|
revision_file = open(compositor_path, "w")
|
||||||
|
revision_file.write(revision)
|
||||||
|
revision_file.close()
|
||||||
|
|
||||||
|
|
||||||
class BuildNotFound(Exception):
|
class BuildNotFound(Exception):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
@ -660,6 +690,8 @@ class CommandBase(object):
|
||||||
if "msvc" in target_platform:
|
if "msvc" in target_platform:
|
||||||
Registrar.dispatch("bootstrap", context=self.context)
|
Registrar.dispatch("bootstrap", context=self.context)
|
||||||
|
|
||||||
|
generate_webrender_revision()
|
||||||
|
|
||||||
self.context.bootstrapped = True
|
self.context.bootstrapped = True
|
||||||
|
|
||||||
def ensure_clobbered(self, target_dir=None):
|
def ensure_clobbered(self, target_dir=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue