From 05eee44039fb1f099f78abaab4eec9bd014be8ee Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Thu, 29 Aug 2019 19:41:42 +0100 Subject: newapkbuild: add rust support --- newapkbuild.in | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/newapkbuild.in b/newapkbuild.in index f0dc911..76fd7ab 100644 --- a/newapkbuild.in +++ b/newapkbuild.in @@ -104,6 +104,12 @@ build_python() { __EOF__ } +build_rust() { + cat >>APKBUILD<<__EOF__ + cargo build --release +__EOF__ +} + build_empty() { cat >>APKBUILD<<__EOF__ # Replace with proper build command(s) @@ -137,6 +143,12 @@ check_meson() { __EOF__ } +check_rust() { + cat >>APKBUILD<<__EOF__ + cargo test --release +__EOF__ +} + # Package sections package_make() { cat >>APKBUILD<<__EOF__ @@ -174,6 +186,13 @@ package_empty() { __EOF__ } +package_rust() { + cat >>APKBUILD<<__EOF__ + cargo install --path . --root="\$pkgdir/usr" + rm "\$pkgdir"/usr/.crates.toml +__EOF__ +} + # Create new aport from templates newaport() { local newname="${1##*/}" @@ -216,6 +235,7 @@ newaport() { python) makedepends="py3-setuptools";; cmake) makedepends="cmake";; meson) makedepends="meson";; + rust) makedepends="cargo";; *) makedepends="\$depends_dev";; esac @@ -288,6 +308,8 @@ __EOF__ buildtype="make" elif [ -r "$sdir"/setup.py ]; then buildtype="python" + elif [ -r "$sdir"/Cargo.toml ]; then + buildtype="rust" fi fi @@ -309,6 +331,8 @@ __EOF__ build_perl;; python) build_python;; + rust) + build_rust;; *) build_empty;; esac @@ -328,6 +352,8 @@ __EOF__ check_make;; python) check_python;; + rust) + check_rust;; *) check_empty;; esac @@ -353,6 +379,8 @@ __EOF__ package_perl;; python) package_python;; + rust) + package_rust;; *) package_empty;; esac @@ -379,7 +407,7 @@ usage() { cat >&2 <<-__EOF__ $program $program_version - generate a new APKBUILD Usage: $program [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL] - [-a | -C | -m | -p | -y] [-s] [-c] [-f] [-h] + [-a | -C | -m | -p | -y | -r] [-s] [-c] [-f] [-h] PKGNAME[-PKGVER] | SRCURL Options: -n Set package name to PKGNAME (only use with SRCURL) @@ -392,6 +420,7 @@ usage() { -m Create meson package (Assume meson.build is there) -p Create perl package (Assume Makefile.PL is there) -y Create python package (Assume setup.py is there) + -r Crate rust package (Assume Cargo.toml is there) -s Use sourceforge source URL -c Copy a sample init.d, conf.d, and install script -f Force even if directory already exists @@ -427,7 +456,7 @@ check_arguments() { fi } -while getopts "acCmd:fhl:n:pyu:s" opt; do +while getopts "acCmd:fhl:n:pyu:sr" opt; do case $opt in 'a') set_buildtype "autotools";; 'c') cpinitd=1;; @@ -440,6 +469,7 @@ while getopts "acCmd:fhl:n:pyu:s" opt; do 'n') pkgname="$OPTARG";; 'p') set_buildtype "perl";; 'y') set_buildtype "python";; + 'r') set_buildtype "rust";; 'u') url="$OPTARG";; 's') sourceforge=1;; esac -- cgit v1.2.3-70-g09d2