aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/servo/Cargo.lock6
-rw-r--r--components/style/.gitignore2
-rw-r--r--components/style/Cargo.toml5
-rw-r--r--components/style/build.rs31
-rw-r--r--components/style/lib.rs7
-rw-r--r--components/style/makefile.cargo8
-rw-r--r--components/style/properties.mako.rs (renamed from components/style/properties/mod.rs.mako)2
7 files changed, 48 insertions, 13 deletions
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 987d2052091..fc43f530cdc 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -554,6 +554,11 @@ dependencies = [
]
[[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"
source = "git+https://github.com/servo/mozjs#58ee8869c7e589244ab2eb3a3ad15e2b64498428"
@@ -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)",
diff --git a/components/style/.gitignore b/components/style/.gitignore
deleted file mode 100644
index 1f18fa1546d..00000000000
--- a/components/style/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-properties/mod.rs
-properties/mod.rs.tmp
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index f5c8bae0939..e37df0d38bc 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -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 = "*" \ No newline at end of file
+url = "*"
+mod_path = "0.1"
diff --git a/components/style/build.rs b/components/style/build.rs
new file mode 100644
index 00000000000..27c71469e4c
--- /dev/null
+++ b/components/style/build.rs
@@ -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();
+}
diff --git a/components/style/lib.rs b/components/style/lib.rs
index 2c5380216f8..527b9ff587f 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -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;
diff --git a/components/style/makefile.cargo b/components/style/makefile.cargo
deleted file mode 100644
index f797dee7237..00000000000
--- a/components/style/makefile.cargo
+++ /dev/null
@@ -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 $@
diff --git a/components/style/properties/mod.rs.mako b/components/style/properties.mako.rs
index 92af5f05bb0..6dc140c993c 100644
--- a/components/style/properties/mod.rs.mako
+++ b/components/style/properties.mako.rs
@@ -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;