Skip to content

Commit e715025

Browse files
author
bors-servo
authored
Auto merge of #11756 - vvuk:servo-msvc, r=<try>
MSVC support for Servo, and CMake builds for native code This is the base PR for MSVC builds of servo and dependent crates. It's got replacements in the Cargo.toml to pull in the right versions, to make sure that crates were properly converted to CMake for all other platforms, not just Windows. (Servo builds with MSVC 2015 with this PR; also with 2013, though a manual change in rust-mozjs to select a different set of bindings is needed.) This PR isn't quite ready yet, but I want bors-servo to do builds. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11756) <!-- Reviewable:end -->
2 parents d620ab7 + d5c2e45 commit e715025

File tree

18 files changed

+455
-30
lines changed

18 files changed

+455
-30
lines changed

components/gfx/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ core-foundation = "0.2"
5151
core-graphics = "0.3"
5252
core-text = "1.1"
5353

54-
[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))'.dependencies]
54+
[target.'cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))'.dependencies]
5555
servo-fontconfig = "0.2"
5656
freetype = {git = "https://github.com/servo/rust-freetype"}
5757

components/gfx/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ extern crate euclid;
3737
extern crate fnv;
3838

3939
// Platforms that use Freetype/Fontconfig library dependencies
40-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
40+
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
4141
extern crate fontconfig;
42-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
42+
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
4343
extern crate freetype;
4444

4545
extern crate gfx_traits;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
use app_units::Au;
6+
use font::{FontHandleMethods, FontMetrics, FontTableMethods};
7+
use font::{FontTableTag, FractionalPixel};
8+
use platform::font_context::FontContextHandle;
9+
use platform::font_template::FontTemplateData;
10+
use std::sync::Arc;
11+
use style::computed_values::{font_stretch, font_weight};
12+
use text::glyph::GlyphId;
13+
14+
#[derive(Debug)]
15+
pub struct FontTable {
16+
buffer: Vec<u8>,
17+
}
18+
19+
impl FontTableMethods for FontTable {
20+
fn buffer(&self) -> &[u8] {
21+
&self.buffer
22+
}
23+
}
24+
25+
#[derive(Debug)]
26+
pub struct FontHandle {
27+
handle: FontContextHandle,
28+
}
29+
30+
impl Drop for FontHandle {
31+
fn drop(&mut self) {
32+
}
33+
}
34+
35+
impl FontHandleMethods for FontHandle {
36+
fn new_from_template(fctx: &FontContextHandle,
37+
template: Arc<FontTemplateData>,
38+
pt_size: Option<Au>)
39+
-> Result<FontHandle, ()> {
40+
Err(())
41+
}
42+
43+
fn template(&self) -> Arc<FontTemplateData> {
44+
unimplemented!()
45+
}
46+
fn family_name(&self) -> String {
47+
String::from("Unknown")
48+
}
49+
fn face_name(&self) -> String {
50+
String::from("Unknown")
51+
}
52+
fn is_italic(&self) -> bool {
53+
false
54+
}
55+
fn boldness(&self) -> font_weight::T {
56+
font_weight::T::Weight400
57+
}
58+
fn stretchiness(&self) -> font_stretch::T {
59+
font_stretch::T::normal
60+
}
61+
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
62+
None
63+
}
64+
fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId)
65+
-> FractionalPixel {
66+
0.0
67+
}
68+
fn can_do_fast_shaping(&self) -> bool {
69+
false
70+
}
71+
fn glyph_h_advance(&self, glyph: GlyphId) -> Option<FractionalPixel> {
72+
None
73+
}
74+
fn metrics(&self) -> FontMetrics {
75+
unimplemented!()
76+
}
77+
fn table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
78+
None
79+
}
80+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
#[derive(Clone, HeapSizeOf, Debug)]
6+
pub struct FontContextHandle;
7+
8+
impl FontContextHandle {
9+
pub fn new() -> FontContextHandle {
10+
FontContextHandle
11+
}
12+
}
13+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String)
6+
{
7+
}
8+
9+
pub fn for_each_variation<F>(family_name: &str, mut callback: F)
10+
where F: FnMut(String)
11+
{
12+
}
13+
14+
pub fn system_default_family(generic_name: &str) -> Option<String> {
15+
None
16+
}
17+
18+
pub fn last_resort_font_families() -> Vec<String> {
19+
vec!(
20+
"Unknown".to_owned()
21+
)
22+
}
23+
24+
pub static SANS_SERIF_FONT_FAMILY: &'static str = "Unknown";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
use string_cache::Atom;
6+
use webrender_traits::NativeFontHandle;
7+
8+
#[derive(Deserialize, Serialize, Debug)]
9+
pub struct FontTemplateData {
10+
pub bytes: Vec<u8>,
11+
pub identifier: Atom,
12+
}
13+
14+
impl FontTemplateData {
15+
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
16+
let bytes = match font_data {
17+
Some(bytes) => {
18+
bytes
19+
},
20+
None => {
21+
unimplemented!()
22+
}
23+
};
24+
25+
FontTemplateData {
26+
bytes: bytes,
27+
identifier: identifier,
28+
}
29+
}
30+
pub fn bytes(&self) -> Vec<u8> {
31+
self.bytes.clone()
32+
}
33+
pub fn bytes_if_in_memory(&self) -> Option<Vec<u8>> {
34+
Some(self.bytes())
35+
}
36+
pub fn native_font(&self) -> Option<NativeFontHandle> {
37+
None
38+
}
39+
}

components/gfx/platform/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
5+
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
66
pub use platform::freetype::{font, font_context, font_list, font_template};
77

88
#[cfg(target_os = "macos")]
99
pub use platform::macos::{font, font_context, font_list, font_template};
1010

11-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
11+
#[cfg(all(target_os = "windows", target_env = "msvc"))]
12+
pub use platform::dummy::{font, font_context, font_list, font_template};
13+
14+
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
1215
mod freetype {
1316
use libc::c_char;
1417
use std::ffi::CStr;
@@ -33,3 +36,11 @@ mod macos {
3336
pub mod font_list;
3437
pub mod font_template;
3538
}
39+
40+
#[cfg(all(target_os = "windows", target_env = "msvc"))]
41+
pub mod dummy {
42+
pub mod font;
43+
pub mod font_context;
44+
pub mod font_list;
45+
pub mod font_template;
46+
}

components/script/CMakeLists.txt

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
project(script)
2+
cmake_minimum_required(VERSION 2.6)
3+
4+
set(DUMMY ${CMAKE_BUILD_TYPE})
5+
6+
FUNCTION(PREPEND var prefix)
7+
SET(listVar "")
8+
FOREACH(f ${ARGN})
9+
LIST(APPEND listVar "${prefix}/${f}")
10+
ENDFOREACH(f)
11+
SET(${var} "${listVar}" PARENT_SCOPE)
12+
ENDFUNCTION(PREPEND)
13+
14+
set(bindings_src ${PROJECT_SOURCE_DIR}/dom/bindings/codegen)
15+
set(webidls_src ${PROJECT_SOURCE_DIR}/dom/webidls)
16+
17+
# Without Bindings/* stuff, since we install that separately below
18+
set(globalgen_base_src
19+
PrototypeList.rs
20+
RegisterBindings.rs
21+
InterfaceObjectMap.rs
22+
InterfaceTypes.rs
23+
InheritTypes.rs
24+
UnionTypes.rs
25+
)
26+
27+
set(globalgen_src
28+
${globalgen_base_src}
29+
Bindings/mod.rs
30+
)
31+
32+
file(GLOB_RECURSE webidls ${webidls_src}/*.webidl)
33+
string(REGEX REPLACE ";" "\n" webidl_filelist "${webidls}")
34+
file(WRITE "${PROJECT_BINARY_DIR}/webidls.list" "${webidl_filelist}")
35+
string(REGEX REPLACE "\\.webidl(;|$)" "\\1" bindings "${webidls}")
36+
string(REGEX REPLACE "(^|;)${webidls_src}/" "\\1" bindings "${bindings}")
37+
38+
set(globalgen_deps
39+
${bindings_src}/GlobalGen.py
40+
${bindings_src}/Bindings.conf
41+
${bindings_src}/Configuration.py
42+
${bindings_src}/CodegenRust.py
43+
${bindings_src}/parser/WebIDL.py
44+
)
45+
set(bindinggen_deps
46+
${bindings_src}/BindingGen.py
47+
${bindings_src}/Bindings.conf
48+
${bindings_src}/Configuration.py
49+
${bindings_src}/CodegenRust.py
50+
${bindings_src}/parser/WebIDL.py
51+
)
52+
53+
add_custom_command(
54+
OUTPUT Bindings
55+
COMMAND ${CMAKE_COMMAND} -E make_directory Bindings
56+
)
57+
add_custom_command(
58+
OUTPUT _cache
59+
COMMAND ${CMAKE_COMMAND} -E make_directory _cache
60+
)
61+
62+
add_custom_command(
63+
OUTPUT ParserResults.pkl ${globalgen_src}
64+
COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply
65+
${bindings_src}/GlobalGen.py
66+
--cachedir=_cache
67+
--filelist=webidls.list
68+
${bindings_src}/Bindings.conf
69+
.
70+
${PROJECT_SOURCE_DIR}
71+
DEPENDS Bindings _cache ${globalgen_deps} ${webidls}
72+
VERBATIM
73+
)
74+
75+
add_custom_target(generate-bindings ALL DEPENDS ${globalgen_src})
76+
77+
foreach(binding IN LISTS bindings)
78+
add_custom_command(
79+
OUTPUT Bindings/${binding}Binding.rs
80+
COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply
81+
${bindings_src}/BindingGen.py
82+
${bindings_src}/Bindings.conf
83+
.
84+
Bindings/${binding}Binding
85+
${webidls_src}/${binding}.webidl
86+
DEPENDS Bindings ${bindinggen_deps} ${webidls_src}/${binding}.webidl ParserResults.pkl
87+
VERBATIM
88+
)
89+
add_custom_target(${binding} DEPENDS Bindings/${binding}Binding.rs)
90+
add_dependencies(generate-bindings ${binding})
91+
endforeach()
92+
93+
PREPEND(globalgen_out ${CMAKE_BINARY_DIR}/ ${globalgen_base_src})
94+
install(FILES ${globalgen_out} DESTINATION .)
95+
install(DIRECTORY ${CMAKE_BINARY_DIR}/Bindings/ DESTINATION Bindings)

components/script/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ uuid = {version = "0.2", features = ["v4"]}
6666
webrender_traits = {git = "https://github.com/servo/webrender_traits"}
6767
websocket = "0.17"
6868
xml5ever = {version = "0.1.2", features = ["unstable"]}
69+
70+
[build-dependencies]
71+
cmake = "0.1"
72+

components/script/build.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use std::process::Command;
5+
extern crate cmake;
66

77
fn main() {
8-
assert!(Command::new("make")
9-
.args(&["-f", "makefile.cargo"])
10-
.status()
11-
.unwrap()
12-
.success());
8+
let _ = cmake::Config::new(".").build();
139
}

0 commit comments

Comments
 (0)