libssh2: update to 1.11.0
[feed/packages.git] / lang / rust / rust-package.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2023 Luca Barbato and Donald Hoskins
4
5 # Variables (all optional) to be set in package Makefiles:
6 #
7 # RUST_PKG_FEATURES - list of options, default empty
8 #
9 # Space or comma separated list of features to activate
10 #
11 # e.g. RUST_PKG_FEATURES:=enable-foo,with-bar
12
13 ifeq ($(origin RUST_INCLUDE_DIR),undefined)
14 RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
15 endif
16 include $(RUST_INCLUDE_DIR)/rust-values.mk
17
18 CARGO_PKG_VARS= \
19 $(CARGO_PKG_CONFIG_VARS) \
20 CC=$(HOSTCC_NOCACHE) \
21 MAKEFLAGS="$(PKG_JOBS)"
22
23 # $(1) path to the package (optional)
24 # $(2) additional arguments to cargo (optional)
25 define Build/Compile/Cargo
26 +$(CARGO_PKG_VARS) \
27 cargo install -v \
28 --profile $(CARGO_PKG_PROFILE) \
29 $(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
30 --root $(PKG_INSTALL_DIR) \
31 --path "$(PKG_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \
32 $(if $(filter --jobserver%,$(PKG_JOBS)),,-j1) \
33 $(2)
34 endef
35
36 define RustBinPackage
37 ifndef Package/$(1)/install
38 define Package/$(1)/install
39 $$(INSTALL_DIR) $$(1)/usr/bin/
40 $$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/bin/* $$(1)/usr/bin/
41 endef
42 endif
43 endef
44
45 Build/Compile=$(call Build/Compile/Cargo)