diff --git a/thirdparty/cpython/HPKBUILD b/thirdparty/cpython/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..19ddecafa1265d01d744b6aa3927ac8b33bd3d36 --- /dev/null +++ b/thirdparty/cpython/HPKBUILD @@ -0,0 +1,92 @@ +# Copyright (c) 2023, HiHope Community. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Contributor: jiajiahao +# Maintainer: jiajiajiao + +pkgname=cpython +pkgver=3.8 +pkgrel=0 +pkgdesc="" +url="https://www.python.org/" +archs=("arm64-v8a") # armeabi-v7a版本编译有问题,只能编译64位的 +license=("MIT") +depends=("gettext" "gdbm" "openssl" "zlib" "libffi" "tcl" "sqlite" "openssl_quic" "xz" "libuuid" "bzip2") +makedepends=() +source="https://codeload.github.com/python/${pkgname}/zip/refs/heads/$pkgver" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-$pkgver +packagename=$builddir.zip +patchflag=true + +source envset.sh +host= +prepare() { + if [ $patchflag == true ];then + cd $builddir + # 打patch的原因: + # 1.解决cpython/Modules/socketmodule.c文件的编译问题,这个问题最终会导致编译_socket模块编译失败,在linux内核中CAN_RAW_FD_FRAMES的值是5 + # 2.解决cpython/Modules/_cryptmodule.c文件的编译问题,crypt函数导致无法编译 + patch -p1 < `pwd`/../cpython_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi + + rm -rf $builddir-$ARCH-build # 重复编译的时候删除上一次编译的目录 + cp -arf $builddir $builddir-$ARCH-build # 创建cpython-3.8-arm64-v8a-build和cpython-3.8-armeabi-v7a-build + if [ $ARCH == "armeabi-v7a" ] + then + host=arm-linux-gnueabi # 编译arm32的cpython的abi是arm-linux-gnueabi + elif [ $ARCH == "arm64-v8a" ] + then + host=aarch64-linux-gnu # 编译arm64的cpython的abi是aarch64-linux-gnu + else + echo "${ARCH} not support" + return -1 + fi +} + +build() { + cd $builddir-$ARCH-build + ./configure "$@" --host=$host --build=x86_64-pc-linux-gnu --disable-ipv6 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no --enable-optimizations \ + CFLAGS="-Wno-deprecated-declarations -Wno-unreachable-code -Wno-implicit-const-int-float-conversion -Wno-sign-compare -Wno-int-to-pointer-cast -Wno-implicit-function-declaration -Wno-int-conversion"\ + LDFLAGS="-L$LYCIUM_ROOT/usr/openssl_quic/$ARCH/lib -L$LYCIUM_ROOT/usr/gettext/$ARCH/lib -L$LYCIUM_ROOT/usr/tcl/$ARCH/lib -L$LYCIUM_ROOT/usr/xz/$ARCH/lib -L$LYCIUM_ROOT/usr/libuuid/$ARCH/lib -L$LYCIUM_ROOT/usr/zlib/$ARCH/lib -L$LYCIUM_ROOT/usr/openssl/$ARCH/lib -L$LYCIUM_ROOT/usr/gdbm/$ARCH/lib -L$LYCIUM_ROOT/usr/bzip2/$ARCH/lib -L$LYCIUM_ROOT/usr/sqlite/$ARCH/lib -L$LYCIUM_ROOT/usr/libffi/$ARCH/lib" \ + CPPFLAGS="-I$LYCIUM_ROOT/usr/openssl_quic/$ARCH/include -I$LYCIUM_ROOT/usr/gettext/$ARCH/include -I$LYCIUM_ROOT/usr/tcl/$ARCH/include -I$LYCIUM_ROOT/usr/xz/$ARCH/include -I$LYCIUM_ROOT/usr/libuuid/$ARCH/include -I$LYCIUM_ROOT/usr/zlib/$ARCH/include -I$LYCIUM_ROOT/usr/openssl/$ARCH/include -I$LYCIUM_ROOT/usr/gdbm/$ARCH/include -I$LYCIUM_ROOT/usr/bzip2/$ARCH/include -I$LYCIUM_ROOT/usr/libffi/$ARCH/include -I$LYCIUM_ROOT/usr/sqlite/$ARCH/include" \ + > $buildlog 2>&1 + $MAKE V=1 >> $buildlog 2>&1 + make install prefix=$builddir-$ARCH-build-install # 安装python到指定路径(必需) + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + $MAKE install >> $buildlog 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" + # TODO +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/cpython/README.OpenSource b/thirdparty/cpython/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..e1137fd7853474b659a353da908a175a1dee1c7c --- /dev/null +++ b/thirdparty/cpython/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "cpython", + "License": "BSD", + "License File": "LICENSE", + "Version Number": "3.8", + "Owner": "jia_jiahao@runkaihong.com.cn", + "Upstream URL": "https://github.com/python/cpython", + "Description": "The Python programming language" + } +] \ No newline at end of file diff --git a/thirdparty/cpython/SHA512SUM b/thirdparty/cpython/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..1441dd0e9dd4e6e9632afa63a35effab04017c13 --- /dev/null +++ b/thirdparty/cpython/SHA512SUM @@ -0,0 +1 @@ +bf73c75c516d993d5d3636a81ab6eabf31a3c7831514c5a78d78ef374133a6e802cf96324cf028669e55d50c78b3f6ddade18c8b018ec049c768f5b150c6f620 cpython-3.8.zip diff --git a/thirdparty/cpython/cpython_oh_pkg.patch b/thirdparty/cpython/cpython_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..6365f03e07f88ee929f2c9558bb61b2858ff15ff --- /dev/null +++ b/thirdparty/cpython/cpython_oh_pkg.patch @@ -0,0 +1,24 @@ +diff -urN a/Modules/_cryptmodule.c b/Modules/_cryptmodule.c +--- a/Modules/_cryptmodule.c ++++ b/Modules/_cryptmodule.c +@@ -39,8 +39,8 @@ + struct crypt_data data; + memset(&data, 0, sizeof(data)); + crypt_result = crypt_r(word, salt, &data); +-#else +- crypt_result = crypt(word, salt); ++//#else ++ //crypt_result = crypt(word, salt); + #endif + return Py_BuildValue("s", crypt_result); + } +diff -urN a/Modules/socketmodule.h b/Modules/socketmodule.h +--- a/Modules/socketmodule.h ++++ b/Modules/socketmodule.h +@@ -1,5 +1,5 @@ + /* Socket module header file */ +- ++#define CAN_RAW_FD_FRAMES 5 + /* Includes needed for the sockaddr_* symbols below */ + #ifndef MS_WINDOWS + #ifdef __VMS \ No newline at end of file