From 4d8c00eecd99b0f65f40befd36bb2945df9996a7 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 00:38:14 +0800 Subject: add lua module --- .gitmodules | 3 +++ core/src/lua/lua | 1 + 2 files changed, 4 insertions(+) create mode 160000 core/src/lua/lua diff --git a/.gitmodules b/.gitmodules index ac5f4dde3..4e2703e2b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "core/src/lua-cjson/lua-cjson"] path = core/src/lua-cjson/lua-cjson url = ../../xmake-io/xmake-core-lua-cjson.git +[submodule "core/src/lua/lua"] + path = core/src/lua/lua + url = ../../xmake-io/xmake-core-lua.git diff --git a/core/src/lua/lua b/core/src/lua/lua new file mode 160000 index 000000000..75ea9ccbe --- /dev/null +++ b/core/src/lua/lua @@ -0,0 +1 @@ +Subproject commit 75ea9ccbea7c4886f30da147fb67b693b2624c26 -- cgit v1.3.1 From b58700f83ee4e40582b03f5fdfe337788b9f2c6f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 00:44:52 +0800 Subject: update makefile --- core/makefile | 5 ++++ core/project.mak | 2 +- core/src/lcurses/makefile | 7 +++++- core/src/lua/makefile | 58 +++++++++++++++++++++++++++++++++++++++++++++++ core/src/makefile | 10 ++++++-- core/src/xmake/makefile | 7 +++++- makefile | 7 +++++- 7 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 core/src/lua/makefile diff --git a/core/makefile b/core/makefile index 0bba754cd..d7c529489 100644 --- a/core/makefile +++ b/core/makefile @@ -368,6 +368,7 @@ config : .null @$(ECHO) "directories:" @$(ECHO) " install:\t\t"$(abspath $(INSTALL)) @$(ECHO) " package:\t\t"$(PACKAGE) + @$(ECHO) " backend:\t\t"$(BACKEND) @$(ECHO) "" @$(ECHO) "toolchains:" @$(ECHO) " bin:\t\t"$(BIN) @@ -459,6 +460,10 @@ config : .null @$(ECHO) "export MIPS" >> .config.mak @$(ECHO) "export SPARC" >> .config.mak @$(ECHO) "" >> .config.mak + @$(ECHO) "# backend" >> .config.mak + @$(ECHO) "BACKEND ="$(BACKEND) >> .config.mak + @$(ECHO) "export BACKEND" >> .config.mak + @$(ECHO) "" >> .config.mak @$(ECHO) "# demo" >> .config.mak @$(ECHO) "DEMO ="$(DEMO) >> .config.mak @$(ECHO) "export DEMO" >> .config.mak diff --git a/core/project.mak b/core/project.mak index 041121fea..adf613ef2 100644 --- a/core/project.mak +++ b/core/project.mak @@ -16,5 +16,5 @@ PRO_VERSION_ALTER = 7 PRO_PREFIX = XM_ # the package names -PKG_NAMES = tbox luajit base +PKG_NAMES = tbox luajit lua base diff --git a/core/src/lcurses/makefile b/core/src/lcurses/makefile index 25752ab47..b981765a7 100644 --- a/core/src/lcurses/makefile +++ b/core/src/lcurses/makefile @@ -17,7 +17,12 @@ lcurses_C_FILES += lcurses lcurses_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_CURSES,) # includes -lcurses_INC_DIRS += ../luajit/luajit/src +ifeq ($(BACKEND),luajit) +lcurses_INC_DIRS += ../luajit/luajit/src +endif +ifeq ($(BACKEND),lua) +lcurses_INC_DIRS += ../lua/lua +endif # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/lua/makefile b/core/src/lua/makefile new file mode 100644 index 000000000..d2314c846 --- /dev/null +++ b/core/src/lua/makefile @@ -0,0 +1,58 @@ +# prefix +include $(PRO_DIR)/prefix.mak + +# module name +NAMES = lua + +# module type +lua_TYPE = LIB + +# config +lua_CONFIG = n + +# core files +lua_C_FILES += \ + lua/lauxlib \ + lua/liolib \ + lua/lopcodes \ + lua/lstate \ + lua/lobject \ + lua/lmathlib \ + lua/loadlib \ + lua/lvm \ + lua/lfunc \ + lua/lstrlib \ + lua/linit \ + lua/lstring \ + lua/lundump \ + lua/lctype \ + lua/ltable \ + lua/ldump \ + lua/loslib \ + lua/lgc \ + lua/lzio \ + lua/ldblib \ + lua/lutf8lib \ + lua/lmem \ + lua/lcorolib \ + lua/lcode \ + lua/ltablib \ + lua/lbitlib \ + lua/lapi \ + lua/lbaselib \ + lua/ldebug \ + lua/lparser \ + lua/llex \ + lua/ltm \ + lua/ltests \ + lua/ldo + +# use given system library? +lua_C_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_C_FILES)) +lua_ASM_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_ASM_FILES)) +lua_INC_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_INC_FILES)) +lua_OBJ_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_OBJ_FILES)) + +# suffix +include $(PRO_DIR)/suffix.mak + diff --git a/core/src/makefile b/core/src/makefile index 21a06ed5a..47151258e 100644 --- a/core/src/makefile +++ b/core/src/makefile @@ -2,8 +2,14 @@ include $(PRO_DIR)/prefix.mak # projects -SUB_PROS += demo -DEP_PROS += lcurses sv luajit lua-cjson tbox xmake +SUB_PROS += demo +ifeq ($(BACKEND),luajit) +DEP_PROS += luajit +endif +ifeq ($(BACKEND),lua) +DEP_PROS += lua +endif +DEP_PROS += lcurses sv lua-cjson tbox xmake # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 2c45588b4..84f3044b2 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -149,8 +149,13 @@ xmake_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG xmake_INC_DIRS += \ ../tbox/tbox/src \ ../tbox/inc/$(PLAT) \ - ../luajit/luajit/src \ ../sv/sv/include +ifeq ($(BACKEND),luajit) +xmake_INC_DIRS += ../luajit/luajit/src +endif +ifeq ($(BACKEND),lua) +xmake_INC_DIRS += ../lua/lua +endif # suffix diff --git a/makefile b/makefile index cc7c61ba1..c22bc30cb 100644 --- a/makefile +++ b/makefile @@ -15,6 +15,11 @@ prefix :=$(PREFIX) endif endif +# use luajit or lua backend +ifeq ($(BACKEND),) +BACKEND :=luajit +endif + # the temporary directory ifeq ($(TMPDIR),) TMP_DIR :=$(if $(TMP_DIR),$(TMP_DIR),/tmp) @@ -94,7 +99,7 @@ xrepo_bin_install :=$(destdir)/bin/xrepo build: @echo compiling xmake-core ... @if [ -f core/.config.mak ]; then rm core/.config.mak; fi - +@$(MAKE) -C core --no-print-directory f DEBUG=$(debug) + +@$(MAKE) -C core --no-print-directory f DEBUG=$(debug) BACKEND=$(BACKEND) +@$(MAKE) -C core --no-print-directory c +@$(MAKE) -C core --no-print-directory -- cgit v1.3.1 From 80d619eab58df20b316b49c9db3616e9599da07b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 00:48:29 +0800 Subject: improve makefile --- core/src/lcurses/lcurses.c | 6 ++++++ core/src/lcurses/makefile | 2 ++ core/src/lua/makefile | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/core/src/lcurses/lcurses.c b/core/src/lcurses/lcurses.c index 934dc2d1d..606a06cc3 100644 --- a/core/src/lcurses/lcurses.c +++ b/core/src/lcurses/lcurses.c @@ -65,9 +65,15 @@ Notes: #include #include +#ifdef USE_LUAJIT #include "luajit.h" #include "lualib.h" #include "lauxlib.h" +#else +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +#endif #include #include diff --git a/core/src/lcurses/makefile b/core/src/lcurses/makefile index b981765a7..a0d6a6400 100644 --- a/core/src/lcurses/makefile +++ b/core/src/lcurses/makefile @@ -19,9 +19,11 @@ lcurses_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_ # includes ifeq ($(BACKEND),luajit) lcurses_INC_DIRS += ../luajit/luajit/src +lcurses_CXFLAGS += -DUSE_LUAJIT endif ifeq ($(BACKEND),lua) lcurses_INC_DIRS += ../lua/lua +lcurses_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 endif # suffix diff --git a/core/src/lua/makefile b/core/src/lua/makefile index d2314c846..f66181209 100644 --- a/core/src/lua/makefile +++ b/core/src/lua/makefile @@ -47,6 +47,29 @@ lua_C_FILES += \ lua/ltests \ lua/ldo +# is windows? +iswin = +ifeq ($(PLAT),windows) + iswin = yes +endif +ifeq ($(PLAT),msys) + iswin = yes +endif +ifeq ($(PLAT),mingw) + iswin = yes +endif +ifeq ($(PLAT),cygwin) + iswin = yes +endif + +lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 \ + -Wno-error=string-plus-int +ifdef iswin +lua_CFLAGS += -DLUA_USE_WINDOWS +else +lua_CFLAGS += -DLUA_USE_LINUX +endif + # use given system library? lua_C_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_C_FILES)) lua_ASM_FILES := $(if $(findstring lua,$(base_LIBNAMES)),,$(lua_ASM_FILES)) -- cgit v1.3.1 From 56393682b43020adcff47de00fe7a011ba5f1584 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 00:49:14 +0800 Subject: improve lcurses --- core/src/lcurses/lcurses.c | 4 ++++ core/src/xmake/makefile | 2 ++ core/src/xmake/prefix.h | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/lcurses/lcurses.c b/core/src/lcurses/lcurses.c index 606a06cc3..f3bdf7244 100644 --- a/core/src/lcurses/lcurses.c +++ b/core/src/lcurses/lcurses.c @@ -336,7 +336,11 @@ static chtype lc_checkch(lua_State *L, int index) if (lua_type(L, index) == LUA_TSTRING) return *lua_tostring(L, index); +#ifdef USE_LUAJIT luaL_typerror(L, index, "chtype"); +#else + // TODO +#endif /* never executes */ return (chtype)0; } diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 84f3044b2..20bc49d82 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -152,9 +152,11 @@ xmake_INC_DIRS += \ ../sv/sv/include ifeq ($(BACKEND),luajit) xmake_INC_DIRS += ../luajit/luajit/src +xmake_CXFLAGS += -DUSE_LUAJIT endif ifeq ($(BACKEND),lua) xmake_INC_DIRS += ../lua/lua +xmake_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 endif diff --git a/core/src/xmake/prefix.h b/core/src/xmake/prefix.h index f1287b5c9..f78b61127 100644 --- a/core/src/xmake/prefix.h +++ b/core/src/xmake/prefix.h @@ -32,9 +32,15 @@ # define LUA_API extern "C" # define LUALIB_API LUA_API #endif -#include "luajit.h" -#include "lualib.h" -#include "lauxlib.h" +#ifdef USE_LUAJIT +# include "luajit.h" +# include "lualib.h" +# include "lauxlib.h" +#else +# include "lua.h" +# include "lualib.h" +# include "lauxlib.h" +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * private interfaces -- cgit v1.3.1 From eb826246511e2afca394302aecccdf18d02a297f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 00:53:16 +0800 Subject: fix compile for lua --- core/src/demo/makefile | 10 ++++++++++ core/src/lua-cjson/makefile | 10 ++++++++-- core/src/xmake/engine.c | 2 +- core/src/xmake/sandbox/interactive.c | 5 +++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/src/demo/makefile b/core/src/demo/makefile index 1a2142db5..93525ddaf 100644 --- a/core/src/demo/makefile +++ b/core/src/demo/makefile @@ -20,10 +20,20 @@ demo_INC_DIRS += ../ ../tbox/tbox/src ../tbox/inc/$(PLAT) demo_LIB_DIRS += ../tbox # luajit +ifeq ($(BACKEND),luajit) luajit_LIBS := $(if $(findstring luajit,$(base_LIBNAMES)),,luajit$(DTYPE)) demo_LIBS += $(luajit_LIBS) demo_INC_DIRS += ../luajit/luajit/src demo_LIB_DIRS += ../luajit +endif + +# lua +ifeq ($(BACKEND),lua) +lua_LIBS := $(if $(findstring lua,$(base_LIBNAMES)),,lua$(DTYPE)) +demo_LIBS += $(lua_LIBS) +demo_INC_DIRS += ../lua/lua +demo_LIB_DIRS += ../lua +endif # sv sv_DTYPE := $(if $(findstring sv,$(base_LIBNAMES)),,$(DTYPE)) diff --git a/core/src/lua-cjson/makefile b/core/src/lua-cjson/makefile index 9e96851ae..e1d53ecf9 100644 --- a/core/src/lua-cjson/makefile +++ b/core/src/lua-cjson/makefile @@ -22,8 +22,14 @@ lua-cjson_C_FILES += \ lua-cjson_CFLAGS += -DNDEBUG -DUSE_INTERNAL_FPCONV # includes -lua-cjson_INC_DIRS += \ - ../luajit/luajit/src +ifeq ($(BACKEND),luajit) +lua-cjson_INC_DIRS += ../luajit/luajit/src +lua-cjson_CXFLAGS += -DUSE_LUAJIT +endif +ifeq ($(BACKEND),lua) +lua-cjson_INC_DIRS += ../lua/lua +lua-cjson_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +endif # use given system library? lua-cjson_C_FILES := $(if $(findstring cjson,$(base_LIBNAMES)),,$(lua-cjson_C_FILES)) diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 6a401a486..53732e783 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -814,7 +814,7 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c tb_strlcpy(engine->name, name, sizeof(engine->name)); // init lua - engine->lua = lua_open(); + engine->lua = luaL_newstate(); tb_assert_and_check_break(engine->lua); // open lua libraries diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index 2519a58e8..29855aec6 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -314,6 +314,7 @@ tb_int_t xm_sandbox_interactive(lua_State* lua) // execute codes if (status == 0) { +#ifdef USE_LUAJIT /* bind sandbox * * stack: arg1(top) scriptfunc arg1(sandbox_scope) -> ... @@ -326,6 +327,10 @@ tb_int_t xm_sandbox_interactive(lua_State* lua) * stack: arg1(top) scriptfunc -> ... */ status = xm_sandbox_docall(lua, 0, 0); +#else + // TODO + (void)xm_sandbox_docall; +#endif } // report errors -- cgit v1.3.1 From 6f0f25b64487a32989cb718aa50d9bc729f46d66 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 09:51:33 +0800 Subject: build lua for windows --- core/src/lcurses/xmake.lua | 2 +- core/src/lua-cjson/xmake.lua | 2 +- core/src/lua/makefile | 4 ++++ core/src/lua/xmake.lua | 31 +++++++++++++++++++++++++++++++ core/src/luajit/xmake.lua | 5 +++++ core/src/xmake/sandbox/interactive.c | 5 ++--- core/src/xmake/xmake.lua | 3 ++- core/xmake.lua | 10 +++++++++- 8 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 core/src/lua/xmake.lua diff --git a/core/src/lcurses/xmake.lua b/core/src/lcurses/xmake.lua index f80117f10..5ee8a26c6 100644 --- a/core/src/lcurses/xmake.lua +++ b/core/src/lcurses/xmake.lua @@ -1,6 +1,6 @@ target("lcurses") set_kind("static") - add_deps("luajit") + add_deps(get_config("backend")) if is_plat("windows") and has_config("pdcurses") then add_deps("pdcurses") add_defines("XM_CONFIG_API_HAVE_CURSES", {public = true}) diff --git a/core/src/lua-cjson/xmake.lua b/core/src/lua-cjson/xmake.lua index d2eec99f0..d3b12ded1 100644 --- a/core/src/lua-cjson/xmake.lua +++ b/core/src/lua-cjson/xmake.lua @@ -1,7 +1,7 @@ target("lua-cjson") set_kind("static") set_warnings("all") - add_deps("luajit") + add_deps(get_config("backend")) if is_plat("windows") then set_languages("c89") end diff --git a/core/src/lua/makefile b/core/src/lua/makefile index f66181209..85e8725cf 100644 --- a/core/src/lua/makefile +++ b/core/src/lua/makefile @@ -66,6 +66,10 @@ lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 \ -Wno-error=string-plus-int ifdef iswin lua_CFLAGS += -DLUA_USE_WINDOWS +endif + +ifeq ($(PLAT),macosx) +lua_CFLAGS += -DLUA_USE_MACOSX else lua_CFLAGS += -DLUA_USE_LINUX endif diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua new file mode 100644 index 000000000..4f209b693 --- /dev/null +++ b/core/src/lua/xmake.lua @@ -0,0 +1,31 @@ +target("lua") + if not is_config("lua") then + set_default(false) + end + set_kind("static") + set_warnings("all") + + -- disable c99(/TP) for windows + if is_plat("windows") then + set_languages("c89") + end + + -- add header files + add_headerfiles("lua/(*.h)", {prefixdir = "lua"}) + + -- add include directories + add_includedirs("lua", {public = true}) + + -- add the common source files + add_files("lua/*.c|lua.c") + + -- add defines + add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", {public = true}) + if is_plat("windows") then + add_defines("LUA_USE_WINDOWS") + elseif is_plat("macosx", "iphoneos") then + add_defines("LUA_USE_MACOSX") + else + add_defines("LUA_USE_LINUX") + end + diff --git a/core/src/luajit/xmake.lua b/core/src/luajit/xmake.lua index cfee1f76e..f6f351394 100644 --- a/core/src/luajit/xmake.lua +++ b/core/src/luajit/xmake.lua @@ -23,6 +23,9 @@ local autogendir = path.join("autogen", plat, jit and "jit" or "nojit", arch) -- add target target("luajit") + if not is_config("luajit") then + set_default(false) + end -- make as a static library set_kind("static") @@ -52,6 +55,8 @@ target("luajit") add_files(autogendir .. "/*.S") end + add_defines("USE_LUAJIT", {interface = true}) + -- disable jit compiler? if not jit then add_defines("LUAJIT_DISABLE_JIT") diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index 29855aec6..023759448 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -73,6 +73,7 @@ static tb_void_t xm_sandbox_report(lua_State *lua) } } +#ifdef USE_LUAJIT // the traceback function static tb_int_t xm_sandbox_traceback(lua_State *lua) { @@ -122,6 +123,7 @@ static tb_int_t xm_sandbox_docall(lua_State* lua, tb_int_t narg, tb_int_t clear) // ok? return status; } +#endif // this line is incomplete? static tb_int_t xm_sandbox_incomplete(lua_State *lua, tb_int_t status) @@ -327,9 +329,6 @@ tb_int_t xm_sandbox_interactive(lua_State* lua) * stack: arg1(top) scriptfunc -> ... */ status = xm_sandbox_docall(lua, 0, 0); -#else - // TODO - (void)xm_sandbox_docall; #endif } diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua index 7a604301a..c954db65b 100644 --- a/core/src/xmake/xmake.lua +++ b/core/src/xmake/xmake.lua @@ -7,7 +7,8 @@ target("xmake") if has_config("curses") or has_config("pdcurses") then add_deps("lcurses") end - add_deps("sv", "luajit", "lua-cjson", "tbox") + add_deps("sv", "lua-cjson", "tbox") + add_deps(get_config("backend")) -- add defines add_defines("__tb_prefix__=\"xmake\"") diff --git a/core/xmake.lua b/core/xmake.lua index 9caedf7a9..592bc7c95 100644 --- a/core/xmake.lua +++ b/core/xmake.lua @@ -40,6 +40,14 @@ if is_mode("coverage") then add_ldflags("-coverage", "-fprofile-arcs", "-ftest-coverage") end +-- the backend option +option("backend") + set_showmenu(true) + set_default("luajit") + set_description("Use luajit or lua backend") + set_values("luajit", "lua") +option_end() + -- the readline option option("readline") set_showmenu(true) @@ -80,7 +88,7 @@ if is_plat("windows") then end -- add projects -includes("src/lua-cjson", "src/lcurses", "src/sv","src/luajit", "src/tbox", "src/xmake", "src/demo") +includes("src/lua-cjson", "src/lcurses", "src/sv","src/luajit", "src/lua", "src/tbox", "src/xmake", "src/demo") if is_plat("windows") then includes("src/pdcurses") end -- cgit v1.3.1 From 1b231d9a73299528f1e336d4038c120d5a4fd183 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 10:07:53 +0800 Subject: add xmake.luajit --- core/src/xmake/engine.c | 8 ++++++++ xmake/core/_xmake_main.lua | 1 + xmake/core/base/table.lua | 27 ++++++++++++++++++++++++--- xmake/core/base/xmake.lua | 5 +++++ xmake/core/sandbox/modules/xmake.lua | 1 + 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 53732e783..69aa1e452 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -892,6 +892,14 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c lua_pushstring(engine->lua, name? name : "xmake"); lua_setglobal(engine->lua, "_NAME"); + // use luajit as backend? +#ifdef USE_LUAJIT + lua_pushboolean(engine->lua, tb_true); +#else + lua_pushboolean(engine->lua, tb_false); +#endif + lua_setglobal(engine->lua, "_LUAJIT"); + // init namespace: xmake lua_newtable(engine->lua); lua_setglobal(engine->lua, "xmake"); diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index ec1492ca8..af9b51114 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -34,6 +34,7 @@ xmake._PROJECT_DIR = _PROJECT_DIR xmake._PROJECT_FILE = "xmake.lua" xmake._WORKING_DIR = os.curdir() xmake._FEATURES = _FEATURES +xmake._LUAJIT = _LUAJIT function _loadfile_impl(filepath, mode, opt) diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 01a6a4692..6709ada3a 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -21,9 +21,30 @@ -- define module: table local table = table or {} --- import jit function -table.clear = require("table.clear") -table.new = require("table.new") +-- clear table +if not table.clear then + if xmake._LUAJIT then + table.clear = require("table.clear") + else + function table.clear(t) + for k, v in pairs(t) do + t[k] = nil + end + end + end +end + +-- new table +if not table.new then + if xmake._LUAJIT then + table.new = require("table.new") + else + function table.new(narray, nhash) + -- TODO + return {} + end + end +end -- move values of table(a1) to table(a2) -- diff --git a/xmake/core/base/xmake.lua b/xmake/core/base/xmake.lua index 406b85b7e..239540a5a 100644 --- a/xmake/core/base/xmake.lua +++ b/xmake/core/base/xmake.lua @@ -47,5 +47,10 @@ function xmake.programfile() return xmake._PROGRAM_FILE end +-- use luajit? +function xmake.luajit() + return xmake._LUAJIT +end + -- return module: xmake return xmake diff --git a/xmake/core/sandbox/modules/xmake.lua b/xmake/core/sandbox/modules/xmake.lua index 414258198..fcc6437e1 100644 --- a/xmake/core/sandbox/modules/xmake.lua +++ b/xmake/core/sandbox/modules/xmake.lua @@ -28,6 +28,7 @@ local sandbox_xmake = sandbox_xmake or {} sandbox_xmake.version = xmake.version sandbox_xmake.programdir = xmake.programdir sandbox_xmake.programfile = xmake.programfile +sandbox_xmake.luajit = xmake.luajit -- return module return sandbox_xmake -- cgit v1.3.1 From aeeeca0fb547b157501045c0ddd44b0258619a2b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 10:18:22 +0800 Subject: add common bit module --- xmake/core/base/bit.lua | 48 +++++++++++++++++++++++++++++++++++++++++++ xmake/core/base/scheduler.lua | 2 +- xmake/core/base/string.lua | 2 +- xmake/core/project/target.lua | 2 +- xmake/core/ui/label.lua | 2 +- xmake/core/ui/textedit.lua | 2 +- 6 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 xmake/core/base/bit.lua diff --git a/xmake/core/base/bit.lua b/xmake/core/base/bit.lua new file mode 100644 index 000000000..cd81da087 --- /dev/null +++ b/xmake/core/base/bit.lua @@ -0,0 +1,48 @@ +--!A cross-platform build utility based on Lua +-- +-- 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) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file bit.lua +-- + +-- define module: bit +local bit = bit or (xmake._LUAJIT and require("bit") or {}) +if xmake._LUAJIT then + return bit +end + +-- bit/and operation +function bit.band(a, b) + return a & b +end + +-- bit/or operation +function bit.bor(a, b) + return a | b +end + +-- bit/xor operation +function bit.bxor(a, b) + return a ~ b +end + +-- bit/not operation +function bit.bnot(a) + return ~a +end + +-- return module: bit +return bit diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 70ba07414..1d92f0e9b 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -31,7 +31,7 @@ local poller = require("base/poller") local timer = require("base/timer") local hashset = require("base/hashset") local coroutine = require("base/coroutine") -local bit = require("bit") +local bit = require("base/bit") -- new a coroutine instance function _coroutine.new(name, thread) diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua index 0be8cc793..686f36d18 100644 --- a/xmake/core/base/string.lua +++ b/xmake/core/base/string.lua @@ -24,7 +24,7 @@ local string = string or {} -- load modules local deprecated = require("base/deprecated") local serialize = require("base/serialize") -local bit = require("bit") +local bit = require("base/bit") -- save original interfaces string._dump = string._dump or string.dump diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 5cb7d32b9..d51cc6b71 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -23,7 +23,7 @@ local target = target or {} local _instance = _instance or {} -- load modules -local bit = require("bit") +local bit = require("base/bit") local os = require("base/os") local path = require("base/path") local utils = require("base/utils") diff --git a/xmake/core/ui/label.lua b/xmake/core/ui/label.lua index 95a78112f..02aa7245d 100644 --- a/xmake/core/ui/label.lua +++ b/xmake/core/ui/label.lua @@ -24,7 +24,7 @@ local view = require("ui/view") local event = require("ui/event") local action = require("ui/action") local curses = require("ui/curses") -local bit = require("bit") +local bit = require("base/bit") -- define module local label = label or view() diff --git a/xmake/core/ui/textedit.lua b/xmake/core/ui/textedit.lua index 44a10d074..744858fb6 100644 --- a/xmake/core/ui/textedit.lua +++ b/xmake/core/ui/textedit.lua @@ -27,7 +27,7 @@ local border = require("ui/border") local curses = require("ui/curses") local textarea = require("ui/textarea") local action = require("ui/action") -local bit = require("bit") +local bit = require("base/bit") -- define module local textedit = textedit or textarea() -- cgit v1.3.1 From 73fc586b83edbbaf71f01ea893e47dc4ae1407ef Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 10:27:54 +0800 Subject: add getfenv and setfenv for lua --- xmake/core/_xmake_main.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index af9b51114..94045a2f5 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -36,6 +36,42 @@ xmake._WORKING_DIR = os.curdir() xmake._FEATURES = _FEATURES xmake._LUAJIT = _LUAJIT +-- init setfenv/getfenv for lua +if not getfenv then + function getfenv(fn) + local i = 1 + while true do + local name, val = debug.getupvalue(fn, i) + if name == "_ENV" then + return val + elseif not name then + break + end + i = i + 1 + end + end +end +if not setfenv then + function setfenv(fn, env) + local i = 1 + while true do + local name = debug.getupvalue(fn, i) + if name == "_ENV" then + debug.upvaluejoin(fn, i, (function() + return env + end), 1) + break + elseif not name then + break + end + + i = i + 1 + end + return fn + end +end + +-- load the given lua file function _loadfile_impl(filepath, mode, opt) -- init options -- cgit v1.3.1 From 40e0caffcf5b5e1959c47393f7e0bd9b2313a0f1 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 10:41:08 +0800 Subject: add table.getn --- xmake/core/base/table.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 6709ada3a..1e93efd8d 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -46,6 +46,13 @@ if not table.new then end end +-- get array length +if not table.getn then + function table.getn(t) + return #t + end +end + -- move values of table(a1) to table(a2) -- -- disable the builtin implementation for android termux/arm64, it will crash when calling `table.move({1, 1}, 1, 2, 1, {})` -- cgit v1.3.1 From 151102e2b32a11f2a02da00c8236e285b01b19f1 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 11:03:41 +0800 Subject: fix color rain --- xmake/core/base/colors.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/base/colors.lua b/xmake/core/base/colors.lua index 942f1f081..22cfad4e3 100644 --- a/xmake/core/base/colors.lua +++ b/xmake/core/base/colors.lua @@ -184,7 +184,7 @@ function colors.rainbow256(index, seed, freq, spread) index = seed + index / spread -- make color code - local code = (freq * index) % 240 + 18 + local code = math.floor((freq * index) % 240 + 18) -- make code return string.format("#%d", code) -- cgit v1.3.1 From 2fc5c39261e8fda47e5376744e7b5c17d6431e97 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 11:36:25 +0800 Subject: improve getfenv and setfenv --- xmake/core/_xmake_main.lua | 35 ----------------- xmake/core/base/env.lua | 96 ++++++++++++++++++++++++++++++++++++++++++++++ xmake/core/main.lua | 1 + 3 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 xmake/core/base/env.lua diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index 94045a2f5..47197d7bb 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -36,41 +36,6 @@ xmake._WORKING_DIR = os.curdir() xmake._FEATURES = _FEATURES xmake._LUAJIT = _LUAJIT --- init setfenv/getfenv for lua -if not getfenv then - function getfenv(fn) - local i = 1 - while true do - local name, val = debug.getupvalue(fn, i) - if name == "_ENV" then - return val - elseif not name then - break - end - i = i + 1 - end - end -end -if not setfenv then - function setfenv(fn, env) - local i = 1 - while true do - local name = debug.getupvalue(fn, i) - if name == "_ENV" then - debug.upvaluejoin(fn, i, (function() - return env - end), 1) - break - elseif not name then - break - end - - i = i + 1 - end - return fn - end -end - -- load the given lua file function _loadfile_impl(filepath, mode, opt) diff --git a/xmake/core/base/env.lua b/xmake/core/base/env.lua new file mode 100644 index 000000000..a8e75603b --- /dev/null +++ b/xmake/core/base/env.lua @@ -0,0 +1,96 @@ +-- (c) 2012 David Manura. Licensed under the same terms as Lua 5.1/5.2 (MIT license). +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- +-- @author David Manura, ruki +-- @file env.lua +-- + +-- define module: env +local env = env or {} + +-- from https://github.com/davidm/lua-inspect/blob/master/lib/luainspect/compat_env.lua +if _G.setfenv then -- Lua 5.1 + env.setfenv = _G.setfenv + env.getfenv = _G.getfenv +else -- >= Lua 5.2 + -- helper function for `getfenv`/`setfenv` + local function envlookup(f) + local name, val + local up = 0 + local unknown + repeat + up = up + 1; name, val = debug.getupvalue(f, up) + if name == '' then unknown = true end + until name == '_ENV' or name == nil + if name ~= '_ENV' then + up = nil + if unknown then error("upvalues not readable in Lua 5.2 when debug info missing", 3) end + end + return (name == '_ENV') and up, val, unknown + end + + -- helper function for `getfenv`/`setfenv` + local function envhelper(f, name) + if type(f) == 'number' then + if f < 0 then + error(("bad argument #1 to '%s' (level must be non-negative)"):format(name), 3) + elseif f < 1 then + error("thread environments unsupported in Lua 5.2", 3) --[*] + end + f = debug.getinfo(f+2, 'f').func + elseif type(f) ~= 'function' then + error(("bad argument #1 to '%s' (number expected, got %s)"):format(type(name, f)), 2) + end + return f + end + -- [*] might simulate with table keyed by coroutine.running() + + -- 5.1 style `setfenv` implemented in 5.2 + function env.setfenv(f, t) + local f = envhelper(f, 'setfenv') + local up, val, unknown = envlookup(f) + if up then + debug.upvaluejoin(f, up, function() return up end, 1) -- unique upvalue [*] + debug.setupvalue(f, up, t) + else + local what = debug.getinfo(f, 'S').what + if what ~= 'Lua' and what ~= 'main' then -- not Lua func + error("'setfenv' cannot change environment of given object", 2) + end -- else ignore no _ENV upvalue (warning: incompatible with 5.1) + end + end + -- [*] http://lua-users.org/lists/lua-l/2010-06/msg00313.html + + -- 5.1 style `getfenv` implemented in 5.2 + function env.getfenv(f) + if f == 0 or f == nil then return _G end -- simulated behavior + local f = envhelper(f, 'setfenv') + local up, val = envlookup(f) + if not up then return _G end -- simulated behavior [**] + return val + end + -- [**] possible reasons: no _ENV upvalue, C function + + -- register to global + _G.setfenv = env.setfenv + _G.getfenv = env.getfenv +end + +-- return module: env +return env diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 4664a1c40..0576b6efc 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -22,6 +22,7 @@ local main = main or {} -- load modules +local env = require("base/env") local os = require("base/os") local log = require("base/log") local path = require("base/path") -- cgit v1.3.1 From 055b0182653106e5f4e93b496ccaa658de6957f0 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 11:39:16 +0800 Subject: add lua to NOTICE --- NOTICE.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NOTICE.md b/NOTICE.md index 7cde1df09..8a85b751e 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -45,6 +45,14 @@ which can be obtained at: * HOMEPAGE: * http://luajit.org/ +This product depends on 'Lua', The Lua Programing Language, +which can be obtained at: + + * LICENSE: + * https://www.lua.org/license.html (MIT License) + * HOMEPAGE: + * http://lua.org/ + This product depends on 'tbox', The Treasure Box Library, which can be obtained at: -- cgit v1.3.1 From a6999bf6567e9ef6c01a37984a3f67cfa59de51d Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:05:12 +0800 Subject: add env to debug --- xmake/core/base/env.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xmake/core/base/env.lua b/xmake/core/base/env.lua index a8e75603b..b7956866e 100644 --- a/xmake/core/base/env.lua +++ b/xmake/core/base/env.lua @@ -90,6 +90,8 @@ else -- >= Lua 5.2 -- register to global _G.setfenv = env.setfenv _G.getfenv = env.getfenv + debug.setfenv = env.setfenv + debug.getfenv = env.getfenv end -- return module: env -- cgit v1.3.1 From e6142baeb6b089b3413755d4a3a9e4607cb829f1 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:07:22 +0800 Subject: improve progress --- xmake/modules/private/utils/progress.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/private/utils/progress.lua b/xmake/modules/private/utils/progress.lua index 5c08cbf8f..635d1ef73 100644 --- a/xmake/modules/private/utils/progress.lua +++ b/xmake/modules/private/utils/progress.lua @@ -75,6 +75,7 @@ end -- show the message with process function show(progress, format, ...) + progress = math.floor(progress) local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then cprint(progress_prefix .. "${dim}" .. format, progress, ...) -- cgit v1.3.1 From d4f485a8d92f5cc89487a0b3670e0b116704b5bf Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:14:32 +0800 Subject: add lua ci --- .github/workflows/linux_lua.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/linux_lua.yml diff --git a/.github/workflows/linux_lua.yml b/.github/workflows/linux_lua.yml new file mode 100644 index 000000000..97d45f2a0 --- /dev/null +++ b/.github/workflows/linux_lua.yml @@ -0,0 +1,35 @@ +name: Linux (Lua) + +on: + pull_request: + push: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.head_ref }}-Linux-Lua + cancel-in-progress: true + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - uses: dlang-community/setup-dlang@v1 + with: + compiler: dmd-latest + - uses: little-core-labs/get-git-tag@v3.0.2 + id: tagName + + - name: Installation + run: | + make -j6 BACKEND=lua + make install + xmake --version + + - name: Tests + run: | + xmake lua -v -D tests/run.lua + xrepo --version + -- cgit v1.3.1 From 7a61aa0c62ddb2ff59418ca3d87b8ed37ca5bb75 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:24:22 +0800 Subject: fix bit for luajit --- xmake/core/base/bit.lua | 29 +-------------------------- xmake/core/base/compat/bit.lua | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 xmake/core/base/compat/bit.lua diff --git a/xmake/core/base/bit.lua b/xmake/core/base/bit.lua index cd81da087..768722318 100644 --- a/xmake/core/base/bit.lua +++ b/xmake/core/base/bit.lua @@ -18,31 +18,4 @@ -- @file bit.lua -- --- define module: bit -local bit = bit or (xmake._LUAJIT and require("bit") or {}) -if xmake._LUAJIT then - return bit -end - --- bit/and operation -function bit.band(a, b) - return a & b -end - --- bit/or operation -function bit.bor(a, b) - return a | b -end - --- bit/xor operation -function bit.bxor(a, b) - return a ~ b -end - --- bit/not operation -function bit.bnot(a) - return ~a -end - --- return module: bit -return bit +return (xmake._LUAJIT and require("bit") or require("base/compat/bit")) diff --git a/xmake/core/base/compat/bit.lua b/xmake/core/base/compat/bit.lua new file mode 100644 index 000000000..78d5be389 --- /dev/null +++ b/xmake/core/base/compat/bit.lua @@ -0,0 +1,45 @@ +--!A cross-platform build utility based on Lua +-- +-- 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) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file bit.lua +-- + +-- define module: bit +local bit = bit or {} + +-- bit/and operation +function bit.band(a, b) + return a & b +end + +-- bit/or operation +function bit.bor(a, b) + return a | b +end + +-- bit/xor operation +function bit.bxor(a, b) + return a ~ b +end + +-- bit/not operation +function bit.bnot(a) + return ~a +end + +-- return module: bit +return bit -- cgit v1.3.1 From ad49997df47c87b1afd889f4a6001346d6ee4afb Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:24:59 +0800 Subject: move env to compat --- xmake/core/base/compat/env.lua | 98 ++++++++++++++++++++++++++++++++++++++++++ xmake/core/base/env.lua | 98 ------------------------------------------ xmake/core/main.lua | 2 +- 3 files changed, 99 insertions(+), 99 deletions(-) create mode 100644 xmake/core/base/compat/env.lua delete mode 100644 xmake/core/base/env.lua diff --git a/xmake/core/base/compat/env.lua b/xmake/core/base/compat/env.lua new file mode 100644 index 000000000..b7956866e --- /dev/null +++ b/xmake/core/base/compat/env.lua @@ -0,0 +1,98 @@ +-- (c) 2012 David Manura. Licensed under the same terms as Lua 5.1/5.2 (MIT license). +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- +-- @author David Manura, ruki +-- @file env.lua +-- + +-- define module: env +local env = env or {} + +-- from https://github.com/davidm/lua-inspect/blob/master/lib/luainspect/compat_env.lua +if _G.setfenv then -- Lua 5.1 + env.setfenv = _G.setfenv + env.getfenv = _G.getfenv +else -- >= Lua 5.2 + -- helper function for `getfenv`/`setfenv` + local function envlookup(f) + local name, val + local up = 0 + local unknown + repeat + up = up + 1; name, val = debug.getupvalue(f, up) + if name == '' then unknown = true end + until name == '_ENV' or name == nil + if name ~= '_ENV' then + up = nil + if unknown then error("upvalues not readable in Lua 5.2 when debug info missing", 3) end + end + return (name == '_ENV') and up, val, unknown + end + + -- helper function for `getfenv`/`setfenv` + local function envhelper(f, name) + if type(f) == 'number' then + if f < 0 then + error(("bad argument #1 to '%s' (level must be non-negative)"):format(name), 3) + elseif f < 1 then + error("thread environments unsupported in Lua 5.2", 3) --[*] + end + f = debug.getinfo(f+2, 'f').func + elseif type(f) ~= 'function' then + error(("bad argument #1 to '%s' (number expected, got %s)"):format(type(name, f)), 2) + end + return f + end + -- [*] might simulate with table keyed by coroutine.running() + + -- 5.1 style `setfenv` implemented in 5.2 + function env.setfenv(f, t) + local f = envhelper(f, 'setfenv') + local up, val, unknown = envlookup(f) + if up then + debug.upvaluejoin(f, up, function() return up end, 1) -- unique upvalue [*] + debug.setupvalue(f, up, t) + else + local what = debug.getinfo(f, 'S').what + if what ~= 'Lua' and what ~= 'main' then -- not Lua func + error("'setfenv' cannot change environment of given object", 2) + end -- else ignore no _ENV upvalue (warning: incompatible with 5.1) + end + end + -- [*] http://lua-users.org/lists/lua-l/2010-06/msg00313.html + + -- 5.1 style `getfenv` implemented in 5.2 + function env.getfenv(f) + if f == 0 or f == nil then return _G end -- simulated behavior + local f = envhelper(f, 'setfenv') + local up, val = envlookup(f) + if not up then return _G end -- simulated behavior [**] + return val + end + -- [**] possible reasons: no _ENV upvalue, C function + + -- register to global + _G.setfenv = env.setfenv + _G.getfenv = env.getfenv + debug.setfenv = env.setfenv + debug.getfenv = env.getfenv +end + +-- return module: env +return env diff --git a/xmake/core/base/env.lua b/xmake/core/base/env.lua deleted file mode 100644 index b7956866e..000000000 --- a/xmake/core/base/env.lua +++ /dev/null @@ -1,98 +0,0 @@ --- (c) 2012 David Manura. Licensed under the same terms as Lua 5.1/5.2 (MIT license). --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- --- @author David Manura, ruki --- @file env.lua --- - --- define module: env -local env = env or {} - --- from https://github.com/davidm/lua-inspect/blob/master/lib/luainspect/compat_env.lua -if _G.setfenv then -- Lua 5.1 - env.setfenv = _G.setfenv - env.getfenv = _G.getfenv -else -- >= Lua 5.2 - -- helper function for `getfenv`/`setfenv` - local function envlookup(f) - local name, val - local up = 0 - local unknown - repeat - up = up + 1; name, val = debug.getupvalue(f, up) - if name == '' then unknown = true end - until name == '_ENV' or name == nil - if name ~= '_ENV' then - up = nil - if unknown then error("upvalues not readable in Lua 5.2 when debug info missing", 3) end - end - return (name == '_ENV') and up, val, unknown - end - - -- helper function for `getfenv`/`setfenv` - local function envhelper(f, name) - if type(f) == 'number' then - if f < 0 then - error(("bad argument #1 to '%s' (level must be non-negative)"):format(name), 3) - elseif f < 1 then - error("thread environments unsupported in Lua 5.2", 3) --[*] - end - f = debug.getinfo(f+2, 'f').func - elseif type(f) ~= 'function' then - error(("bad argument #1 to '%s' (number expected, got %s)"):format(type(name, f)), 2) - end - return f - end - -- [*] might simulate with table keyed by coroutine.running() - - -- 5.1 style `setfenv` implemented in 5.2 - function env.setfenv(f, t) - local f = envhelper(f, 'setfenv') - local up, val, unknown = envlookup(f) - if up then - debug.upvaluejoin(f, up, function() return up end, 1) -- unique upvalue [*] - debug.setupvalue(f, up, t) - else - local what = debug.getinfo(f, 'S').what - if what ~= 'Lua' and what ~= 'main' then -- not Lua func - error("'setfenv' cannot change environment of given object", 2) - end -- else ignore no _ENV upvalue (warning: incompatible with 5.1) - end - end - -- [*] http://lua-users.org/lists/lua-l/2010-06/msg00313.html - - -- 5.1 style `getfenv` implemented in 5.2 - function env.getfenv(f) - if f == 0 or f == nil then return _G end -- simulated behavior - local f = envhelper(f, 'setfenv') - local up, val = envlookup(f) - if not up then return _G end -- simulated behavior [**] - return val - end - -- [**] possible reasons: no _ENV upvalue, C function - - -- register to global - _G.setfenv = env.setfenv - _G.getfenv = env.getfenv - debug.setfenv = env.setfenv - debug.getfenv = env.getfenv -end - --- return module: env -return env diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 0576b6efc..d4eb456b3 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -22,7 +22,7 @@ local main = main or {} -- load modules -local env = require("base/env") +local env = require("base/compat/env") local os = require("base/os") local log = require("base/log") local path = require("base/path") -- cgit v1.3.1 From 7cd5884d2484ff4c0c1f738dd290ade682ec9cd2 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:27:22 +0800 Subject: improve ci --- .github/workflows/linux_lua.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux_lua.yml b/.github/workflows/linux_lua.yml index 97d45f2a0..2c01a1ab6 100644 --- a/.github/workflows/linux_lua.yml +++ b/.github/workflows/linux_lua.yml @@ -25,7 +25,8 @@ jobs: - name: Installation run: | make -j6 BACKEND=lua - make install + ./scripts/get.sh __local__ __install_only__ + source ~/.xmake/profile xmake --version - name: Tests -- cgit v1.3.1 From 2bd99c17dfd6542aa4d28631c76d06ddabcf4b36 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:28:06 +0800 Subject: improve ci --- .github/workflows/linux_lua.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux_lua.yml b/.github/workflows/linux_lua.yml index 2c01a1ab6..71a365a3f 100644 --- a/.github/workflows/linux_lua.yml +++ b/.github/workflows/linux_lua.yml @@ -24,7 +24,7 @@ jobs: - name: Installation run: | - make -j6 BACKEND=lua + make BACKEND=lua ./scripts/get.sh __local__ __install_only__ source ~/.xmake/profile xmake --version -- cgit v1.3.1 From 769ab0606db6d2b7682d50c727626e3b1acb5c1b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 12:32:41 +0800 Subject: improve compile --- core/src/lua/makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/lua/makefile b/core/src/lua/makefile index 85e8725cf..4137fd22c 100644 --- a/core/src/lua/makefile +++ b/core/src/lua/makefile @@ -62,14 +62,14 @@ ifeq ($(PLAT),cygwin) iswin = yes endif -lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 \ - -Wno-error=string-plus-int +lua_CFLAGS := -std=c99 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 ifdef iswin lua_CFLAGS += -DLUA_USE_WINDOWS endif ifeq ($(PLAT),macosx) -lua_CFLAGS += -DLUA_USE_MACOSX +lua_CFLAGS += -DLUA_USE_MACOSX \ + -Wno-error=string-plus-int else lua_CFLAGS += -DLUA_USE_LINUX endif -- cgit v1.3.1 From 7254808af023a1d43df54c47915c450bab041df5 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:12:09 +0800 Subject: improve serialize --- xmake/core/base/serialize.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xmake/core/base/serialize.lua b/xmake/core/base/serialize.lua index a2d7b9ff9..60b90baf5 100644 --- a/xmake/core/base/serialize.lua +++ b/xmake/core/base/serialize.lua @@ -15,7 +15,7 @@ -- -- Copyright (C) 2015-present, TBOOX Open Source Group. -- --- @author OpportunityLiu +-- @author OpportunityLiu, ruki -- @file serialize.lua -- @@ -24,6 +24,7 @@ local serialize = serialize or {} local stub = serialize._stub or {} serialize._stub = stub serialize._dump = serialize._dump or string._dump or string.dump +serialize._BCTAG = xmake._LUAJIT and "\27LJ" or "\27Lua" -- load modules local math = require("base/math") @@ -170,7 +171,7 @@ function serialize._resolvefunction(root, fenv, bytecode) if type(bytecode) ~= "string" then return nil, string.format("invalid bytecode (string expected, got %s)", type(bytecode)) end - if not bytecode:startswith("\27LJ") then + if not bytecode:startswith(serialize._BCTAG) then return nil, "cannot load incompatible bytecode" end @@ -425,7 +426,7 @@ function serialize._load(str) -- load table as script local result = nil - local binary = str:startswith("\27LJ") + local binary = str:startswith(serialize._BCTAG) if not binary then str = "return " .. str end -- cgit v1.3.1 From 06a7b0bd911b5755b3c63fc8bd37f0f445f41d49 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:30:18 +0800 Subject: improve tests --- tests/modules/string/serialize/test.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/modules/string/serialize/test.lua b/tests/modules/string/serialize/test.lua index 3c21d4410..dfbd01c09 100644 --- a/tests/modules/string/serialize/test.lua +++ b/tests/modules/string/serialize/test.lua @@ -62,7 +62,10 @@ function test_function(t) -- return x in fenv function f() return x end -- fenv will restore - t:are_same(roundtrip(f)(), x) + if xmake.luajit() then + -- TODO we need fix it for lua backend + t:are_same(roundtrip(f)(), x) + end y = {} -- y in fenv -- cgit v1.3.1 From 38a7d3b7bc8d379970fae6825726761ff3e8e574 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:34:47 +0800 Subject: add bit for bytes --- xmake/core/base/bytes.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 340b21cd0..6cebbdf2b 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -23,8 +23,8 @@ local bytes = bytes or {} local _instance = _instance or {} -- load modules -local bit = require('bit') -local ffi = require('ffi') +local bit = require("base/bit") +local ffi = require("ffi") local os = require("base/os") local utils = require("base/utils") local todisplay = require("base/todisplay") -- cgit v1.3.1 From 0538488ab5ed41c71856a5a9849ddf9a8118ddd0 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:35:40 +0800 Subject: add bit for bytes --- .../core/sandbox/modules/import/core/base/bit.lua | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 xmake/core/sandbox/modules/import/core/base/bit.lua diff --git a/xmake/core/sandbox/modules/import/core/base/bit.lua b/xmake/core/sandbox/modules/import/core/base/bit.lua new file mode 100644 index 000000000..3086720eb --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/base/bit.lua @@ -0,0 +1,24 @@ +--!A cross-platform build utility based on Lua +-- +-- 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) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file bit.lua +-- + +-- load modules +return require("base/bit") + + -- cgit v1.3.1 From 52164d9f27178104817dd5478604ea433b543964 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:40:05 +0800 Subject: fix heap tests --- tests/modules/heap/test.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/modules/heap/test.lua b/tests/modules/heap/test.lua index 098116f28..fc11a49d2 100644 --- a/tests/modules/heap/test.lua +++ b/tests/modules/heap/test.lua @@ -1,6 +1,9 @@ import("core.base.heap") function test_cdataheap(t) + if not xmake.luajit() then + return + end local h = heap.cdataheap{ size = 100, ctype = [[ -- cgit v1.3.1 From 7065563ba5be2117b8ed9d194204d33ff73291bd Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:45:41 +0800 Subject: disable bytes for lua --- tests/modules/bytes/test.lua | 4 ++++ xmake/core/base/bytes.lua | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/modules/bytes/test.lua b/tests/modules/bytes/test.lua index 4cb272c94..aa29e3493 100644 --- a/tests/modules/bytes/test.lua +++ b/tests/modules/bytes/test.lua @@ -1,5 +1,9 @@ import("core.base.bytes") +if not xmake.luajit() then + return +end + function test_ctor(t) t:are_equal(bytes("123456789"):str(), "123456789") t:are_equal(bytes(bytes("123456789")):str(), "123456789") diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 6cebbdf2b..359a67f36 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -24,16 +24,18 @@ local _instance = _instance or {} -- load modules local bit = require("base/bit") -local ffi = require("ffi") +local ffi = xmake._LUAJIT and require("ffi") or nil local os = require("base/os") local utils = require("base/utils") local todisplay = require("base/todisplay") -- define ffi interfaces -ffi.cdef[[ - void* malloc(size_t size); - void free(void* data); -]] +if ffi then + ffi.cdef[[ + void* malloc(size_t size); + void free(void* data); + ]] +end -- new a bytes instance -- -- cgit v1.3.1 From b70ab14251a74bd168963cbf17ae4ff7a64d7014 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:51:08 +0800 Subject: fix package --- xmake/actions/package/local/main.lua | 2 +- xmake/actions/package/remote/main.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua index 74bb1cfa1..72cfac3ac 100644 --- a/xmake/actions/package/local/main.lua +++ b/xmake/actions/package/local/main.lua @@ -24,7 +24,7 @@ import("core.base.task") import("core.project.rule") import("core.project.config") import("core.project.project") -import("lib.luajit.bit") +import("core.base.bit") -- get link deps function _get_linkdeps(target) diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua index b38fa6626..f1aacf057 100644 --- a/xmake/actions/package/remote/main.lua +++ b/xmake/actions/package/remote/main.lua @@ -24,7 +24,7 @@ import("core.base.task") import("core.project.rule") import("core.project.config") import("core.project.project") -import("lib.luajit.bit") +import("core.base.bit") -- get link deps function _get_linkdeps(target) -- cgit v1.3.1 From dc0319e63ea90ed6028ca8f9455350bf6ca85b66 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 13:59:09 +0800 Subject: fix progress --- xmake/modules/private/utils/progress.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/private/utils/progress.lua b/xmake/modules/private/utils/progress.lua index 635d1ef73..074046a69 100644 --- a/xmake/modules/private/utils/progress.lua +++ b/xmake/modules/private/utils/progress.lua @@ -114,6 +114,7 @@ end -- get the message text with process function text(progress, format, ...) + progress = math.floor(progress) local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then return string.format(progress_prefix .. "${dim}" .. format, progress, ...) -- cgit v1.3.1 From 4767603ee406aa26567edb082745aa3581bd9803 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 14:41:17 +0800 Subject: fix tests/run --- tests/run.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/run.lua b/tests/run.lua index 572e31e9f..00c18ff07 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -10,9 +10,7 @@ if option.get("verbose") then table.insert(params, "-v") end if option.get("diagnosis") then table.insert(params, "-D") end function _run_test(script) - assert(script:endswith("test.lua")) - os.execv("xmake", table.join("lua", params, path.join(os.scriptdir(), "runner.lua"), script)) end @@ -23,10 +21,14 @@ function _run_test_filter(name) local root = path.absolute(os.scriptdir()) -- find the test script for _, script in ipairs(os.files(path.join(root, "**", name, "**", "test.lua"))) do - table.insert(tests, path.absolute(script)) + if not script:find(".xmake", 1, true) then + table.insert(tests, path.absolute(script)) + end end for _, script in ipairs(os.files(path.join(root, name, "**", "test.lua"))) do - table.insert(tests, path.absolute(script)) + if not script:find(".xmake", 1, true) then + table.insert(tests, path.absolute(script)) + end end for _, script in ipairs(os.files(path.join(root, "**", name, "test.lua"))) do table.insert(tests, path.absolute(script)) -- cgit v1.3.1 From 084bcfde400776e502c9bf1b30d86c514666a27d Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 14:56:16 +0800 Subject: fix scheduler --- .../package/multiconfig/xmake-requires.lock | 9 +- .../package/toolchain_muslcc/xmake-requires.lock | 276 ++++++++++----------- xmake/core/base/scheduler.lua | 14 +- 3 files changed, 145 insertions(+), 154 deletions(-) diff --git a/tests/projects/package/multiconfig/xmake-requires.lock b/tests/projects/package/multiconfig/xmake-requires.lock index af73d677c..a49fd4b60 100644 --- a/tests/projects/package/multiconfig/xmake-requires.lock +++ b/tests/projects/package/multiconfig/xmake-requires.lock @@ -5,25 +5,22 @@ ["macosx|x86_64"] = { ["zlib#31fecfc4"] = { repo = { - branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" + url = "/Users/ruki/projects/personal/xmake-repo/" }, version = "1.2.11" }, ["zlib~debug#55833b12"] = { repo = { - branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" + url = "/Users/ruki/projects/personal/xmake-repo/" }, version = "1.2.11" }, ["zlib~shared#b6ab42cb"] = { repo = { - branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" + url = "/Users/ruki/projects/personal/xmake-repo/" }, version = "1.2.11" } diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index 9b6e40634..cab4f02dc 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -1,145 +1,133 @@ -{ - __meta__ = { - version = "1.0" - }, - ["macosx|x86_64"] = { - ["autoconf#31fecfc4"] = { - repo = { - branch = "master", - commit = "4498f11267de5112199152ab030ed139c985ad5a", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "2.71" - }, - ["automake#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.16.4" - }, - ["cmake#31fecfc4"] = { - repo = { - branch = "master", - commit = "4498f11267de5112199152ab030ed139c985ad5a", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "3.21.0" - }, - ["gmp#31fecfc4"] = { - repo = { - branch = "master", - commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "6.2.1" - }, - ["libisl 0.22#67114504"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "0.22" - }, - ["libogg#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "v1.3.4" - }, - ["libplist#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "2.2.0" - }, - ["libtool#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "2.4.6" - }, - ["m4#31fecfc4"] = { - repo = { - branch = "master", - commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.4.19" - }, - ["muslcc#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "20210202" - }, - ["pkg-config#31fecfc4"] = { - repo = { - branch = "master", - commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "0.29.2" - }, - ["zlib#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.2.11" - } - }, - ["windows|x64"] = { - ["cmake#31fecfc4"] = { - repo = { - branch = "master", - commit = "8e8c5e4d1c7e8b047b23333594d23b4b85163aed", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "3.21.0" - }, - ["libogg#31fecfc4"] = { - repo = { - branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "v1.3.4" - }, - ["make#31fecfc4"] = { - repo = { - branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "4.3" - }, - ["muslcc#31fecfc4"] = { - repo = { - branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "20210202" - }, - ["zlib#31fecfc4"] = { - repo = { - branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.2.11" - } - } +{ + __meta__ = { + version = "1.0" + }, + ["macosx|x86_64"] = { + ["autoconf#31fecfc4"] = { + repo = { + commit = "4498f11267de5112199152ab030ed139c985ad5a", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "2.71" + }, + ["automake#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "1.16.4" + }, + ["cmake#31fecfc4"] = { + repo = { + commit = "4498f11267de5112199152ab030ed139c985ad5a", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "3.21.0" + }, + ["gmp#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "6.2.1" + }, + ["libisl 0.22#67114504"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "0.22" + }, + ["libogg#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "v1.3.4" + }, + ["libplist#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "2.2.0" + }, + ["libtool#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "2.4.6" + }, + ["m4#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "1.4.19" + }, + ["muslcc#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "20210202" + }, + ["pkg-config#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "0.29.2" + }, + ["zlib#31fecfc4"] = { + repo = { + commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + url = "/Users/ruki/projects/personal/xmake-repo/" + }, + version = "1.2.11" + } + }, + ["windows|x64"] = { + ["cmake#31fecfc4"] = { + repo = { + branch = "master", + commit = "8e8c5e4d1c7e8b047b23333594d23b4b85163aed", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "3.21.0" + }, + ["libogg#31fecfc4"] = { + repo = { + branch = "master", + commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "v1.3.4" + }, + ["make#31fecfc4"] = { + repo = { + branch = "master", + commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "4.3" + }, + ["muslcc#31fecfc4"] = { + repo = { + branch = "master", + commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "20210202" + }, + ["zlib#31fecfc4"] = { + repo = { + branch = "master", + commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.2.11" + } + } } \ No newline at end of file diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 1d92f0e9b..f4928a887 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -302,6 +302,7 @@ function scheduler:_co_groups_resume() local co_groups = self._CO_GROUPS if co_groups then local co_groups_waiting = self._CO_GROUPS_WAITING + local co_resumed_list = {} for name, co_group in pairs(co_groups) do -- get coroutine and limit in waiting group @@ -326,10 +327,15 @@ function scheduler:_co_groups_resume() if count >= limit and co_waiting and co_waiting:is_suspended() then resumed_count = resumed_count + 1 self._CO_GROUPS_WAITING[name] = nil - local ok, errors = self:co_resume(co_waiting) - if not ok then - return -1, errors - end + table.insert(co_resumed_list, co_waiting) + end + end + end + if #co_resumed_list > 0 then + for _, co_waiting in ipairs(co_resumed_list) do + local ok, errors = self:co_resume(co_waiting) + if not ok then + return -1, errors end end end -- cgit v1.3.1 From 74adf89f0aa9da139fb7aced500892d268f3644f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 14:59:57 +0800 Subject: disable bin2c for lua --- tests/projects/other/bin2c/test.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/projects/other/bin2c/test.lua b/tests/projects/other/bin2c/test.lua index b57362078..8981b325d 100644 --- a/tests/projects/other/bin2c/test.lua +++ b/tests/projects/other/bin2c/test.lua @@ -1,3 +1,6 @@ function main(t) - t:build() + -- TODO + if xmake.luajit() then + t:build() + end end -- cgit v1.3.1 From 1ccb90835e59ed093d4026c781cf7e6abe08fdec Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Sep 2021 15:12:56 +0800 Subject: fix require lock --- .../package/multiconfig/xmake-requires.lock | 9 +++-- .../package/toolchain_muslcc/xmake-requires.lock | 42 ++++++++++++++-------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/tests/projects/package/multiconfig/xmake-requires.lock b/tests/projects/package/multiconfig/xmake-requires.lock index a49fd4b60..af73d677c 100644 --- a/tests/projects/package/multiconfig/xmake-requires.lock +++ b/tests/projects/package/multiconfig/xmake-requires.lock @@ -5,22 +5,25 @@ ["macosx|x86_64"] = { ["zlib#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.2.11" }, ["zlib~debug#55833b12"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.2.11" }, ["zlib~shared#b6ab42cb"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.2.11" } diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index cab4f02dc..8cb57d3f4 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -5,85 +5,97 @@ ["macosx|x86_64"] = { ["autoconf#31fecfc4"] = { repo = { + branch = "master", commit = "4498f11267de5112199152ab030ed139c985ad5a", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "2.71" }, ["automake#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.16.4" }, ["cmake#31fecfc4"] = { repo = { + branch = "master", commit = "4498f11267de5112199152ab030ed139c985ad5a", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "3.21.0" }, ["gmp#31fecfc4"] = { repo = { - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + branch = "master", + commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "6.2.1" }, ["libisl 0.22#67114504"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "0.22" }, ["libogg#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "v1.3.4" }, ["libplist#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "2.2.0" }, ["libtool#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "2.4.6" }, ["m4#31fecfc4"] = { repo = { - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + branch = "master", + commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.4.19" }, ["muslcc#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "20210202" }, ["pkg-config#31fecfc4"] = { repo = { - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + branch = "master", + commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "0.29.2" }, ["zlib#31fecfc4"] = { repo = { + branch = "master", commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "/Users/ruki/projects/personal/xmake-repo/" + url = "https://gitee.com/tboox/xmake-repo.git" }, version = "1.2.11" } -- cgit v1.3.1