diff --git a/user/c2rust/patches/tomllib.patch b/user/c2rust/patches/tomllib.patch new file mode 100644 index 0000000000..e03445f763 --- /dev/null +++ b/user/c2rust/patches/tomllib.patch @@ -0,0 +1,18 @@ +diff -ruN a/scripts/query_toml.py b/scripts/query_toml.py +--- a/scripts/query_toml.py 2024-08-30 15:13:52.000000000 +0200 ++++ b/scripts/query_toml.py 2024-10-29 10:35:11.831126267 +0100 +@@ -3,11 +3,12 @@ + from argparse import ArgumentParser + from pathlib import Path + from typing import Any, Iterable +-import toml ++import tomllib + + + def query_toml(path: Path, query: Iterable[str]) -> Any: +- result = toml.load(path) ++ with open(path, "rb") as f: ++ result = tomllib.load(f) + for field in query: + if isinstance(result, list): + field = int(field) diff --git a/user/c2rust/patches/use-system-tinycbor.patch b/user/c2rust/patches/use-system-tinycbor.patch new file mode 100644 index 0000000000..0aa5716a68 --- /dev/null +++ b/user/c2rust/patches/use-system-tinycbor.patch @@ -0,0 +1,66 @@ +Patch-Source: https://gitlab.alpinelinux.org/alpine/aports/-/blob/a21369ad7a02256c0120b756e0757cd30b449888/testing/c2rust/0002-use-system-tinycbor.patch + +Use system's tinycbor instead of vendoring it in +diff -rupN a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs +--- a/c2rust-ast-exporter/build.rs 2023-05-22 22:14:35.000000000 +0200 ++++ b/c2rust-ast-exporter/build.rs 2024-01-06 22:54:06.039088094 +0100 +@@ -142,7 +142,7 @@ fn build_native(llvm_info: &LLVMInfo) { + }; + + // Statically link against 'clangAstExporter' which requires 'tinycbor' +- println!("cargo:rustc-link-lib=static=tinycbor"); ++ println!("cargo:rustc-link-lib=dylib=tinycbor"); + println!("cargo:rustc-link-lib=static=clangAstExporter"); + + println!("cargo:rustc-link-search=native={}", llvm_lib_dir); +diff -rupN a/c2rust-ast-exporter/src/CMakeLists.txt b/c2rust-ast-exporter/src/CMakeLists.txt +--- a/c2rust-ast-exporter/src/CMakeLists.txt 2023-05-22 22:14:35.000000000 +0200 ++++ b/c2rust-ast-exporter/src/CMakeLists.txt 2024-01-06 22:55:39.124799597 +0100 +@@ -5,14 +5,9 @@ project(ASTExporter) + # TinyCBOR # + ################################################# + +-set(TINYCBOR_REPO "https://github.com/intel/tinycbor.git" CACHE STRING "tinycbor git repo URL") +- +-# v0.6.3 tag, but using the commit hash instead (of the tarball hash) for integrity checks +-# unlike a .tar.gz MD5 hash, this SHA-1 commit hash should stay stable regardless of compression/archiving +-# (GitHub has changed this), and still retains the integrity check +-set(TINYCBOR_TAG "d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7" CACHE STRING "tinycbor git tag/branch/commit hash") +- +-set(TINYCBOR_PREFIX "${CMAKE_BINARY_DIR}/tinycbor" CACHE STRING "tinycbor install prefix") ++include(FindPkgConfig) ++pkg_search_module(TINYCBOR REQUIRED tinycbor) ++include_directories(${TINYCBOR_INCLUDE_DIRS}) + + if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(MAKE "gmake") +@@ -20,29 +15,6 @@ else() + set(MAKE "make") + endif() + +-include(ExternalProject) +-ExternalProject_Add(tinycbor_build +- PREFIX ${TINYCBOR_PREFIX} +- INSTALL_DIR ${CMAKE_BINARY_DIR} +- GIT_REPOSITORY ${TINYCBOR_REPO} +- GIT_TAG ${TINYCBOR_TAG} +- # the fd redirection here fails when the build run inside Cargo. +- # patch from upstream: +- # https://github.com/intel/tinycbor/commit/6176e0a28d7c5ef3a5e9cbd02521999c412de72c +- PATCH_COMMAND patch --forward -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor_fix_build.patch || true +- CONFIGURE_COMMAND ${MAKE} .config && cat ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor.config >> .config +- BUILD_COMMAND ${MAKE} --quiet prefix= CFLAGS=-fPIC +- INSTALL_COMMAND ${MAKE} --quiet prefix= install +- BUILD_IN_SOURCE 1 +- BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/lib/libtinycbor.a +-) +- +-include_directories(${CMAKE_BINARY_DIR}/include) +- +-add_library(tinycbor STATIC IMPORTED) +-set_target_properties(tinycbor PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib/libtinycbor.a) +-add_dependencies(tinycbor tinycbor_build) +- + set(AST_EXPORTER_SRCS + AstExporter.cpp + FloatingLexer.cpp diff --git a/user/c2rust/template.py b/user/c2rust/template.py new file mode 100644 index 0000000000..016a28bf41 --- /dev/null +++ b/user/c2rust/template.py @@ -0,0 +1,42 @@ +pkgname = "c2rust" +pkgver = "0.19.0" +pkgrel = 0 +build_style = "cargo" +make_build_args = ["--package", "c2rust"] +hostmakedepends = [ + "cargo-auditable", + "clang-tools-extra", + "cmake", + "pkgconf", +] +makedepends = [ + "clang-devel", + "clang-devel-static", + "llvm-devel", + "rust-std", + "tinycbor-devel", +] +checkdepends = [ + "python", + "python-plumbum", + "python-psutil", + "python-tomli", +] +pkgdesc = "C to Rust migration tool" +maintainer = "Erica Z " +license = "BSD-3-Clause" +url = "https://c2rust.com" +source = ( + f"https://github.com/immunant/c2rust/archive/refs/tags/v{pkgver}.tar.gz" +) +sha256 = "912c28e5e289d1a9ef1e0f6c89db97eba19eda58625ca8bdc5b513fdb3c19ba4" +# check: requires nightly +options = ["!check"] + + +def install(self): + self.install_bin(f"target/{self.profile().triplet}/release/c2rust") + self.install_bin( + f"target/{self.profile().triplet}/release/c2rust-transpile" + ) + self.install_license("LICENSE") diff --git a/user/coverage/template.py b/user/coverage/template.py new file mode 100644 index 0000000000..13dc660133 --- /dev/null +++ b/user/coverage/template.py @@ -0,0 +1,40 @@ +pkgname = "coverage" +pkgver = "7.6.4" +pkgrel = 0 +build_style = "python_pep517" +make_check_args = ["-k", "not VirtualenvTest"] +hostmakedepends = [ + "python-build", + "python-installer", + "python-setuptools", +] +makedepends = [ + "python-devel", +] +checkdepends = [ + "python-flaky", + "python-hypothesis", + "python-pytest", + "python-pytest-xdist", +] +depends = [ + "python", + self.with_pkgver("python-coverage"), +] +pkgdesc = "Tool for measuring Python code coverage" +maintainer = "Erica Z " +license = "Apache-2.0" +url = "https://coverage.readthedocs.io" +source = f"$(PYPI_SITE)/c/coverage/coverage-{pkgver}.tar.gz" +sha256 = "29fc0f17b1d3fea332f8001d4558f8214af7f1d87a345f3a133c901d60347c73" + + +def pre_check(self): + # generate some required test files + self.do("python", "igor.py", "zip_mods") + + +@subpackage("python-coverage") +def _(self): + self.subdesc = "Python module" + return ["usr/lib"] diff --git a/user/python-coverage b/user/python-coverage new file mode 120000 index 0000000000..ed9f9cc128 --- /dev/null +++ b/user/python-coverage @@ -0,0 +1 @@ +coverage \ No newline at end of file diff --git a/user/python-plumbum/template.py b/user/python-plumbum/template.py new file mode 100644 index 0000000000..b4380f5362 --- /dev/null +++ b/user/python-plumbum/template.py @@ -0,0 +1,35 @@ +pkgname = "python-plumbum" +pkgver = "1.9.0" +pkgrel = 0 +build_style = "python_pep517" +make_check_args = [ + "-k", + # expects a different error message from ls + "not test_iter_lines_error", +] +hostmakedepends = [ + "python-build", + "python-hatch_vcs", + "python-hatchling", + "python-installer", +] +checkdepends = [ + "bash", + "openssh", + "procps", + "python-psutil", + "python-pytest", + "python-pytest-cov", + "python-pytest-mock", + "python-pytest-timeout", +] +pkgdesc = "Shell script idioms for Python" +maintainer = "Erica Z " +license = "MIT" +url = "https://plumbum.readthedocs.io/en/stable" +source = f"$(PYPI_SITE)/p/plumbum/plumbum-{pkgver}.tar.gz" +sha256 = "e640062b72642c3873bd5bdc3effed75ba4d3c70ef6b6a7b907357a84d909219" + + +def post_install(self): + self.install_license("LICENSE") diff --git a/user/python-pytest-cov/template.py b/user/python-pytest-cov/template.py new file mode 100644 index 0000000000..8d949d1386 --- /dev/null +++ b/user/python-pytest-cov/template.py @@ -0,0 +1,29 @@ +pkgname = "python-pytest-cov" +pkgver = "5.0.0" +pkgrel = 0 +build_style = "python_pep517" +hostmakedepends = [ + "python-build", + "python-installer", + "python-setuptools", +] +checkdepends = [ + "python-coverage", + "python-pytest", +] +depends = [ + "python-coverage", + "python-pytest", +] +pkgdesc = "Coverage reports for Pytest" +maintainer = "Erica Z " +license = "MIT" +url = "https://github.com/pytest-dev/pytest-cov" +source = f"$(PYPI_SITE)/p/pytest-cov/pytest-cov-{pkgver}.tar.gz" +sha256 = "5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857" +# ModuleNotFoundError: No module named 'virtualenv' +options = ["!check"] + + +def post_install(self): + self.install_license("LICENSE") diff --git a/user/tinycbor-devel b/user/tinycbor-devel new file mode 120000 index 0000000000..a0f22a3dfd --- /dev/null +++ b/user/tinycbor-devel @@ -0,0 +1 @@ +tinycbor \ No newline at end of file diff --git a/user/tinycbor-progs b/user/tinycbor-progs new file mode 120000 index 0000000000..a0f22a3dfd --- /dev/null +++ b/user/tinycbor-progs @@ -0,0 +1 @@ +tinycbor \ No newline at end of file diff --git a/user/tinycbor/patches/allow-qt6.patch b/user/tinycbor/patches/allow-qt6.patch new file mode 100644 index 0000000000..22fc399683 --- /dev/null +++ b/user/tinycbor/patches/allow-qt6.patch @@ -0,0 +1,38 @@ +From db9f29d4994d1ccb14f4abbfab335c23b5b1bd84 Mon Sep 17 00:00:00 2001 +From: Thiago Macieira +Date: Wed, 1 May 2024 18:01:24 -0700 +Subject: [PATCH] CI/Makefile: do allow Qt 6 + +I don't think we need to worry about Qt 4 any more. + +Signed-off-by: Thiago Macieira +--- + .github/workflows/build.yml | 2 +- + Makefile | 14 -------------- + 2 files changed, 1 insertion(+), 15 deletions(-) + +diff --git a/Makefile b/Makefile +index 26925eee..6df16553 100644 +--- a/Makefile ++++ b/Makefile +@@ -65,20 +65,6 @@ VERSION = $(shell cat $(SRCDIR)VERSION) + SOVERSION = $(shell cut -f1-2 -d. $(SRCDIR)VERSION) + PACKAGE = tinycbor-$(VERSION) + +-# Check that QMAKE is Qt 5 +-ifeq ($(origin QMAKE),file) +- check_qmake = $(strip $(shell $(1) -query QT_VERSION 2>/dev/null | cut -b1)) +- ifneq ($(call check_qmake,$(QMAKE)),5) +- QMAKE := qmake -qt5 +- ifneq ($(call check_qmake,$(QMAKE)),5) +- QMAKE := qmake-qt5 +- ifneq ($(call check_qmake,$(QMAKE)),5) +- QMAKE := @echo >&2 $(MAKEFILE): Cannot find a Qt 5 qmake; false +- endif +- endif +- endif +-endif +- + -include .config + + ifeq ($(wildcard .config),) diff --git a/user/tinycbor/patches/disable-c90-test.patch b/user/tinycbor/patches/disable-c90-test.patch new file mode 100644 index 0000000000..05348bce3b --- /dev/null +++ b/user/tinycbor/patches/disable-c90-test.patch @@ -0,0 +1,26 @@ +From 4df5e4f70045730c045a8fefa9aaadb673513f2a Mon Sep 17 00:00:00 2001 +From: Thiago Macieira +Date: Wed, 1 May 2024 18:26:51 -0700 +Subject: [PATCH] Tests: disable the C90 test + +We don't support this any more. +``` +../../src/cbor.h:255:69: error: '_Bool' is a C99 extension [-Werror,-Wc99-extensions] +CBOR_INLINE_API CborError cbor_encode_boolean(CborEncoder *encoder, bool value) + ^ +``` + +Signed-off-by: Thiago Macieira +--- + tests/tests.pro | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/tests.pro b/tests/tests.pro +index 6036f0f9..627ffbc1 100644 +--- a/tests/tests.pro ++++ b/tests/tests.pro +@@ -1,3 +1,3 @@ + TEMPLATE = subdirs +-SUBDIRS = parser encoder c90 cpp tojson ++SUBDIRS = parser encoder cpp tojson + msvc: SUBDIRS -= tojson diff --git a/user/tinycbor/template.py b/user/tinycbor/template.py new file mode 100644 index 0000000000..46e60bef0e --- /dev/null +++ b/user/tinycbor/template.py @@ -0,0 +1,31 @@ +pkgname = "tinycbor" +pkgver = "0.6.0" +pkgrel = 0 +build_style = "makefile" +make_install_args = ["prefix=/usr"] +make_check_args = ["QMAKE=qmake6"] +hostmakedepends = [ + "file", + "pkgconf", +] +checkdepends = ["qt6-qtbase-devel"] +pkgdesc = "Concise binary object representation library" +maintainer = "Erica Z " +license = "MIT" +url = "https://github.com/intel/tinycbor" +source = f"{url}/archive/refs/tags/v{pkgver}.tar.gz" +sha256 = "512e2c9fce74f60ef9ed3af59161e905f9e19f30a52e433fc55f39f4c70d27e4" + + +def post_install(self): + self.install_license("LICENSE") + + +@subpackage("tinycbor-devel") +def _(self): + return self.default_devel() + + +@subpackage("tinycbor-progs") +def _(self): + return self.default_progs()