servo: Merge #4864 - Gonk upgrade (from Manishearth:gonkup1); r=larsbergstrom

This does a rustup to our current rustc.

Gonk now compiles, but doesn't run. Trying to fix this, but thought I'd PR my progress.

This needs a couple of things to work:

 - An override of time  (7f105d4dd2), with `timegm(struct tm *tm)`  from `src/time_helpers.c` commented out
 - An override of openssl (1a60bccb6a), with [this patch](http://hastebin.com/onovacofuj.diff)
 - An override of gl-rs (230e6c9ed6), with submodules updated. This is because the lockfile is messed up due to conflicting github and registry deps. While I could fix this by forking things, this goes away next rustup anyway (the deps all move to a common source), so I just worked around it with a clone.
 - Env vars similar to [this](http://hastebin.com/hawadubolu.bash)
 - After the last failed link step, run `../../mach rustc` with the same args (extracted from `../../mach cargo -v`), along with `-C link-args="$LDFLAGS -lGLESv2 -L $GONKDIR/backup-flame/system/lib/"`
 - (Steps for creating a B2G build [here](https://www.irccloud.com/pastebin/VG2lHBVP))

r? @larsbergstrom

(No need for a merge, just a check on the unsafe stuff would be fine)

Source-Repo: https://github.com/servo/servo
Source-Revision: 11edfdc9353362161b0ff9a654d61dccd1d438f0
This commit is contained in:
Manish Goregaokar 2015-02-07 09:09:43 -07:00
Родитель d93ca71608
Коммит 49c6598243
7 изменённых файлов: 103 добавлений и 60 удалений

Просмотреть файл

@ -30,7 +30,7 @@ path = "../../tests/contenttest.rs"
harness = false
[features]
default = ["window"]
default = ["glutin_app", "window"]
window = ["glutin_app/window"]
headless = ["glutin_app/headless"]
@ -60,6 +60,7 @@ path = "../devtools"
[dependencies.glutin_app]
path = "../../ports/glutin"
optional = true
[dependencies.android_glue]
path = "../../support/android-rs-glue/glue"

24
servo/ports/gonk/Cargo.lock сгенерированный
Просмотреть файл

@ -3,9 +3,11 @@ name = "b2s"
version = "0.0.1"
dependencies = [
"compositing 0.0.1",
"devtools 0.0.1",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"layout 0.0.1",
"msg 0.0.1",
"script 0.0.1",
"servo 0.0.1",
@ -33,6 +35,7 @@ version = "0.0.1"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"gfx 0.0.1",
"util 0.0.1",
]
@ -51,7 +54,6 @@ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
"core_text 0.1.0 (git+https://github.com/servo/rust-core-text)",
"devtools 0.0.1",
"devtools_traits 0.0.1",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"gfx 0.0.1",
@ -70,7 +72,7 @@ dependencies = [
[[package]]
name = "cookie"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "git+https://github.com/servo/cookie-rs?branch=lenientparse_backport#47ffa4d3c6f85d28f222d6e1d54635fff5622ea3"
dependencies = [
"openssl 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -116,6 +118,7 @@ version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
"msg 0.0.1",
"time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
@ -322,9 +325,9 @@ source = "git+https://github.com/servo/html5ever#d35dfaaf0d85007057a299afc370d07
[[package]]
name = "hyper"
version = "0.1.1"
source = "git+https://github.com/servo/hyper?branch=servo#7f48a7e945180a4f762dc75236210d20a69b4a6a"
source = "git+https://github.com/servo/hyper?branch=old_servo_new_cookies#7a346f481d683705709526594aa5f13b5c923bc1"
dependencies = [
"cookie 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"cookie 0.1.8 (git+https://github.com/servo/cookie-rs?branch=lenientparse_backport)",
"log 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mucell 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -460,7 +463,7 @@ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=servo)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=old_servo_new_cookies)",
"io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"style 0.0.1",
@ -477,8 +480,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "net"
version = "0.0.1"
dependencies = [
"cookie 0.1.8 (git+https://github.com/servo/cookie-rs?branch=lenientparse_backport)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=servo)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=old_servo_new_cookies)",
"openssl 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
@ -497,11 +501,11 @@ dependencies = [
[[package]]
name = "openssl-sys"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -527,7 +531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "pkg-config"
version = "0.1.2"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -574,7 +578,7 @@ dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"gfx 0.0.1",
"html5ever 0.0.0 (git+https://github.com/servo/html5ever)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=servo)",
"hyper 0.1.1 (git+https://github.com/servo/hyper?branch=old_servo_new_cookies)",
"js 0.1.0 (git+https://github.com/servo/rust-mozjs)",
"msg 0.0.1",
"net 0.0.1",

Просмотреть файл

@ -3,7 +3,7 @@ name = "b2s"
version = "0.0.1"
authors = ["The Servo Project Developers"]
build = "make -f makefile.cargo"
build = "build.rs"
[dependencies.compositing]
path = "../../components/compositing"
@ -20,6 +20,12 @@ path = "../../components/msg"
[dependencies.script]
path = "../../components/script"
[dependencies.layout]
path = "../../components/layout"
[dependencies.devtools]
path = "../../components/devtools"
[dependencies.servo]
path = "../../components/servo"
default-features = false

19
servo/ports/gonk/build.rs Normal file
Просмотреть файл

@ -0,0 +1,19 @@
/* 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::io::process::{Command, ProcessExit, StdioContainer};
use std::os;
fn main() {
let out_dir = os::getenv("OUT_DIR").unwrap();
let result = Command::new("make")
.args(&["-f", "makefile.cargo"])
.stdout(StdioContainer::InheritFd(1))
.stderr(StdioContainer::InheritFd(2))
.status()
.unwrap();
assert_eq!(result, ProcessExit::ExitStatus(0));
println!("cargo:rustc-flags=-L native={}", out_dir);
}

Просмотреть файл

@ -10,6 +10,8 @@ use std::os::errno;
use std::os::unix::AsRawFd;
use std::num::Float;
use std::io::File;
use std::thread::Thread;
use std::sync::mpsc::Sender;
use geom::point::TypedPoint2D;
@ -116,9 +118,9 @@ fn read_input_device(device_path: &Path,
println!("xMin: {}, yMin: {}, touchWidth: {}, touchHeight: {}", xInfo.minimum, yInfo.minimum, touchWidth, touchHeight);
// XXX: Why isn't size_of treated as constant?
// let buf: [u8, ..(16 * size_of::<linux_input_event>())];
let mut buf: [u8, ..(16 * 16)] = unsafe { zeroed() };
let mut slots: [input_slot, ..10] = unsafe { zeroed() };
// let buf: [u8; (16 * size_of::<linux_input_event>())];
let mut buf: [u8; (16 * 16)] = unsafe { zeroed() };
let mut slots: [input_slot; 10] = unsafe { zeroed() };
for slot in slots.iter_mut() {
slot.tracking_id = -1;
}
@ -234,7 +236,7 @@ fn read_input_device(device_path: &Path,
pub fn run_input_loop(event_sender: &Sender<WindowEvent>) {
let sender = event_sender.clone();
spawn(proc () {
Thread::spawn(move || {
// XXX need to scan all devices and read every one.
let touchinputdev = Path::new("/dev/input/event0");
read_input_device(&touchinputdev, &sender);

Просмотреть файл

@ -2,7 +2,9 @@
* 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/. */
#![feature(macro_rules, phase, thread_local)]
#![feature(thread_local)]
#![feature(box_syntax)]
#![feature(int_uint)]
#![deny(unused_imports)]
#![deny(unused_variables)]
@ -20,7 +22,6 @@ extern crate script;
extern crate layout;
extern crate gfx;
extern crate libc;
extern crate rustrt;
extern crate url;
use compositing::CompositorEventListener;
@ -57,7 +58,9 @@ use std::os;
#[cfg(not(test))]
use std::rc::Rc;
#[cfg(not(test))]
use std::task::TaskBuilder;
use std::thread::Builder;
#[cfg(not(test))]
use std::sync::mpsc::channel;
pub struct Browser<Window> {
compositor: Box<CompositorEventListener + 'static>,
@ -85,8 +88,8 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
let (result_chan, result_port) = channel();
let compositor_proxy_for_constellation = compositor_proxy.clone_compositor_proxy();
TaskBuilder::new()
.spawn(proc() {
Builder::new()
.spawn(move || {
let opts = &opts_clone;
// Create a Servo instance.
let resource_task = new_resource_task(opts.user_agent.clone());
@ -128,7 +131,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
result_chan.send(constellation_chan);
});
let constellation_chan = result_port.recv();
let constellation_chan = result_port.recv().unwrap();
debug!("preparing to enter main loop");
let compositor = CompositorTask::create(window,

Просмотреть файл

@ -15,12 +15,13 @@ use msg::compositor_msg::{ReadyState, PaintState};
use msg::constellation_msg::{Key, KeyModifiers};
use msg::constellation_msg::LoadData;
use std::cell::Cell;
use std::comm::Receiver;
use std::sync::mpsc::{channel, Sender, Receiver};
use std::rc::Rc;
use std::mem::transmute;
use std::mem::size_of;
use std::mem::zeroed;
use std::ptr;
use std::ffi::CString;
use util::cursor::Cursor;
use util::geometry::ScreenPx;
use gleam::gl;
@ -50,7 +51,7 @@ pub struct native_handle {
version: c_int,
numFds: c_int,
numInts: c_int,
data: [c_int, ..0],
data: [c_int; 0],
}
// system/core/include/system/window.h
@ -59,7 +60,7 @@ pub struct native_handle {
pub struct ANativeBase {
magic: u32,
version: u32,
reserved: [int, ..4],
reserved: [int; 4],
incRef: extern fn(*mut ANativeBase),
decRef: extern fn(*mut ANativeBase),
}
@ -72,9 +73,9 @@ pub struct ANativeWindowBuffer {
stride: c_int,
format: c_int,
usage: c_int,
reserved: [*mut c_void, ..2],
reserved: [*mut c_void; 2],
handle: *const native_handle,
reserved_proc: [*mut c_void, ..8],
reserved_proc: [*mut c_void; 8],
}
#[repr(C)]
@ -85,7 +86,7 @@ pub struct ANativeWindow {
maxSwapInterval: c_int,
xdpi: f32,
ydpi: f32,
oem: [int, ..4],
oem: [int; 4],
setSwapInterval: extern fn(*mut ANativeWindow, c_int) -> c_int,
//dequeueBuffer_DEPRECATED: extern fn(*mut ANativeWindow, *mut *mut ANativeWindowBuffer) -> c_int,
//lockBuffer_DEPRECATED: extern fn(*mut ANativeWindow, *mut ANativeWindowBuffer) -> c_int,
@ -119,7 +120,7 @@ pub struct hw_module {
author: *const c_char,
methods: *mut hw_module_methods,
dso: *mut u32,
reserved: [u32, ..(32-7)],
reserved: [u32; (32-7)],
}
#[repr(C)]
@ -127,7 +128,7 @@ pub struct hw_device {
tag: u32,
version: u32,
module: *mut hw_module,
reserved: [u32, ..12],
reserved: [u32; 12],
close: extern fn(*mut hw_device) -> c_int,
}
@ -183,8 +184,8 @@ pub struct hwc_layer {
acquireFenceFd: c_int,
releaseFenceFd: c_int,
planeAlpha: u8,
pad: [u8, ..3],
reserved: [i32, ..(24 - 19)],
pad: [u8; 3],
reserved: [i32; (24 - 19)],
}
#[repr(C)]
@ -195,7 +196,7 @@ pub struct hwc_display_contents {
outbufAcquireFenceFd: c_int,
flags: u32,
numHwLayers: size_t,
hwLayers: [hwc_layer, ..2],
hwLayers: [hwc_layer; 2],
}
#[repr(C)]
@ -224,7 +225,7 @@ pub struct hwc_composer_device {
dump: extern fn(*mut hwc_composer_device, *const c_char, c_int),
getDisplayConfigs: extern fn(*mut hwc_composer_device, c_int, *mut u32, *mut size_t) -> c_int,
getDisplayAttributes: extern fn(*mut hwc_composer_device, c_int, u32, *const u32, *mut i32) -> c_int,
reserved: [*mut c_void, ..4],
reserved: [*mut c_void; 4],
}
// system/core/include/system/graphics.h
@ -237,7 +238,7 @@ pub struct android_ycbcr {
ystride: size_t,
cstride: size_t,
chroma_step: size_t,
reserved: [u32, ..8],
reserved: [u32; 8],
}
// hardware/libhardware/include/hardware/gralloc.h
@ -251,7 +252,7 @@ pub struct gralloc_module {
unlock: extern fn(*const gralloc_module, *const native_handle) -> c_int,
perform: extern fn(*const gralloc_module, c_int, ...) -> c_int,
lock_ycbcr: extern fn(*const gralloc_module, *const native_handle, c_int, c_int, c_int, c_int, c_int, *mut android_ycbcr) -> c_int,
reserved: [*mut c_void, ..6],
reserved: [*mut c_void; 6],
}
#[repr(C)]
@ -261,7 +262,7 @@ pub struct alloc_device {
alloc: extern fn(*mut alloc_device, c_int, c_int, c_int, c_int, *mut *const native_handle, *mut c_int) -> c_int,
free: extern fn(*mut alloc_device, *const native_handle) -> c_int,
dump: Option<extern fn(*mut alloc_device, *mut c_char, c_int)>,
reserved: [*mut c_void, ..7],
reserved: [*mut c_void; 7],
}
#[repr(C)]
@ -282,13 +283,13 @@ pub struct GonkNativeWindow {
usage: c_int,
last_fence: c_int,
last_idx: i32,
bufs: [Option<*mut GonkNativeWindowBuffer>, ..2],
fences: [c_int, ..2],
bufs: [Option<*mut GonkNativeWindowBuffer>; 2],
fences: [c_int; 2],
}
impl ANativeBase {
fn magic(a: char, b: char, c: char, d: char) -> u32 {
a as u32 << 24 | b as u32 << 16 | c as u32 << 8 | d as u32
(a as u32) << 24 | (b as u32) << 16 | (c as u32) << 8 | d as u32
}
}
@ -452,7 +453,7 @@ extern fn gnw_decRef(base: *mut ANativeBase) {
impl GonkNativeWindow {
pub fn new(alloc_dev: *mut alloc_device, hwc_dev: *mut hwc_composer_device, width: i32, height: i32, usage: c_int) -> *mut GonkNativeWindow {
let mut win = box GonkNativeWindow {
let mut win = Box::new(GonkNativeWindow {
window: ANativeWindow {
common: ANativeBase {
magic: ANativeBase::magic('_', 'w', 'n', 'd'),
@ -495,7 +496,7 @@ impl GonkNativeWindow {
last_idx: -1,
bufs: unsafe { zeroed() },
fences: [-1, -1],
};
});
unsafe { transmute(win) }
}
@ -557,7 +558,7 @@ impl GonkNativeWindow {
],
};
unsafe {
let mut displays: [*mut hwc_display_contents, ..3] = [ &mut list, ptr::null_mut(), ptr::null_mut(), ];
let mut displays: [*mut hwc_display_contents; 3] = [ &mut list, ptr::null_mut(), ptr::null_mut(), ];
let _ = ((*self.hwc_dev).prepare)(self.hwc_dev, displays.len() as size_t, transmute(displays.as_mut_ptr()));
let _ = ((*self.hwc_dev).set)(self.hwc_dev, displays.len() as size_t, transmute(displays.as_mut_ptr()));
if list.retireFenceFd >= 0 {
@ -583,7 +584,7 @@ extern fn gnwb_decRef(base: *mut ANativeBase) {
impl GonkNativeWindowBuffer {
pub fn new(dev: *mut alloc_device, width: i32, height: i32, format: c_int, usage: c_int) -> *mut GonkNativeWindowBuffer {
let mut buf = box GonkNativeWindowBuffer {
let mut buf = Box::new(GonkNativeWindowBuffer {
buffer: ANativeWindowBuffer {
common: ANativeBase {
magic: ANativeBase::magic('_', 'b', 'f', 'r'),
@ -602,7 +603,7 @@ impl GonkNativeWindowBuffer {
reserved_proc: unsafe { zeroed() },
},
count: 1,
};
});
let ret = unsafe { ((*dev).alloc)(dev, width, height, format, usage, &mut buf.buffer.handle, &mut buf.buffer.stride) };
assert!(ret == 0, "Failed to allocate gralloc buffer!");
@ -631,14 +632,18 @@ impl Window {
pub fn new() -> Rc<Window> {
let mut hwc_mod = ptr::null();
unsafe {
let ret = "hwcomposer".with_c_str(|s| hw_get_module(s, &mut hwc_mod));
let cstr = CString::from_slice("hwcomposer".as_bytes());
let ptr = cstr.as_ptr();
let ret = hw_get_module(ptr, &mut hwc_mod);
assert!(ret == 0, "Failed to get HWC module!");
}
let mut hwc_device: *mut hwc_composer_device;
unsafe {
let mut device = ptr::null();
let ret = "composer".with_c_str(|s| ((*(*hwc_mod).methods).open)(hwc_mod, s, &mut device));
let cstr = CString::from_slice("composer".as_bytes());
let ptr = cstr.as_ptr();
let ret = ((*(*hwc_mod).methods).open)(hwc_mod, ptr, &mut device);
assert!(ret == 0, "Failed to get HWC device!");
hwc_device = transmute(device);
// Require HWC 1.1 or newer
@ -646,12 +651,12 @@ impl Window {
assert!((*hwc_device).common.version > (1 << 8), "HWC too old!");
}
let attrs: [u32, ..4] = [
let attrs: [u32; 4] = [
HWC_DISPLAY_WIDTH,
HWC_DISPLAY_HEIGHT,
HWC_DISPLAY_DPI_X,
HWC_DISPLAY_NO_ATTRIBUTE];
let mut values: [i32, ..4] = [0, 0, 0, 0];
let mut values: [i32; 4] = [0, 0, 0, 0];
unsafe {
// In theory, we should check the return code.
// However, there are HALs which implement this wrong.
@ -662,10 +667,13 @@ impl Window {
let mut alloc_dev: *mut alloc_device;
unsafe {
let mut device = ptr::null();
let ret1 = "gralloc".with_c_str(|s| hw_get_module(s, &mut gralloc_mod));
let cstr = CString::from_slice("gralloc".as_bytes());
let ptr = cstr.as_ptr();
let ret1 = hw_get_module(ptr, &mut gralloc_mod);
assert!(ret1 == 0, "Failed to get gralloc moudle!");
let ret2 = "gpu0".with_c_str(|s| ((*(*gralloc_mod).methods).open)(gralloc_mod, s, &mut device));
let cstr2 = CString::from_slice("gpu0".as_bytes());
let ptr2 = cstr2.as_ptr();
let ret2 = ((*(*gralloc_mod).methods).open)(gralloc_mod, ptr2, &mut device);
assert!(ret2 == 0, "Failed to get gralloc moudle!");
alloc_dev = transmute(device);
}
@ -755,7 +763,7 @@ impl Window {
}
pub fn wait_events(&self) -> WindowEvent {
self.event_recv.recv()
self.event_recv.recv().unwrap()
}
}
@ -769,8 +777,8 @@ impl Drop for Window {
impl WindowMethods for Window {
/// Returns the size of the window in hardware pixels.
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint> {
TypedSize2D(self.width as uint, self.height as uint)
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, u32> {
TypedSize2D(self.width as u32, self.height as u32)
}
/// Returns the size of the window in density-independent "px" units.
@ -818,11 +826,11 @@ impl WindowMethods for Window {
fn create_compositor_channel(window: &Option<Rc<Window>>)
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>) {
let (sender, receiver) = channel();
(box GonkCompositorProxy {
(Box::new(GonkCompositorProxy {
sender: sender,
event_sender: window.as_ref().unwrap().event_send.clone(),
} as Box<CompositorProxy+Send>,
box receiver as Box<CompositorReceiver>)
}) as Box<CompositorProxy+Send>,
Box::new(receiver) as Box<CompositorReceiver>)
}
fn set_cursor(&self, _: Cursor) {
@ -845,10 +853,10 @@ impl CompositorProxy for GonkCompositorProxy {
self.event_sender.send(WindowEvent::Idle);
}
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
box GonkCompositorProxy {
Box::new(GonkCompositorProxy {
sender: self.sender.clone(),
event_sender: self.event_sender.clone(),
} as Box<CompositorProxy+Send>
}) as Box<CompositorProxy+Send>
}
}