mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
style::properties : move generated file out of source tree, use new-style Cargo build script.
This commit is contained in:
parent
d13d36f57f
commit
6e95bd8e50
7 changed files with 48 additions and 13 deletions
6
components/servo/Cargo.lock
generated
6
components/servo/Cargo.lock
generated
|
@ -553,6 +553,11 @@ dependencies = [
|
|||
"log 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mod_path"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "mozjs-sys"
|
||||
version = "0.0.0"
|
||||
|
@ -753,6 +758,7 @@ dependencies = [
|
|||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||
"lazy_static 0.1.6 (git+https://github.com/Kimundi/lazy-static.rs)",
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mod_path 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||
|
|
2
components/style/.gitignore
vendored
2
components/style/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
properties/mod.rs
|
||||
properties/mod.rs.tmp
|
|
@ -3,7 +3,7 @@ name = "style"
|
|||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
|
||||
build = "make -f makefile.cargo"
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "style"
|
||||
|
@ -34,4 +34,5 @@ git = "https://github.com/servo/string-cache"
|
|||
text_writer = "0.1.1"
|
||||
encoding = "0.2"
|
||||
matches = "0.1"
|
||||
url = "*"
|
||||
url = "*"
|
||||
mod_path = "0.1"
|
||||
|
|
31
components/style/build.rs
Normal file
31
components/style/build.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* 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/. */
|
||||
|
||||
use std::os;
|
||||
use std::path::Path;
|
||||
use std::io::process::{Command, ProcessExit, StdioContainer};
|
||||
use std::io::File;
|
||||
|
||||
|
||||
fn main() {
|
||||
let python = if Command::new("python2.7").arg("--version").status() == Ok(ProcessExit::ExitStatus(0)) {
|
||||
"python2.7"
|
||||
} else {
|
||||
"python"
|
||||
};
|
||||
let style = Path::new(file!()).dir_path();
|
||||
let mako = style.join("Mako-0.9.1.zip");
|
||||
let template = style.join("properties.mako.rs");
|
||||
let result = Command::new(python)
|
||||
.env("PYTHONPATH", mako.as_str().unwrap())
|
||||
.env("TEMPLATE", template.as_str().unwrap())
|
||||
.arg("-c")
|
||||
.arg("from os import environ; from mako.template import Template; print(Template(filename=environ['TEMPLATE']).render())")
|
||||
.stderr(StdioContainer::InheritFd(2))
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(result.status, ProcessExit::ExitStatus(0));
|
||||
let out = Path::new(os::getenv("OUT_DIR").unwrap());
|
||||
File::create(&out.join("properties.rs")).unwrap().write(&*result.output).unwrap();
|
||||
}
|
|
@ -34,13 +34,18 @@ extern crate lazy_static;
|
|||
|
||||
extern crate util;
|
||||
|
||||
#[plugin] #[no_link] extern crate mod_path;
|
||||
|
||||
|
||||
pub mod stylesheets;
|
||||
pub mod parser;
|
||||
pub mod selectors;
|
||||
pub mod selector_matching;
|
||||
#[macro_use] pub mod values;
|
||||
#[macro_use] pub mod properties;
|
||||
|
||||
// Generated from the properties.mako.rs template by build.rs
|
||||
mod_path! properties (concat!(env!("OUT_DIR"), "/properties.rs"));
|
||||
|
||||
pub mod node;
|
||||
pub mod media_queries;
|
||||
pub mod font_face;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
MAKO_ZIP = Mako-0.9.1.zip
|
||||
PYTHON = $(shell which python2.7 2>/dev/null || echo python)
|
||||
|
||||
all: properties/mod.rs
|
||||
|
||||
properties/mod.rs: properties/mod.rs.mako
|
||||
PYTHONPATH=$(MAKO_ZIP) $(PYTHON) -c "from mako.template import Template; print(Template(filename='$<').render())" > $@.tmp
|
||||
mv $@.tmp $@
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
// This file is a Mako template: http://www.makotemplates.org/
|
||||
|
||||
#![macro_use]
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::fmt;
|
Loading…
Add table
Add a link
Reference in a new issue