mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Auto merge of #15099 - servo:phf-no-macros, r=jdm
Remove usage of phf_macros. It’s a compiler plugin that uses unstable compiler APIs that are not on a path to stabilization. With this changes, there is one less thing that might break when we update the compiler. For example: https://github.com/sfackler/rust-phf/pull/101 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15099) <!-- Reviewable:end -->
This commit is contained in:
commit
eade32ed16
7 changed files with 59 additions and 26 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -2016,15 +2016,6 @@ dependencies = [
|
||||||
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "phf_macros"
|
|
||||||
version = "0.7.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"phf_generator 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf_shared"
|
name = "phf_shared"
|
||||||
version = "0.7.20"
|
version = "0.7.20"
|
||||||
|
@ -2296,7 +2287,8 @@ dependencies = [
|
||||||
"open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_codegen 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
|
@ -2308,6 +2300,7 @@ dependencies = [
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_atoms 0.0.1",
|
"servo_atoms 0.0.1",
|
||||||
"servo_config 0.0.1",
|
"servo_config 0.0.1",
|
||||||
"servo_geometry 0.0.1",
|
"servo_geometry 0.0.1",
|
||||||
|
@ -2484,7 +2477,6 @@ dependencies = [
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"net_tests 0.0.1",
|
"net_tests 0.0.1",
|
||||||
"net_traits_tests 0.0.1",
|
"net_traits_tests 0.0.1",
|
||||||
"phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"plugin_compiletest 0.0.1",
|
"plugin_compiletest 0.0.1",
|
||||||
"profile_tests 0.0.1",
|
"profile_tests 0.0.1",
|
||||||
"script_tests 0.0.1",
|
"script_tests 0.0.1",
|
||||||
|
@ -3547,7 +3539,6 @@ dependencies = [
|
||||||
"checksum phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6afb2057bb5f846a7b75703f90bc1cef4970c35209f712925db7768e999202"
|
"checksum phf 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6afb2057bb5f846a7b75703f90bc1cef4970c35209f712925db7768e999202"
|
||||||
"checksum phf_codegen 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "6b63f121bf9a128f2172a65d8313a8e0e79d63874eeb4b4b7d82e6dda6b62f7c"
|
"checksum phf_codegen 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "6b63f121bf9a128f2172a65d8313a8e0e79d63874eeb4b4b7d82e6dda6b62f7c"
|
||||||
"checksum phf_generator 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "50ffbd7970f75afa083c5dd7b6830c97b72b81579c7a92d8134ef2ee6c0c7eb0"
|
"checksum phf_generator 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "50ffbd7970f75afa083c5dd7b6830c97b72b81579c7a92d8134ef2ee6c0c7eb0"
|
||||||
"checksum phf_macros 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "619b2c128703c63376de760377600b924fc0257487f51bc156f596cf8762e497"
|
|
||||||
"checksum phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "286385a0e50d4147bce15b2c19f0cf84c395b0e061aaf840898a7bf664c2cfb7"
|
"checksum phf_shared 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "286385a0e50d4147bce15b2c19f0cf84c395b0e061aaf840898a7bf664c2cfb7"
|
||||||
"checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"
|
"checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"
|
||||||
"checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b"
|
"checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b"
|
||||||
|
|
|
@ -16,6 +16,9 @@ debugmozjs = ['js/debugmozjs']
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cmake = "0.1"
|
cmake = "0.1"
|
||||||
|
phf_codegen = "0.7.18"
|
||||||
|
phf_shared = "0.7.18"
|
||||||
|
serde_json = "0.8"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
||||||
tinyfiledialogs = "2.5.9"
|
tinyfiledialogs = "2.5.9"
|
||||||
|
@ -57,7 +60,6 @@ offscreen_gl_context = "0.5.0"
|
||||||
open = "1.1.1"
|
open = "1.1.1"
|
||||||
parking_lot = "0.3"
|
parking_lot = "0.3"
|
||||||
phf = "0.7.18"
|
phf = "0.7.18"
|
||||||
phf_macros = "0.7.18"
|
|
||||||
plugins = {path = "../plugins"}
|
plugins = {path = "../plugins"}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
range = {path = "../range"}
|
range = {path = "../range"}
|
||||||
|
|
|
@ -3,7 +3,16 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
extern crate cmake;
|
extern crate cmake;
|
||||||
|
extern crate phf_codegen;
|
||||||
|
extern crate phf_shared;
|
||||||
|
extern crate serde_json;
|
||||||
|
|
||||||
|
use serde_json::Value;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -34,4 +43,33 @@ fn main() {
|
||||||
build.build();
|
build.build();
|
||||||
|
|
||||||
println!("Binding generation completed in {}s", start.elapsed().as_secs());
|
println!("Binding generation completed in {}s", start.elapsed().as_secs());
|
||||||
|
|
||||||
|
let json = PathBuf::from(env::var("OUT_DIR").unwrap()).join("build").join("InterfaceObjectMapData.json");
|
||||||
|
let json: Value = serde_json::from_reader(File::open(&json).unwrap()).unwrap();
|
||||||
|
let mut map = phf_codegen::Map::new();
|
||||||
|
for (key, value) in json.as_object().unwrap() {
|
||||||
|
map.entry(Bytes(key), value.as_str().unwrap());
|
||||||
|
}
|
||||||
|
let phf = PathBuf::from(env::var("OUT_DIR").unwrap()).join("InterfaceObjectMapPhf.rs");
|
||||||
|
let mut phf = File::create(&phf).unwrap();
|
||||||
|
write!(&mut phf, "pub static MAP: phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)> = ").unwrap();
|
||||||
|
map.build(&mut phf).unwrap();
|
||||||
|
write!(&mut phf, ";\n").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
|
struct Bytes<'a>(&'a str);
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for Bytes<'a> {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
formatter.write_str("b\"")?;
|
||||||
|
formatter.write_str(self.0)?;
|
||||||
|
formatter.write_str("\" as &'static [u8]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> phf_shared::PhfHash for Bytes<'a> {
|
||||||
|
fn phf_hash<H: std::hash::Hasher>(&self, hasher: &mut H) {
|
||||||
|
self.0.as_bytes().phf_hash(hasher)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6840,6 +6840,15 @@ class GlobalGenRoots():
|
||||||
], "\n")), pre="pub flags Globals: u8 {\n", post="\n}")
|
], "\n")), pre="pub flags Globals: u8 {\n", post="\n}")
|
||||||
globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}")
|
globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}")
|
||||||
|
|
||||||
|
phf = CGGeneric("include!(concat!(env!(\"OUT_DIR\"), \"/InterfaceObjectMapPhf.rs\"));")
|
||||||
|
|
||||||
|
return CGList([
|
||||||
|
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
||||||
|
CGList([imports, globals_, phf], "\n\n")
|
||||||
|
])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def InterfaceObjectMapData(config):
|
||||||
pairs = []
|
pairs = []
|
||||||
for d in config.getDescriptors(hasInterfaceObject=True, isInline=False):
|
for d in config.getDescriptors(hasInterfaceObject=True, isInline=False):
|
||||||
binding = toBindingNamespace(d.name)
|
binding = toBindingNamespace(d.name)
|
||||||
|
@ -6848,19 +6857,13 @@ class GlobalGenRoots():
|
||||||
pairs.append((ctor.identifier.name, binding, binding))
|
pairs.append((ctor.identifier.name, binding, binding))
|
||||||
pairs.sort(key=operator.itemgetter(0))
|
pairs.sort(key=operator.itemgetter(0))
|
||||||
mappings = [
|
mappings = [
|
||||||
CGGeneric('b"%s" => codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _),' % pair)
|
CGGeneric('"%s": "codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _)"' % pair)
|
||||||
for pair in pairs
|
for pair in pairs
|
||||||
]
|
]
|
||||||
mapType = "phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)>"
|
return CGWrapper(
|
||||||
phf = CGWrapper(
|
CGList(mappings, ",\n"),
|
||||||
CGIndenter(CGList(mappings, "\n")),
|
pre="{\n",
|
||||||
pre="pub static MAP: %s = phf_map! {\n" % mapType,
|
post="\n}\n")
|
||||||
post="\n};\n")
|
|
||||||
|
|
||||||
return CGList([
|
|
||||||
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
|
||||||
CGList([imports, globals_, phf], "\n\n")
|
|
||||||
])
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def PrototypeList(config):
|
def PrototypeList(config):
|
||||||
|
|
|
@ -76,6 +76,7 @@ def main():
|
||||||
('PrototypeList', 'PrototypeList.rs'),
|
('PrototypeList', 'PrototypeList.rs'),
|
||||||
('RegisterBindings', 'RegisterBindings.rs'),
|
('RegisterBindings', 'RegisterBindings.rs'),
|
||||||
('InterfaceObjectMap', 'InterfaceObjectMap.rs'),
|
('InterfaceObjectMap', 'InterfaceObjectMap.rs'),
|
||||||
|
('InterfaceObjectMapData', 'InterfaceObjectMapData.json'),
|
||||||
('InterfaceTypes', 'InterfaceTypes.rs'),
|
('InterfaceTypes', 'InterfaceTypes.rs'),
|
||||||
('InheritTypes', 'InheritTypes.rs'),
|
('InheritTypes', 'InheritTypes.rs'),
|
||||||
('Bindings', os.path.join('Bindings', 'mod.rs')),
|
('Bindings', os.path.join('Bindings', 'mod.rs')),
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#![doc = "The script crate contains all matters DOM."]
|
#![doc = "The script crate contains all matters DOM."]
|
||||||
|
|
||||||
#![plugin(phf_macros)]
|
|
||||||
#![plugin(plugins)]
|
#![plugin(plugins)]
|
||||||
|
|
||||||
extern crate angle;
|
extern crate angle;
|
||||||
|
|
|
@ -41,7 +41,6 @@ browserhtml = {git = "https://github.com/browserhtml/browserhtml", branch = "cra
|
||||||
glutin_app = {path = "../../ports/glutin"}
|
glutin_app = {path = "../../ports/glutin"}
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
libservo = {path = "../../components/servo"}
|
libservo = {path = "../../components/servo"}
|
||||||
phf_macros = "0.7.19"
|
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
sig = "0.1"
|
sig = "0.1"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue