diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 9e1eaa1725e8..91d62e7cdd16 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -57,7 +57,7 @@ core-foundation = "0.2" core-graphics = "0.4" core-text = "2.0" -[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))'.dependencies] +[target.'cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))'.dependencies] freetype = {git = "https://github.com/servo/rust-freetype"} servo-fontconfig = "0.2.1" diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index b16ae9c555b0..bed633b9562b 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -37,9 +37,9 @@ extern crate euclid; extern crate fnv; // Platforms that use Freetype/Fontconfig library dependencies -#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))] extern crate fontconfig; -#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))] extern crate freetype; extern crate gfx_traits; diff --git a/components/gfx/platform/dummy/font.rs b/components/gfx/platform/dummy/font.rs new file mode 100644 index 000000000000..096580c66db5 --- /dev/null +++ b/components/gfx/platform/dummy/font.rs @@ -0,0 +1,80 @@ +/* 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 app_units::Au; +use font::{FontHandleMethods, FontMetrics, FontTableMethods}; +use font::{FontTableTag, FractionalPixel}; +use platform::font_context::FontContextHandle; +use platform::font_template::FontTemplateData; +use std::sync::Arc; +use style::computed_values::{font_stretch, font_weight}; +use text::glyph::GlyphId; + +#[derive(Debug)] +pub struct FontTable { + buffer: Vec, +} + +impl FontTableMethods for FontTable { + fn buffer(&self) -> &[u8] { + &self.buffer + } +} + +#[derive(Debug)] +pub struct FontHandle { + handle: FontContextHandle, +} + +impl Drop for FontHandle { + fn drop(&mut self) { + } +} + +impl FontHandleMethods for FontHandle { + fn new_from_template(fctx: &FontContextHandle, + template: Arc, + pt_size: Option) + -> Result { + Err(()) + } + + fn template(&self) -> Arc { + unimplemented!() + } + fn family_name(&self) -> String { + String::from("Unknown") + } + fn face_name(&self) -> String { + String::from("Unknown") + } + fn is_italic(&self) -> bool { + false + } + fn boldness(&self) -> font_weight::T { + font_weight::T::Weight400 + } + fn stretchiness(&self) -> font_stretch::T { + font_stretch::T::normal + } + fn glyph_index(&self, codepoint: char) -> Option { + None + } + fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId) + -> FractionalPixel { + 0.0 + } + fn can_do_fast_shaping(&self) -> bool { + false + } + fn glyph_h_advance(&self, glyph: GlyphId) -> Option { + None + } + fn metrics(&self) -> FontMetrics { + unimplemented!() + } + fn table_for_tag(&self, tag: FontTableTag) -> Option { + None + } +} diff --git a/components/gfx/platform/dummy/font_context.rs b/components/gfx/platform/dummy/font_context.rs new file mode 100644 index 000000000000..4b07896b2dca --- /dev/null +++ b/components/gfx/platform/dummy/font_context.rs @@ -0,0 +1,13 @@ +/* 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/. */ + +#[derive(Clone, HeapSizeOf, Debug)] +pub struct FontContextHandle; + +impl FontContextHandle { + pub fn new() -> FontContextHandle { + FontContextHandle + } +} + diff --git a/components/gfx/platform/dummy/font_list.rs b/components/gfx/platform/dummy/font_list.rs new file mode 100644 index 000000000000..6502572c2871 --- /dev/null +++ b/components/gfx/platform/dummy/font_list.rs @@ -0,0 +1,24 @@ +/* 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/. */ + +pub fn for_each_available_family(mut callback: F) where F: FnMut(String) +{ +} + +pub fn for_each_variation(family_name: &str, mut callback: F) + where F: FnMut(String) +{ +} + +pub fn system_default_family(generic_name: &str) -> Option { + None +} + +pub fn last_resort_font_families() -> Vec { + vec!( + "Unknown".to_owned() + ) +} + +pub static SANS_SERIF_FONT_FAMILY: &'static str = "Unknown"; diff --git a/components/gfx/platform/dummy/font_template.rs b/components/gfx/platform/dummy/font_template.rs new file mode 100644 index 000000000000..5e38165a7c6a --- /dev/null +++ b/components/gfx/platform/dummy/font_template.rs @@ -0,0 +1,39 @@ +/* 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 string_cache::Atom; +use webrender_traits::NativeFontHandle; + +#[derive(Deserialize, Serialize, Debug)] +pub struct FontTemplateData { + pub bytes: Vec, + pub identifier: Atom, +} + +impl FontTemplateData { + pub fn new(identifier: Atom, font_data: Option>) -> FontTemplateData { + let bytes = match font_data { + Some(bytes) => { + bytes + }, + None => { + unimplemented!() + } + }; + + FontTemplateData { + bytes: bytes, + identifier: identifier, + } + } + pub fn bytes(&self) -> Vec { + self.bytes.clone() + } + pub fn bytes_if_in_memory(&self) -> Option> { + Some(self.bytes()) + } + pub fn native_font(&self) -> Option { + None + } +} diff --git a/components/gfx/platform/mod.rs b/components/gfx/platform/mod.rs index fed557814863..9f81d124b291 100644 --- a/components/gfx/platform/mod.rs +++ b/components/gfx/platform/mod.rs @@ -2,13 +2,16 @@ * 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/. */ -#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))] pub use platform::freetype::{font, font_context, font_list, font_template}; #[cfg(target_os = "macos")] pub use platform::macos::{font, font_context, font_list, font_template}; -#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))] +#[cfg(all(target_os = "windows", target_env = "msvc"))] +pub use platform::dummy::{font, font_context, font_list, font_template}; + +#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))] mod freetype { use libc::c_char; use std::ffi::CStr; @@ -33,3 +36,11 @@ mod macos { pub mod font_list; pub mod font_template; } + +#[cfg(all(target_os = "windows", target_env = "msvc"))] +mod dummy { + pub mod font; + pub mod font_context; + pub mod font_list; + pub mod font_template; +} diff --git a/components/script/CMakeLists.txt b/components/script/CMakeLists.txt new file mode 100644 index 000000000000..30bb03f56b5b --- /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 717de7b380aa..2799b9bc4a43 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 a0d693d152fe..019a55f25a6a 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 23779d9e6d5e..8f122f52bd18 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 000000000000..793089551b59 --- /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 c2121c84139e..432246d814f4 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 e12c4bdab234..000000000000 --- 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 $@ diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 12f930bdb009..8a0d39026025 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -19,6 +19,23 @@ test = false doc = false bench = false +[replace] +"azure:0.4.5" = { git = "https://github.com/vvuk/rust-azure.git", branch = "msvcize" } +"servo-skia:0.20130412.0" = { git = "https://github.com/vvuk/skia.git", branch = "msvcize" } +"mozjs_sys:0.0.0" = { git = "https://github.com/vvuk/mozjs.git", branch = "rust-msvc" } +"js:0.1.3" = { git = "https://github.com/vvuk/rust-mozjs.git", branch = "rust-msvc" } +"angle:0.1.0" = { git = "https://github.com/vvuk/angle.git", branch = "msvcize" } +"expat-sys:2.1.2" = { git = "https://github.com/metajack/libexpat.git", branch = "msvcize" } +"servo-freetype-sys:2.4.11" = { git = "https://github.com/vvuk/libfreetype2.git", branch = "msvcize" } +"harfbuzz-sys:0.1.5" = { git = "https://github.com/vvuk/rust-harfbuzz.git", branch = "msvcize" } +"servo-skia:0.20130412.9" = { git = "https://github.com/vvuk/skia.git", branch = "msvcize" } +"servo-fontconfig-sys:2.11.3" = { git = "https://github.com/vvuk/libfontconfig.git", branch = "msvcize" } +"hbs-builder:0.2.1" = { git = "https://github.com/vvuk/heartbeats-simple-sys.git", branch = "msvcize" } +"hbs-acc-pow-sys:0.2.1" = { git = "https://github.com/vvuk/heartbeats-simple-sys.git", branch = "msvcize" } +"hbs-acc-sys:0.2.1" = { git = "https://github.com/vvuk/heartbeats-simple-sys.git", branch = "msvcize" } +"hbs-common-sys:0.2.1" = { git = "https://github.com/vvuk/heartbeats-simple-sys.git", branch = "msvcize" } +"hbs-pow-sys:0.2.1" = { git = "https://github.com/vvuk/heartbeats-simple-sys.git", branch = "msvcize" } + [features] default = ["webdriver", "max_log_level"] max_log_level = ["log/release_max_level_info"] diff --git a/mach b/mach index 4fb1f0d62ebd..4a8d7a349b00 100755 --- a/mach +++ b/mach @@ -12,10 +12,11 @@ from __future__ import print_function, unicode_literals import os +from os import path import sys def main(args): - topdir = os.path.dirname(sys.argv[0]) + topdir = path.abspath(path.dirname(sys.argv[0])) sys.path.insert(0, os.path.join(topdir, "python")) import mach_bootstrap mach = mach_bootstrap.bootstrap(topdir) diff --git a/mach.bat b/mach.bat new file mode 100644 index 000000000000..d98f7953934c --- /dev/null +++ b/mach.bat @@ -0,0 +1,2 @@ +@echo off +python mach %*