aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/CMakeLists.txt102
-rw-r--r--components/script/Cargo.toml3
-rw-r--r--components/script/build.rs33
-rw-r--r--components/script/dom/bindings/codegen/GlobalGen.py7
-rw-r--r--components/script/dom/bindings/codegen/pythonpath.py61
-rw-r--r--components/script/dom/mod.rs3
-rw-r--r--components/script/makefile.cargo59
7 files changed, 201 insertions, 67 deletions
diff --git a/components/script/CMakeLists.txt b/components/script/CMakeLists.txt
new file mode 100644
index 00000000000..30bb03f56b5
--- /dev/null
+++ b/components/script/CMakeLists.txt
@@ -0,0 +1,102 @@
+project(script)
+cmake_minimum_required(VERSION 2.6)
+
+set(DUMMY ${CMAKE_BUILD_TYPE})
+
+FUNCTION(PREPEND var prefix)
+ SET(listVar "")
+ FOREACH(f ${ARGN})
+ LIST(APPEND listVar "${prefix}/${f}")
+ ENDFOREACH(f)
+ SET(${var} "${listVar}" PARENT_SCOPE)
+ENDFUNCTION(PREPEND)
+
+set(bindings_src ${PROJECT_SOURCE_DIR}/dom/bindings/codegen)
+set(webidls_src ${PROJECT_SOURCE_DIR}/dom/webidls)
+
+# Without Bindings/* stuff, since we install that separately below
+set(globalgen_base_src
+ PrototypeList.rs
+ RegisterBindings.rs
+ InterfaceObjectMap.rs
+ InterfaceTypes.rs
+ InheritTypes.rs
+ UnionTypes.rs
+ )
+
+set(globalgen_src
+ ${globalgen_base_src}
+ Bindings/mod.rs
+ )
+
+file(GLOB_RECURSE webidls ${webidls_src}/*.webidl)
+string(REGEX REPLACE ";" "\n" webidl_filelist "${webidls}")
+file(WRITE "${PROJECT_BINARY_DIR}/webidls.list" "${webidl_filelist}")
+string(REGEX REPLACE "\\.webidl(;|$)" "\\1" bindings "${webidls}")
+string(REGEX REPLACE "(^|;)${webidls_src}/" "\\1" bindings "${bindings}")
+
+set(globalgen_deps
+ ${bindings_src}/GlobalGen.py
+ ${bindings_src}/Bindings.conf
+ ${bindings_src}/Configuration.py
+ ${bindings_src}/CodegenRust.py
+ ${bindings_src}/parser/WebIDL.py
+ )
+set(bindinggen_deps
+ ${bindings_src}/BindingGen.py
+ ${bindings_src}/Bindings.conf
+ ${bindings_src}/Configuration.py
+ ${bindings_src}/CodegenRust.py
+ ${bindings_src}/parser/WebIDL.py
+ )
+
+add_custom_command(
+ OUTPUT Bindings
+ COMMAND ${CMAKE_COMMAND} -E make_directory Bindings
+ )
+add_custom_command(
+ OUTPUT _cache
+ COMMAND ${CMAKE_COMMAND} -E make_directory _cache
+ )
+
+add_custom_command(
+ OUTPUT ParserResults.pkl
+ COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply
+ ${bindings_src}/GlobalGen.py
+ --cachedir=_cache
+ --filelist=webidls.list
+ ${bindings_src}/Bindings.conf
+ .
+ ${PROJECT_SOURCE_DIR}
+ DEPENDS Bindings _cache ${globalgen_deps} ${webidls}
+ VERBATIM
+ )
+
+# We need an intermediate custom target for this, due to this misfeature:
+# > If any dependency is an OUTPUT of another custom command in the same
+# > directory CMake automatically brings the other custom command into the
+# > target in which this command is built.
+# So, depending directly on ParserResults.pkl from the add_custom_command
+# below would cause GlobalGen.py to be executed each time.
+add_custom_target(ParserResults ALL DEPENDS ParserResults.pkl)
+add_custom_target(generate-bindings ALL)
+
+foreach(binding IN LISTS bindings)
+ add_custom_command(
+ OUTPUT Bindings/${binding}Binding.rs
+ COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply
+ ${bindings_src}/BindingGen.py
+ ${bindings_src}/Bindings.conf
+ .
+ Bindings/${binding}Binding
+ ${webidls_src}/${binding}.webidl
+ DEPENDS Bindings ${bindinggen_deps} ${webidls_src}/${binding}.webidl ParserResults
+ VERBATIM
+ )
+ add_custom_target(${binding} DEPENDS Bindings/${binding}Binding.rs)
+ add_dependencies(generate-bindings ${binding})
+endforeach()
+
+PREPEND(globalgen_out ${CMAKE_BINARY_DIR}/ ${globalgen_base_src})
+install(FILES ${globalgen_out} DESTINATION .)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/Bindings/ DESTINATION Bindings)
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 717de7b380a..2799b9bc4a4 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -14,6 +14,9 @@ path = "lib.rs"
[features]
debugmozjs = ['js/debugmozjs']
+[build-dependencies]
+cmake = "0.1"
+
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
tinyfiledialogs = {git = "https://github.com/jdm/tinyfiledialogs"}
diff --git a/components/script/build.rs b/components/script/build.rs
index a0d693d152f..019a55f25a6 100644
--- a/components/script/build.rs
+++ b/components/script/build.rs
@@ -2,17 +2,36 @@
* 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/. */
+extern crate cmake;
use std::env;
-use std::process::Command;
use std::time::Instant;
fn main() {
let start = Instant::now();
- let num_jobs = env::var("NUM_JOBS").unwrap();
- assert!(Command::new("make")
- .args(&["-f", "makefile.cargo", "-j", &num_jobs])
- .status()
- .unwrap()
- .success());
+
+ // This must use the Ninja generator -- it's the only one that
+ // parallelizes cmake's output properly. (Cmake generates
+ // separate makefiles, each of which try to build
+ // ParserResults.pkl, and then stomp on eachother.)
+ let mut build = cmake::Config::new(".");
+
+ let target = env::var("TARGET").unwrap();
+ if target.contains("windows-msvc") {
+ // We must use Ninja on Windows for this -- msbuild is painfully slow,
+ // and ninja is easier to install than make.
+ build.generator("Ninja");
+ // because we're using ninja, we need to explicitly set these
+ // to VC++, otherwise it'll try to use cc
+ build.define("CMAKE_C_COMPILER", "cl.exe")
+ .define("CMAKE_CXX_COMPILER", "cl.exe");
+ // We have to explicitly specify the full path to link.exe,
+ // for reasons that I don't understand. If we just give
+ // link.exe, it tries to use script-*/out/link.exe, which of
+ // course does not exist.
+ build.define("CMAKE_LINKER", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe");
+ }
+
+ build.build();
+
println!("Binding generation completed in {}s", start.elapsed().as_secs());
}
diff --git a/components/script/dom/bindings/codegen/GlobalGen.py b/components/script/dom/bindings/codegen/GlobalGen.py
index 23779d9e6d5..8f122f52bd1 100644
--- a/components/script/dom/bindings/codegen/GlobalGen.py
+++ b/components/script/dom/bindings/codegen/GlobalGen.py
@@ -34,6 +34,8 @@ def main():
help="Directory in which to cache lex/parse tables.")
o.add_option("--only-html", dest='only_html', action="store_true",
help="Only generate HTML from WebIDL inputs")
+ o.add_option("--filelist", dest='filelist', default=None,
+ help="A file containing the list (one per line) of webidl files to process.")
(options, args) = o.parse_args()
if len(args) < 2:
@@ -42,7 +44,10 @@ def main():
configFile = args[0]
outputdir = args[1]
baseDir = args[2]
- fileList = args[3:]
+ if options.filelist is not None:
+ fileList = (l.strip() for l in open(options.filelist).xreadlines())
+ else:
+ fileList = args[3:]
# Parse the WebIDL.
parser = WebIDL.Parser(options.cachedir)
diff --git a/components/script/dom/bindings/codegen/pythonpath.py b/components/script/dom/bindings/codegen/pythonpath.py
new file mode 100644
index 00000000000..793089551b5
--- /dev/null
+++ b/components/script/dom/bindings/codegen/pythonpath.py
@@ -0,0 +1,61 @@
+# 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/.
+
+"""
+Run a python script, adding extra directories to the python path.
+"""
+
+
+def main(args):
+ def usage():
+ print >>sys.stderr, "pythonpath.py -I directory script.py [args...]"
+ sys.exit(150)
+
+ paths = []
+
+ while True:
+ try:
+ arg = args[0]
+ except IndexError:
+ usage()
+
+ if arg == '-I':
+ args.pop(0)
+ try:
+ path = args.pop(0)
+ except IndexError:
+ usage()
+
+ paths.append(os.path.abspath(path))
+ continue
+
+ if arg.startswith('-I'):
+ paths.append(os.path.abspath(args.pop(0)[2:]))
+ continue
+
+ if arg.startswith('-D'):
+ os.chdir(args.pop(0)[2:])
+ continue
+
+ break
+
+ script = args[0]
+
+ sys.path[0:0] = [os.path.abspath(os.path.dirname(script))] + paths
+ sys.argv = args
+ sys.argc = len(args)
+
+ frozenglobals['__name__'] = '__main__'
+ frozenglobals['__file__'] = script
+
+ execfile(script, frozenglobals)
+
+# Freeze scope here ... why this makes things work I have no idea ...
+frozenglobals = globals()
+
+import sys
+import os
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index c2121c84139..432246d814f 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -206,7 +206,10 @@
pub mod macros;
pub mod types {
+ #[cfg(not(target_env = "msvc"))]
include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs"));
+ #[cfg(target_env = "msvc")]
+ include!(concat!(env!("OUT_DIR"), "/build/InterfaceTypes.rs"));
}
pub mod abstractworker;
diff --git a/components/script/makefile.cargo b/components/script/makefile.cargo
deleted file mode 100644
index e12c4bdab23..00000000000
--- a/components/script/makefile.cargo
+++ /dev/null
@@ -1,59 +0,0 @@
-# Recursive wildcard function
-# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
-rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
- $(filter $(subst *,%,$2),$d))
-
-PYTHON = $(shell which python2.7 2>/dev/null || echo python) -B
-BINDINGS_SRC = $(shell pwd)/dom/bindings/codegen
-WEBIDLS_SRC = $(shell pwd)/dom/webidls
-WEBIDLS = $(call rwildcard,$(WEBIDLS_SRC),*.webidl)
-BINDINGS = $(patsubst %.webidl,%Binding.rs,$(WEBIDLS))
-AUTOGEN_SRC = $(foreach var,$(BINDINGS),$(subst $(WEBIDLS_SRC),$(OUT_DIR)/Bindings,$(var)))
-
-export PYTHONPATH := $(BINDINGS_SRC)/parser:$(BINDINGS_SRC)/ply:$(PYTHONPATH)
-
-CACHE_DIR = $(OUT_DIR)/_cache
-
-bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/,BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(OUT_DIR)/ParserResults.pkl $(OUT_DIR)/Bindings/.done
-
-globalgen_dependencies := $(addprefix $(BINDINGS_SRC)/,GlobalGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(CACHE_DIR)/.done $(OUT_DIR)/Bindings/.done
-
-.PHONY: all dom_docs
-all: $(AUTOGEN_SRC)
-
-$(OUT_DIR)/Bindings/.done:
- mkdir -p $(OUT_DIR)/Bindings
- touch $@
-
-$(CACHE_DIR)/.done:
- mkdir -p $(CACHE_DIR)
- touch $@
-
-$(OUT_DIR)/ParserResults.pkl: $(globalgen_dependencies) $(WEBIDLS)
- $(PYTHON) \
- $(BINDINGS_SRC)/GlobalGen.py \
- --cachedir=$(CACHE_DIR) \
- $(BINDINGS_SRC)/Bindings.conf \
- $(OUT_DIR) \
- . \
- $(WEBIDLS)
-
-dom_docs: $(CACHE_DIR)/.done
- $(PYTHON) \
- $(BINDINGS_SRC)/GlobalGen.py \
- --cachedir=$(CACHE_DIR) \
- --only-html \
- $(BINDINGS_SRC)/Bindings.conf \
- $(OUT_DIR) \
- . \
- $(WEBIDLS)
-
-$(AUTOGEN_SRC): $(OUT_DIR)/Bindings/%Binding.rs: $(bindinggen_dependencies) \
- $(addprefix $(WEBIDLS_SRC)/,%.webidl)
- $(PYTHON) \
- $(BINDINGS_SRC)/BindingGen.py \
- $(BINDINGS_SRC)/Bindings.conf \
- $(OUT_DIR) \
- $(OUT_DIR)/Bindings/$*Binding \
- $(addprefix $(WEBIDLS_SRC)/,$*.webidl)
- touch $@