From 1956589a554d085efe46cd18e66a1d1114718506 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Wed, 27 Aug 2014 21:34:06 -0600 Subject: [PATCH] Cargoify rust-mozjs --- .gitignore | 2 ++ Cargo.toml | 12 ++++++++++++ Makefile.in | 10 +++++----- makefile.cargo | 19 +++++++++++++++++++ glue.rs => src/glue.rs | 0 jsapi.rs => src/jsapi.rs | 0 jsfriendapi.rs => src/jsfriendapi.rs | 0 jsglue.cpp => src/jsglue.cpp | 0 jsval.rs => src/jsval.rs | 0 js.rc => src/lib.rs | 0 linkhack.rs => src/linkhack.rs | 0 rust.rs => src/rust.rs | 0 trace.rs => src/trace.rs | 0 13 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Cargo.toml create mode 100644 makefile.cargo rename glue.rs => src/glue.rs (100%) rename jsapi.rs => src/jsapi.rs (100%) rename jsfriendapi.rs => src/jsfriendapi.rs (100%) rename jsglue.cpp => src/jsglue.cpp (100%) rename jsval.rs => src/jsval.rs (100%) rename js.rc => src/lib.rs (100%) rename linkhack.rs => src/linkhack.rs (100%) rename rust.rs => src/rust.rs (100%) rename trace.rs => src/trace.rs (100%) diff --git a/.gitignore b/.gitignore index 20fa88f9d..8c57a5f96 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ libmozjs.so *~ js /doc +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..f16bed168 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] + +name = "js" +version = "0.1.0" +authors = ["The Servo Project Developers"] + +build = "make -f makefile.cargo" + +[dependencies.mozjs-sys] + +git = "https://github.com/servo/mozjs" + diff --git a/Makefile.in b/Makefile.in index 4cb978c74..df1f09aa6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,28 +14,28 @@ ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1) CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof endif -RUST_SRC = $(shell find $(VPATH)/. -type f -name '*.rs') +RUST_SRC = $(shell find $(VPATH)/src -type f -name '*.rs') .PHONY: all all: libjs.dummy -libjs.dummy: js.rc $(RUST_SRC) libjsglue.a $(EXT_DEPS) +libjs.dummy: src/lib.rs $(RUST_SRC) libjsglue.a $(EXT_DEPS) $(RUSTC) $(RUSTFLAGS) $< --out-dir . touch $@ -js-test: js.rc $(RUST_SRC) libjsglue.a +js-test: src/lib.rs $(RUST_SRC) libjsglue.a $(RUSTC) $(RUSTFLAGS) $< -o $@ --test libjsglue.a: jsglue.o $(AR) rcs libjsglue.a jsglue.o -jsglue.o: jsglue.cpp +jsglue.o: src/jsglue.cpp $(CXX) $(CFLAGS) -fno-rtti $< -o $@ -c .PHONY: doc doc: $(RUSTDOC_TARGET)/js/index.html -$(RUSTDOC_TARGET)/js/index.html: js.rc $(RUST_SRC) libjsglue.a $(EXT_DEPS) +$(RUSTDOC_TARGET)/js/index.html: src/lib.rs $(RUST_SRC) libjsglue.a $(EXT_DEPS) $(RUSTDOC) $(RUSTDOC_FLAGS) $< -o $(RUSTDOC_TARGET) check: js-test diff --git a/makefile.cargo b/makefile.cargo new file mode 100644 index 000000000..769ebcd5f --- /dev/null +++ b/makefile.cargo @@ -0,0 +1,19 @@ +CXX ?= g++ +AR ?= ar +CFLAGS += -fPIC + +ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1) +CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof +endif + +MOZJS_OUTDIR = $(shell find $(OUT_DIR)/.. -name 'mozjs-sys-*' -type d) +CFLAGS += -I$(MOZJS_OUTDIR)/dist/include + +.PHONY: all +all: $(OUT_DIR)/libjsglue.a + +$(OUT_DIR)/libjsglue.a: $(OUT_DIR)/jsglue.o + $(AR) rcs $@ $^ + +$(OUT_DIR)/jsglue.o: src/jsglue.cpp + $(CXX) $(CFLAGS) -fno-rtti $< -o $@ -c diff --git a/glue.rs b/src/glue.rs similarity index 100% rename from glue.rs rename to src/glue.rs diff --git a/jsapi.rs b/src/jsapi.rs similarity index 100% rename from jsapi.rs rename to src/jsapi.rs diff --git a/jsfriendapi.rs b/src/jsfriendapi.rs similarity index 100% rename from jsfriendapi.rs rename to src/jsfriendapi.rs diff --git a/jsglue.cpp b/src/jsglue.cpp similarity index 100% rename from jsglue.cpp rename to src/jsglue.cpp diff --git a/jsval.rs b/src/jsval.rs similarity index 100% rename from jsval.rs rename to src/jsval.rs diff --git a/js.rc b/src/lib.rs similarity index 100% rename from js.rc rename to src/lib.rs diff --git a/linkhack.rs b/src/linkhack.rs similarity index 100% rename from linkhack.rs rename to src/linkhack.rs diff --git a/rust.rs b/src/rust.rs similarity index 100% rename from rust.rs rename to src/rust.rs diff --git a/trace.rs b/src/trace.rs similarity index 100% rename from trace.rs rename to src/trace.rs