Bug 1219452 - Update script for rust mp4parser. r=kinetik
authorRalph Giles <giles@mozilla.com>
Wed, 28 Oct 2015 14:55:45 -0700
changeset 305271 c40a1cdc964104abc5f99dc689171ebcfed7ddda
parent 305270 b98837042b2000e7ef30f62b0f2832f94291d10f
child 305272 7ad35617e91ba9d5fd336237b240b4c0f6ad91a0
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1219452
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1219452 - Update script for rust mp4parser. r=kinetik Automate update and patching of the rust mp4 parser from the upstream repo. A rev for mp4parse-rust can be passed on the command line, but the byteorder crate's version is hardcoded. Differences to adapt to the gecko build system are applied as patches like we do for other media code. Unfortunately cargo isn't much help here. It can download crates for us, and we can set CARGO_HOME to force it to use a specific directory, but it doesn't return enough information to get the versions, etc. without some guessing/scraping to find the packaged source.
media/libstagefright/binding/byteorder-mod.patch
media/libstagefright/binding/mp4parse-mod.patch
media/libstagefright/binding/update-rust.sh
new file mode 100644
--- /dev/null
+++ b/media/libstagefright/binding/byteorder-mod.patch
@@ -0,0 +1,37 @@
+diff --git a/media/libstagefright/binding/byteorder/mod.rs b/media/libstagefright/binding/byteorder/mod.rs
+index 59ba692..9d2d1d5 100644
+--- a/media/libstagefright/binding/byteorder/mod.rs
++++ b/media/libstagefright/binding/byteorder/mod.rs
+@@ -36,16 +36,16 @@ assert_eq!(wtr, vec![5, 2, 0, 3]);
+ ```
+ */
+ 
+-#![crate_name = "byteorder"]
+ #![doc(html_root_url = "http://burntsushi.net/rustdoc/byteorder")]
+ 
+ #![deny(missing_docs)]
+ 
+ use std::mem::transmute;
+ 
+-pub use new::{ReadBytesExt, WriteBytesExt, Error, Result};
++pub use byteorder::new::{ReadBytesExt, WriteBytesExt, Error, Result};
+ 
+-mod new;
++// Re-export new so gecko can build us as a mod intead of a crate.
++pub mod new;
+ 
+ #[inline]
+ fn extend_sign(val: u64, nbytes: usize) -> i64 {
+diff --git a/media/libstagefright/binding/byteorder/new.rs b/media/libstagefright/binding/byteorder/new.rs
+index bbef0cd..a2e5393 100644
+--- a/media/libstagefright/binding/byteorder/new.rs
++++ b/media/libstagefright/binding/byteorder/new.rs
+@@ -3,7 +3,7 @@ use std::fmt;
+ use std::io;
+ use std::result;
+ 
+-use ByteOrder;
++use byteorder::ByteOrder;
+ 
+ /// A short-hand for `result::Result<T, byteorder::Error>`.
+ pub type Result<T> = result::Result<T, Error>;
new file mode 100644
--- /dev/null
+++ b/media/libstagefright/binding/mp4parse-mod.patch
@@ -0,0 +1,13 @@
+diff --git a/media/libstagefright/binding/MP4Metadata.rs b/media/libstagefright/binding/MP4Metadata.rs
+index a9ab567..b746f15 100644
+--- a/media/libstagefright/binding/MP4Metadata.rs
++++ b/media/libstagefright/binding/MP4Metadata.rs
+@@ -214,7 +214,7 @@ pub struct Track {
+     track_type: TrackType,
+ }
+ 
+-extern crate byteorder;
++mod byteorder; // 'extern crate' upstream.
+ use byteorder::{BigEndian, ReadBytesExt};
+ use std::io::{Read, BufRead, Take};
+ use std::io::Cursor;
new file mode 100755
--- /dev/null
+++ b/media/libstagefright/binding/update-rust.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Script to update mp4parse-rust sources to latest upstream
+
+# Default version.
+VER=v0.1.2
+
+# Accept version or commit from the command line.
+if test -n "$1"; then
+  VER=$1
+fi
+
+echo "Fetching sources..."
+rm -rf _upstream
+git clone https://github.com/mozilla/mp4parse-rust _upstream/mp4parse
+pushd _upstream/mp4parse
+git checkout ${VER}
+popd
+cp _upstream/mp4parse/src/lib.rs MP4Metadata.rs
+cp _upstream/mp4parse/src/capi.rs .
+
+# TODO: download deps from crates.io.
+
+git clone https://github.com/BurntSushi/byteorder _upstream/byteorder
+pushd _upstream/byteorder
+git checkout 0.3.13
+popd
+cp _upstream/byteorder/src/lib.rs byteorder/mod.rs
+cp _upstream/byteorder/src/new.rs byteorder/new.rs
+
+echo "Applying patches..."
+patch -p4 < byteorder-mod.patch
+patch -p4 < mp4parse-mod.patch
+
+echo "Cleaning up..."
+rm -rf _upstream
+
+echo "Updated to ${VER}."