From 11f8e29e17af6f68ac7803c0ab293e125f693dad Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 14 Feb 2014 07:18:10 +1100 Subject: [PATCH] Add Makefile and enable rust-ci doc export --- .gitignore | 8 ++--- .travis.yml | 33 +++++++++++++++---- Makefile | 83 +++++++++++++++++++++++++++++++++++++++++++++++ src/cgmath/lib.rs | 3 +- 4 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 150fbbd..95053da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -.rust -bin -build -lib +/lib/ +/bench/ +/test/ +/doc/ diff --git a/.travis.yml b/.travis.yml index b0da575..73f6c03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,33 @@ +# Copyright 2014 The CGMath Developers. For a full listing of the authors, +# refer to the AUTHORS file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +env: + global: + - secure: N41M4QTWbez7FRMh2HQqB3Z051FcruoRGLTdMdQJNMaZRqJiAfUBTO5NGXS5XGjIofknE4r/+WLv7KED2rTf6nvLFOHmGY2pL+agABcyD0DU0ltRLckjONWTxFN+SMTB0l38v3XIXxXX5y977Hl6wk3++kYZgCNVG3OTkJwWzQg= before_install: - yes | sudo add-apt-repository ppa:hansjorg/rust - sudo apt-get update install: - sudo apt-get install rust-nightly script: - - mkdir -p lib bin - - rustc --out-dir lib ./src/cgmath/lib.rs - - rustc --out-dir bin --test -L ./lib ./src/test/test.rs - - rustc --out-dir bin --test -L ./lib ./src/bench/bench.rs - - ./bin/test -# - ./bin/bench --bench + - make +# - make check # bench is too slow + - make test + - sudo make install + - sudo make uninstall + - make clean + - make doc +after_script: + - curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..49361cc --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +# Copyright 2014 The CGMath Developers. For a full listing of the authors, +# refer to the AUTHORS file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +RUSTC = rustc +RUSTDOC = rustdoc + +SRC_DIR = src +LIB_FILE = $(SRC_DIR)/cgmath/lib.rs +TEST_FILE = $(SRC_DIR)/test/test.rs +BENCH_FILE = $(SRC_DIR)/bench/bench.rs + +CRATE_NAME = $(shell $(RUSTC) --crate-name $(LIB_FILE)) +CRATE_FILES = $(shell $(RUSTC) --crate-file-name $(LIB_FILE)) + +LIB_DIR = lib +TEST_DIR = test +BENCH_DIR = bench +DOC_DIR = doc + +INSTALL_PREFIX = /usr/local +LIB_INSTALL_DIR = $(INSTALL_PREFIX)/lib + +all: lib doc + +lib: + mkdir -p $(LIB_DIR) + $(RUSTC) --out-dir=$(LIB_DIR) -O $(LIB_FILE) + +test: lib + mkdir -p $(TEST_DIR) + $(RUSTC) -L $(LIB_DIR) --out-dir=$(TEST_DIR) --test $(TEST_FILE) + $(TEST_DIR)/test + +bench: lib + mkdir -p $(BENCH_DIR) + $(RUSTC) -L $(LIB_DIR) --out-dir=$(BENCH_DIR) -O --test $(BENCH_FILE) + $(BENCH_DIR)/bench --bench + +check: test bench + +doc: + mkdir -p $(DOC_DIR) + $(RUSTDOC) -o $(DOC_DIR) $(LIB_FILE) + +install: lib + @ $(foreach crate, $(CRATE_FILES), \ + cp $(LIB_DIR)/$(crate) $(LIB_INSTALL_DIR)/$(crate) && \ + echo "Installed $(crate) to $(LIB_INSTALL_DIR)" ; \ + ) + +uninstall: + @-rm -f $(LIB_INSTALL_DIR)/lib$(CRATE_NAME)-*.rlib ||: + @-rm -f $(LIB_INSTALL_DIR)/lib$(CRATE_NAME)-*.so ||: + @-rm -f $(LIB_INSTALL_DIR)/lib$(CRATE_NAME)-*.dylib ||: + +clean: + rm -rf $(LIB_DIR) + rm -rf $(TEST_DIR) + rm -rf $(BENCH_DIR) + rm -rf $(DOC_DIR) + +.PHONY: \ + all \ + lib \ + test \ + bench \ + check \ + doc \ + install \ + uninstall \ + clean diff --git a/src/cgmath/lib.rs b/src/cgmath/lib.rs index 726a805..3ceb124 100644 --- a/src/cgmath/lib.rs +++ b/src/cgmath/lib.rs @@ -14,7 +14,8 @@ // limitations under the License. #[crate_id="cgmath#0.1"]; -#[crate_type = "lib"]; +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; #[comment = "A mathematics library for computer graphics."]; #[license = "ASL2"];