From 1d5b51450bd193ee2979045c94f5f569d7261e75 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Mon, 21 Jul 2014 17:17:35 +0300 Subject: [PATCH] Break the layout -> compositing dependency This adds a new layout_traits component for the shared trait. This should allow for faster builds. --- Makefile.in | 24 ++++++--- configure | 1 + src/components/compositing/compositing.rs | 2 +- src/components/compositing/constellation.rs | 2 +- src/components/compositing/pipeline.rs | 2 +- src/components/layout/layout.rs | 1 + src/components/layout/layout_task.rs | 18 +------ src/components/layout_traits/layout_traits.rs | 52 +++++++++++++++++++ 8 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 src/components/layout_traits/layout_traits.rs diff --git a/Makefile.in b/Makefile.in index 8ad50a95772..d5c5e186f10 100644 --- a/Makefile.in +++ b/Makefile.in @@ -274,30 +274,38 @@ DONE_style = $(B)src/components/style/libstyle.dummy DEPS_style = $(CRATE_style) $(SRC_style) $(DONE_SUBMODULES) $(DONE_util) $(DONE_macros) -RFLAGS_layout = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/style -L $(B)src/components/msg -L$(B)src/components/macros +RFLAGS_layout_traits = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/style -L $(B)src/components/msg + +SRC_layout_traits = $(call rwildcard,$(S)src/components/layout_traits/,*.rs) +CRATE_layout_traits = $(S)src/components/layout_traits/layout_traits.rs +DONE_layout_traits = $(B)src/components/layout_traits/liblayout_traits.dummy + +DEPS_layout_traits = $(CRATE_layout_traits) $(SRC_layout_traits) $(DONE_script) $(DONE_msg) $(DONE_net) $(DONE_gfx) $(DONE_util) + +RFLAGS_layout = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/style -L $(B)src/components/msg -L$(B)src/components/macros -L$(B)src/components/layout_traits SRC_layout = $(call rwildcard,$(S)src/components/layout/,*.rs) $(S)src/components/layout/css/user-agent.css CRATE_layout = $(S)src/components/layout/layout.rs DONE_layout = $(B)src/components/layout/liblayout.dummy -DEPS_layout = $(CRATE_layout) $(SRC_layout) $(DONE_script) $(DONE_style) $(DONE_msg) $(DONE_macros) $(DONE_gfx) $(DONE_util) +DEPS_layout = $(CRATE_layout) $(SRC_layout) $(DONE_script) $(DONE_style) $(DONE_msg) $(DONE_macros) $(DONE_gfx) $(DONE_util) $(DONE_layout_traits) -RFLAGS_compositing = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout -L $(B)src/components/style -L $(B)src/components/msg +RFLAGS_compositing = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout_traits -L $(B)src/components/style -L $(B)src/components/msg SRC_compositing = $(call rwildcard,$(S)src/components/compositing/,*.rs) CRATE_compositing = $(S)src/components/compositing/compositing.rs DONE_compositing = $(B)src/components/compositing/libcompositing.dummy -DEPS_compositing = $(CRATE_compositing) $(SRC_compositing) $(DONE_util) $(DONE_msg) $(DONE_gfx) $(DONE_script) $(DONE_layout) $(DONE_style) +DEPS_compositing = $(CRATE_compositing) $(SRC_compositing) $(DONE_util) $(DONE_msg) $(DONE_gfx) $(DONE_script) $(DONE_layout_traits) $(DONE_style) -RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout -L $(B)src/components/compositing -L $(B)src/components/style -L $(B)src/components/msg -L$(B)src/components/macros +RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout_traits -L $(B)src/components/layout -L $(B)src/components/compositing -L $(B)src/components/style -L $(B)src/components/msg -L$(B)src/components/macros SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs) CRATE_servo = $(S)src/components/main/servo.rs -DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_script) $(DONE_net) $(DONE_msg) $(DONE_style) $(DONE_macros) $(DONE_layout) $(DONE_compositing) +DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_script) $(DONE_net) $(DONE_msg) $(DONE_style) $(DONE_macros) $(DONE_layout) $(DONE_layout_traits) $(DONE_compositing) -SERVO_LIB_CRATES = macros util net msg gfx script style layout compositing +SERVO_LIB_CRATES = macros util net msg gfx script style layout layout_traits compositing # rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc) # and SERVO_LIB_CRATES @@ -364,7 +372,7 @@ servo: $(DEPS_servo) @$(call E, compile: $@) $(Q)$(RUSTC) $(RFLAGS_servo) $< --crate-type bin,dylib,rlib -RFLAGS_embedding = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout -L $(B)src/components/compositing -L $(B)src/components/style -L $(B)src/components/msg -L $(B).. -L $(B)src/components/main -L $(B)src/components/macros -A non_camel_case_types -A unused_variable +RFLAGS_embedding = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout -L $(B)src/components/layout_traits -L $(B)src/components/compositing -L $(B)src/components/style -L $(B)src/components/msg -L $(B).. -L $(B)src/components/main -L $(B)src/components/macros -A non_camel_case_types -A unused_variable ifeq ($(CFG_OSTYPE),apple-darwin) RFLAGS_embedding += -C link-args="-Wl,-U,_tc_new -Wl,-U,_tc_newarray -Wl,-U,_tc_delete -Wl,-U,_tc_deletearray" diff --git a/configure b/configure index 9361723d2d2..8d2abe5e1ef 100755 --- a/configure +++ b/configure @@ -616,6 +616,7 @@ make_dir ${CFG_BUILD_DIR}src/components/msg make_dir ${CFG_BUILD_DIR}src/components/net make_dir ${CFG_BUILD_DIR}src/components/gfx make_dir ${CFG_BUILD_DIR}src/components/layout +make_dir ${CFG_BUILD_DIR}src/components/layout_traits make_dir ${CFG_BUILD_DIR}src/components/script make_dir ${CFG_BUILD_DIR}src/components/style make_dir ${CFG_BUILD_DIR}src/components/main diff --git a/src/components/compositing/compositing.rs b/src/components/compositing/compositing.rs index b7700ef51c1..7e8c4e0fa93 100644 --- a/src/components/compositing/compositing.rs +++ b/src/components/compositing/compositing.rs @@ -26,7 +26,7 @@ extern crate glfw; #[cfg(target_os="android")] extern crate glut; extern crate layers; -extern crate layout; +extern crate layout_traits; extern crate opengles; extern crate png; extern crate script; diff --git a/src/components/compositing/constellation.rs b/src/components/compositing/constellation.rs index d06e2a64211..91d44d04d94 100644 --- a/src/components/compositing/constellation.rs +++ b/src/components/compositing/constellation.rs @@ -10,7 +10,7 @@ use geom::size::TypedSize2D; use gfx::render_task; use libc; use pipeline::{Pipeline, CompositionPipeline}; -use layout::layout_task::LayoutTaskFactory; +use layout_traits::LayoutTaskFactory; use script::script_task::{ResizeMsg, ResizeInactiveMsg, ExitPipelineMsg}; use script::layout_interface; use script::layout_interface::LayoutChan; diff --git a/src/components/compositing/pipeline.rs b/src/components/compositing/pipeline.rs index a7181491df5..4351dc79b69 100644 --- a/src/components/compositing/pipeline.rs +++ b/src/components/compositing/pipeline.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use CompositorChan; -use layout::layout_task::LayoutTaskFactory; +use layout_traits::LayoutTaskFactory; use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked}; use gfx::render_task::{RenderChan, RenderTask}; diff --git a/src/components/layout/layout.rs b/src/components/layout/layout.rs index d864ec9d848..f17d1225204 100644 --- a/src/components/layout/layout.rs +++ b/src/components/layout/layout.rs @@ -19,6 +19,7 @@ extern crate debug; extern crate geom; extern crate gfx; +extern crate layout_traits; extern crate script; extern crate style; #[phase(plugin)] diff --git a/src/components/layout/layout_task.rs b/src/components/layout/layout_task.rs index 65305d27152..cb40a8f011d 100644 --- a/src/components/layout/layout_task.rs +++ b/src/components/layout/layout_task.rs @@ -30,6 +30,7 @@ use gfx::display_list::{DisplayItemIterator, DisplayList, OpaqueNode}; use gfx::font_context::FontContext; use gfx::render_task::{RenderMsg, RenderChan, RenderLayer}; use gfx::{render_task, color}; +use layout_traits::LayoutTaskFactory; use script::dom::bindings::js::JS; use script::dom::event::ReflowEvent; use script::dom::node::{ElementNodeTypeId, LayoutDataRef, Node}; @@ -62,23 +63,6 @@ use style::{AuthorOrigin, Stylesheet, Stylist}; use sync::{Arc, Mutex}; use url::Url; -// A static method creating a layout task -pub trait LayoutTaskFactory { - fn create(_phantom: Option<&mut Self>, // FIXME: use a proper static method - id: PipelineId, - port: Receiver, - chan: LayoutChan, - constellation_chan: ConstellationChan, - failure_msg: Failure, - script_chan: ScriptChan, - render_chan: RenderChan, - img_cache_task: ImageCacheTask, - font_cache_task: FontCacheTask, - opts: Opts, - time_profiler_chan: TimeProfilerChan, - shutdown_chan: Sender<()>); -} - /// Information needed by the layout task. pub struct LayoutTask { /// The ID of the pipeline that we belong to. diff --git a/src/components/layout_traits/layout_traits.rs b/src/components/layout_traits/layout_traits.rs new file mode 100644 index 00000000000..cf95de37678 --- /dev/null +++ b/src/components/layout_traits/layout_traits.rs @@ -0,0 +1,52 @@ +/* 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/. */ + +#![crate_id = "github.com/mozilla/servo#layout_traits:0.1"] +#![crate_type = "lib"] +#![crate_type = "dylib"] +#![crate_type = "rlib"] + +#![comment = "The Servo Parallel Browser Project"] +#![license = "MPL"] + +extern crate gfx; +extern crate script; +extern crate servo_msg = "msg"; +extern crate servo_net = "net"; +extern crate servo_util = "util"; + +// This module contains traits in layout used generically +// in the rest of Servo. +// The traits are here instead of in layout so +// that these modules won't have to depend on layout. + +use gfx::font_cache_task::FontCacheTask; +use gfx::render_task::RenderChan; +use servo_msg::constellation_msg::{ConstellationChan, PipelineId}; +use servo_msg::constellation_msg::Failure; +use servo_net::image_cache_task::ImageCacheTask; +use servo_util::opts::Opts; +use servo_util::time::TimeProfilerChan; +use script::layout_interface::{LayoutChan, Msg}; +use script::script_task::ScriptChan; +use std::comm::{Sender, Receiver}; + +// A static method creating a layout task +// Here to remove the compositor -> layout dependency +pub trait LayoutTaskFactory { + // FIXME: use a proper static method + fn create(_phantom: Option<&mut Self>, + id: PipelineId, + port: Receiver, + chan: LayoutChan, + constellation_chan: ConstellationChan, + failure_msg: Failure, + script_chan: ScriptChan, + render_chan: RenderChan, + img_cache_task: ImageCacheTask, + font_cache_task: FontCacheTask, + opts: Opts, + time_profiler_chan: TimeProfilerChan, + shutdown_chan: Sender<()>); +}