Skip to content

Commit

Permalink
Merge Official Source
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Oct 20, 2023
2 parents 37eea02 + 985d0af commit 10e6e85
Show file tree
Hide file tree
Showing 46 changed files with 2,101 additions and 248 deletions.
1 change: 1 addition & 0 deletions admin/bottom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE

PKG_BUILD_DEPENDS:=rust/host
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
Expand Down
4 changes: 2 additions & 2 deletions lang/golang/golang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk

GO_VERSION_MAJOR_MINOR:=1.21
GO_VERSION_PATCH:=2
GO_VERSION_PATCH:=3

PKG_NAME:=golang
PKG_VERSION:=$(GO_VERSION_MAJOR_MINOR)$(if $(GO_VERSION_PATCH),.$(GO_VERSION_PATCH))
Expand All @@ -21,7 +21,7 @@ GO_SOURCE_URLS:=https://dl.google.com/go/ \

PKG_SOURCE:=go$(PKG_VERSION).src.tar.gz
PKG_SOURCE_URL:=$(GO_SOURCE_URLS)
PKG_HASH:=45e59de173baec39481854490d665b726cec3e5b159f6b4172e5ec7780b2c201
PKG_HASH:=186f2b6f8c8b704e696821b09ab2041a5c1ee13dcbc3156a13adcf75931ee488

PKG_MAINTAINER:=Jeffery To <[email protected]>
PKG_LICENSE:=BSD-3-Clause
Expand Down
1 change: 1 addition & 0 deletions lang/maturin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=license-apache license-mit

HOST_BUILD_DEPENDS:=rust/host
HOST_BUILD_PARALLEL:=1
PKG_HOST_ONLY:=1

include $(INCLUDE_DIR)/host-build.mk
Expand Down
2 changes: 1 addition & 1 deletion lang/python/python-setuptools-rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=python-setuptools-rust
PKG_VERSION:=1.7.0
PKG_RELEASE:=1
PKG_RELEASE:=2

PYPI_NAME:=setuptools-rust
PKG_HASH:=c7100999948235a38ae7e555fe199aa66c253dc384b125f5d85473bf81eae3a3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From b10cab4efeb80abb5a236d651c9ff9355e470527 Mon Sep 17 00:00:00 2001
From: Jeffery To <[email protected]>
Date: Mon, 2 Oct 2023 16:13:51 +0800
Subject: [PATCH] Allow profile to be set by SETUPTOOLS_RUST_CARGO_PROFILE env
variable

This allows the profile to be set dynamically, without having to edit
pyproject.toml/setup.py.
---
setuptools_rust/build.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

--- a/setuptools_rust/build.py
+++ b/setuptools_rust/build.py
@@ -528,10 +528,10 @@ class build_rust(RustCommand):
if target_triple is not None:
args.extend(["--target", target_triple])

- if release:
- profile = ext.get_cargo_profile()
- if not profile:
- args.append("--release")
+ ext_profile = ext.get_cargo_profile()
+ env_profile = os.getenv("SETUPTOOLS_RUST_CARGO_PROFILE")
+ if release and not ext_profile and not env_profile:
+ args.append("--release")

if quiet:
args.append("-q")
@@ -552,6 +552,18 @@ class build_rust(RustCommand):
if ext.args is not None:
args.extend(ext.args)

+ if env_profile:
+ if ext_profile:
+ args = [p for p in args if not p.startswith("--profile=")]
+ while True:
+ try:
+ index = args.index("--profile")
+ del args[index:index + 2]
+ except ValueError:
+ break
+
+ args.extend(["--profile", env_profile])
+
if ext.cargo_manifest_args is not None:
args.extend(ext.cargo_manifest_args)

6 changes: 3 additions & 3 deletions lang/python/python-zope-interface/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=python-zope-interface
PKG_VERSION:=6.0
PKG_VERSION:=6.1
PKG_RELEASE:=1

PYPI_NAME:=zope.interface
PKG_HASH:=aab584725afd10c710b8f1e6e208dbee2d0ad009f57d674cb9d1b3964037275d
PKG_HASH:=2fdc7ccbd6eb6b7df5353012fbed6c3c5d04ceaca0038f75e601060e95345309

PKG_LICENSE:=ZPL-2.1
PKG_LICENSE_FILES:=LICENSE.txt
Expand All @@ -29,7 +29,7 @@ define Package/python3-zope-interface
SUBMENU:=Python
TITLE:=Interfaces for Python
URL:=https://github.com/zopefoundation/zope.interface
DEPENDS:=+python3-light
DEPENDS:=+python3-light +python3-logging
endef

define Package/python3-zope-interface/description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/setup.py
+++ b/setup.py
@@ -124,7 +124,7 @@ setup(name='zope.interface',
@@ -125,7 +125,7 @@ setup(name='zope.interface',
"Framework :: Zope :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand All @@ -9,7 +9,7 @@
package_dir={'': 'src'},
namespace_packages=["zope"],
cmdclass={
@@ -132,6 +132,7 @@ setup(name='zope.interface',
@@ -133,6 +133,7 @@ setup(name='zope.interface',
},
test_suite='zope.interface.tests',
include_package_data=True,
Expand Down
5 changes: 5 additions & 0 deletions lang/python/python-zope-interface/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

[ "$1" = python3-zope-interface ] || exit 0

python3 -c 'import zope.interface'
4 changes: 2 additions & 2 deletions lang/python/python3-host.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ HOST_PYTHON3_VARS = \
CFLAGS="$(HOST_CFLAGS)" \
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib" \
CARGO_HOME="$(CARGO_HOME)" \
PATH="$(CARGO_HOME)/bin:$(PATH)"
$(CARGO_HOST_CONFIG_VARS) \
SETUPTOOLS_RUST_CARGO_PROFILE="$(CARGO_HOST_PROFILE)"

# $(1) => directory of python script
# $(2) => python script and its arguments
Expand Down
6 changes: 2 additions & 4 deletions lang/python/python3-package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ PYTHON3_VARS = \
_python_sysroot="$(STAGING_DIR)" \
_python_prefix="/usr" \
_python_exec_prefix="/usr" \
CARGO_BUILD_TARGET="$(RUSTC_TARGET_ARCH)" \
CARGO_HOME="$(CARGO_HOME)" \
PATH="$(CARGO_HOME)/bin:$(PATH)" \
$(CARGO_PKG_CONFIG_VARS) \
PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)" \
RUSTFLAGS="$(CARGO_RUSTFLAGS)"
SETUPTOOLS_RUST_CARGO_PROFILE="$(CARGO_PKG_PROFILE)"

# $(1) => directory of python script
# $(2) => python script and its arguments
Expand Down
15 changes: 15 additions & 0 deletions lang/rust/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
menu "Configuration options (for developers)"

config RUST_SCCACHE
bool "Use sccache"
help
Shared compilation cache; see https://github.com/mozilla/sccache

config RUST_SCCACHE_DIR
string "Set sccache directory" if RUST_SCCACHE
default ""
help
Store sccache in this directory.
If not set, uses './.sccache'

endmenu
54 changes: 29 additions & 25 deletions lang/rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=rust
PKG_VERSION:=1.72.0
PKG_RELEASE:=2
PKG_VERSION:=1.73.0
PKG_RELEASE:=1

PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
PKG_HASH:=ea9d61bbb51d76b6ea681156f69f0e0596b59722f04414b01c6e100b4b5be3a1
PKG_HASH:=96d62e6d1f2d21df7ac8acb3b9882411f9e7c7036173f7f2ede9e1f1f6b1bb3a
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src

PKG_MAINTAINER:=Luca Barbato <[email protected]>
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

HOST_BUILD_DEPENDS:=python3/host
PKG_HOST_ONLY:=1

include $(INCLUDE_DIR)/host-build.mk
Expand All @@ -31,7 +30,6 @@ define Package/rust
TITLE:=Rust Programming Language Compiler
URL:=https://www.rust-lang.org/
DEPENDS:=$(RUST_ARCH_DEPENDS)
BUILDONLY:=1
endef

define Package/rust/description
Expand All @@ -40,8 +38,12 @@ define Package/rust/description
guarantee memory safety by using a borrow checker to validate references.
endef

define Package/rust/config
source "$(SOURCE)/Config.in"
endef

# Rust-lang has an uninstall script
RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh

# Target Flags
TARGET_CONFIGURE_ARGS = \
Expand All @@ -50,23 +52,24 @@ TARGET_CONFIGURE_ARGS = \
--set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \
--set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \
--set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) \
--set=target.$(RUSTC_TARGET_ARCH).crt-static=false \
$(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR))

# CARGO_HOME is an environmental
HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)"
HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"

# Rust Configuration Arguments
HOST_CONFIGURE_ARGS = \
--build=$(RUSTC_HOST_ARCH) \
--target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
--host=$(RUSTC_HOST_ARCH) \
--prefix=$(CARGO_HOME) \
--bindir=$(CARGO_HOME)/bin \
--libdir=$(CARGO_HOME)/lib \
--sysconfdir=$(CARGO_HOME)/etc \
--datadir=$(CARGO_HOME)/share \
--mandir=$(CARGO_HOME)/man \
--dist-compression-formats=xz \
--prefix=$(STAGING_DIR)/host \
--bindir=$(STAGING_DIR)/host/bin \
--libdir=$(STAGING_DIR)/host/lib \
--sysconfdir=$(STAGING_DIR)/host/etc \
--datadir=$(STAGING_DIR)/host/share \
--mandir=$(STAGING_DIR)/host/man \
--dist-compression-formats=gz \
--enable-missing-tools \
--disable-sanitizers \
--release-channel=stable \
Expand All @@ -81,22 +84,23 @@ define Host/Uninstall
endef

define Host/Compile
( \
cd $(HOST_BUILD_DIR) ; \
$(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
rustc rust-std rust-src ; \
)
$(RUST_SCCACHE_VARS) \
CARGO_HOME=$(CARGO_HOME) \
OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
$(PYTHON) $(HOST_BUILD_DIR)/x.py \
--build-dir $(HOST_BUILD_DIR)/build \
--config $(HOST_BUILD_DIR)/config.toml \
dist build-manifest cargo llvm-tools rustc rust-std rust-src
endef

define Host/Install
( \
cd $(HOST_BUILD_DIR)/build/dist ; \
find -iname "*.xz" -exec tar -xJf {} \; ; \
find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \
\
sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
-e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
$(CURDIR)/files/cargo-config > $(CARGO_HOME)/config.toml ; \
for targz in *.tar.gz; do \
$(STAGING_DIR_HOST)/bin/libdeflate-gzip -dc "$$$$targz" | tar -xf - ; \
done ; \
find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
-execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
)
endef

Expand Down
7 changes: 0 additions & 7 deletions lang/rust/files/cargo-config

This file was deleted.

4 changes: 2 additions & 2 deletions lang/rust/patches/0001-Update-xz2-and-use-it-static.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Subject: [PATCH] Update xz2 and use it static

--- a/src/bootstrap/Cargo.lock
+++ b/src/bootstrap/Cargo.lock
@@ -430,9 +430,9 @@ dependencies = [
@@ -434,9 +434,9 @@ dependencies = [

[[package]]
name = "lzma-sys"
Expand All @@ -23,7 +23,7 @@ Subject: [PATCH] Update xz2 and use it static
dependencies = [
"cc",
"libc",
@@ -899,9 +899,9 @@ dependencies = [
@@ -903,9 +903,9 @@ dependencies = [

[[package]]
name = "xz2"
Expand Down
37 changes: 37 additions & 0 deletions lang/rust/patches/0002-rustc-bootstrap-cache.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -546,7 +546,7 @@ class RustBuild(object):
shutil.rmtree(bin_root)

key = self.stage0_compiler.date
- cache_dst = os.path.join(self.build_dir, "cache")
+ cache_dst = os.getenv('OPENWRT_RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache"))
rustc_cache = os.path.join(cache_dst, key)
if not os.path.exists(rustc_cache):
os.makedirs(rustc_cache)
--- a/src/bootstrap/download.rs
+++ b/src/bootstrap/download.rs
@@ -520,7 +520,10 @@ impl Config {
key: &str,
destination: &str,
) {
- let cache_dst = self.out.join("cache");
+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
+ Some(v) => PathBuf::from(v),
+ None => self.out.join("cache"),
+ };
let cache_dir = cache_dst.join(key);
if !cache_dir.exists() {
t!(fs::create_dir_all(&cache_dir));
@@ -647,7 +650,10 @@ download-rustc = false
let llvm_assertions = self.llvm_assertions;

let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
- let cache_dst = self.out.join("cache");
+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
+ Some(v) => PathBuf::from(v),
+ None => self.out.join("cache"),
+ };
let rustc_cache = cache_dst.join(cache_prefix);
if !rustc_cache.exists() {
t!(fs::create_dir_all(&rustc_cache));
Loading

0 comments on commit 10e6e85

Please sign in to comment.