-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
synocli-file: add ripgrep, initial rust support (#3883)
* ripgrep: initial package v. 11.0.2 This also adds support for building rust packages. * update ripgrep to v13.0.0 * build with pcre2 feature * enhance rust build - install cargo to /opt/cargo - download additional rust targets * Add rust build to framework - add common Makefile for rust build and installation - install rust targets on demand - remove rust target installation from Dockerfile * Add ripgrep to synocli-file - add ripgrep to synocli-file - move spk/ripgrep to diyspk/ripgrep * enhance rust Makefile - allow to define other release channel than 'stable' - allow to define additional cargo build args * Install rustup when compiling package. * ripgrep: include build for ARMv7L Co-authored-by: hgy59 <[email protected]> Co-authored-by: etcusrvar <[email protected]>
- Loading branch information
1 parent
55a15e8
commit bab9528
Showing
8 changed files
with
240 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
PKG_NAME = ripgrep | ||
PKG_VERS = 13.0.0 | ||
PKG_EXT = tar.gz | ||
PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT) | ||
PKG_DIST_SITE = https://github.com/BurntSushi/ripgrep/archive | ||
PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) | ||
PKG_DIR = $(PKG_NAME)-$(PKG_VERS) | ||
|
||
DEPENDS = | ||
|
||
# powerpc archs (except qoriq) are not supported | ||
UNSUPPORTED_ARCHS += $(OLD_PPC_ARCHS) | ||
|
||
HOMEPAGE = https://github.com/BurntSushi/ripgrep | ||
COMMENT = ripgrep recursively searches directories for a regex pattern | ||
LICENSE = public domain/Unlicense | ||
|
||
CARGO_BUILD_ARGS += --features 'pcre2' | ||
|
||
include ../../mk/spksrc.cross-rust.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin:bin/rg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ripgrep-13.0.0.tar.gz SHA1 1e67603fbc5dd955d0f65fb6ea3c380145fbcb01 | ||
ripgrep-13.0.0.tar.gz SHA256 0fb17aaf285b3eee8ddab17b833af1e190d73de317ff9648751ab0660d763ed2 | ||
ripgrep-13.0.0.tar.gz MD5 3080265a3ccc09bdc0c81527b09afa15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SPK_NAME = ripgrep | ||
SPK_VERS = 13.0.0 | ||
SPK_REV = 1 | ||
SPK_ICON = src/ripgrep.png | ||
|
||
DEPENDS = cross/$(SPK_NAME) | ||
|
||
# powerpc archs (except qoriq) are not supported | ||
UNSUPPORTED_ARCHS += $(OLD_PPC_ARCHS) | ||
|
||
MAINTAINER = Hylen | ||
DESCRIPTION = ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. | ||
DISPLAY_NAME = ripgrep | ||
STARTABLE = no | ||
|
||
SPK_COMMANDS = bin/rg | ||
|
||
HOMEPAGE = https://github.com/BurntSushi/ripgrep | ||
LICENSE = public domain/Unlicense | ||
|
||
include ../../mk/spksrc.spk.mk |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
# Build rust programs | ||
# | ||
# prerequisites: | ||
# - module does not require kernel (REQUIRE_KERNEL) | ||
# | ||
# remarks: | ||
# - most content is taken from spksrc.cc.mk and modified for rust | ||
# - CONFIGURE_TARGET is not supported (used for rust target installation) | ||
# - build and install is done in one step | ||
# | ||
|
||
# Common makefiles | ||
include ../../mk/spksrc.common.mk | ||
include ../../mk/spksrc.directories.mk | ||
|
||
# Configure the included makefiles | ||
URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) | ||
NAME = $(PKG_NAME) | ||
COOKIE_PREFIX = $(PKG_NAME)- | ||
ifneq ($(PKG_DIST_FILE),) | ||
LOCAL_FILE = $(PKG_DIST_FILE) | ||
else | ||
LOCAL_FILE = $(PKG_DIST_NAME) | ||
endif | ||
DIST_FILE = $(DISTRIB_DIR)/$(LOCAL_FILE) | ||
DIST_EXT = $(PKG_EXT) | ||
|
||
ifneq ($(ARCH),) | ||
ARCH_SUFFIX = -$(ARCH)-$(TCVERSION) | ||
TC = syno$(ARCH_SUFFIX) | ||
endif | ||
|
||
##### rust specific configurations | ||
|
||
# configure is used to install rust targets | ||
CONFIGURE_TARGET = install_rust_target | ||
|
||
# skip compile_target if not used by module | ||
ifeq ($(strip $(COMPILE_TARGET)),) | ||
COMPILE_TARGET = nop | ||
endif | ||
|
||
RUST_TOOLCHAIN ?= stable | ||
|
||
RUST_TARGET = | ||
# map archs to rust targets | ||
ifeq ($(findstring $(ARCH), $(x64_ARCHS)),$(ARCH)) | ||
RUST_TARGET=x86_64-unknown-linux-gnu | ||
endif | ||
ifeq ($(findstring $(ARCH), $(i686_ARCHS)),$(ARCH)) | ||
RUST_TARGET=i686-unknown-linux-gnu | ||
endif | ||
ifeq ($(findstring $(ARCH), $(ARMv5_ARCHS)),$(ARCH)) | ||
# may be not supported for cargo | ||
RUST_TARGET=armv5te-unknown-linux-gnueabi | ||
endif | ||
ifeq ($(findstring $(ARCH), $(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH)) | ||
RUST_TARGET=armv7-unknown-linux-gnueabihf | ||
endif | ||
ifeq ($(findstring $(ARCH), $(ARMv7L_ARCHS)),$(ARCH)) | ||
RUST_TARGET=armv7-unknown-linux-gnueabi | ||
endif | ||
ifeq ($(findstring $(ARCH), $(ARMv8_ARCHS)),$(ARCH)) | ||
RUST_TARGET=aarch64-unknown-linux-gnu | ||
endif | ||
ifeq ($(findstring $(ARCH), $(PPC_ARCHS)),$(ARCH)) | ||
RUST_TARGET=powerpc-unknown-linux-gnu | ||
endif | ||
ifeq ($(RUST_TARGET),) | ||
$(error Arch $(ARCH) not supported) | ||
endif | ||
|
||
# Use distrib folder as cargo download cache | ||
CARGO_HOME_PATH=/spksrc/distrib/cargo | ||
ENV += CARGO_HOME=$(CARGO_HOME_PATH) | ||
ENV += PATH=:$(CARGO_HOME_PATH)/bin/:$(PATH) | ||
|
||
ifeq (,$(shell $(ENV) which rustup)) | ||
install_rustup: | ||
@echo " ==> install rustup" ; \ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ | ||
CARGO_HOME=$(CARGO_HOME_PATH) sh -s -- -y | ||
else | ||
install_rustup: | ||
@echo " ==> rustup already installed" ; | ||
endif | ||
|
||
install_rust_toolchain: install_rustup | ||
@echo " ==> install rust toolchain [$(RUST_TOOLCHAIN)]" ; \ | ||
env $(ENV) rustup toolchain install $(RUST_TOOLCHAIN) ; | ||
env $(ENV) rustup default $(RUST_TOOLCHAIN) ; | ||
|
||
# Install rust target on demand: | ||
install_rust_target: install_rust_toolchain | ||
@echo " ==> install rust target [$(RUST_TARGET)]" ; \ | ||
env $(ENV) rustup target install $(RUST_TARGET) ; | ||
|
||
# Set default RUST_SRC_DIR | ||
ifeq ($(strip $(RUST_SRC_DIR)),) | ||
RUST_SRC_DIR = $(WORK_DIR)/$(PKG_DIR) | ||
endif | ||
|
||
# Set linker environment variable | ||
RUST_LINKER_ENV=CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_LINKER | ||
CARGO_ENV=$(RUST_LINKER_ENV)=$(TC_PATH)$(TC_PREFIX)gcc | ||
|
||
# Set the cargo parameters | ||
CARGO_BUILD_ARGS += --target=$(RUST_TARGET) | ||
CARGO_BUILD_ARGS += --path $(RUST_SRC_DIR) | ||
CARGO_BUILD_ARGS += --root $(STAGING_INSTALL_PREFIX) | ||
|
||
|
||
ifeq ($(strip $(INSTALL_TARGET)),) | ||
INSTALL_TARGET = rust_build_and_install_target | ||
endif | ||
|
||
# Default rust build and installation with cargo | ||
rust_build_and_install_target: | ||
@echo " ==> Cargo install rust package $(PKG_NAME)" | ||
$(ENV) $(CARGO_ENV) cargo install $(CARGO_BUILD_ARGS) | ||
|
||
|
||
##### | ||
|
||
include ../../mk/spksrc.pre-check.mk | ||
|
||
include ../../mk/spksrc.cross-env.mk | ||
|
||
include ../../mk/spksrc.download.mk | ||
|
||
include ../../mk/spksrc.depend.mk | ||
|
||
checksum: download | ||
include ../../mk/spksrc.checksum.mk | ||
|
||
extract: checksum depend | ||
include ../../mk/spksrc.extract.mk | ||
|
||
patch: extract | ||
include ../../mk/spksrc.patch.mk | ||
|
||
configure: patch | ||
include ../../mk/spksrc.configure.mk | ||
|
||
compile: configure | ||
include ../../mk/spksrc.compile.mk | ||
|
||
install: compile | ||
include ../../mk/spksrc.install.mk | ||
|
||
plist: install | ||
include ../../mk/spksrc.plist.mk | ||
|
||
### Clean rules | ||
smart-clean: | ||
rm -rf $(WORK_DIR)/$(PKG_DIR) | ||
rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* | ||
|
||
clean: | ||
rm -fr work work-* | ||
|
||
all: install plist | ||
|
||
### For make kernel-required (used by spksrc.spk.mk) | ||
include ../../mk/spksrc.kernel-required.mk | ||
|
||
### For make digests | ||
include ../../mk/spksrc.generate-digests.mk | ||
|
||
### For make dependency-tree | ||
include ../../mk/spksrc.dependency-tree.mk | ||
|
||
.PHONY: all-archs | ||
all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) | ||
|
||
#### | ||
|
||
arch-%: | ||
@$(MSG) Building package for arch $* | ||
-@MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) | ||
|
||
#### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters