2015-04-18 18:17:25 +00:00
|
|
|
TARGETDIR=../target/debug
|
|
|
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
2016-03-05 23:03:17 +00:00
|
|
|
SHELL=/bin/bash -o pipefail
|
|
|
|
|
2015-05-24 18:06:08 +00:00
|
|
|
ifndef PY
|
2015-10-25 16:55:29 +00:00
|
|
|
PY := $(word 2, $(subst ., ,$(shell python --version 2>&1)))
|
2015-05-24 18:06:08 +00:00
|
|
|
endif
|
2016-03-05 23:03:17 +00:00
|
|
|
ifndef NIGHTLY
|
|
|
|
ifeq ($(word 3, $(subst -, ,$(shell rustc --version 2>&1))),nightly)
|
|
|
|
NIGHTLY := 1
|
|
|
|
else
|
|
|
|
NIGHTLY := 0
|
|
|
|
endif
|
|
|
|
endif
|
2016-03-05 00:16:54 +00:00
|
|
|
|
2015-04-18 18:17:25 +00:00
|
|
|
all:
|
|
|
|
|
|
|
|
clean:
|
|
|
|
-rm *.so
|
|
|
|
-rm *.out
|
2016-03-06 12:33:57 +00:00
|
|
|
-rm *_expanded.rs
|
2015-04-18 18:17:25 +00:00
|
|
|
-rm -r stamps
|
|
|
|
|
|
|
|
stamps:
|
|
|
|
mkdir stamps
|
|
|
|
|
2015-05-24 18:06:08 +00:00
|
|
|
stamps/rust-cpython-$(PY): $(call rwildcard,../src,*.rs) Makefile | stamps
|
|
|
|
-rm stamps/rust-cpython-*
|
|
|
|
cd .. && make build PY=$(PY)
|
2015-04-18 18:17:25 +00:00
|
|
|
touch $@
|
|
|
|
|
2015-05-24 18:06:08 +00:00
|
|
|
%.so: %.rs stamps/rust-cpython-$(PY)
|
2016-03-06 09:29:28 +00:00
|
|
|
rustc $< -g -L $(TARGETDIR) -L $(TARGETDIR)/deps -o $@
|
|
|
|
|
|
|
|
%_expanded.rs: %.rs stamps/rust-cpython-$(PY)
|
|
|
|
rustc $< -g -L $(TARGETDIR) -L $(TARGETDIR)/deps -Z unstable-options --pretty=expanded -o $@
|
2015-04-18 18:17:25 +00:00
|
|
|
|
|
|
|
hello.out: hello.so
|
2015-05-24 18:06:08 +00:00
|
|
|
python$(PY) -c "import hello; hello.run(hello.val())" 2>&1 | tee $@
|
2015-04-18 18:17:25 +00:00
|
|
|
|
|
|
|
all: stamps/test-hello
|
|
|
|
stamps/test-hello: hello.out
|
|
|
|
@grep "Rust says: Hello Python!" hello.out >/dev/null
|
|
|
|
@grep "Rust got 42" hello.out >/dev/null
|
2016-04-17 13:53:57 +00:00
|
|
|
@touch $@
|
2015-04-18 18:17:25 +00:00
|
|
|
|
2016-03-06 05:29:43 +00:00
|
|
|
custom_class.out: custom_class.so
|
|
|
|
python$(PY) -c "import custom_class; custom_class.MyType(42).a()" 2>&1 | tee $@
|
|
|
|
|
2016-04-17 13:53:57 +00:00
|
|
|
all: stamps/test-custom_class
|
2016-03-06 05:29:43 +00:00
|
|
|
stamps/test-custom_class: custom_class.out
|
|
|
|
@grep "a() was called with self=42" custom_class.out >/dev/null
|
2016-04-17 13:53:57 +00:00
|
|
|
@touch $@
|
2016-03-06 05:29:43 +00:00
|
|
|
|
2016-04-17 21:26:33 +00:00
|
|
|
all: stamps/test-btree
|
2016-04-17 13:53:57 +00:00
|
|
|
stamps/test-btree: test_btree.py btree.so
|
|
|
|
python$(PY) test_btree.py
|
|
|
|
@touch $@
|
2015-04-18 18:17:25 +00:00
|
|
|
|