Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit 1956589

Browse files
committed
Cargoify rust-mozjs
1 parent 5c14ef4 commit 1956589

13 files changed

Lines changed: 38 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ libmozjs.so
22
*~
33
js
44
/doc
5+
/target
6+
/Cargo.lock

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
3+
name = "js"
4+
version = "0.1.0"
5+
authors = ["The Servo Project Developers"]
6+
7+
build = "make -f makefile.cargo"
8+
9+
[dependencies.mozjs-sys]
10+
11+
git = "https://github.com/servo/mozjs"
12+

Makefile.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1)
1414
CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof
1515
endif
1616

17-
RUST_SRC = $(shell find $(VPATH)/. -type f -name '*.rs')
17+
RUST_SRC = $(shell find $(VPATH)/src -type f -name '*.rs')
1818

1919
.PHONY: all
2020
all: libjs.dummy
2121

22-
libjs.dummy: js.rc $(RUST_SRC) libjsglue.a $(EXT_DEPS)
22+
libjs.dummy: src/lib.rs $(RUST_SRC) libjsglue.a $(EXT_DEPS)
2323
$(RUSTC) $(RUSTFLAGS) $< --out-dir .
2424
touch $@
2525

26-
js-test: js.rc $(RUST_SRC) libjsglue.a
26+
js-test: src/lib.rs $(RUST_SRC) libjsglue.a
2727
$(RUSTC) $(RUSTFLAGS) $< -o $@ --test
2828

2929
libjsglue.a: jsglue.o
3030
$(AR) rcs libjsglue.a jsglue.o
3131

32-
jsglue.o: jsglue.cpp
32+
jsglue.o: src/jsglue.cpp
3333
$(CXX) $(CFLAGS) -fno-rtti $< -o $@ -c
3434

3535
.PHONY: doc
3636
doc: $(RUSTDOC_TARGET)/js/index.html
3737

38-
$(RUSTDOC_TARGET)/js/index.html: js.rc $(RUST_SRC) libjsglue.a $(EXT_DEPS)
38+
$(RUSTDOC_TARGET)/js/index.html: src/lib.rs $(RUST_SRC) libjsglue.a $(EXT_DEPS)
3939
$(RUSTDOC) $(RUSTDOC_FLAGS) $< -o $(RUSTDOC_TARGET)
4040

4141
check: js-test

makefile.cargo

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CXX ?= g++
2+
AR ?= ar
3+
CFLAGS += -fPIC
4+
5+
ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1)
6+
CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof
7+
endif
8+
9+
MOZJS_OUTDIR = $(shell find $(OUT_DIR)/.. -name 'mozjs-sys-*' -type d)
10+
CFLAGS += -I$(MOZJS_OUTDIR)/dist/include
11+
12+
.PHONY: all
13+
all: $(OUT_DIR)/libjsglue.a
14+
15+
$(OUT_DIR)/libjsglue.a: $(OUT_DIR)/jsglue.o
16+
$(AR) rcs $@ $^
17+
18+
$(OUT_DIR)/jsglue.o: src/jsglue.cpp
19+
$(CXX) $(CFLAGS) -fno-rtti $< -o $@ -c
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)