diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index caa0344..3535dec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,21 +59,15 @@ jobs: xmake smart-image -f ext4 -vD -o build/${{ matrix.arch }}-ext4.img popd - - name: ⬆️ upload artifact - uses: actions/upload-artifact@v3 - with: - name: build-smart-apps-${{ github.run_number }} - path: | - apps/build/cross - apps/build/rootfs - apps/build/*.img - build-linux-apps: runs-on: ubuntu-latest strategy: matrix: app: + - busybox + - cpp - hello + - micropython - zlib steps: @@ -95,10 +89,3 @@ jobs: xmake f -a x86_64 --target_os=linux -vyD xmake -j$(nproc) -vyD ${{ matrix.app }} popd - - - name: ⬆️ upload artifact - uses: actions/upload-artifact@v3 - with: - name: build-smart-apps-${{ github.run_number }} - path: | - apps/build/cross diff --git a/apps/busybox/xmake.lua b/apps/busybox/xmake.lua index 2b0160a..b7fc6b9 100644 --- a/apps/busybox/xmake.lua +++ b/apps/busybox/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-06-21 zhouquan initial version +-- 2023-06-21 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/cpp/xmake.lua b/apps/cpp/xmake.lua index f151caa..d00367d 100644 --- a/apps/cpp/xmake.lua +++ b/apps/cpp/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/hello/xmake.lua b/apps/hello/xmake.lua index f1ceab4..1316896 100644 --- a/apps/hello/xmake.lua +++ b/apps/hello/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/micropython/xmake.lua b/apps/micropython/xmake.lua new file mode 100644 index 0000000..e69a0f5 --- /dev/null +++ b/apps/micropython/xmake.lua @@ -0,0 +1,32 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-06-21 xqyjlj initial version +-- +add_rules("mode.debug", "mode.release") + +add_requires("micropython", {configs = {shared = false}}) + +target("micropython") +do + set_kind("phony") + add_packages("micropython") +end +target_end() diff --git a/apps/shm_ping/xmake.lua b/apps/shm_ping/xmake.lua index c7ff6e9..529032f 100644 --- a/apps/shm_ping/xmake.lua +++ b/apps/shm_ping/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/shm_pong/xmake.lua b/apps/shm_pong/xmake.lua index 1e2cdb1..ab29da5 100644 --- a/apps/shm_pong/xmake.lua +++ b/apps/shm_pong/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/umailbox/xmake.lua b/apps/umailbox/xmake.lua index b0a7375..66f9a2f 100644 --- a/apps/umailbox/xmake.lua +++ b/apps/umailbox/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/webclient/xmake.lua b/apps/webclient/xmake.lua index d25a5d0..405148d 100644 --- a/apps/webclient/xmake.lua +++ b/apps/webclient/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/webserver/xmake.lua b/apps/webserver/xmake.lua index 18caed7..05f3b68 100644 --- a/apps/webserver/xmake.lua +++ b/apps/webserver/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/apps/zlib/xmake.lua b/apps/zlib/xmake.lua index b29881b..cbc6eb9 100644 --- a/apps/zlib/xmake.lua +++ b/apps/zlib/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- add_rules("mode.debug", "mode.release") diff --git a/prebuilt/qemu-virt64-aarch64/run.sh b/prebuilt/qemu-virt64-aarch64/run.sh index 25ebadd..980a451 100755 --- a/prebuilt/qemu-virt64-aarch64/run.sh +++ b/prebuilt/qemu-virt64-aarch64/run.sh @@ -1,12 +1,12 @@ #!/bin/bash -# @author zhouquan +# @author xqyjlj # @file run.sh # # Change Logs: # Date Author Notes # ------------ ---------- ----------------------------------------------- -# 2023-01-12 zhouquan initial version +# 2023-01-12 xqyjlj initial version # script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/prebuilt/qemu-virt64-aarch64/run_debug.sh b/prebuilt/qemu-virt64-aarch64/run_debug.sh index 3dba716..432e70e 100755 --- a/prebuilt/qemu-virt64-aarch64/run_debug.sh +++ b/prebuilt/qemu-virt64-aarch64/run_debug.sh @@ -1,12 +1,12 @@ #!/bin/bash -# @author zhouquan +# @author xqyjlj # @file run.sh # # Change Logs: # Date Author Notes # ------------ ---------- ----------------------------------------------- -# 2023-01-12 zhouquan initial version +# 2023-01-12 xqyjlj initial version # script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/prebuilt/qemu-virt64-riscv/run.sh b/prebuilt/qemu-virt64-riscv/run.sh index 679ead3..1de4a9b 100755 --- a/prebuilt/qemu-virt64-riscv/run.sh +++ b/prebuilt/qemu-virt64-riscv/run.sh @@ -1,12 +1,12 @@ #!/bin/bash -# @author zhouquan +# @author xqyjlj # @file run.sh # # Change Logs: # Date Author Notes # ------------ ---------- ----------------------------------------------- -# 2023-01-12 zhouquan initial version +# 2023-01-12 xqyjlj initial version # script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/prebuilt/qemu-virt64-riscv/run_debug.sh b/prebuilt/qemu-virt64-riscv/run_debug.sh index 917c7ee..4dfcd0f 100755 --- a/prebuilt/qemu-virt64-riscv/run_debug.sh +++ b/prebuilt/qemu-virt64-riscv/run_debug.sh @@ -1,12 +1,12 @@ #!/bin/bash -# @author zhouquan +# @author xqyjlj # @file run.sh # # Change Logs: # Date Author Notes # ------------ ---------- ----------------------------------------------- -# 2023-01-12 zhouquan initial version +# 2023-01-12 xqyjlj initial version # script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/readme.md b/readme.md index 661469f..1c61cc4 100644 --- a/readme.md +++ b/readme.md @@ -86,7 +86,7 @@ xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua ```shell cd prebuilt/qemu-virt64-aarch64/ - ./qemu.sh + ./run.sh ``` ![image-20230531174321326](./assets/image-20230531174321326.png) diff --git a/repo/packages/a/aarch64-smart-musleabi/xmake.lua b/repo/packages/a/aarch64-smart-musleabi/xmake.lua index 32e9ceb..792d73d 100644 --- a/repo/packages/a/aarch64-smart-musleabi/xmake.lua +++ b/repo/packages/a/aarch64-smart-musleabi/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-08 zhouquan initial version +-- 2023-05-08 xqyjlj initial version -- package("aarch64-smart-musleabi") do diff --git a/repo/packages/a/arm-smart-musleabi/xmake.lua b/repo/packages/a/arm-smart-musleabi/xmake.lua index 5662261..60cdec0 100644 --- a/repo/packages/a/arm-smart-musleabi/xmake.lua +++ b/repo/packages/a/arm-smart-musleabi/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-12 zhouquan initial version +-- 2023-05-12 xqyjlj initial version -- package("arm-smart-musleabi") do diff --git a/repo/packages/b/busybox/scripts/deploy.lua b/repo/packages/b/busybox/scripts/deploy.lua index c6de5e3..21e3ef3 100644 --- a/repo/packages/b/busybox/scripts/deploy.lua +++ b/repo/packages/b/busybox/scripts/deploy.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file deploy.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-09 zhouquan initial version +-- 2023-05-09 xqyjlj initial version -- import("rt.rt_utils") diff --git a/repo/packages/b/busybox/xmake.lua b/repo/packages/b/busybox/xmake.lua index 5c312fe..d4c438a 100644 --- a/repo/packages/b/busybox/xmake.lua +++ b/repo/packages/b/busybox/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-04 zhouquan initial version +-- 2023-05-04 xqyjlj initial version -- package("busybox") do diff --git a/repo/packages/f/ffmpeg/scripts/deploy.lua b/repo/packages/f/ffmpeg/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/f/ffmpeg/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/f/ffmpeg/scripts/export.lua b/repo/packages/f/ffmpeg/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/f/ffmpeg/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/f/ffmpeg/xmake.lua b/repo/packages/f/ffmpeg/xmake.lua new file mode 100644 index 0000000..bb90d2d --- /dev/null +++ b/repo/packages/f/ffmpeg/xmake.lua @@ -0,0 +1,98 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-06 xqyjlj initial version +-- +package("ffmpeg") +do + set_homepage("https://www.ffmpeg.org") + set_description( + "A collection of libraries to process multimedia content such as audio, video, subtitles and related metadata.") + + add_urls("https://ffmpeg.org/releases/ffmpeg-$(version).tar.bz2") + + add_versions("5.1.2", "39a0bcc8d98549f16c570624678246a6ac736c066cebdb409f9502e915b22f2b") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = ""} + local cc = info.cc + local cxx = info.cxx + local arch = info.arch + local cpu = info.cpu + local ldflags = {} + local packagedeps = {} + os.setenv("PATH", info.toolchainsdir .. ":" .. os.getenv("PATH")) + + if host == "aarch64-linux-musleabi" then + arch = "aarch64" + cpu = "armv8-a" + end + + table.insert(configs, "--cross-prefix=" .. host .. "-") + table.insert(configs, "--enable-cross-compile") + table.insert(configs, "--target-os=none") + table.insert(configs, "--cc=" .. cc) + table.insert(configs, "--cxx=" .. cxx) + table.insert(configs, "--arch=" .. arch) + table.insert(configs, "--cpu=" .. cpu) + if package:config("shared") then + table.insert(configs, "--enable-shared") + end + + -- table.insert(configs, "$ADDITIONAL_CONFIGURE_FLAG") + + local buildenvs = import("package.tools.autoconf").buildenvs(package, + {ldflags = ldflags, packagedeps = packagedeps}) + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + for _, suffix in ipairs({".a", ".so"}) do + if os.isfile(path.join(package:installdir("lib"), "libavdevice" .. suffix)) then + package:add("links", "avdevice") -- avdevice first + end + if os.isfile(path.join(package:installdir("lib"), "libavfilter" .. suffix)) then + package:add("links", "avfilter") + end + if os.isfile(path.join(package:installdir("lib"), "libavformat" .. suffix)) then + package:add("links", "avformat") + end + if os.isfile(path.join(package:installdir("lib"), "libavcodec" .. suffix)) then + package:add("links", "avcodec") + end + if os.isfile(path.join(package:installdir("lib"), "libswresample" .. suffix)) then + package:add("links", "swresample") + end + if os.isfile(path.join(package:installdir("lib"), "libswscale" .. suffix)) then + package:add("links", "swscale") + end + if os.isfile(path.join(package:installdir("lib"), "libavutil" .. suffix)) then + package:add("links", "avutil") + end + end + end) + + on_test(function(package) + assert(package:has_cfuncs("avformat_open_input", {includes = "libavformat/avformat.h"})) + end) +end diff --git a/repo/packages/l/libffi/patches/3.4.4/01_src_tramp.diff b/repo/packages/l/libffi/patches/3.4.4/01_src_tramp.diff new file mode 100644 index 0000000..1f7322d --- /dev/null +++ b/repo/packages/l/libffi/patches/3.4.4/01_src_tramp.diff @@ -0,0 +1,15 @@ +diff --git a/src/tramp.c b/src/tramp.c +index b9d273a..9bc7994 100644 +--- a/src/tramp.c ++++ b/src/tramp.c +@@ -48,8 +48,8 @@ + #include + #include + #ifdef __linux__ +-#include +-#include ++#include ++// #include + #endif + #ifdef __CYGWIN__ + #include diff --git a/repo/packages/l/libffi/scripts/deploy.lua b/repo/packages/l/libffi/scripts/deploy.lua new file mode 100644 index 0000000..d3bc28e --- /dev/null +++ b/repo/packages/l/libffi/scripts/deploy.lua @@ -0,0 +1,30 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "lib64") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libffi/scripts/export.lua b/repo/packages/l/libffi/scripts/export.lua new file mode 100644 index 0000000..afe425c --- /dev/null +++ b/repo/packages/l/libffi/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib64") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib64") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libffi/xmake.lua b/repo/packages/l/libffi/xmake.lua new file mode 100644 index 0000000..1e6ea77 --- /dev/null +++ b/repo/packages/l/libffi/xmake.lua @@ -0,0 +1,73 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-03-02 xqyjlj initial version +-- +package("libffi") +do + set_homepage("https://sourceware.org/libffi/") + set_description("Portable Foreign Function Interface library.") + + add_urls("https://github.com/libffi/libffi/releases/download/v$(version)/libffi-$(version).tar.gz") + + add_versions("3.4.4", "d66c56ad259a82cf2a9dfc408b32bf5da52371500b84745f7fb8b645712df676") + + add_patches("3.4.4", path.join(os.scriptdir(), "patches", "3.4.4", "01_src_tramp.diff"), + "6a16954ca8c1b1549b2f0eae369b1abe11cdbb70e7d1e94c32f94defbae4bc60") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + if package:config("debug") then + table.insert(configs, "--enable-debug") + else + table.insert(configs, "--disable-debug") + end + + table.insert(configs, "--enable-static=yes") + if package:config("shared") then + table.insert(configs, "--enable-shared=yes") + else + table.insert(configs, "--enable-shared=no") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package) + + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + local lib64 = path.join(package:installdir(), "lib64") + if os.isdir(lib64) then + package:add("links", "ffi") + package:add("linkdirs", "lib64") + end + end) + + on_test(function(package) + assert(package:has_cfuncs("ffi_closure_alloc", {includes = "ffi.h"})) + end) +end diff --git a/repo/packages/l/libjpeg/scripts/deploy.lua b/repo/packages/l/libjpeg/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/l/libjpeg/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libjpeg/scripts/export.lua b/repo/packages/l/libjpeg/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/l/libjpeg/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libjpeg/xmake.lua b/repo/packages/l/libjpeg/xmake.lua new file mode 100644 index 0000000..8621490 --- /dev/null +++ b/repo/packages/l/libjpeg/xmake.lua @@ -0,0 +1,62 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-02-28 xqyjlj initial version +-- +package("libjpeg") +do + set_homepage("http://ijg.org/") + set_description("A widely used C library for reading and writing JPEG image files.") + + add_urls("https://www.ijg.org/files/jpegsrc.$(version).tar.gz") + + add_versions("v9b", "566241ad815df935390b341a5d3d15a73a4000e5aab40c58505324c2855cbbb8") + add_versions("v9c", "682aee469c3ca857c4c38c37a6edadbfca4b04d42e56613b11590ec6aa4a278d") + add_versions("v9d", "2303a6acfb6cc533e0e86e8a9d29f7e6079e118b9de3f96e07a71a11c082fa6a") + add_versions("v9e", "4077d6a6a75aeb01884f708919d25934c93305e49f7e3f36db9129320e6f4f3d") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(configs, "--enable-static=yes") + if package:config("shared") then + table.insert(configs, "--enable-shared=yes") + else + table.insert(configs, "--enable-shared=no") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package, {ldflags = ldflags}) + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("jpeg_create_compress(0)", {includes = {"stdio.h", "jpeglib.h"}})) + end) +end diff --git a/repo/packages/l/libpng/scripts/deploy.lua b/repo/packages/l/libpng/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/l/libpng/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libpng/scripts/export.lua b/repo/packages/l/libpng/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/l/libpng/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/libpng/xmake.lua b/repo/packages/l/libpng/xmake.lua new file mode 100644 index 0000000..9810f59 --- /dev/null +++ b/repo/packages/l/libpng/xmake.lua @@ -0,0 +1,70 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-03-02 xqyjlj initial version +-- +package("libpng") +do + set_homepage("http://www.libpng.org/pub/png/libpng.html") + set_description("The official PNG reference library") + set_license("libpng-2.0") + + add_urls("https://github.com/glennrp/libpng/archive/$(version).zip") + + add_versions("v1.6.34", "7ffa5eb8f9f3ed23cf107042e5fec28699718916668bbce48b968600475208d3") + add_versions("v1.6.35", "3d22d46c566b1761a0e15ea397589b3a5f36ac09b7c785382e6470156c04247f") + add_versions("v1.6.36", "6274d3f761cc80f7f6e2cde6c07bed10c00bc4ddd24c4f86e25eb51affa1664d") + add_versions("v1.6.37", "c2c50c13a727af73ecd3fc0167d78592cf5e0bca9611058ca414b6493339c784") + add_versions("v1.6.38", "e1ab4aae9b88329d34bd1ca47adf3fb06c10153dbb660f4c80e2673f9fa94b24") + add_versions("v1.6.39", "eca1ea183643d0b35a764554ede4714cf5dbc30b66845630d81b995c3b2dd571") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_load(function(package) + package:add("deps", "zlib", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(configs, "--enable-static=yes") + if package:config("shared") then + table.insert(configs, "--enable-shared=yes") + else + table.insert(configs, "--enable-shared=no") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package, + {ldflags = ldflags, packagedeps = {"zlib"}}) + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("png_create_read_struct", {includes = "png.h"})) + end) +end diff --git a/repo/packages/l/lua/patches/5.1.4/01_makefile.diff b/repo/packages/l/lua/patches/5.1.4/01_makefile.diff new file mode 100644 index 0000000..b6cfa9e --- /dev/null +++ b/repo/packages/l/lua/patches/5.1.4/01_makefile.diff @@ -0,0 +1,95 @@ +diff --git a/Makefile b/Makefile +index 6e78f66..bdc6887 100644 +--- a/Makefile ++++ b/Makefile +@@ -9,7 +9,7 @@ PLAT= none + + # Where to install. The installation starts in the src and doc directories, + # so take care if INSTALL_TOP is not an absolute path. +-INSTALL_TOP= /usr/local ++ + INSTALL_BIN= $(INSTALL_TOP)/bin + INSTALL_INC= $(INSTALL_TOP)/include + INSTALL_LIB= $(INSTALL_TOP)/lib +@@ -43,7 +43,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + # What to install. + TO_BIN= lua luac + TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp +-TO_LIB= liblua.a ++TO_LIB= liblua.a liblua.so + TO_MAN= lua.1 luac.1 + + # Lua version and release. +diff --git a/src/Makefile b/src/Makefile +index e4a3cd6..8ad051c 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -5,24 +5,25 @@ + # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + + # Your platform. See PLATS for possible values. +-PLAT= none ++PLAT= generic + +-CC= gcc +-CFLAGS= -O2 -Wall $(MYCFLAGS) +-AR= ar rcu +-RANLIB= ranlib ++CC = $(CROSS_COMPILE)gcc ++CXX = $(CROSS_COMPILE)g++ ++CFLAGS = -O2 -Wall -fPIC $(MYCFLAGS) ++AR = $(CROSS_COMPILE)ar rcu ++RANLIB = $(CROSS_COMPILE)ranlib + RM= rm -f + LIBS= -lm $(MYLIBS) + +-MYCFLAGS= +-MYLDFLAGS= +-MYLIBS= ++MYLIBS := -lreadline -lhistory -lncurses ++MYCFLAGS += -DLUA_USE_LINUX + + # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + + PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + + LUA_A= liblua.a ++LUA_SO= liblua.so + CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +@@ -36,7 +37,7 @@ LUAC_T= luac + LUAC_O= luac.o print.o + + ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ++ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO) + ALL_A= $(LUA_A) + + default: $(PLAT) +@@ -51,11 +52,14 @@ $(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + ++$(LUA_SO): $(CORE_O) $(LIB_O) ++ $(CC) -o $@ -shared $? ++ + $(LUA_T): $(LUA_O) $(LUA_A) +- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) ++ $(CXX) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + + $(LUAC_T): $(LUAC_O) $(LUA_A) +- $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) ++ $(CXX) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + + clean: + $(RM) $(ALL_T) $(ALL_O) +@@ -93,7 +97,7 @@ freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + + generic: +- $(MAKE) all MYCFLAGS= ++ $(MAKE) all + + linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" diff --git a/repo/packages/l/lua/scripts/deploy.lua b/repo/packages/l/lua/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/l/lua/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/lua/scripts/export.lua b/repo/packages/l/lua/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/l/lua/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/l/lua/xmake.lua b/repo/packages/l/lua/xmake.lua new file mode 100644 index 0000000..d0e8162 --- /dev/null +++ b/repo/packages/l/lua/xmake.lua @@ -0,0 +1,74 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-07 xqyjlj initial version +-- +package("lua") +do + set_homepage("http://lua.org") + set_description("A powerful, efficient, lightweight, embeddable scripting language.") + + add_urls("https://www.lua.org/ftp/lua-$(version).tar.gz") + + add_versions("5.1.4", "b038e225eaf2a5b57c9bcc35cd13aa8c6c8288ef493d52970c9545074098af3a") + + add_patches("5.1.4", path.join(os.scriptdir(), "patches", "5.1.4", "01_makefile.diff"), + "ce22ca035ebc054876005aa252c2284266c1f34706b12f7219165dbcd5797e4b") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_load(function(package) + package:add("deps", "readline", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + package:add("deps", "ncurses", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + local buildenvs = import("package.tools.autoconf").buildenvs(package, { + ldflags = ldflags, + packagedeps = {"readline", "ncurses"} + }) + + buildenvs.LDFLAGS = string.gsub(buildenvs.LDFLAGS, " %-lncurses%+%+_g", "") + buildenvs.LDFLAGS = string.gsub(buildenvs.LDFLAGS, " %-lncurses%+%+", "") + + table.insert(configs, "generic") + configs.INSTALL_TOP = package:installdir() + + import("package.tools.make").build(package, configs, { + envs = {CROSS_COMPILE = host .. "-", MYCFLAGS = buildenvs.CFLAGS, MYLDFLAGS = buildenvs.LDFLAGS} + }) + table.insert(configs, "install") + import("package.tools.make").build(package, configs, { + envs = {CROSS_COMPILE = host .. "-", MYCFLAGS = buildenvs.CFLAGS, MYLDFLAGS = buildenvs.LDFLAGS} + }) + end) + + on_test(function(package) + assert(package:has_cfuncs("lua_getinfo", {includes = "lua.h"})) + end) +end diff --git a/repo/packages/m/micropython/patches/1.20.0/01_adapt_smart.diff b/repo/packages/m/micropython/patches/1.20.0/01_adapt_smart.diff new file mode 100644 index 0000000..b51546e --- /dev/null +++ b/repo/packages/m/micropython/patches/1.20.0/01_adapt_smart.diff @@ -0,0 +1,26 @@ +diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h +index 8eafb6119..04d284e8f 100644 +--- a/ports/unix/mpconfigport.h ++++ b/ports/unix/mpconfigport.h +@@ -43,7 +43,7 @@ + #if defined(__APPLE__) && defined(__MACH__) + #define MICROPY_PY_SYS_PLATFORM "darwin" + #else +- #define MICROPY_PY_SYS_PLATFORM "linux" ++ #define MICROPY_PY_SYS_PLATFORM "rt-smart" + #endif + #endif + +diff --git a/ports/unix/mpconfigport.mk b/ports/unix/mpconfigport.mk +index ce6183c13..f98769960 100644 +--- a/ports/unix/mpconfigport.mk ++++ b/ports/unix/mpconfigport.mk +@@ -9,7 +9,7 @@ MICROPY_FORCE_32BIT = 0 + MICROPY_USE_READLINE = 1 + + # btree module using Berkeley DB 1.xx +-MICROPY_PY_BTREE = 1 ++MICROPY_PY_BTREE = 0 + + # _thread module using pthreads + MICROPY_PY_THREAD = 1 diff --git a/repo/packages/m/micropython/scripts/deploy.lua b/repo/packages/m/micropython/scripts/deploy.lua new file mode 100644 index 0000000..b084b0b --- /dev/null +++ b/repo/packages/m/micropython/scripts/deploy.lua @@ -0,0 +1,30 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-09 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end +end diff --git a/repo/packages/m/micropython/xmake.lua b/repo/packages/m/micropython/xmake.lua new file mode 100644 index 0000000..d03b553 --- /dev/null +++ b/repo/packages/m/micropython/xmake.lua @@ -0,0 +1,77 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-06-25 xqyjlj initial version +-- +package("micropython") +do + set_homepage("https://micropython.org/") + set_description("MicroPython is a lean and efficient implementation of the Python 3 programming language.") + + add_urls("https://github.com/micropython/micropython/releases/download/v$(version)/micropython-$(version).tar.xz") + + add_versions("1.20.0", "098ef8e40abdc62551b5460d0ffe9489074240c0cb5589ca3c3a425551beb9bf") + + add_patches("1.20.0", path.join(os.scriptdir(), "patches", "1.20.0", "01_adapt_smart.diff"), + "d0eb05d02339977f9c5771dcc81d2a616962ec57cb4d272fe8da3b8b22cc830c") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + add_configs("with_ffi", {description = "use libffi library.", default = false, type = "boolean"}) + + on_load(function(package) + if package:config("with_ffi") then + package:add("deps", "libffi", + {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end + end) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local version = info.version + local host = info.host + local cc = info.cc + local configs = {host = ""} + local cxflags = {} + local packagedeps = {} + + if package:config("with_ffi") then + table.insert(cxflags, "-DMICROPY_FORCE_PLAT_ALLOC_EXEC=0") + table.insert(packagedeps, "libffi") + else + io.gsub("ports/unix/mpconfigport.mk", "MICROPY_PY_FFI =.-\n", 'MICROPY_PY_FFI = 0') + end + + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + local buildenvs = import("package.tools.autoconf").buildenvs(package, + {cxflags = cxflags, packagedeps = packagedeps}) + + import("package.tools.make").build(package, {"-C", "mpy-cross"}, {envs = {}}) + import("package.tools.make").build(package, {"-C", "ports/unix", "VARIANT=standard"}, { + envs = {CROSS_COMPILE = host .. "-", LDFLAGS = buildenvs.LDFLAGS, CFLAGS_EXTRA = buildenvs.CFLAGS} + }) + os.vcp("ports/unix/build-standard/micropython", package:installdir("bin")) + end) + + on_test(function(package) + assert(os.isfile(path.join(package:installdir("bin"), "micropython"))) + end) +end diff --git a/repo/packages/n/ncurses/scripts/deploy.lua b/repo/packages/n/ncurses/scripts/deploy.lua new file mode 100644 index 0000000..598cb72 --- /dev/null +++ b/repo/packages/n/ncurses/scripts/deploy.lua @@ -0,0 +1,43 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-06-26 zy copy terminfo database +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filedir in ipairs(os.filedirs(path.join(installdir, "share", "terminfo") .. "/*")) do + local inc = path.join(installdir, "share", "terminfo") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "etc", "terminfo", name), + {rootdir = inc, symlink = true}) + end +end diff --git a/repo/packages/n/ncurses/scripts/export.lua b/repo/packages/n/ncurses/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/n/ncurses/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/n/ncurses/xmake.lua b/repo/packages/n/ncurses/xmake.lua new file mode 100644 index 0000000..112f69d --- /dev/null +++ b/repo/packages/n/ncurses/xmake.lua @@ -0,0 +1,71 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-03-02 xqyjlj initial version +-- +package("ncurses") +do + set_homepage("https://www.gnu.org/software/ncurses/") + set_description("A free software emulation of curses.") + + add_urls("https://ftpmirror.gnu.org/ncurses/ncurses-$(version).tar.gz") + add_urls("https://ftp.gnu.org/pub/gnu/ncurses/ncurses-$(version).tar.gz") + add_urls("https://invisible-mirror.net/archives/ncurses/ncurses-$(version).tar.gz") + + add_versions("6.4", "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(configs, "--disable-stripping") + table.insert(configs, "--with-terminfo-dirs=/etc/terminfo:/lib/terminfo:/usr/share/terminfo") + if package:config("debug") then + table.insert(configs, "--with-debug") + table.insert(configs, "--with-trace") + + else + table.insert(configs, "--without-debug") + table.insert(configs, "--without-trace") + end + + table.insert(ldflags, "-lstdc++") + if package:config("shared") then + table.insert(configs, "--with-shared") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package, {ldflags = ldflags}) + buildenvs.ARFLAGS = "" + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("initscr", {includes = "ncurses/ncurses.h"})) + end) +end diff --git a/repo/packages/o/openssl/patches/1.1.1-i/01_crypto_mem_sec.diff b/repo/packages/o/openssl/patches/1.1.1-i/01_crypto_mem_sec.diff new file mode 100644 index 0000000..937d13b --- /dev/null +++ b/repo/packages/o/openssl/patches/1.1.1-i/01_crypto_mem_sec.diff @@ -0,0 +1,13 @@ +diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c +index b5f959b..8cdf8d3 100644 +--- a/crypto/mem_sec.c ++++ b/crypto/mem_sec.c +@@ -30,7 +30,7 @@ + # if defined(OPENSSL_SYS_LINUX) + # include + # if defined(SYS_mlock2) +-# include ++# include + # include + # endif + # endif diff --git a/repo/packages/o/openssl/patches/1.1.1-i/02_engines_e_afalg.diff b/repo/packages/o/openssl/patches/1.1.1-i/02_engines_e_afalg.diff new file mode 100644 index 0000000..9afcf4e --- /dev/null +++ b/repo/packages/o/openssl/patches/1.1.1-i/02_engines_e_afalg.diff @@ -0,0 +1,15 @@ +diff --git a/engines/e_afalg.c b/engines/e_afalg.c +index 4b17228..b4987dc 100644 +--- a/engines/e_afalg.c ++++ b/engines/e_afalg.c +@@ -22,8 +22,8 @@ + + #include + #include +-#define K_MAJ 4 +-#define K_MIN1 1 ++#define K_MAJ 5 ++#define K_MIN1 9 + #define K_MIN2 0 + #if LINUX_VERSION_CODE < KERNEL_VERSION(K_MAJ, K_MIN1, K_MIN2) || \ + !defined(AF_ALG) diff --git a/repo/packages/o/openssl/patches/1.1.1-i/03_include_linux_version.diff b/repo/packages/o/openssl/patches/1.1.1-i/03_include_linux_version.diff new file mode 100644 index 0000000..bc7b017 --- /dev/null +++ b/repo/packages/o/openssl/patches/1.1.1-i/03_include_linux_version.diff @@ -0,0 +1,8 @@ +diff --git a/include/linux/version.h b/include/linux/version.h +new file mode 100644 +index 0000000..e5d14f7 +--- /dev/null ++++ b/include/linux/version.h +@@ -0,0 +1,2 @@ ++#define LINUX_VERSION_CODE 328777 ++#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/repo/packages/o/openssl/scripts/deploy.lua b/repo/packages/o/openssl/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/o/openssl/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/o/openssl/scripts/export.lua b/repo/packages/o/openssl/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/o/openssl/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/o/openssl/xmake.lua b/repo/packages/o/openssl/xmake.lua new file mode 100644 index 0000000..2c3a913 --- /dev/null +++ b/repo/packages/o/openssl/xmake.lua @@ -0,0 +1,90 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj initial version +-- +package("openssl") +do + set_homepage("https://www.openssl.org/") + set_description("A robust, commercial-grade, and full-featured toolkit for TLS and SSL.") + + add_urls("https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_$(version).tar.gz", { + version = function(version) + return version:gsub("^(%d+)%.(%d+)%.(%d+)-?(%a*)$", "%1_%2_%3%4") + end, + excludes = "*/fuzz/*" + }) + + add_versions("1.1.1-i", "728d537d466a062e94705d44ee8c13c7b82d1b66f59f4e948e0cbf1cd7c461d8") + + add_patches("1.1.1-i", path.join(os.scriptdir(), "patches", "1.1.1-i", "01_crypto_mem_sec.diff"), + "0667c3d25ace4aa416d31ad4f9e867aa7e8a1406dabe3db59da6afd228206f9c") + add_patches("1.1.1-i", path.join(os.scriptdir(), "patches", "1.1.1-i", "02_engines_e_afalg.diff"), + "e807384466d3f063da1b85f1ec2173d053954561a32506d58cda91fabc44bf64") + add_patches("1.1.1-i", path.join(os.scriptdir(), "patches", "1.1.1-i", "03_include_linux_version.diff"), + "334e52ac96629e2c0e2c35b77bfa597a22fd10c7d3b1c5ed8ac95b7275505373") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + if package:config("debug") then + table.insert(configs, "--debug") + end + + if package:config("shared") then + table.insert(configs, "shared") + else + table.insert(configs, "no-shared") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package, {ldflags = ldflags}) + + table.insert(configs, "linux-generic64") + table.insert(configs, "-DOPENSSL_NO_HEARTBEATS") + table.insert(configs, "no-threads") + table.insert(configs, "--prefix=/") + table.insert(configs, "--openssldir=/etc/ssl") + + os.vrunv("./Configure", configs, {envs = buildenvs}) + import("package.tools.make").build(package, {}, {envs = buildenvs}) + import("package.tools.make").make(package, {"install_sw", "DESTDIR=" .. package:installdir()}, + {envs = buildenvs}) + for _, suffix in ipairs({".a", ".so"}) do + if os.isfile(path.join(package:installdir("lib"), "libssl" .. suffix)) then + package:add("links", "ssl") -- ssl first + end + if os.isfile(path.join(package:installdir("lib"), "libcrypto" .. suffix)) then + package:add("links", "crypto") -- crypto must come after ssl + end + end + end) + + on_test(function(package) + assert(package:has_cfuncs("SSL_new", {includes = "openssl/ssl.h"})) + end) +end diff --git a/repo/packages/p/pcre/scripts/deploy.lua b/repo/packages/p/pcre/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/p/pcre/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/p/pcre/scripts/export.lua b/repo/packages/p/pcre/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/p/pcre/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/p/pcre/xmake.lua b/repo/packages/p/pcre/xmake.lua new file mode 100644 index 0000000..ae8d425 --- /dev/null +++ b/repo/packages/p/pcre/xmake.lua @@ -0,0 +1,75 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-05 xqyjlj initial version +-- +package("pcre") +do + set_homepage("https://www.pcre.org/") + set_description("A Perl Compatible Regular Expressions Library") + + add_urls("https://github.com/xmake-mirror/pcre/releases/download/$(version)/pcre-$(version).tar.bz2") + add_versions("8.45", "4dae6fdcd2bb0bb6c37b5f97c33c2be954da743985369cddac3546e3218bffb8") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + add_configs("jit", {description = "Enable jit.", default = false, type = "boolean"}) + add_configs("bitwidth", {description = "Set the code unit width.", default = "8", values = {"8", "16", "32"}}) + + on_install("cross@linux,windows", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(configs, "-DPCRE_BUILD_TESTS=OFF") + if package:config("shared") then + table.insert(configs, "-DBUILD_SHARED_LIBS=ON") + table.insert(configs, "-DBUILD_STATIC_LIBS=OFF") + else + table.insert(configs, "-DBUILD_SHARED_LIBS=OFF") + table.insert(configs, "-DBUILD_STATIC_LIBS=ON") + end + + if package:config("jit") then + table.insert(configs, "-DPCRE_SUPPORT_JIT=ON") + else + table.insert(configs, "-DPCRE_SUPPORT_JIT=OFF") + end + + local bitwidth = package:config("bitwidth") or "8" + if bitwidth ~= "8" then + table.insert(configs, "-DPCRE_BUILD_PCRE8=OFF") + table.insert(configs, "-DPCRE_BUILD_PCRE" .. bitwidth .. "=ON") + end + + local instance = package:toolchain(info.toolchains) + local ld = instance:get("toolset")["ld"] + local cxx = instance:get("toolset")["cxx"] + instance:set("toolset", "ld", cxx) + import("package.tools.cmake").install(package, configs, {buildir = "build", ldflags = ldflags}) + instance:set("toolset", "ld", ld) + end) + + on_test(function(package) + end) +end diff --git a/repo/packages/r/readline/scripts/deploy.lua b/repo/packages/r/readline/scripts/deploy.lua new file mode 100644 index 0000000..b8ba071 --- /dev/null +++ b/repo/packages/r/readline/scripts/deploy.lua @@ -0,0 +1,30 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/r/readline/scripts/export.lua b/repo/packages/r/readline/scripts/export.lua new file mode 100644 index 0000000..8eee8fb --- /dev/null +++ b/repo/packages/r/readline/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include") .. "/*")) do + local inc = path.join(installdir, "include") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/r/readline/xmake.lua b/repo/packages/r/readline/xmake.lua new file mode 100644 index 0000000..e1d87de --- /dev/null +++ b/repo/packages/r/readline/xmake.lua @@ -0,0 +1,64 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-03-03 xqyjlj initial version +-- +package("readline") +do + set_homepage("https://tiswww.case.edu/php/chet/readline/rltop.html") + set_description("Library for command-line editing") + + add_urls("https://ftp.gnu.org/gnu/readline/readline-$(version).tar.gz") + add_urls("https://ftpmirror.gnu.org/readline/readline-$(version).tar.gz") + + add_versions("8.1", "f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02") + + on_load(function(package) + -- package:add("deps", "ncurses", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end) + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + if not package:config("shared") then + table.insert(configs, "--enable-shared=no") + else + table.insert(configs, "--enable-shared=yes") + end + + local buildenvs = import("package.tools.autoconf").buildenvs(package) + + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("readline", {includes = {"stdio.h", "readline/readline.h"}})) + end) +end diff --git a/repo/packages/r/riscv64gc-unknown-smart-musl/xmake.lua b/repo/packages/r/riscv64gc-unknown-smart-musl/xmake.lua index d4bb645..05b56c5 100644 --- a/repo/packages/r/riscv64gc-unknown-smart-musl/xmake.lua +++ b/repo/packages/r/riscv64gc-unknown-smart-musl/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-12 zhouquan initial version +-- 2023-05-12 xqyjlj initial version -- package("riscv64gc-unknown-smart-musl") do diff --git a/repo/packages/s/sdl2/patches/2.0.14/01_adapt_smart.diff b/repo/packages/s/sdl2/patches/2.0.14/01_adapt_smart.diff new file mode 100644 index 0000000..b6b1ad5 --- /dev/null +++ b/repo/packages/s/sdl2/patches/2.0.14/01_adapt_smart.diff @@ -0,0 +1,1382 @@ +diff --git a/configure.ac b/configure.ac +index b7e519b8f..a0b2ddcdf 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2281,6 +2281,48 @@ AS_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[defa + fi + } + ++CheckRttVideo() ++{ ++ AC_ARG_ENABLE(video-rtt, ++AS_HELP_STRING([--enable-video-rtt], [use rt-smart video driver [[default=yes]]]), ++ , enable_video_rtt=yes) ++ if test x$enable_video_rtt = xyes; then ++ AC_DEFINE(SDL_VIDEO_DRIVER_RTT, 1, [ ]) ++ SOURCES="$SOURCES $srcdir/src/video/rtt/*.c" ++ have_video=yes ++ fi ++} ++ ++CheckRttVideoVirtioGpu() ++{ ++ AC_ARG_ENABLE(video-rtt-virtio-gpu, ++AS_HELP_STRING([--enable-video-rtt-virtio-gpu], [use rt-smart video virtio-gpu driver [[default=no]]]), ++ , enable_video_rtt_virtio_gpu=no) ++ if test x$enable_video_rtt_virtio_gpu = xyes; then ++ AC_DEFINE(SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU, 1, [ ]) ++ fi ++} ++ ++CheckRttVideoFbdev() ++{ ++ AC_ARG_ENABLE(video-rtt-fbdev, ++AS_HELP_STRING([--enable-video-rtt-fbdev], [use rt-smart video fbdev driver [[default=no]]]), ++ , enable_video_rtt_fbdev=no) ++ if test x$enable_video_rtt_fbdev = xyes; then ++ AC_DEFINE(SDL_VIDEO_DRIVER_RTT_FBDEV, 1, [ ]) ++ fi ++} ++ ++CheckRttVideoTouch() ++{ ++ AC_ARG_ENABLE(video-rtt-touch, ++AS_HELP_STRING([--enable-video-rtt-touch], [use rt-smart video touch driver [[default=no]]]), ++ , enable_video_rtt_touch=no) ++ if test x$enable_video_rtt_touch = xyes; then ++ AC_DEFINE(SDL_VIDEO_DRIVER_RTT_TOUCH, 1, [ ]) ++ fi ++} ++ + dnl rcg04172001 Set up the Null video driver. + CheckDummyVideo() + { +@@ -3536,6 +3578,10 @@ case "$host" in + CheckVisibilityHidden + CheckDeclarationAfterStatement + CheckDummyVideo ++ CheckRttVideo ++ CheckRttVideoVirtioGpu ++ CheckRttVideoFbdev ++ CheckRttVideoTouch + CheckDiskAudio + CheckDummyAudio + CheckDLOPEN +diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in +index 3a2a7149d..24e3f2e29 100644 +--- a/include/SDL_config.h.in ++++ b/include/SDL_config.h.in +@@ -344,6 +344,10 @@ + #undef SDL_VIDEO_DRIVER_DIRECTFB + #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC + #undef SDL_VIDEO_DRIVER_DUMMY ++#undef SDL_VIDEO_DRIVER_RTT ++#undef SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU ++#undef SDL_VIDEO_DRIVER_RTT_FBDEV ++#undef SDL_VIDEO_DRIVER_RTT_TOUCH + #undef SDL_VIDEO_DRIVER_WINDOWS + #undef SDL_VIDEO_DRIVER_WAYLAND + #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h +index e9c66c05f..a0021cca4 100644 +--- a/src/core/linux/SDL_evdev_capabilities.h ++++ b/src/core/linux/SDL_evdev_capabilities.h +@@ -25,7 +25,7 @@ + #ifndef SDL_evdev_capabilities_h_ + #define SDL_evdev_capabilities_h_ + +-#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) ++#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) || defined(SDL_HAPTIC_LINUX) + + #include + +diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c +index d210fdba0..17d4215ae 100644 +--- a/src/events/SDL_quit.c ++++ b/src/events/SDL_quit.c +@@ -35,6 +35,8 @@ + #define HAVE_SIGNAL_SUPPORT 1 + #endif + ++#define SDL_FOREGROUNDING_SIGNAL 1 ++ + #ifdef HAVE_SIGNAL_SUPPORT + static SDL_bool disable_signals = SDL_FALSE; + static SDL_bool send_quit_pending = SDL_FALSE; +@@ -44,7 +46,7 @@ static SDL_bool send_backgrounding_pending = SDL_FALSE; + #endif + + #ifdef SDL_FOREGROUNDING_SIGNAL +-static SDL_bool send_foregrounding_pending = SDL_FALSE; ++static SDL_bool send_foregrounding_pending = SDL_TRUE; + #endif + + static void +diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h +index c8c425b6b..38d3979e4 100644 +--- a/src/video/SDL_sysvideo.h ++++ b/src/video/SDL_sysvideo.h +@@ -439,6 +439,7 @@ extern VideoBootStrap QNX_bootstrap; + extern VideoBootStrap OFFSCREEN_bootstrap; + extern VideoBootStrap OS2DIVE_bootstrap; + extern VideoBootStrap OS2VMAN_bootstrap; ++extern VideoBootStrap RTT_bootstrap; + + extern SDL_VideoDevice *SDL_GetVideoDevice(void); + extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); +diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c +index a0ca32243..b9990236c 100644 +--- a/src/video/SDL_video.c ++++ b/src/video/SDL_video.c +@@ -119,6 +119,9 @@ static VideoBootStrap *bootstrap[] = { + #endif + #if SDL_VIDEO_DRIVER_DUMMY + &DUMMY_bootstrap, ++#endif ++#if SDL_VIDEO_DRIVER_RTT ++ &RTT_bootstrap, + #endif + NULL + }; +@@ -462,6 +465,7 @@ SDL_GetVideoDriver(int index) + return NULL; + } + ++ + /* + * Initialize the video and event subsystems -- determine native pixel format + */ +diff --git a/src/video/rtt/SDL_rttcommon.h b/src/video/rtt/SDL_rttcommon.h +new file mode 100644 +index 000000000..8bc85fe7b +--- /dev/null ++++ b/src/video/rtt/SDL_rttcommon.h +@@ -0,0 +1,43 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#ifndef __SDL_RTTCOMMON_H__ ++#define __SDL_RTTCOMMON_H__ ++ ++#include "../../SDL_internal.h" ++#include "SDL_surface.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++#if SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU && SDL_VIDEO_DRIVER_RTT_FBDEV ++#error "only use one of them" ++#endif ++ ++#if !SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU && !SDL_VIDEO_DRIVER_RTT_FBDEV ++#error "must use one of them" ++#endif ++ ++#define RTT_SDL_FORMAT SDL_PIXELFORMAT_BGR888 ++ ++#if SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU ++ ++#ifndef HAVE_CCONFIG_H ++#define HAVE_CCONFIG_H ++#endif ++ ++#include "rtthread.h" ++ ++#define RTT_FORMAT RTGRAPHIC_PIXEL_FORMAT_RGB888 ++ ++#endif ++ ++#endif ++ ++#endif +diff --git a/src/video/rtt/SDL_rttframebuffer.c b/src/video/rtt/SDL_rttframebuffer.c +new file mode 100755 +index 000000000..b20219c0d +--- /dev/null ++++ b/src/video/rtt/SDL_rttframebuffer.c +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "../SDL_sysvideo.h" ++#include "SDL_rttcommon.h" ++#include "SDL_rttframebuffer.h" ++#include "SDL_rttscreen.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++#define RTT_SURFACE "_SDL_RttSurface" ++ ++extern uint32_t g_sdl_rtt_pixel_format; ++ ++int SDL_RTT_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) ++{ ++ SDL_Surface *surface; ++ int w, h; ++ int bpp; ++ Uint32 Rmask, Gmask, Bmask, Amask; ++ /* Free the old framebuffer surface */ ++ surface = (SDL_Surface *)SDL_GetWindowData(window, RTT_SURFACE); ++ SDL_FreeSurface(surface); ++ ++ /* Create a new one */ ++ SDL_PixelFormatEnumToMasks(g_sdl_rtt_pixel_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); ++ SDL_GetWindowSize(window, &w, &h); ++ surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); ++ if(!surface) ++ { ++ return -1; ++ } ++ /* Save the info and return! */ ++ SDL_SetWindowData(window, RTT_SURFACE, surface); ++ *format = g_sdl_rtt_pixel_format; ++ *pixels = surface->pixels; ++ *pitch = surface->pitch; ++ return 0; ++} ++ ++int SDL_RTT_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) ++{ ++ static int frame_number; ++ SDL_Surface *surface; ++ surface = (SDL_Surface *)SDL_GetWindowData(window, RTT_SURFACE); ++ if(!surface) ++ { ++ return SDL_SetError("Couldn't find rtt surface for window"); ++ } ++ if(SDL_getenv("SDL_VIDEO_RTT_SAVE_FRAMES")) ++ { ++ char file[128]; ++ SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); ++ SDL_SaveBMP(surface, file); ++ } ++ RTT_surface2screen(surface, window->x, window->y); ++ return 0; ++} ++ ++void SDL_RTT_DestroyWindowFramebuffer(_THIS, SDL_Window *window) ++{ ++ SDL_Surface *surface; ++ surface = (SDL_Surface *)SDL_SetWindowData(window, RTT_SURFACE, NULL); ++ SDL_FreeSurface(surface); ++} ++ ++#endif +diff --git a/src/video/rtt/SDL_rttframebuffer.h b/src/video/rtt/SDL_rttframebuffer.h +new file mode 100755 +index 000000000..d0de80f8d +--- /dev/null ++++ b/src/video/rtt/SDL_rttframebuffer.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#ifndef __SDL_RTTFRAMEBUFFER_H__ ++#define __SDL_RTTFRAMEBUFFER_H__ ++ ++int SDL_RTT_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); ++int SDL_RTT_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); ++void SDL_RTT_DestroyWindowFramebuffer(_THIS, SDL_Window *window); ++ ++#endif +diff --git a/src/video/rtt/SDL_rttkeyboard.c b/src/video/rtt/SDL_rttkeyboard.c +new file mode 100644 +index 000000000..5f432e366 +--- /dev/null ++++ b/src/video/rtt/SDL_rttkeyboard.c +@@ -0,0 +1,46 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "../../events/SDL_keyboard_c.h" ++#include "SDL_keyboard.h" ++#include "SDL_rttkeyboard.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++void RTT_InitKeyboard(void) ++{ ++ // TODO ++} ++ ++int RTT_HeldKeyboardCode(int index) ++{ ++ // TODO ++ return 0; ++} ++ ++int RTT_GetKeyboardCode(int keycode) ++{ ++ // TODO ++ return 0; ++} ++ ++void RTT_PollKeyboard(void) ++{ ++ // TODO ++} ++ ++void RTT_QuitKeyboard(void) ++{ ++ // TODO ++} ++ ++#endif +diff --git a/src/video/rtt/SDL_rttkeyboard.h b/src/video/rtt/SDL_rttkeyboard.h +new file mode 100644 +index 000000000..1cad947ea +--- /dev/null ++++ b/src/video/rtt/SDL_rttkeyboard.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#ifndef __SDL_RTTKEYBOARD_H__ ++#define __SDL_RTTKEYBOARD_H__ ++ ++void RTT_InitKeyboard(void); ++void RTT_PollKeyboard(void); ++void RTT_QuitKeyboard(void); ++ ++#endif +diff --git a/src/video/rtt/SDL_rttmouse.c b/src/video/rtt/SDL_rttmouse.c +new file mode 100644 +index 000000000..d96c46dd6 +--- /dev/null ++++ b/src/video/rtt/SDL_rttmouse.c +@@ -0,0 +1,34 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "../../events/SDL_mouse_c.h" ++#include "SDL_mouse.h" ++#include "SDL_rttmouse.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++void RTT_InitMouse(void) ++{ ++ // TODO ++} ++ ++void RTT_PollMouse(void) ++{ ++ // TODO ++} ++ ++void RTT_QuitMouse(void) ++{ ++ // TODO ++} ++ ++#endif +diff --git a/src/video/rtt/SDL_rttmouse.h b/src/video/rtt/SDL_rttmouse.h +new file mode 100644 +index 000000000..c82509744 +--- /dev/null ++++ b/src/video/rtt/SDL_rttmouse.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#ifndef __SDL_RTTMOUSE_H__ ++#define __SDL_RTTMOUSE_H__ ++ ++void RTT_InitMouse(void); ++void RTT_PollMouse(void); ++void RTT_QuitMouse(void); ++ ++#endif +diff --git a/src/video/rtt/SDL_rttscreen.c b/src/video/rtt/SDL_rttscreen.c +new file mode 100755 +index 000000000..4e76086d1 +--- /dev/null ++++ b/src/video/rtt/SDL_rttscreen.c +@@ -0,0 +1,387 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-samrt ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "SDL_pixels.h" ++#include "SDL_rttcommon.h" ++#include "SDL_rttscreen.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++#if SDL_VIDEO_DRIVER_RTT_VIRTIO_GPU ++ ++#define VIRTIO_GPU_FORMAT_BPP 32 ++#define VIRTIO_GPU_FORMAT_PIXEL 4 ++#define VIRTIO_GPU_CURSOR_WIDTH 64 ++#define VIRTIO_GPU_CURSOR_HEIGHT 64 ++#define VIRTIO_GPU_CURSOR_IMG_SIZE (VIRTIO_GPU_CURSOR_WIDTH * VIRTIO_GPU_CURSOR_HEIGHT * VIRTIO_GPU_FORMAT_PIXEL) ++ ++#define VIRTIO_PAGE_SHIFT 12 ++#define VIRTIO_PAGE_SIZE (1 << VIRTIO_PAGE_SHIFT) ++ ++enum ++{ ++ VIRTIO_DEVICE_CTRL_GPU_SET_PRIMARY = 0x20, ++ VIRTIO_DEVICE_CTRL_GPU_CREATE_2D, ++ ++ VIRTIO_DEVICE_CTRL_CURSOR_SETUP, ++ VIRTIO_DEVICE_CTRL_CURSOR_SET_IMG, ++ VIRTIO_DEVICE_CTRL_CURSOR_MOVE, ++ ++ VIRTIO_DEVICE_CTRL_FRAMEBUFFER_COPY, ++}; ++ ++rt_device_t gpu_dev = RT_NULL; ++struct virtio_gpu_device *virtio_gpu_dev = RT_NULL; ++static rt_uint8_t cursor[VIRTIO_GPU_CURSOR_IMG_SIZE] ALIGN(VIRTIO_PAGE_SIZE); ++struct rt_device_graphic_info graphic_info; ++struct rt_device_rect_info rect_info; ++ ++int RTT_surface2screen(SDL_Surface *surface, int x, int y) ++{ ++ if(gpu_dev) ++ { ++ rt_device_control(gpu_dev, VIRTIO_DEVICE_CTRL_FRAMEBUFFER_COPY, surface->pixels); ++ rt_device_control(gpu_dev, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info); ++ } ++ return 0; ++} ++ ++int RTT_screenInit(struct rtt_screen_config *config) ++{ ++ rt_err_t ret = -1; ++ uint32_t i = 0; ++ if(config == NULL) ++ { ++ return 1; ++ } ++ ++ gpu_dev = rt_device_find("virtio-gpu0"); ++ if(gpu_dev != RT_NULL && rt_device_open(gpu_dev, 0) == RT_EOK) ++ { ++ rt_memset(&rect_info, 0, sizeof(rect_info)); ++ rt_device_control(gpu_dev, VIRTIO_DEVICE_CTRL_GPU_SET_PRIMARY, RT_NULL); ++ rt_device_control(gpu_dev, VIRTIO_DEVICE_CTRL_GPU_CREATE_2D, (void *)RTT_FORMAT); ++ rt_device_control(gpu_dev, RTGRAPHIC_CTRL_GET_INFO, &graphic_info); ++ config->pixel_format = RTT_SDL_FORMAT; ++ config->width = graphic_info.width; ++ config->height = graphic_info.height; ++ rect_info.x = 0; ++ rect_info.y = 0; ++ rect_info.width = graphic_info.width; ++ rect_info.height = graphic_info.height; ++ while(i < sizeof(cursor) / 4) ++ { ++ /* R: 0x4c G: 0xaf B: 0x50 A: 0.8 */ ++ ((rt_uint32_t *)cursor)[i] = 0xcc4caf50; ++ ++i; ++ } ++ rt_device_control(gpu_dev, VIRTIO_DEVICE_CTRL_CURSOR_SETUP, cursor); ++ rt_device_control(gpu_dev, VIRTIO_DEVICE_CTRL_CURSOR_MOVE, (rt_uint32_t[]){0, 0}); ++ virtio_gpu_dev = (struct virtio_gpu_device *)gpu_dev; ++ ret = 0; ++ } ++ ++ return ret; ++} ++ ++int RTT_screenQuit() ++{ ++ rt_err_t ret = -1; ++ if(gpu_dev) ++ { ++ ret = rt_device_close(gpu_dev); ++ gpu_dev = NULL; ++ } ++ return ret; ++} ++ ++#elif SDL_VIDEO_DRIVER_RTT_FBDEV ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define __u32 uint32_t ++#define __u16 uint16_t ++ ++#define FBIOGET_VSCREENINFO 0x4600 ++#define FBIOPUT_VSCREENINFO 0x4601 ++#define FBIOGET_FSCREENINFO 0x4602 ++ ++#define FBIOPAN_DISPLAY 0x4606 ++ ++#define FBIOBLANK 0x4611 /* arg: 0 or vesa level + 1 */ ++ ++/* VESA Blanking Levels */ ++#define VESA_NO_BLANKING 0 ++#define VESA_VSYNC_SUSPEND 1 ++#define VESA_HSYNC_SUSPEND 2 ++#define VESA_POWERDOWN 3 ++ ++enum ++{ ++ /* screen: unblanked, hsync: on, vsync: on */ ++ FB_BLANK_UNBLANK = VESA_NO_BLANKING, ++ /* screen: blanked, hsync: on, vsync: on */ ++ FB_BLANK_NORMAL = VESA_NO_BLANKING + 1, ++ /* screen: blanked, hsync: on, vsync: off */ ++ FB_BLANK_VSYNC_SUSPEND = VESA_VSYNC_SUSPEND + 1, ++ /* screen: blanked, hsync: off, vsync: on */ ++ FB_BLANK_HSYNC_SUSPEND = VESA_HSYNC_SUSPEND + 1, ++ /* screen: blanked, hsync: off, vsync: off */ ++ FB_BLANK_POWERDOWN = VESA_POWERDOWN + 1 ++}; ++ ++struct fb_bitfield ++{ ++ __u32 offset; /* beginning of bitfield */ ++ __u32 length; /* length of bitfield */ ++ __u32 msb_right; /* != 0 : Most significant bit is */ ++ /* right */ ++}; ++ ++struct fb_var_screeninfo ++{ ++ __u32 xres; /* visible resolution */ ++ __u32 yres; ++ __u32 xres_virtual; /* virtual resolution */ ++ __u32 yres_virtual; ++ __u32 xoffset; /* offset from virtual to visible */ ++ __u32 yoffset; /* resolution */ ++ ++ __u32 bits_per_pixel; /* guess what */ ++ __u32 grayscale; /* 0 = color, 1 = grayscale, */ ++ /* >1 = FOURCC */ ++ struct fb_bitfield red; /* bitfield in fb mem if true color, */ ++ struct fb_bitfield green; /* else only length is significant */ ++ struct fb_bitfield blue; ++ struct fb_bitfield transp; /* transparency */ ++ ++ __u32 nonstd; /* != 0 Non standard pixel format */ ++ ++ __u32 activate; /* see FB_ACTIVATE_* */ ++ ++ __u32 height; /* height of picture in mm */ ++ __u32 width; /* width of picture in mm */ ++ ++ __u32 accel_flags; /* (OBSOLETE) see fb_info.flags */ ++ ++ /* Timing: All values in pixclocks, except pixclock (of course) */ ++ __u32 pixclock; /* pixel clock in ps (pico seconds) */ ++ __u32 left_margin; /* time from sync to picture */ ++ __u32 right_margin; /* time from picture to sync */ ++ __u32 upper_margin; /* time from sync to picture */ ++ __u32 lower_margin; ++ __u32 hsync_len; /* length of horizontal sync */ ++ __u32 vsync_len; /* length of vertical sync */ ++ __u32 sync; /* see FB_SYNC_* */ ++ __u32 vmode; /* see FB_VMODE_* */ ++ __u32 rotate; /* angle we rotate counter clockwise */ ++ __u32 colorspace; /* colorspace for FOURCC-based modes */ ++ __u32 reserved[4]; /* Reserved for future compatibility */ ++}; ++ ++struct fb_fix_screeninfo ++{ ++ char id[16]; /* identification string eg "TT Builtin" */ ++ unsigned long smem_start; /* Start of frame buffer mem */ ++ /* (physical address) */ ++ __u32 smem_len; /* Length of frame buffer mem */ ++ __u32 type; /* see FB_TYPE_* */ ++ __u32 type_aux; /* Interleave for interleaved Planes */ ++ __u32 visual; /* see FB_VISUAL_* */ ++ __u16 xpanstep; /* zero if no hardware panning */ ++ __u16 ypanstep; /* zero if no hardware panning */ ++ __u16 ywrapstep; /* zero if no hardware ywrap */ ++ __u32 line_length; /* length of a line in bytes */ ++ unsigned long mmio_start; /* Start of Memory Mapped I/O */ ++ /* (physical address) */ ++ __u32 mmio_len; /* Length of Memory Mapped I/O */ ++ __u32 accel; /* Indicate to driver which */ ++ /* specific chip/card we have */ ++ __u16 capabilities; /* see FB_CAP_* */ ++ __u16 reserved[2]; /* Reserved for future compatibility */ ++}; ++ ++#define FBDEV_PATH "/dev/fb0" ++ ++static struct fb_var_screeninfo vinfo; ++static struct fb_fix_screeninfo finfo; ++ ++static char *fbp = 0; ++static long int screensize = 0; ++static int fbfd = 0; ++ ++uint32_t g_sdl_rtt_pixel_format = 0; ++uint32_t g_sdl_rtt_screen_width; ++uint32_t g_sdl_rtt_screen_heigth; ++ ++static int __var_to_pixfmt(struct fb_var_screeninfo *var) ++{ ++ /* ++ * Check for 565/1555. ++ */ ++ if(var->bits_per_pixel == 16 && var->red.length <= 5 && var->green.length <= 6 && var->blue.length <= 5) ++ { ++ if(var->transp.length == 0) ++ { ++ if(var->red.offset >= var->blue.offset) ++ return SDL_PIXELFORMAT_RGB565; ++ else ++ return SDL_PIXELFORMAT_BGR565; ++ } ++ } ++ ++ /* ++ * Check for 888/A888. ++ */ ++ if(var->bits_per_pixel <= 32 && var->red.length <= 8 && var->green.length <= 8 && var->blue.length <= 8) ++ { ++ if(var->bits_per_pixel == 24 && var->transp.length == 0) ++ { ++ if(var->red.offset >= var->blue.offset) ++ return SDL_PIXELFORMAT_RGB888; ++ else ++ return SDL_PIXELFORMAT_BGR888; ++ } ++ ++ if(var->bits_per_pixel == 32) ++ { ++ if(var->transp.offset == 24) ++ { ++ if(var->red.offset >= var->blue.offset) ++ return SDL_PIXELFORMAT_ARGB8888; ++ else ++ return SDL_PIXELFORMAT_ABGR8888; ++ } ++ else if(var->transp.offset == 0) ++ { ++ if(var->red.offset >= var->blue.offset) ++ return SDL_PIXELFORMAT_RGBA8888; ++ else ++ return SDL_PIXELFORMAT_BGRA8888; ++ } ++ } ++ } ++ ++ return 0; ++} ++ ++int RTT_surface2screen(SDL_Surface *surface, int x, int y) ++{ ++ int i = 0, pitch = 0; ++ int fbp_offset = 0, pixels_offset = 0; ++ ++ pitch = surface->pitch / surface->w; ++ ++ printf("%d %d %d %d %d\n", surface->pitch, surface->w, surface->h, x, y); ++ for(i = 0; i < surface->h; i++) ++ { ++ fbp_offset = (g_sdl_rtt_screen_width * pitch * (i + y)) + pitch * x; ++ pixels_offset = surface->pitch * i; ++ ++ if(fbp_offset + surface->pitch > screensize) ++ { ++ printf("framebuffer overflow\n"); ++ return 1; ++ } ++ memcpy(fbp + fbp_offset, surface->pixels + pixels_offset, surface->pitch); ++ } ++ if(ioctl(fbfd, FBIOPAN_DISPLAY, &vinfo) == -1) ++ { ++ perror("Error to FBIOPAN_DISPLAY"); ++ return 1; ++ } ++ return 0; ++} ++ ++int RTT_screenInit(struct rtt_screen_config *config) ++{ ++ uint32_t pixel_format = 0; ++ ++ if(config == NULL) ++ { ++ return 1; ++ } ++ ++ fbfd = open(FBDEV_PATH, O_RDWR); ++ if(fbfd == -1) ++ { ++ perror("Error: cannot open framebuffer device"); ++ return 1; ++ } ++ ++ // Make sure that the display is on. ++ // if(ioctl(fbfd, FBIOBLANK, FB_BLANK_UNBLANK) != 0) ++ // { ++ // perror("ioctl(FBIOBLANK)"); ++ // Don't return. Some framebuffer drivers like efifb or simplefb don't implement FBIOBLANK. ++ // } ++ ++ if(ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) ++ { ++ perror("Error reading fixed information"); ++ return 1; ++ } ++ ++ // Get variable screen information ++ if(ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) ++ { ++ perror("Error reading variable information"); ++ return 1; ++ } ++ ++ screensize = finfo.smem_len; // finfo.line_length * vinfo.yres; ++ ++ pixel_format = __var_to_pixfmt(&vinfo); ++ if(pixel_format <= 0) ++ { ++ printf("unknown pixel format, use default format: %d\n", RTT_SDL_FORMAT); ++ config->pixel_format = RTT_SDL_FORMAT; ++ g_sdl_rtt_pixel_format = RTT_SDL_FORMAT; ++ } ++ else ++ { ++ config->pixel_format = pixel_format; ++ g_sdl_rtt_pixel_format = pixel_format; ++ } ++ config->width = vinfo.xres; ++ config->height = vinfo.yres; ++ g_sdl_rtt_screen_width = config->width; ++ g_sdl_rtt_screen_heigth = config->height; ++ ++ fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); ++ if((intptr_t)fbp == -1) ++ { ++ perror("Error: failed to map framebuffer device to memory"); ++ return 1; ++ } ++ return 0; ++} ++ ++int RTT_screenQuit() ++{ ++ if(fbp) munmap(fbp, screensize); ++ if(fbfd) close(fbfd); ++ return 0; ++} ++ ++#endif ++ ++#endif +diff --git a/src/video/rtt/SDL_rttscreen.h b/src/video/rtt/SDL_rttscreen.h +new file mode 100755 +index 000000000..868d4e2c6 +--- /dev/null ++++ b/src/video/rtt/SDL_rttscreen.h +@@ -0,0 +1,29 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-smart ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#ifndef __SDL_RTTSCREEN_H__ ++#define __SDL_RTTSCREEN_H__ ++ ++#include "SDL_rttcommon.h" ++ ++int RTT_surface2screen(SDL_Surface *surface, int x, int y); ++int RTT_screenInit(); ++int RTT_screenQuit(); ++ ++struct rtt_screen_config ++{ ++ Uint32 width; ++ Uint32 height; ++ Uint32 pixel_format; ++}; ++ ++#endif +diff --git a/src/video/rtt/SDL_rtttouch.c b/src/video/rtt/SDL_rtttouch.c +new file mode 100644 +index 000000000..60f41ae5f +--- /dev/null ++++ b/src/video/rtt/SDL_rtttouch.c +@@ -0,0 +1,96 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "../../events/SDL_touch_c.h" ++#include "../SDL_sysvideo.h" ++#include "SDL_hints.h" ++#include "SDL_rttcommon.h" ++#include "SDL_touch.h" ++ ++#if SDL_VIDEO_DRIVER_RTT && SDL_VIDEO_DRIVER_RTT_TOUCH ++ ++#define RT_TOUCH_EVENT_NONE (0) /* Touch none */ ++#define RT_TOUCH_EVENT_UP (1) /* Touch up event */ ++#define RT_TOUCH_EVENT_DOWN (2) /* Touch down event */ ++#define RT_TOUCH_EVENT_MOVE (3) /* Touch move event */ ++ ++struct rt_touch_data ++{ ++ rt_uint8_t event; /* The touch event of the data */ ++ rt_uint8_t track_id; /* Track id of point */ ++ rt_uint8_t width; /* Point of width */ ++ rt_uint16_t x_coordinate; /* Point of x coordinate */ ++ rt_uint16_t y_coordinate; /* Point of y coordinate */ ++ rt_tick_t timestamp; /* The timestamp when the data was received */ ++}; ++ ++extern Uint32 g_sdl_rtt_screen_width; ++extern Uint32 g_sdl_rtt_screen_heigth; ++ ++static rt_device_t touch = NULL; ++static struct rt_touch_data touch_data; ++ ++void RTT_InitTouch(void) ++{ ++ touch = rt_device_find("virtio-touch0"); ++ if(touch) ++ { ++ rt_device_open(touch, RT_DEVICE_FLAG_STREAM); ++ SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "RTTTouch"); ++ SDL_SetHintWithPriority(SDL_HINT_TOUCH_MOUSE_EVENTS, "0", SDL_HINT_DEFAULT); ++ } ++} ++ ++void RTT_QuitTouch(void) ++{ ++ if(touch) ++ { ++ rt_device_close(touch); ++ touch = NULL; ++ } ++} ++ ++void RTT_PollTouch(void) ++{ ++ if(touch) ++ { ++ SDL_Window *window = SDL_GetFocusWindow(); ++ ++ if(window == NULL) ++ { ++ return; ++ } ++ ++ if(rt_device_read(touch, 0, &touch_data, 1) == 1) ++ { ++ if(touch_data.event == RT_TOUCH_EVENT_DOWN) ++ { ++ SDL_SendTouch(0, (SDL_FingerID)0, window, SDL_TRUE, ++ (float)touch_data.x_coordinate / g_sdl_rtt_screen_width, ++ (float)touch_data.y_coordinate / g_sdl_rtt_screen_heigth, 1); ++ } ++ else if(touch_data.event == RT_TOUCH_EVENT_UP) ++ { ++ SDL_SendTouch(0, (SDL_FingerID)0, window, SDL_FALSE, ++ (float)touch_data.x_coordinate / g_sdl_rtt_screen_width, ++ (float)touch_data.y_coordinate / g_sdl_rtt_screen_heigth, 1); ++ } ++ else if(touch_data.event == RT_TOUCH_EVENT_MOVE) ++ { ++ SDL_SendTouchMotion(0, (SDL_FingerID)0, window, (float)touch_data.x_coordinate / g_sdl_rtt_screen_width, ++ (float)touch_data.y_coordinate / g_sdl_rtt_screen_heigth, 1); ++ } ++ } ++ } ++} ++ ++#endif +diff --git a/src/video/rtt/SDL_rtttouch.h b/src/video/rtt/SDL_rtttouch.h +new file mode 100644 +index 000000000..3c2b8409b +--- /dev/null ++++ b/src/video/rtt/SDL_rtttouch.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#ifndef __SDL_RTTTOUCH_H__ ++#define __SDL_RTTTOUCH_H__ ++ ++void RTT_InitTouch(void); ++void RTT_QuitTouch(void); ++void RTT_PollTouch(void); ++ ++#endif +diff --git a/src/video/rtt/SDL_rttvideo.c b/src/video/rtt/SDL_rttvideo.c +new file mode 100755 +index 000000000..a2c5cc780 +--- /dev/null ++++ b/src/video/rtt/SDL_rttvideo.c +@@ -0,0 +1,125 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-smart ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#include "../../events/SDL_events_c.h" ++#include "../SDL_pixels_c.h" ++#include "../SDL_sysvideo.h" ++#include "SDL_mouse.h" ++#include "SDL_rttframebuffer.h" ++#include "SDL_rttkeyboard.h" ++#include "SDL_rttmouse.h" ++#include "SDL_rttscreen.h" ++#include "SDL_rtttouch.h" ++#include "SDL_rttvideo.h" ++#include "SDL_video.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++#define RTT_DRIVER_NAME "rtt" ++ ++static int RTT_VideoInit(_THIS); ++static int RTT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); ++static void RTT_VideoQuit(_THIS); ++ ++void RTT_PumpEvents(_THIS) ++{ ++#if SDL_VIDEO_DRIVER_RTT_TOUCH ++ RTT_PollTouch(); ++#endif ++ // RTT_PollKeyboard(); //TODO ++ // RTT_PollMouse(); //TODO ++} ++ ++static void RTT_DeleteDevice(SDL_VideoDevice *device) ++{ ++ SDL_free(device); ++} ++ ++int RTT_CreateWindow(_THIS, SDL_Window *window) ++{ ++ return 0; ++} ++ ++void RTT_SetWindowTitle(_THIS, SDL_Window *window) ++{ ++ // TODO ++} ++ ++static SDL_VideoDevice *RTT_CreateDevice(int devindex) ++{ ++ SDL_VideoDevice *device; ++ ++ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); ++ if(!device) ++ { ++ SDL_OutOfMemory(); ++ return (0); ++ } ++ device->is_dummy = SDL_TRUE; ++ ++ /* Set the function pointers */ ++ device->VideoInit = RTT_VideoInit; ++ device->VideoQuit = RTT_VideoQuit; ++ device->SetDisplayMode = RTT_SetDisplayMode; ++ device->CreateWindowFramebuffer = SDL_RTT_CreateWindowFramebuffer; ++ device->UpdateWindowFramebuffer = SDL_RTT_UpdateWindowFramebuffer; ++ device->DestroyWindowFramebuffer = SDL_RTT_DestroyWindowFramebuffer; ++ device->CreateSDLWindow = RTT_CreateWindow; ++ device->SetWindowTitle = RTT_SetWindowTitle; ++ device->PumpEvents = RTT_PumpEvents; ++ device->free = RTT_DeleteDevice; ++ return device; ++} ++ ++VideoBootStrap RTT_bootstrap = {RTT_DRIVER_NAME, "rt-smart video driver", RTT_CreateDevice}; ++ ++int RTT_VideoInit(_THIS) ++{ ++ SDL_DisplayMode mode; ++ struct rtt_screen_config config; ++ if(RTT_screenInit(&config) != 0) ++ { ++ return -1; ++ } ++ mode.format = config.pixel_format; ++ mode.w = config.width; ++ mode.h = config.height; ++ mode.refresh_rate = 0; ++ mode.driverdata = NULL; ++ if(SDL_AddBasicVideoDisplay(&mode) < 0) ++ { ++ return -1; ++ } ++ SDL_zero(mode); ++ SDL_AddDisplayMode(&_this->displays[0], &mode); ++#if SDL_VIDEO_DRIVER_RTT_TOUCH ++ RTT_InitTouch(); ++#endif ++ return 0; ++} ++ ++static int RTT_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) ++{ ++ return 0; ++} ++ ++void RTT_VideoQuit(_THIS) ++{ ++ RTT_screenQuit(); ++#if SDL_VIDEO_DRIVER_RTT_TOUCH ++ RTT_QuitTouch(); ++#endif ++} ++ ++#endif +diff --git a/src/video/rtt/SDL_rttvideo.h b/src/video/rtt/SDL_rttvideo.h +new file mode 100755 +index 000000000..a648c4a2e +--- /dev/null ++++ b/src/video/rtt/SDL_rttvideo.h +@@ -0,0 +1,17 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ * 2023-02-12 xqyjlj adapt rt-smart ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#ifndef __SDL_RTTVIDEO_H__ ++#define __SDL_RTTVIDEO_H__ ++ ++#endif +diff --git a/test/Makefile.in b/test/Makefile.in +index 8c3bbf2a1..f3c65cb68 100644 +--- a/test/Makefile.in ++++ b/test/Makefile.in +@@ -68,6 +68,7 @@ TARGETS = \ + testwm2$(EXE) \ + testyuv$(EXE) \ + torturethread$(EXE) \ ++ testrtt$(EXE) \ + + + @OPENGL_TARGETS@ += testgl2$(EXE) testshader$(EXE) +@@ -315,6 +316,8 @@ testvulkan$(EXE): $(srcdir)/testvulkan.c + testlocale$(EXE): $(srcdir)/testlocale.c + $(CC) -o $@ $? $(CFLAGS) $(LIBS) + ++testrtt$(EXE): $(srcdir)/testrtt.c ++ $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + + + clean: +diff --git a/test/testrtt.c b/test/testrtt.c +new file mode 100755 +index 000000000..259464b58 +--- /dev/null ++++ b/test/testrtt.c +@@ -0,0 +1,204 @@ ++/* ++ * Copyright (c) 2006-2020, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2020-1-6 eason The first version ++ */ ++#include ++#include ++#include ++ ++#define POINTS_COUNT 4 ++#define SCREEN_WIDTH 800 ++#define SCREEN_HEIGTH 600 ++ ++static SDL_Point points[POINTS_COUNT] = { ++ {320, 200}, ++ {300, 240}, ++ {340, 240}, ++ {320, 200} ++}; ++ ++void usage(char *proc_name) ++{ ++ printf("\nUsage: %s option\n", proc_name); ++ printf("\toption:\n" ++ "\t-l draw line \n" ++ "\t-r draw a rectangle \n" ++ "\t-t draw a rectangle with texture \n" ++ "\t-p [path] draw a bmp picture with texture\n" ++ "\t-d draw dot \n" ++ "\t-w draw different color in different window\n" ++ "\t-f test touch finger\n"); ++} ++ ++int main(int argc, char *argv[]) ++{ ++ // The window we'll be rendering to ++ SDL_Window *window = NULL; ++ ++ // The surface contained by the window ++ SDL_Surface *screenSurface = NULL; ++ SDL_Renderer *renderer; ++ SDL_Texture *texture; ++ ++ if((argc != 2) && (argc != 3)) ++ { ++ usage(argv[0]); ++ return (1); ++ } ++ // use dummy video driver ++ SDL_setenv("SDL_VIDEODRIVER", "rtt", 1); ++ // Initialize SDL ++ if(SDL_Init(SDL_INIT_VIDEO) < 0) ++ { ++ printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); ++ return -1; ++ } ++ ++ window = ++ SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 340, 340, SDL_WINDOW_SHOWN); ++ if(window == NULL) ++ { ++ printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); ++ return -1; ++ } ++ ++ renderer = SDL_CreateRenderer(window, -1, 0); ++ SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE); ++ SDL_RenderClear(renderer); ++ ++ if(0 == strcmp("-l", argv[1])) ++ { ++ SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE); ++ SDL_RenderDrawLine(renderer, 0, 0, 320, 200); ++ ++ // SDL_RenderDrawLine(renderer, 320, 0, 320, 480); ++ SDL_RenderDrawLines(renderer, points, POINTS_COUNT); ++ } ++ else if(0 == strcmp("-r", argv[1])) ++ { ++ SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE); ++ SDL_Rect rect = {10, 30, 320, 240}; ++ SDL_RenderDrawRect(renderer, &rect); ++ // SDL_RenderFillRect(renderer, &rect); ++ } ++ else if(0 == strcmp("-t", argv[1])) ++ { ++ texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 340, 340); ++ SDL_Rect rect = {10, 30, 200, 200}; ++ SDL_SetRenderTarget(renderer, texture); ++ SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE); ++ SDL_RenderClear(renderer); ++ SDL_RenderDrawRect(renderer, &rect); ++ ++ SDL_SetRenderDrawColor(renderer, 0, 0, 255, SDL_ALPHA_OPAQUE); ++ SDL_RenderFillRect(renderer, &rect); ++ ++ SDL_SetRenderTarget(renderer, NULL); ++ SDL_RenderCopy(renderer, texture, NULL, NULL); ++ } ++ else if(0 == strcmp("-p", argv[1])) ++ { ++ if(!argv[2]) ++ { ++ printf("use -p [path]\n"); ++ goto end; ++ } ++ if(access(argv[2], 0)) ++ { ++ printf("the file %s is not exits\n", argv[2]); ++ goto end; ++ } ++ screenSurface = SDL_LoadBMP(argv[2]); ++ if(!screenSurface) ++ { ++ printf("SDL_LoadBMP failed\n"); ++ goto end; ++ } ++ texture = SDL_CreateTextureFromSurface(renderer, screenSurface); ++ SDL_SetRenderTarget(renderer, texture); ++ SDL_RenderCopy(renderer, texture, NULL, NULL); ++ } ++ else if(0 == strcmp("-f", argv[1])) ++ { ++ while(1) ++ { ++ SDL_Event event; ++ while(SDL_PollEvent(&event)) ++ { ++ switch(event.type) ++ { ++ case SDL_FINGERDOWN: ++ case SDL_FINGERUP: ++ case SDL_FINGERMOTION: ++ { ++ printf("type: %d (%f %f)(%f %f), (%f %f)\n", event.tfinger.type, event.tfinger.x, ++ event.tfinger.y, event.tfinger.x * 800, event.tfinger.y * 600, event.tfinger.dx, ++ event.tfinger.dx); ++ break; ++ } ++ } ++ } ++ } ++ } ++ else if(0 == strcmp("-d", argv[1])) ++ { ++ SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE); ++ for(int i = 0; i < 100; i += 5) ++ { ++ for(int j = 0; j < i; j += 5) ++ { ++ SDL_RenderDrawPoint(renderer, i, j); ++ } ++ } ++ } ++ else if(0 == strcmp("-w", argv[1])) ++ { ++ SDL_Window *win2 = SDL_CreateWindow("MultiWindow2", 100, 100, 400, 240, SDL_WINDOW_SHOWN); ++ SDL_Renderer *renderer2 = SDL_CreateRenderer(win2, -1, 0); ++ SDL_Window *win3 = SDL_CreateWindow("MultiWindow3", 500, 100, 400, 240, SDL_WINDOW_SHOWN); ++ SDL_Renderer *renderer3 = SDL_CreateRenderer(win3, -1, 0); ++ SDL_Window *win4 = SDL_CreateWindow("MultiWindow4", 900, 100, 400, 240, SDL_WINDOW_SHOWN); ++ SDL_Renderer *renderer4 = SDL_CreateRenderer(win4, -1, 0); ++ SDL_SetRenderDrawColor(renderer2, 255, 0, 0, SDL_ALPHA_OPAQUE); ++ SDL_RenderClear(renderer2); ++ SDL_SetRenderDrawColor(renderer3, 0, 255, 0, SDL_ALPHA_OPAQUE); ++ SDL_RenderClear(renderer3); ++ SDL_SetRenderDrawColor(renderer4, 0, 0, 255, SDL_ALPHA_OPAQUE); ++ SDL_RenderClear(renderer4); ++ ++ SDL_RenderPresent(renderer2); ++ SDL_DestroyRenderer(renderer2); ++ SDL_DestroyWindow(win2); ++ SDL_RenderPresent(renderer3); ++ SDL_DestroyRenderer(renderer3); ++ SDL_DestroyWindow(win3); ++ SDL_RenderPresent(renderer4); ++ SDL_DestroyRenderer(renderer4); ++ SDL_DestroyWindow(win4); ++ } ++ else ++ { ++ usage(argv[0]); ++ } ++ ++ SDL_RenderPresent(renderer); ++ SDL_Delay(2000); ++end: ++ // destory renderer ++ if(renderer) ++ { ++ SDL_DestroyRenderer(renderer); ++ } ++ // Destroy window ++ SDL_DestroyWindow(window); ++ ++ // Quit SDL subsystems ++ SDL_Quit(); ++ ++ return 0; ++} diff --git a/repo/packages/s/sdl2/scripts/deploy.lua b/repo/packages/s/sdl2/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/s/sdl2/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/s/sdl2/scripts/export.lua b/repo/packages/s/sdl2/scripts/export.lua new file mode 100644 index 0000000..7082c06 --- /dev/null +++ b/repo/packages/s/sdl2/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include", "SDL2") .. "/*")) do + local inc = path.join(installdir, "include", "SDL2") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", "SDL2", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/s/sdl2/xmake.lua b/repo/packages/s/sdl2/xmake.lua new file mode 100644 index 0000000..6313d2f --- /dev/null +++ b/repo/packages/s/sdl2/xmake.lua @@ -0,0 +1,84 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-22 xqyjlj initial version +-- +package("sdl2") +do + set_homepage("https://libsdl.org/") + set_description("Simple DirectMedia Layer.") + + add_urls("https://github.com/libsdl-org/SDL/archive/refs/tags/release-$(version).tar.gz") + + add_versions("2.0.14", "f85233bc8d4f30a7caa5aea7de0f95b8f4b1f7272473aea4b3ec4ede0a27357f") + + add_patches("2.0.14", path.join(os.scriptdir(), "patches", "2.0.14", "01_adapt_smart.diff"), + "b23de0d3b13dd7d3a12a07a94ec84d51c78c9960058730d920e321871418e12b") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + add_includedirs("include", "include/SDL2") + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(configs, "--enable-static=yes") + if package:config("shared") then + table.insert(configs, "--enable-shared=yes") + else + table.insert(configs, "--enable-shared=no") + end + + table.insert(configs, "--build=i686-pc-linux-gnu") + table.insert(configs, "--enable-joystick-virtual=no") + table.insert(configs, "--enable-render-d3d=no") + table.insert(configs, "--enable-sdl-dlopen=no") + table.insert(configs, "--enable-joystick=no") + table.insert(configs, "--enable-joystick-mfi=no") + table.insert(configs, "--enable-hidapi=no") + table.insert(configs, "--enable-hidapi-libusb=no") + table.insert(configs, "--enable-threads=no") + table.insert(configs, "--enable-3dnow=no") + table.insert(configs, "--enable-jack-shared=no") + table.insert(configs, "--enable-pulseaudio-shared=no") + table.insert(configs, "--enable-pulseaudio=no") + table.insert(configs, "--enable-cpuinfo=no") + table.insert(configs, "--enable-video-directfb") + table.insert(configs, "--enable-directfb-shared=no") + table.insert(configs, "--enable-video-rtt-virtio-gpu=no") + table.insert(configs, "--enable-video-rtt-touch=no") + table.insert(configs, "--enable-video-rtt-fbdev=yes") + + local buildenvs = import("package.tools.autoconf").buildenvs(package, {ldflags = ldflags}) + os.vrun("./autogen.sh", {envs = buildenvs}) + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("SDL_Init", {includes = {"SDL.h"}})) + end) +end diff --git a/repo/packages/s/sdl2_image/scripts/deploy.lua b/repo/packages/s/sdl2_image/scripts/deploy.lua new file mode 100644 index 0000000..89d2118 --- /dev/null +++ b/repo/packages/s/sdl2_image/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/s/sdl2_image/scripts/export.lua b/repo/packages/s/sdl2_image/scripts/export.lua new file mode 100644 index 0000000..7082c06 --- /dev/null +++ b/repo/packages/s/sdl2_image/scripts/export.lua @@ -0,0 +1,42 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file export.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-23 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filedir in ipairs(os.filedirs(path.join(installdir, "include", "SDL2") .. "/*")) do + local inc = path.join(installdir, "include", "SDL2") + local name = path.relative(filedir, inc) + rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", "SDL2", name), + {rootdir = inc, symlink = true}) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename)) + end +end diff --git a/repo/packages/s/sdl2_image/xmake.lua b/repo/packages/s/sdl2_image/xmake.lua new file mode 100644 index 0000000..9d7de65 --- /dev/null +++ b/repo/packages/s/sdl2_image/xmake.lua @@ -0,0 +1,73 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-06 xqyjlj initial version +-- +package("sdl2_image") +do + set_homepage("https://libsdl.org/") + set_description("Simple DirectMedia Layer.") + + add_urls("https://github.com/libsdl-org/SDL_image/archive/refs/tags/release-$(version).tar.gz") + + add_versions("2.0.5", "76b7f67f4c1a5f8368658f0e1e59bdaa4555d1cc7f3a4413178cd735019983ff") + + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) + + on_load(function(package) + package:add("deps", "zlib", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + package:add("deps", "libpng", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + package:add("deps", "libjpeg", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + package:add("deps", "sdl2", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local configs = {host = host} + local cc = info.cc + local ldflags = {} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + local sdl2 = package:dep("sdl2") + + if package:config("shared") then + table.insert(configs, "--enable-shared=yes") + table.insert(configs, "--enable-static=no") + else + table.insert(configs, "--enable-shared=no") + table.insert(configs, "--enable-static=yes") + end + + table.insert(configs, "--build=i686-pc-linux-gnu") + table.insert(configs, "--with-sdl-prefix=" .. sdl2:installdir()) + local buildenvs = import("package.tools.autoconf").buildenvs(package, { + ldflags = ldflags, + packagedeps = {"libpng", "libjpeg", "sdl2", "zlib"} + }) + -- os.vrun("autoreconf -fiv || true", {envs = buildenvs}) + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) + import("package.tools.make").install(package, {}, {envs = buildenvs}) + end) + + on_test(function(package) + assert(package:has_cfuncs("IMG_Init", {includes = "SDL2/SDL_image.h", configs = {defines = "SDL_MAIN_HANDLED"}})) + end) +end diff --git a/repo/packages/u/uhttpd/patches/v21/01_makefile.diff b/repo/packages/u/uhttpd/patches/v21/01_makefile.diff new file mode 100644 index 0000000..cb8b835 --- /dev/null +++ b/repo/packages/u/uhttpd/patches/v21/01_makefile.diff @@ -0,0 +1,85 @@ +diff --git a/Makefile b/Makefile +index 6dcc355..284066b 100644 +--- a/Makefile ++++ b/Makefile +@@ -2,8 +2,7 @@ CGI_SUPPORT ?= 1 + LUA_SUPPORT ?= 1 + TLS_SUPPORT ?= 1 + +-CFLAGS ?= -I./lua-5.1.4/src -I./cyassl-1.4.0/include -O0 -ggdb3 +-LDFLAGS ?= -L./lua-5.1.4/src -L./cyassl-1.4.0/src/.libs ++ARFLAGS=rc + + CFLAGS += -Wall --std=gnu99 + +@@ -27,32 +26,58 @@ ifeq ($(CGI_SUPPORT),1) + CFLAGS += -DHAVE_CGI + endif + ++ + ifeq ($(LUA_SUPPORT),1) ++ OBJL = uhttpd-lua.o + CFLAGS += -DHAVE_LUA +- LUALIB = uhttpd_lua.so + +- $(LUALIB): uhttpd-lua.c +- $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \ +- -shared -lm -llua -ldl \ +- -o $(LUALIB) uhttpd-lua.c ++ LUALIB = libuhttpd_lua.a ++ $(LUALIB): $(OBJL) ++ $(AR) $(ARFLAGS) $@ $(OBJL) ++ -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 ++ ++ LIB+= -lm -llua -ldl -luhttpd_lua + endif + ++#ifeq ($(LUA_SUPPORT),1) ++# CFLAGS += -DHAVE_LUA ++# LUALIB = uhttpd_lua.a ++ ++# $(LUALIB): uhttpd-lua.c ++# $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \ ++# -static -lm -llua -ldl \ ++# -o $(LUALIB) uhttpd-lua.c ++#endif ++ ++ + ifeq ($(TLS_SUPPORT),1) ++ OBJT = uhttpd-tls.o + CFLAGS += -DHAVE_TLS +- TLSLIB = uhttpd_tls.so + +- $(TLSLIB): uhttpd-tls.c +- $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \ +- -shared -lcyassl \ +- -o $(TLSLIB) uhttpd-tls.c ++ TLSLIB = libuhttpd_tls.a ++ $(TLSLIB): $(OBJT) ++ $(AR) $(ARFLAGS) $@ $(OBJT) ++ -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 ++ ++ LIB+= -lssl -luhttpd_tls + endif + ++#ifeq ($(TLS_SUPPORT),1) ++# CFLAGS += -DHAVE_TLS ++# TLSLIB = uhttpd_tls.a ++ ++# $(TLSLIB): uhttpd-tls.c ++# $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \ ++# -static -lssl \ ++# -o $(TLSLIB) uhttpd-tls.c ++#endif ++ + %.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + + compile: $(OBJ) $(TLSLIB) $(LUALIB) +- $(CC) -o uhttpd $(LDFLAGS) $(LIB) $(OBJ) ++ $(CXX) -o uhttpd $(LDFLAGS) $(LIB) $(OBJ) + + clean: +- rm -f *.o *.so uhttpd ++ rm -f *.o *.a uhttpd + diff --git a/repo/packages/u/uhttpd/patches/v21/02_uhttpd.diff b/repo/packages/u/uhttpd/patches/v21/02_uhttpd.diff new file mode 100644 index 0000000..dd0efee --- /dev/null +++ b/repo/packages/u/uhttpd/patches/v21/02_uhttpd.diff @@ -0,0 +1,205 @@ +diff --git a/uhttpd-cgi.c b/uhttpd-cgi.c +index 8c17251..7bec929 100644 +--- a/uhttpd-cgi.c ++++ b/uhttpd-cgi.c +@@ -202,7 +202,7 @@ void uh_cgi_request( + dup2(wfd[0], 0); + + /* check for regular, world-executable file _or_ interpreter */ +- if( ((pi->stat.st_mode & S_IFREG) && ++ if( ((pi->stat.st_mode & S_IFREG) || + (pi->stat.st_mode & S_IXOTH)) || (ip != NULL) + ) { + /* build environment */ +@@ -385,8 +385,8 @@ void uh_cgi_request( + FD_SET(rfd[0], &reader); + FD_SET(wfd[1], &writer); + +- timeout.tv_sec = (header_sent < 1) ? cl->server->conf->script_timeout : 3; +- timeout.tv_usec = 0; ++ timeout.tv_sec = 0; ++ timeout.tv_usec = 1000; + + ensure_out(rv = select_intr(fd_max, &reader, + (content_length > -1) ? &writer : NULL, NULL, &timeout)); +@@ -584,6 +584,8 @@ void uh_cgi_request( + close(rfd[0]); + close(wfd[1]); + ++ uh_http_send(cl, req, "", 0); ++ + if( !kill(child, 0) ) + { + kill(child, SIGTERM); +diff --git a/uhttpd-cgi.h b/uhttpd-cgi.h +index cb84dae..35a00d7 100644 +--- a/uhttpd-cgi.h ++++ b/uhttpd-cgi.h +@@ -22,7 +22,7 @@ + #include + #include + #include +-#include ++#include + + void uh_cgi_request( + struct client *cl, struct http_request *req, +diff --git a/uhttpd-file.c b/uhttpd-file.c +index fda86d7..dc0f393 100644 +--- a/uhttpd-file.c ++++ b/uhttpd-file.c +@@ -108,6 +108,10 @@ static int uh_file_response_ok_hdrs(struct client *cl, struct http_request *req, + ensure_ret(uh_http_sendf(cl, NULL, "Last-Modified: %s\r\n", uh_file_unix2date(s->st_mtime))); + } + ++ if (uh_file_header_lookup(req, "ACCEPT-LANGUAGE")) { ++ ensure_ret(uh_http_sendf(cl, NULL, "CONTENT-LANGUAGE: en\r\n")); ++ } ++ + return uh_http_sendf(cl, NULL, "Date: %s\r\n", uh_file_unix2date(time(NULL))); + } + +@@ -355,11 +359,17 @@ void uh_file_request(struct client *cl, struct http_request *req, struct path_in + ensure_out(uh_file_response_200(cl, req, &pi->stat)); + + ensure_out(uh_http_sendf(cl, NULL, "Content-Type: %s\r\n", uh_file_mime_lookup(pi->name))); +- ensure_out(uh_http_sendf(cl, NULL, "Content-Length: %i\r\n", pi->stat.st_size)); + + /* if request was HTTP 1.1 we'll respond chunked */ + if( (req->version > 1.0) && (req->method != UH_HTTP_MSG_HEAD) ) + ensure_out(uh_http_send(cl, NULL, "Transfer-Encoding: chunked\r\n", -1)); ++ /* ++ * Messages _must_ not include both a Content-Length header field and a non-identity ++ * transfer coding. If the message does include a non-identity transfer-coding, the ++ * Content-Length _must_ be ignored. ++ */ ++ else ++ ensure_out(uh_http_sendf(cl, NULL, "Content-Length: %i\r\n", pi->stat.st_size)); + + /* close header */ + ensure_out(uh_http_send(cl, NULL, "\r\n", -1)); +diff --git a/uhttpd-file.h b/uhttpd-file.h +index 3d46815..ef2c3d0 100644 +--- a/uhttpd-file.h ++++ b/uhttpd-file.h +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + + struct mimetype { + const char *extn; +diff --git a/uhttpd.c b/uhttpd.c +index 1fd2134..7364226 100644 +--- a/uhttpd.c ++++ b/uhttpd.c +@@ -688,7 +688,7 @@ int main (int argc, char **argv) + + #ifdef HAVE_TLS + /* load TLS plugin */ +- if( ! (lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) ) ++ /*if( ! (lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) ) + { + fprintf(stderr, + "Notice: Unable to load TLS plugin - disabling SSL support! " +@@ -697,8 +697,8 @@ int main (int argc, char **argv) + } + else + { +- /* resolve functions */ +- if( !(conf.tls_init = dlsym(lib, "uh_tls_ctx_init")) || ++ */ /* resolve functions */ ++/* if( !(conf.tls_init = dlsym(lib, "uh_tls_ctx_init")) || + !(conf.tls_cert = dlsym(lib, "uh_tls_ctx_cert")) || + !(conf.tls_key = dlsym(lib, "uh_tls_ctx_key")) || + !(conf.tls_free = dlsym(lib, "uh_tls_ctx_free")) || +@@ -713,14 +713,14 @@ int main (int argc, char **argv) + ); + exit(1); + } +- ++*/ + /* init SSL context */ +- if( ! (conf.tls = conf.tls_init()) ) ++/* if( ! (conf.tls = conf.tls_init()) ) + { + fprintf(stderr, "Error: Failed to initalize SSL context\n"); + exit(1); + } +- } ++*/ //} + #endif + + while( (opt = getopt(argc, argv, +@@ -808,12 +808,7 @@ int main (int argc, char **argv) + + /* docroot */ + case 'h': +- if( ! realpath(optarg, conf.docroot) ) +- { +- fprintf(stderr, "Error: Invalid directory %s: %s\n", +- optarg, strerror(errno)); +- exit(1); +- } ++ strcpy(conf.docroot, optarg); + break; + + /* error handler */ +@@ -1022,7 +1017,7 @@ int main (int argc, char **argv) + + #ifdef HAVE_LUA + /* load Lua plugin */ +- if( ! (lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) ) ++ /*if( ! (lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) ) + { + fprintf(stderr, + "Notice: Unable to load Lua plugin - disabling Lua support! " +@@ -1031,8 +1026,8 @@ int main (int argc, char **argv) + } + else + { +- /* resolve functions */ +- if( !(conf.lua_init = dlsym(lib, "uh_lua_init")) || ++ */ /* resolve functions */ ++/* if( !(conf.lua_init = dlsym(lib, "uh_lua_init")) || + !(conf.lua_close = dlsym(lib, "uh_lua_close")) || + !(conf.lua_request = dlsym(lib, "uh_lua_request")) + ) { +@@ -1042,17 +1037,17 @@ int main (int argc, char **argv) + ); + exit(1); + } +- ++*/ + /* init Lua runtime if handler is specified */ +- if( conf.lua_handler ) +- { ++// if( conf.lua_handler ) ++// { + /* default lua prefix */ +- if( ! conf.lua_prefix ) ++/* if( ! conf.lua_prefix ) + conf.lua_prefix = "/lua"; + + conf.lua_state = conf.lua_init(conf.lua_handler); + } +- } ++*/ //} + #endif + + /* fork (if not disabled) */ +diff --git a/uhttpd.h b/uhttpd.h +index ff058d6..b376d75 100644 +--- a/uhttpd.h ++++ b/uhttpd.h +@@ -30,7 +30,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include diff --git a/repo/packages/u/uhttpd/scripts/deploy.lua b/repo/packages/u/uhttpd/scripts/deploy.lua new file mode 100644 index 0000000..c183a0f --- /dev/null +++ b/repo/packages/u/uhttpd/scripts/deploy.lua @@ -0,0 +1,35 @@ +-- 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. +-- +-- Copyright (C) 2023-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file deploy.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-05-11 xqyjlj initial version +-- +import("rt.rt_utils") + +function main(rootfs, installdir) + for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) + end + + for _, filepath in ipairs(os.files(path.join(installdir, "sbin") .. "/*")) do + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "sbin", filename)) + end +end diff --git a/repo/packages/u/uhttpd/xmake.lua b/repo/packages/u/uhttpd/xmake.lua new file mode 100644 index 0000000..63fc61f --- /dev/null +++ b/repo/packages/u/uhttpd/xmake.lua @@ -0,0 +1,78 @@ +-- 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. +-- +-- Copyright (C) 2022-2023 RT-Thread Development Team +-- +-- @author xqyjlj +-- @file xmake.lua +-- +-- Change Logs: +-- Date Author Notes +-- ------------ ---------- ----------------------------------------------- +-- 2023-03-07 xqyjlj initial version +-- +package("uhttpd") +do + set_homepage("https://openwrt.org/docs/guide-user/services/webserver/http.uhttpd") + set_description("a web server written to be an efficient and stable server.") + + add_urls("https://github.com/xqyjlj/uhttpd/archive/refs/tags/$(version).tar.gz") + + add_versions("v21", "171ee5a9188480ea6c70d52d7226e33c9c1fa942e9d1d8a31a75b86a0262e096") + + add_patches("v21", path.join(os.scriptdir(), "patches", "v21", "01_makefile.diff"), + "4033da4550957f37122b650cb7195e13282b3e5cd1f9eedb6e15ec2440cb27da") + add_patches("v21", path.join(os.scriptdir(), "patches", "v21", "02_uhttpd.diff"), + "3723479bd6141d1d0d706962806fb10c91a949435d481b1193dc1e0c9c7ac3b1") + + add_deps("lua", {configs = {shared = false}}) + add_deps("openssl", {configs = {shared = false}}) + + on_install("cross@linux", function(package) + import("rt.private.build.rtflags") + local info = rtflags.get_package_info(package) + local host = info.host + local cc = info.cc + local configs = {host = host} + local ldflags = {"-L."} + local cxflags = {"-O2"} + os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) + + table.insert(ldflags, "--static") + local ldscript = rtflags.get_ldscripts(false) + table.join2(ldflags, ldscript.ldflags) + + local sdk = rtflags.get_sdk() + table.join2(ldflags, sdk.ldflags) + table.join2(cxflags, sdk.cxflags) + + local lua = package:dep("lua"):fetch() + local openssl = package:dep("openssl"):fetch() + table.insert(ldflags, "-L" .. lua.linkdirs[1]) + table.insert(ldflags, "-llua") + table.insert(ldflags, "-L" .. openssl.linkdirs[1]) + table.insert(ldflags, "-lssl") + table.insert(ldflags, "-lcrypto") + local buildenvs = import("package.tools.autoconf").buildenvs(package, { + cxflags = cxflags, + ldflags = ldflags, + packagedeps = {"lua", "openssl"} + }) + buildenvs.LDFLAGS = table.concat(ldflags, " ") + import("package.tools.make").build(package, {}, {envs = buildenvs}) + os.vcp("uhttpd", package:installdir("bin")) + end) + + on_test(function(package) + assert(os.isfile(path.join(package:installdir("bin"), "uhttpd"))) + end) +end diff --git a/repo/packages/x/x86_64-linux-musl/xmake.lua b/repo/packages/x/x86_64-linux-musl/xmake.lua index 8a5f3fd..7e1d6c4 100644 --- a/repo/packages/x/x86_64-linux-musl/xmake.lua +++ b/repo/packages/x/x86_64-linux-musl/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-18 zhouquan initial version +-- 2023-05-18 xqyjlj initial version -- package("x86_64-linux-musl") do diff --git a/repo/packages/z/zlib/scripts/deploy.lua b/repo/packages/z/zlib/scripts/deploy.lua index 35a99df..b8ba071 100644 --- a/repo/packages/z/zlib/scripts/deploy.lua +++ b/repo/packages/z/zlib/scripts/deploy.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file deploy.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-11 zhouquan initial version +-- 2023-05-11 xqyjlj initial version -- import("rt.rt_utils") diff --git a/repo/packages/z/zlib/scripts/export.lua b/repo/packages/z/zlib/scripts/export.lua index 8dbd3d6..8eee8fb 100644 --- a/repo/packages/z/zlib/scripts/export.lua +++ b/repo/packages/z/zlib/scripts/export.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file export.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-23 zhouquan initial version +-- 2023-05-23 xqyjlj initial version -- import("rt.rt_utils") diff --git a/repo/packages/z/zlib/xmake.lua b/repo/packages/z/zlib/xmake.lua index c08f7ec..06c7f90 100644 --- a/repo/packages/z/zlib/xmake.lua +++ b/repo/packages/z/zlib/xmake.lua @@ -12,15 +12,15 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-06 zhouquan adapt debug shared --- 2023-03-01 zhouquan add copy artifacts to "RT_XMAKE_PKG_INSTALLDIR" --- 2023-02-28 zhouquan initial version +-- 2023-03-06 xqyjlj adapt debug shared +-- 2023-03-01 xqyjlj add copy artifacts to "RT_XMAKE_PKG_INSTALLDIR" +-- 2023-02-28 xqyjlj initial version -- package("zlib") do diff --git a/repo/xmake.lua b/repo/xmake.lua index c7c15dc..acc79f1 100644 --- a/repo/xmake.lua +++ b/repo/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-02-28 zhouquan initial version +-- 2023-02-28 xqyjlj initial version -- set_xmakever("2.7.8") -- set xmake minimal version diff --git a/tools/plugins/install.sh b/tools/plugins/install.sh new file mode 100644 index 0000000..d0e0d6a --- /dev/null +++ b/tools/plugins/install.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +mkdir -p ~/.xmake/plugins/ + +for var in $(ls -d */); do + rm -rf ~/.xmake/plugins/${var} + cp -rf ${script_dir}/${var} ~/.xmake/plugins/ +done diff --git a/tools/plugins/smart-create/main.lua b/tools/plugins/smart-create/main.lua index df073be..fc360be 100644 --- a/tools/plugins/smart-create/main.lua +++ b/tools/plugins/smart-create/main.lua @@ -12,18 +12,18 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file main.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-27 zhouquan initial version +-- 2023-05-27 xqyjlj initial version -- import("core.base.option") import("core.project.project") -function create_project(template, targetname) +function create_project(template, targetname, package) if not table.contains(os.dirs(path.join(os.scriptdir(), "templates", "*")), path.join(os.scriptdir(), "templates", template)) then raise("unsupport template => %s", template) @@ -68,6 +68,7 @@ function create_project(template, targetname) local builtinvars = {} builtinvars.FAQ = io.readfile(path.join(os.scriptdir(), "faq.lua")) builtinvars.TARGETNAME = targetname + builtinvars.PACKAGE = package for _, configfile in ipairs(filedirs) do local pattern = "%${(.-)}" @@ -94,7 +95,7 @@ function main() local olddir = os.cd(os.workingdir()) local targetname = option.get("target") or "demo" cprint("${bright}create %s ...", targetname) -- trace - create_project(option.get("template"), targetname) + create_project(option.get("template"), targetname, option.get("package")) cprint("${color.success}create ok!") -- trace os.cd(olddir) end diff --git a/tools/plugins/smart-create/templates/lib/main.c b/tools/plugins/smart-create/templates/lib/main.c index c322966..96cc5f4 100644 --- a/tools/plugins/smart-create/templates/lib/main.c +++ b/tools/plugins/smart-create/templates/lib/main.c @@ -1,22 +1,8 @@ #include -#include -#include int main() { - int r = 0; - - unsigned char str_src[] = "hello world\n"; - unsigned char buf[32] = {0}; - unsigned char str_dst[32] = {0}; - unsigned long src_len = sizeof(str_src); - unsigned long buf_len = sizeof(buf); - unsigned long dst_len = sizeof(str_dst); - - compress(buf, &buf_len, str_src, src_len); - uncompress(str_dst, &dst_len, buf, buf_len); - - printf("%s\n", str_dst); + printf("hello world\n"); return 0; } diff --git a/tools/plugins/smart-create/templates/lib/xmake.lua b/tools/plugins/smart-create/templates/lib/xmake.lua index 10bb836..63d7b8f 100644 --- a/tools/plugins/smart-create/templates/lib/xmake.lua +++ b/tools/plugins/smart-create/templates/lib/xmake.lua @@ -1,11 +1,11 @@ add_rules("mode.debug", "mode.release") -add_requires("zlib") +add_requires("${PACKAGE}") target("${TARGETNAME}") do add_files("*.c") - add_packages("zlib") + add_packages("${PACKAGE}") end target_end() diff --git a/tools/plugins/smart-create/xmake.lua b/tools/plugins/smart-create/xmake.lua index 06f766a..1f88353 100644 --- a/tools/plugins/smart-create/xmake.lua +++ b/tools/plugins/smart-create/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-27 zhouquan initial version +-- 2023-05-27 xqyjlj initial version -- task("smart-create") do @@ -37,8 +37,9 @@ do {'f', "force", "k", nil, "Force to create project in a non-empty directory."}, {'t', "template", "kv", "helloworld", "Select the project template id or name of the given language.", ' - helloworld: Create "hello world" project', - ' - lib: Create a lib project based on "zlib"', + ' - lib: Create a lib project based on ""', ' - app: Create a app project based on "busybox"'}, + {'p', "package", "kv", "zlib", "Force to create project in a non-empty directory."}, {}, {nil, "target", "v", nil, "Create the given target.", "Uses the project name as target if not exists."} diff --git a/tools/scripts/modules.lua b/tools/scripts/modules.lua index b947e1f..a3be4cd 100644 --- a/tools/scripts/modules.lua +++ b/tools/scripts/modules.lua @@ -12,12 +12,12 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file modules.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-08 zhouquan initial version +-- 2023-05-08 xqyjlj initial version -- add_moduledirs(path.join(os.scriptdir(), "modules")) diff --git a/tools/scripts/modules/rt/private/build/rtflags.lua b/tools/scripts/modules/rt/private/build/rtflags.lua index d0b9b0e..6bf67a0 100644 --- a/tools/scripts/modules/rt/private/build/rtflags.lua +++ b/tools/scripts/modules/rt/private/build/rtflags.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rtflags.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-09 zhouquan initial version +-- 2023-05-09 xqyjlj initial version -- import("rt.rt_utils") import("core.project.config") @@ -53,7 +53,7 @@ function get_ldscripts(shared) if not shared then table.insert(ldflags, "-n") - table.insert(ldflags, "-static") + table.insert(ldflags, "--static") end local linkerscript = path.join(rootdir, arch, "link" .. (shared and ".so" or "") .. ".lds") @@ -129,6 +129,8 @@ function get_package_info(package) if rtn.arch == "aarch64" then rtn.cpu = "armv8-a" + else + rtn.cpu = "" end vprint(rtn) diff --git a/tools/scripts/modules/rt/rt_utils.lua b/tools/scripts/modules/rt/rt_utils.lua index a1f5dd7..04dcc77 100644 --- a/tools/scripts/modules/rt/rt_utils.lua +++ b/tools/scripts/modules/rt/rt_utils.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rt_utils.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-09 zhouquan initial version +-- 2023-05-09 xqyjlj initial version -- import("core.project.project") import("core.project.config") diff --git a/tools/scripts/rules.lua b/tools/scripts/rules.lua index 63d873c..2a326d9 100644 --- a/tools/scripts/rules.lua +++ b/tools/scripts/rules.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rules.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- set_xmakever("2.7.2") diff --git a/tools/scripts/rules/rt.cpp.lua b/tools/scripts/rules/rt.cpp.lua index 7ee4b6a..5f288f3 100644 --- a/tools/scripts/rules/rt.cpp.lua +++ b/tools/scripts/rules/rt.cpp.lua @@ -12,22 +12,28 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rt.cpp.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-06-12 zhouquan initial version +-- 2023-06-12 xqyjlj initial version -- rule("rt.cpp") do on_config(function(target) + import("core.project.config") import("rt.private.build.rtflags") - local flags = rtflags.get_sdk() + local flags = rtflags.get_sdk() local cxx, _ = target:tool("cxx") target:set("toolset", "ld", cxx) + + if config.get("target_os") ~= "rt-smart" then + return + end + target:add("ldflags", flags.ldflags_lib, {force = true}) target:add("ldflags", "-lcxx", {force = true}) end) diff --git a/tools/scripts/rules/rt.map.lua b/tools/scripts/rules/rt.map.lua index 1402057..a6a3171 100644 --- a/tools/scripts/rules/rt.map.lua +++ b/tools/scripts/rules/rt.map.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rt.map.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- set_xmakever("2.7.2") diff --git a/tools/scripts/rules/rt.sdk.lua b/tools/scripts/rules/rt.sdk.lua index d332cf8..019a355 100644 --- a/tools/scripts/rules/rt.sdk.lua +++ b/tools/scripts/rules/rt.sdk.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file rt.sdk.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-08 zhouquan initial version +-- 2023-05-08 xqyjlj initial version -- set_xmakever("2.7.2") diff --git a/tools/scripts/tasks.lua b/tools/scripts/tasks.lua index 3215654..321ed52 100644 --- a/tools/scripts/tasks.lua +++ b/tools/scripts/tasks.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file tasks.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-06 zhouquan initial version +-- 2023-05-06 xqyjlj initial version -- set_xmakever("2.7.2") diff --git a/tools/scripts/tasks/smart-image/on_run.lua b/tools/scripts/tasks/smart-image/on_run.lua index dc48eaf..f779dac 100644 --- a/tools/scripts/tasks/smart-image/on_run.lua +++ b/tools/scripts/tasks/smart-image/on_run.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file on_run.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-06 zhouquan initial version +-- 2023-05-06 xqyjlj initial version -- import("core.project.project") import("core.project.config") diff --git a/tools/scripts/tasks/smart-rootfs/on_run.lua b/tools/scripts/tasks/smart-rootfs/on_run.lua index daa3bc6..e9f2c60 100644 --- a/tools/scripts/tasks/smart-rootfs/on_run.lua +++ b/tools/scripts/tasks/smart-rootfs/on_run.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file on_run.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-09 zhouquan initial version +-- 2023-05-09 xqyjlj initial version -- import("core.project.config") import("core.project.project") diff --git a/tools/scripts/toolchains.lua b/tools/scripts/toolchains.lua index 3f0cc9d..445f327 100644 --- a/tools/scripts/toolchains.lua +++ b/tools/scripts/toolchains.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file toolchains.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-02-28 zhouquan initial version +-- 2023-02-28 xqyjlj initial version -- set_xmakever("2.7.2") diff --git a/tools/scripts/toolchains/aarch64-smart-musleabi.lua b/tools/scripts/toolchains/aarch64-smart-musleabi.lua index 7d60139..d6b1afc 100644 --- a/tools/scripts/toolchains/aarch64-smart-musleabi.lua +++ b/tools/scripts/toolchains/aarch64-smart-musleabi.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file aarch64-smart-musleabi.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-02-28 zhouquan initial version +-- 2023-02-28 xqyjlj initial version -- set_xmakever("2.7.2") @@ -38,7 +38,6 @@ do local link_type = os.getenv("RT_XMAKE_LINK_TYPE") or "shared" if link_type == "static" then - toolchain:add("ldflags", "--static", {force = true}) local ldscript = rtflags.get_ldscripts(false) toolchain:add("ldflags", ldscript.ldflags, {force = true}) else diff --git a/tools/scripts/toolchains/arm-smart-musleabi.lua b/tools/scripts/toolchains/arm-smart-musleabi.lua index 0313852..766801e 100644 --- a/tools/scripts/toolchains/arm-smart-musleabi.lua +++ b/tools/scripts/toolchains/arm-smart-musleabi.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file arm-smart-musleabi.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-10 zhouquan initial version +-- 2023-03-10 xqyjlj initial version -- set_xmakever("2.7.2") @@ -37,7 +37,6 @@ do local link_type = os.getenv("RT_XMAKE_LINK_TYPE") or "shared" if link_type == "static" then - toolchain:add("ldflags", "--static", {force = true}) local ldscript = rtflags.get_ldscripts(false) toolchain:add("ldflags", ldscript.ldflags, {force = true}) else diff --git a/tools/scripts/toolchains/riscv64gc-unknown-smart-musl.lua b/tools/scripts/toolchains/riscv64gc-unknown-smart-musl.lua index 21aabea..2525082 100644 --- a/tools/scripts/toolchains/riscv64gc-unknown-smart-musl.lua +++ b/tools/scripts/toolchains/riscv64gc-unknown-smart-musl.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file riscv64gc-unknown-smart-musl.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-03-08 zhouquan initial version +-- 2023-03-08 xqyjlj initial version -- set_xmakever("2.7.2") @@ -37,7 +37,6 @@ do local link_type = os.getenv("RT_XMAKE_LINK_TYPE") or "shared" if link_type == "static" then - toolchain:add("ldflags", "--static", {force = true}) local ldscript = rtflags.get_ldscripts(false) toolchain:add("ldflags", ldscript.ldflags, {force = true}) else diff --git a/tools/scripts/toolchains/x86_64-linux-musl.lua b/tools/scripts/toolchains/x86_64-linux-musl.lua index a369a43..f0ec352 100644 --- a/tools/scripts/toolchains/x86_64-linux-musl.lua +++ b/tools/scripts/toolchains/x86_64-linux-musl.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2023-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file x86_64-linux-musleabi.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-05-18 zhouquan initial version +-- 2023-05-18 xqyjlj initial version -- toolchain("x86_64-linux-musl") -- add toolchain do @@ -26,6 +26,10 @@ do set_description("x86_64 cross compiler for linux.") on_load(function(toolchain) toolchain:load_cross_toolchain() + + toolchain:set("toolset", "cxx", "x86_64-linux-musl-g++") + toolchain:set("toolset", "ld", "x86_64-linux-musl-gcc") + toolchain:add("ldflags", "--static", {force = true}) end) end diff --git a/tools/scripts/xmake.lua b/tools/scripts/xmake.lua index c36aa38..7e8b861 100644 --- a/tools/scripts/xmake.lua +++ b/tools/scripts/xmake.lua @@ -12,13 +12,13 @@ -- -- Copyright (C) 2022-2023 RT-Thread Development Team -- --- @author zhouquan +-- @author xqyjlj -- @file xmake.lua -- -- Change Logs: -- Date Author Notes -- ------------ ---------- ----------------------------------------------- --- 2023-02-28 zhouquan initial version +-- 2023-02-28 xqyjlj initial version -- set_xmakever("2.7.2")