mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
refactor(build): generate revision into out_dir
This commit is contained in:
parent
f9230975f5
commit
b957f6aad7
4 changed files with 6 additions and 29 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,7 +23,6 @@ Servo.app
|
||||||
.config.mk.last
|
.config.mk.last
|
||||||
/glfw
|
/glfw
|
||||||
capture_webrender/
|
capture_webrender/
|
||||||
/components/compositing/webrender_revision.rs
|
|
||||||
|
|
||||||
# Editors
|
# Editors
|
||||||
|
|
||||||
|
|
|
@ -7,27 +7,11 @@ extern crate toml;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
use std::path::Path;
|
||||||
const WEBRENDER_REVISION_TEMPLATE: &'static str =
|
|
||||||
"/* 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/. */
|
|
||||||
|
|
||||||
/// auto-generated by cargo. do not manually modify.
|
|
||||||
pub const REVISION: &'static str = ";
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let current_path = env::current_dir().expect("Failed to access path to lockfile");
|
let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("..").join("..").join("Cargo.lock");
|
||||||
let lockfile_path = current_path.join("..").join("..").join("Cargo.lock");
|
let revision_file_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("webrender_revision.rs");
|
||||||
let revision_file_path = current_path.join("webrender_revision.rs");
|
|
||||||
|
|
||||||
let mut existing_revision_exported = String::new();
|
|
||||||
match File::open(&revision_file_path) {
|
|
||||||
Ok(mut f) => {
|
|
||||||
f.read_to_string(&mut existing_revision_exported).unwrap_or_default();
|
|
||||||
},
|
|
||||||
Err(_) => ()
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut lockfile = String::new();
|
let mut lockfile = String::new();
|
||||||
File::open(lockfile_path).expect("Cannot open lockfile")
|
File::open(lockfile_path).expect("Cannot open lockfile")
|
||||||
|
@ -49,13 +33,8 @@ fn main() {
|
||||||
let parsed: Vec<&str> = source.split("#").collect();
|
let parsed: Vec<&str> = source.split("#").collect();
|
||||||
let revision = if parsed.len() > 1 { parsed[1] } else { source };
|
let revision = if parsed.len() > 1 { parsed[1] } else { source };
|
||||||
|
|
||||||
if let Some(_) = existing_revision_exported.find(revision) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let revision_contents = format!("{}\"{}\";", WEBRENDER_REVISION_TEMPLATE, revision);
|
|
||||||
let mut revision_module_file = File::create(&revision_file_path).unwrap();
|
let mut revision_module_file = File::create(&revision_file_path).unwrap();
|
||||||
write!(&mut revision_module_file, "{}", revision_contents).unwrap();
|
write!(&mut revision_module_file, "{}", format!("\"{}\"", revision)).unwrap();
|
||||||
},
|
},
|
||||||
_ => panic!("Cannot find package definitions in lockfile")
|
_ => panic!("Cannot find package definitions in lockfile")
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ use touch::{TouchHandler, TouchAction};
|
||||||
use webrender;
|
use webrender;
|
||||||
use webrender_api::{self, DeviceIntPoint, DevicePoint, DeviceUintRect, DeviceUintSize, HitTestFlags, HitTestResult};
|
use webrender_api::{self, DeviceIntPoint, DevicePoint, DeviceUintRect, DeviceUintSize, HitTestFlags, HitTestResult};
|
||||||
use webrender_api::{LayoutVector2D, ScrollEventPhase, ScrollLocation};
|
use webrender_api::{LayoutVector2D, ScrollEventPhase, ScrollLocation};
|
||||||
use webrender_revision::REVISION;
|
|
||||||
use windowing::{self, MouseWindowEvent, WebRenderDebugOption, WindowMethods};
|
use windowing::{self, MouseWindowEvent, WebRenderDebugOption, WindowMethods};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
@ -1553,7 +1552,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
match File::create(revision_file_path) {
|
match File::create(revision_file_path) {
|
||||||
Ok(mut file) => {
|
Ok(mut file) => {
|
||||||
if let Err(err) = write!(&mut file, "{}", REVISION) {
|
let revision = include!(concat!(env!("OUT_DIR"), "/webrender_revision.rs"));
|
||||||
|
if let Err(err) = write!(&mut file, "{}", revision) {
|
||||||
println!("Unable to write webrender revision: {:?}", err)
|
println!("Unable to write webrender revision: {:?}", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ use style_traits::CSSPixel;
|
||||||
mod compositor;
|
mod compositor;
|
||||||
pub mod compositor_thread;
|
pub mod compositor_thread;
|
||||||
mod touch;
|
mod touch;
|
||||||
mod webrender_revision;
|
|
||||||
pub mod windowing;
|
pub mod windowing;
|
||||||
|
|
||||||
pub struct SendableFrameTree {
|
pub struct SendableFrameTree {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue