Skip to content

Commit

Permalink
enhance(main/{plutolang->libpluto}): several changes
Browse files Browse the repository at this point in the history
* rename plutolang to libpluto
* rename subpkg libpluto to plutolang
* build package with php scripts instead
  • Loading branch information
mbekkomo committed Aug 28, 2024
1 parent f7bfd1a commit 02380d5
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 169 deletions.
48 changes: 48 additions & 0 deletions packages/libpluto/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
TERMUX_PKG_HOMEPAGE=https://plutolang.github.io/
TERMUX_PKG_DESCRIPTION="Shared library for the Pluto interpreter"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="Komo @cattokomo"
TERMUX_PKG_VERSION="0.9.4"
TERMUX_PKG_SRCURL=https://github.com/PlutoLang/Pluto/archive/refs/tags/${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=6a4fae052a9ad47e29a6767047c3e55ab5c887486d14e39248657ff43b45875c
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_DEPENDS="libc++"
TERMUX_PKG_BUILD_DEPENDS="readline"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_BREAKS="plutolang (<< 0.9.4-2)"
TERMUX_PKG_REPLACES="plutolang (<< 0.9.4-2)"

termux_step_configure() {
# can't use php version from termux repo, there's no build for the latest version on the pre-built binaries
local php_version="8.3.9"
local tarball_checksum="6c7b45dabc362c9c447c6c9688f8922d0cfa3d5c4618d632c504342d37085e2f"

mkdir -p "${TERMUX_PKG_CACHEDIR}/php"
termux_download "https://dl.static-php.dev/static-php-cli/common/php-${php_version}-cli-linux-x86_64.tar.gz" \
"${TERMUX_PKG_CACHEDIR}/php.tar.gz" \
"${tarball_checksum}"
tar -zxf "${TERMUX_PKG_CACHEDIR}/php.tar.gz" -C "${TERMUX_PKG_CACHEDIR}/php"
chmod +x "${TERMUX_PKG_CACHEDIR}/php/php"
export PATH="${TERMUX_PKG_CACHEDIR}/php:$PATH"
}

termux_step_make() {
local build linkreadline

export TARGET_ARCH="${TERMUX_ARCH}"
CXXFLAGS+=" -DLUA_USE_LINUX -DLUA_USE_READLINE"

CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}" php scripts/compile.php "${CXX}"
for build in 'pluto' 'plutoc' 'shared' 'static'; do
linkreadline=""
[[ "$build" == "pluto" ]] && linkreadline="-lreadline"
# ANDROID_ROOT is just a dummy variable, it's required to detect Android platform
ANDROID_ROOT=/system LDFLAGS="${LDFLAGS} ${linkreadline}" php scripts/link_"$build".php "${CXX}"
done
}

termux_step_make_install() {
install -Dm755 -t "${TERMUX_PREFIX}/bin" src/pluto{,c}
install -Dm644 -t "${TERMUX_PREFIX}/lib" src/libpluto{.so,static.a}
install -Dm644 -t "${TERMUX_PREFIX}/include" src/{lua,lauxlib,lualib,luaconf}.h src/lua.hpp
}
3 changes: 3 additions & 0 deletions packages/libpluto/plutolang.subpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TERMUX_SUBPKG_INCLUDE="bin/"
TERMUX_SUBPKG_DEPENDS="readline"
TERMUX_SUBPKG_DESCRIPTION="A superset of Lua 5.4 with a focus on general-purpose programming."
24 changes: 24 additions & 0 deletions packages/libpluto/scripts-common.php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/scripts/common.php b/scripts/common.php
index 66ea1d0..366643f 100644
--- a/scripts/common.php
+++ b/scripts/common.php
@@ -44,12 +44,19 @@ function check_compiler()
}
}
}
+ if (getenv("CXXFLAGS"))
+ {
+ $compiler .= " ".getenv("CXXFLAGS");
+ }
}

function prepare_link()
{
global $compiler;
$compiler .= " -L".__DIR__."/../src/vendor/Soup -lsoup";
+ if (getenv("LDFLAGS")) {
+ $compiler .= " ".getenv("LDFLAGS");
+ }
}

function resolve_installed_program($exe)
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions packages/libpluto/src-vendor-Soup-build_common.php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/vendor/Soup/build_common.php b/src/vendor/Soup/build_common.php
index 3f0a7f4..8845a4b 100644
--- a/src/vendor/Soup/build_common.php
+++ b/src/vendor/Soup/build_common.php
@@ -1,6 +1,6 @@
<?php
// Config
-$clang = "clang -std=c++17 -fno-rtti -DSOUP_USE_INTRIN -O3";
+$clang = getenv("CXX")." -std=c++17 -fno-rtti -DSOUP_USE_INTRIN -O3";
if (defined("PHP_WINDOWS_VERSION_MAJOR"))
{
$clang .= " -D_CRT_SECURE_NO_WARNINGS";
18 changes: 18 additions & 0 deletions packages/libpluto/src-vendor-Soup-build_lib.php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/src/vendor/Soup/build_lib.php b/src/vendor/Soup/build_lib.php
index e32b4ab..cab4f07 100644
--- a/src/vendor/Soup/build_lib.php
+++ b/src/vendor/Soup/build_lib.php
@@ -28,11 +28,11 @@ foreach(scandir(__DIR__."/soup") as $file)
}
if(is_dir(__DIR__."/Intrin"))
{
- if (php_uname("m") == "aarch64")
+ if (getenv("TARGET_ARCH") == "aarch64")
{
$clang .= " -march=armv8+crypto+crc";
}
- else
+ elseif (getenv("TARGET_ARCH") != "arm")
{
$clang .= " -maes -mpclmul -mrdrnd -mrdseed -msha -msse4.1";
}
39 changes: 0 additions & 39 deletions packages/plutolang/Makefile.patch

This file was deleted.

26 changes: 0 additions & 26 deletions packages/plutolang/build.sh

This file was deleted.

17 changes: 0 additions & 17 deletions packages/plutolang/intrin-detection.patch

This file was deleted.

30 changes: 0 additions & 30 deletions packages/plutolang/intrin-patch.patch

This file was deleted.

2 changes: 0 additions & 2 deletions packages/plutolang/libpluto.subpackage.sh

This file was deleted.

55 changes: 0 additions & 55 deletions packages/plutolang/src-Makefile.patch

This file was deleted.

0 comments on commit 02380d5

Please sign in to comment.