diff options
author | Teddy Wing | 2020-10-03 18:24:56 +0200 |
---|---|---|
committer | Teddy Wing | 2020-10-03 18:24:56 +0200 |
commit | da94442fae40736859787575b65720382c1f231c (patch) | |
tree | 078a8f8748c2f307493ea46af0734ed39673d49c | |
parent | 90969d5e9defcd593c7acc416247cd7a6b04e532 (diff) | |
download | git-todo-da94442fae40736859787575b65720382c1f231c.tar.bz2 |
Build for release and configure static linkingv0.0.1
Set up a release build and distribution packaging. Configure static
linking for 'openssl' and 'libgit2'.
Based on or copied from code from 'git-suggestion'.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.lock | 10 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Makefile | 52 |
4 files changed, 62 insertions, 3 deletions
@@ -1 +1,2 @@ +/dist/ /target @@ -155,6 +155,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] +name = "openssl-src" +version = "111.11.0+1.1.1h" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380fe324132bea01f45239fadfec9343adb044615f29930d039bec1ae7b9fa5b" +dependencies = [ + "cc", +] + +[[package]] name = "openssl-sys" version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -163,6 +172,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -6,5 +6,5 @@ edition = "2018" [dependencies] exitcode = "1.1.2" getopts = "0.2.21" -git2 = "0.13.11" +git2 = { version = "0.13.11", features = ["vendored-openssl"] } thiserror = "1.0.20" @@ -14,15 +14,33 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. +VERSION := $(shell egrep '^version = ' Cargo.toml | awk -F '"' '{ print $$2 }') +TOOLCHAIN := $(shell fgrep default_host_triple $(HOME)/.rustup/settings.toml | awk -F '"' '{ print $$2 }') + SOURCES := $(shell find . -name '*.rs') DEPENDENCIES := Cargo.toml + +MAN_PAGE := doc/git-todo.1 + DEBUG_PRODUCT := target/debug/git-todo +RELEASE_PRODUCT := target/release/git-todo + +DIST := $(abspath dist) +DIST_PRODUCT := $(DIST)/bin/git-todo +DIST_MAN_PAGE := $(DIST)/share/man/man1/git-todo.1 + +# Set STATIC=1 to build a static binary. +STATIC ?= 0 + +ifeq ($(STATIC), 1) +BUILD_VARS += PKG_CONFIG_LIBDIR='' +endif .PHONY: doc -doc: doc/git-todo.1 +doc: $(MAN_PAGE) -doc/git-todo.1: doc/git-todo.1.txt +$(MAN_PAGE): doc/git-todo.1.txt sed 's/`/*/g' $< > $@.transformed a2x --no-xmllint --format manpage $@.transformed rm $@.transformed @@ -34,3 +52,33 @@ test: $(DEBUG_PRODUCT) $(DEBUG_PRODUCT): $(SOURCES) $(DEPENDENCIES) cargo build + + +$(RELEASE_PRODUCT): $(SOURCES) $(DEPENDENCIES) + $(BUILD_VARS) cargo build --release + + +.PHONY: dist +dist: $(DIST_PRODUCT) $(DIST_MAN_PAGE) + +$(DIST): + mkdir -p $@ + +$(DIST)/bin: $(DIST) + mkdir -p $@ + +$(DIST)/share/man/man1: $(DIST) + mkdir -p $@ + +$(DIST_PRODUCT): $(DIST)/bin $(RELEASE_PRODUCT) + cp $(RELEASE_PRODUCT) $< + +$(DIST_MAN_PAGE): $(DIST)/share/man/man1 $(MAN_PAGE) + cp $(MAN_PAGE) $< + + +.PHONY: pkg +pkg: git-todo_$(VERSION)_$(TOOLCHAIN).tar.bz2 + +git-todo_$(VERSION)_$(TOOLCHAIN).tar.bz2: dist + tar cjv -s /dist/git-todo_$(VERSION)_$(TOOLCHAIN)/ -f $@ dist |