From f4513cc28aa778e1ad0d050511cc7e295fe81e32 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 29 Mar 2026 22:31:50 +0800 Subject: update to lua5.5 --- core/src/lua/lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/lua') diff --git a/core/src/lua/lua b/core/src/lua/lua index 1ab3208a1..a5522f06d 160000 --- a/core/src/lua/lua +++ b/core/src/lua/lua @@ -1 +1 @@ -Subproject commit 1ab3208a1fceb12fca8f24ba57d6e13c5bff15e3 +Subproject commit a5522f06d2679b8f18534fd6a9968f7eb539dc31 -- cgit v1.3.1 From 87e2b7c579d49bd20b69304b38c285989369967a Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 31 Mar 2026 00:48:06 +0800 Subject: allow reassignment of for-loop control variables --- core/src/lua/xmake.lua | 5 +++++ core/src/lua/xmake.sh | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 006480397..6a3fa78a6 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -21,6 +21,11 @@ target("lua") -- add definitions add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true}) + + -- allow reassignment of for-loop control variables (lua 5.4 compatible) + add_undefines("RDKCONST") + add_defines("RDKCONST=0") + if is_plat("windows", "mingw") then -- it has been defined in luaconf.h --add_defines("LUA_USE_WINDOWS") diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index 59eff5dd3..cfffd000c 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -44,6 +44,11 @@ target "lua" # add definitions add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}" + + # allow reassignment of for-loop control variables (lua 5.4 compatible) + add_undefines "RDKCONST" + add_defines "RDKCONST=0" + if is_plat "mingw"; then true # it has been defined in luaconf.h #add_defines "LUA_USE_WINDOWS" -- cgit v1.3.1 From 0dddc81ee9a97221f2e20851ac133cc2a105125b Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 31 Mar 2026 00:51:17 +0800 Subject: revert rdkconst --- core/src/lua/xmake.lua | 4 ---- core/src/lua/xmake.sh | 4 ---- 2 files changed, 8 deletions(-) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 6a3fa78a6..39d7b0baa 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -22,10 +22,6 @@ target("lua") -- add definitions add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true}) - -- allow reassignment of for-loop control variables (lua 5.4 compatible) - add_undefines("RDKCONST") - add_defines("RDKCONST=0") - if is_plat("windows", "mingw") then -- it has been defined in luaconf.h --add_defines("LUA_USE_WINDOWS") diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index cfffd000c..6c504c3d0 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -45,10 +45,6 @@ target "lua" # add definitions add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}" - # allow reassignment of for-loop control variables (lua 5.4 compatible) - add_undefines "RDKCONST" - add_defines "RDKCONST=0" - if is_plat "mingw"; then true # it has been defined in luaconf.h #add_defines "LUA_USE_WINDOWS" -- cgit v1.3.1 From 9ed41d0ba846861f13ac5aa3fd35fa2ef82bd8c9 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 31 Mar 2026 00:51:31 +0800 Subject: revert rdkconst --- core/src/lua/xmake.lua | 4 ++++ core/src/lua/xmake.sh | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 39d7b0baa..6a3fa78a6 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -22,6 +22,10 @@ target("lua") -- add definitions add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true}) + -- allow reassignment of for-loop control variables (lua 5.4 compatible) + add_undefines("RDKCONST") + add_defines("RDKCONST=0") + if is_plat("windows", "mingw") then -- it has been defined in luaconf.h --add_defines("LUA_USE_WINDOWS") diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index 6c504c3d0..cfffd000c 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -45,6 +45,10 @@ target "lua" # add definitions add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}" + # allow reassignment of for-loop control variables (lua 5.4 compatible) + add_undefines "RDKCONST" + add_defines "RDKCONST=0" + if is_plat "mingw"; then true # it has been defined in luaconf.h #add_defines "LUA_USE_WINDOWS" -- cgit v1.3.1 From 1c6ad67e90e5035e49c0a73d232d74346a4072b1 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 31 Mar 2026 22:43:31 +0800 Subject: revert rdkconst --- core/src/lua/xmake.lua | 4 ---- core/src/lua/xmake.sh | 4 ---- 2 files changed, 8 deletions(-) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 6a3fa78a6..39d7b0baa 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -22,10 +22,6 @@ target("lua") -- add definitions add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true}) - -- allow reassignment of for-loop control variables (lua 5.4 compatible) - add_undefines("RDKCONST") - add_defines("RDKCONST=0") - if is_plat("windows", "mingw") then -- it has been defined in luaconf.h --add_defines("LUA_USE_WINDOWS") diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index cfffd000c..6c504c3d0 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -45,10 +45,6 @@ target "lua" # add definitions add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}" - # allow reassignment of for-loop control variables (lua 5.4 compatible) - add_undefines "RDKCONST" - add_defines "RDKCONST=0" - if is_plat "mingw"; then true # it has been defined in luaconf.h #add_defines "LUA_USE_WINDOWS" -- cgit v1.3.1 From cd9baa4ed45496095ca324d12425908c0443e1f9 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 1 Apr 2026 22:10:04 +0800 Subject: improve xmake.sh to replace rdkconst --- configure | 140 +++++++++++++++++++++++++++++++++++++++++++++----- core/src/lua/xmake.sh | 3 +- 2 files changed, 129 insertions(+), 14 deletions(-) (limited to 'core/src/lua') diff --git a/configure b/configure index 1220a4cb9..d6e9db71f 100755 --- a/configure +++ b/configure @@ -1649,6 +1649,41 @@ _get_target_librarydeps() { _ret="${librarydeps}" } +# sanitize file path for use as map key +_sanitize_filekey() { + local key="${1}" + string_replace "${key}" "/" "__"; key="${_ret}" + string_replace "${key}" "." "_"; key="${_ret}" + string_replace "${key}" "-" "_"; key="${_ret}" + string_replace "${key}" "+" "_"; key="${_ret}" + _ret="${key}" +} + +# add file replace rule for target +# stores sed patterns like "s|search|replace|g" per source file +_add_target_file_replace() { + local target="${1}" + local sourcefile="${2}" + local search="${3}" + local replace="${4}" + _sanitize_filekey "${sourcefile}"; local filekey="${_ret}" + _map_get "targets" "${target}_replaces_${filekey}"; local patterns="${_ret}" + if test_nz "${patterns}"; then + patterns="${patterns};s|${search}|${replace}|g" + else + patterns="s|${search}|${replace}|g" + fi + _map_set "targets" "${target}_replaces_${filekey}" "${patterns}" +} + +# get file replace sed patterns for target +_get_target_file_replaces() { + local target="${1}" + local sourcefile="${2}" + _sanitize_filekey "${sourcefile}"; local filekey="${_ret}" + _map_get "targets" "${target}_replaces_${filekey}" +} + # get sourcefiles in target _get_target_sourcefiles() { local name="${1}" @@ -2063,6 +2098,7 @@ _add_target_filepaths() { _targets_toolkinds="${_targets_toolkinds} ${sourcekind}" done fi + _xmake_sh_last_resolved_files="" for file in ${list}; do string_replace "${file}" "?" "*"; file="${_ret}" if ! path_is_absolute "${file}"; then @@ -2083,6 +2119,7 @@ _add_target_filepaths() { for file in ${files}; do path_relative "${xmake_sh_projectdir}" "${file}"; file="${_ret}" _add_target_item "${_xmake_sh_target_current}" "${key}" "${file}" + _xmake_sh_last_resolved_files="${_xmake_sh_last_resolved_files} ${file}" done done } @@ -2273,7 +2310,40 @@ add_files() { if ! ${_loading_targets}; then return fi - _add_target_filepaths "files" "$@" + + # separate file patterns from replace rules + local has_replaces=false + local fileargs="" + for arg in "$@"; do + case "${arg}" in + \{replace*) has_replaces=true ;; + *) fileargs="${fileargs} ${arg}" ;; + esac + done + + _add_target_filepaths "files" ${fileargs} + + # store replace rules for resolved files + if ${has_replaces}; then + local sourcefile="" + for sourcefile in ${_xmake_sh_last_resolved_files}; do + for arg in "$@"; do + case "${arg}" in + \{replace*\}) + # parse {replace = {search, replace}} + local content="${arg#\{replace = \{}" + content="${content%\}\}}" + local search="${content%%,*}" + local rep="${content#*,}" + # trim spaces + search="${search# }"; search="${search% }" + rep="${rep# }"; rep="${rep% }" + _add_target_file_replace "${_xmake_sh_target_current}" "${sourcefile}" "${search}" "${rep}" + ;; + esac + done + done + fi } # add install files in target @@ -4196,9 +4266,14 @@ _gmake_add_build_object_for_gcc_clang() { local sourcefile="${2}" local objectfile="${3}" local flagname="${4}" + local replace_cmd="${5}" + local extra_flags="${6}" path_directory "${objectfile}"; local objectdir="${_ret}" + if test_nz "${replace_cmd}"; then + print "\t@${replace_cmd}" >> "${xmake_sh_makefile}" + fi print "\t@mkdir -p ${objectdir}" >> "${xmake_sh_makefile}" - print "\t\$(VV)\$(${kind}) -c \$(${flagname}) -o ${objectfile} ${sourcefile}" >> "${xmake_sh_makefile}" + print "\t\$(VV)\$(${kind}) -c ${extra_flags}\$(${flagname}) -o ${objectfile} ${sourcefile}" >> "${xmake_sh_makefile}" } _gmake_add_build_object() { @@ -4210,18 +4285,37 @@ _gmake_add_build_object() { path_toolname "${program}"; local toolname="${_ret}" _get_flagname "${sourcekind}"; local flagname="${_ret}" flagname="${target}_${flagname}" + + # check for file replace rules + local actual_sourcefile="${sourcefile}" + _get_target_file_replaces "${target}" "${sourcefile}"; local replace_patterns="${_ret}" + local replace_cmd="" + local extra_flags="" + if test_nz "${replace_patterns}"; then + local replacefile="${xmake_sh_builddir}/.replace/${target}/${sourcefile}" + path_directory "${replacefile}"; local replacefile_dir="${_ret}" + replace_cmd="mkdir -p \"${replacefile_dir}\" && sed '${replace_patterns}' \"${sourcefile}\" > \"${replacefile}\"" + actual_sourcefile="${replacefile}" + # add original source directory to include path for resolving relative #include + path_directory "${sourcefile}"; local source_dir="${_ret}" + extra_flags="-I${source_dir} " + fi + echo "${objectfile}: ${sourcefile}" >> "${xmake_sh_makefile}" + if test_nz "${replace_cmd}"; then + print "\t@echo replacing.${_target_mode} ${sourcefile}" >> "${xmake_sh_makefile}" + fi print "\t@echo compiling.${_target_mode} ${sourcefile}" >> "${xmake_sh_makefile}" case "${toolname}" in - gcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - gxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - clang) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - clangxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - emcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - emxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - cosmocc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - cosmocxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; - tcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";; + gcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + gxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + clang) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + clangxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + emcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + emxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + cosmocc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + cosmocxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; + tcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${actual_sourcefile}" "${objectfile}" "${flagname}" "${replace_cmd}" "${extra_flags}";; *) raise "unknown toolname(${toolname})!" ;; esac echo "" >> "${xmake_sh_makefile}" @@ -4683,10 +4777,30 @@ _ninja_add_build_object() { local objectfile="${3}" path_sourcekind "${sourcefile}"; local sourcekind="${_ret}" _get_target_flags "${target}" "${sourcekind}"; local flags="${_ret}" - _toolchain_compcmd "${sourcekind}" "${objectfile}" "${sourcefile}" "${flags}"; local compcmd="${_ret}" + + # check for file replace rules + local actual_sourcefile="${sourcefile}" + _get_target_file_replaces "${target}" "${sourcefile}"; local replace_patterns="${_ret}" + local replace_cmd="" + if test_nz "${replace_patterns}"; then + local replacefile="${xmake_sh_builddir}/.replace/${target}/${sourcefile}" + path_directory "${replacefile}"; local replacefile_dir="${_ret}" + replace_cmd="mkdir -p \"${replacefile_dir}\" && sed '${replace_patterns}' \"${sourcefile}\" > \"${replacefile}\"" + actual_sourcefile="${replacefile}" + # add original source directory to include path for resolving relative #include + path_directory "${sourcefile}"; local source_dir="${_ret}" + flags="-I${source_dir} ${flags}" + fi + + _toolchain_compcmd "${sourcekind}" "${objectfile}" "${actual_sourcefile}" "${flags}"; local compcmd="${_ret}" path_directory "${objectfile}"; local objectdir="${_ret}" local use_shell_wrapper=false - local command="mkdir -p \"${objectdir}\" && ${compcmd}" + local command="" + if test_nz "${replace_cmd}"; then + command="echo replacing.${_target_mode} ${sourcefile} && ${replace_cmd} && mkdir -p \"${objectdir}\" && ${compcmd}" + else + command="mkdir -p \"${objectdir}\" && ${compcmd}" + fi if is_host "msys" "cygwin" "mingw"; then use_shell_wrapper=true fi diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index 6c504c3d0..472063c5f 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -30,7 +30,8 @@ target "lua" add_files "lua/lobject.c" add_files "lua/lopcodes.c" add_files "lua/loslib.c" - add_files "lua/lparser.c" + # allow reassignment of for-loop control variables (lua 5.4 compatible) + add_files "lua/lparser.c" "{replace = {RDKCONST, 0}}" add_files "lua/lstate.c" add_files "lua/lstring.c" add_files "lua/lstrlib.c" -- cgit v1.3.1 From 5527d6c88fd8ec864cf4c1978c49d2a819f0d2af Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 1 Apr 2026 22:36:05 +0800 Subject: fix replace RDKCONST --- core/src/lua/xmake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index 472063c5f..754cbcdb3 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -31,7 +31,7 @@ target "lua" add_files "lua/lopcodes.c" add_files "lua/loslib.c" # allow reassignment of for-loop control variables (lua 5.4 compatible) - add_files "lua/lparser.c" "{replace = {RDKCONST, 0}}" + add_files "lua/lparser.c" "{replace = {RDKCONST);, VDKREG);}}" add_files "lua/lstate.c" add_files "lua/lstring.c" add_files "lua/lstrlib.c" -- cgit v1.3.1 From c63ac2d50545f2f58872c5be9a46d8fb5b3e8016 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 2 Apr 2026 00:01:02 +0800 Subject: fix lua55 limit --- core/src/lua/xmake.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/src/lua') diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 39d7b0baa..d732b89fb 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -14,7 +14,12 @@ target("lua") add_includedirs("lua", {public = true}) -- add the common source files - add_files("lua/*.c|lua.c|onelua.c|loslib.c") + add_files("lua/*.c|lua.c|onelua.c|loslib.c|lparser.c") + + -- allow reassignment of for-loop control variables (lua 5.4 compatible) + add_files("lua/lparser.c", {rules = "utils.replace", replaces = { + {"RDKCONST%);", "VDKREG);"}, + }}) if not is_plat("iphoneos") then add_files("lua/loslib.c") end -- cgit v1.3.1