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.
This commit is contained in:
Ralph Giles 2015-10-28 14:55:45 -07:00
Родитель 9e9747858c
Коммит 5ffe01b5a7
3 изменённых файлов: 87 добавлений и 0 удалений

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

@ -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>;

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

@ -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;

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

@ -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}."