From d6f3120ac195a1ad0d3b6f017aba76558c9ed36d Mon Sep 17 00:00:00 2001 From: beicause <1494181792@qq.com> Date: Sat, 1 Jun 2024 12:41:50 +0800 Subject: [PATCH 1/4] Fix compilation in godot 4.3 master --- src/classes/luaCoroutine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/luaCoroutine.cpp b/src/classes/luaCoroutine.cpp index ced035dd..83ff5a7e 100644 --- a/src/classes/luaCoroutine.cpp +++ b/src/classes/luaCoroutine.cpp @@ -162,7 +162,7 @@ Variant LuaCoroutine::resume(Array args) { return LuaError::newError("Cannot have more than one connection to the coroutine_resume signal", LuaError::ERR_RUNTIME); } - Callable callback = resume_connections[0].callable; + Callable callback = resume_connections.begin()->callable; if (!callback.is_valid()) { return LuaError::newError("Invalid callable connected to the coroutine_resume signal", LuaError::ERR_RUNTIME); } From e3d215df8629709b08c3bacff22deab580c246df Mon Sep 17 00:00:00 2001 From: beicause <1494181792@qq.com> Date: Mon, 3 Jun 2024 17:19:06 +0800 Subject: [PATCH 2/4] update doc --- doc_classes/LuaAPI.xml | 105 +++++++++++----------- doc_classes/LuaCallableExtra.xml | 50 +++++------ doc_classes/LuaCoroutine.xml | 96 ++++++++++---------- doc_classes/LuaDefaultObjectMetatable.xml | 8 +- doc_classes/LuaError.xml | 2 +- doc_classes/LuaFunctionRef.xml | 4 +- doc_classes/LuaObjectMetatable.xml | 60 ++++++------- doc_classes/LuaTuple.xml | 65 +++++++------- 8 files changed, 196 insertions(+), 194 deletions(-) diff --git a/doc_classes/LuaAPI.xml b/doc_classes/LuaAPI.xml index 1f005322..f8271e10 100644 --- a/doc_classes/LuaAPI.xml +++ b/doc_classes/LuaAPI.xml @@ -1,5 +1,5 @@ - + Execute Lua code at runtime and make your own API. @@ -9,25 +9,29 @@ - - + + + - This method will create a coroutine that is already bound to this runtime. + Bind lua libraries to the LuaAPI Object. + Returns an error if a library fails to bind. + Note: in C#, the param Array must be a [code]Godot.Collections.Array[/code] and not a [code]System.Array[/code] class. - - + + + + - Intended to be called from a lua hook. Returns the current running coroutine. + Calls a function inside current Lua state. This can be either a exposed function or a function defined with with Lua. You may want to check if the function actually exists with [code]function_exists(LuaFunctionName)[/code]. This function supports 1 return value from lua. It will be returned as a variant and if Lua returns no value it will be null. If an error occurs while calling this function, a LuaError object will be returned. - - - + + + + - Bind lua libraries to the LuaAPI Object. - Returns an error if a library fails to bind. - Note: in C#, the param Array must be a [code]Godot.Collections.Array[/code] and not a [code]System.Array[/code] class. + Controls the garbage collector. The option can be one of the following: [constant GC_STOP], [constant GC_RESTART], [constant GC_COLLECT], [constant GC_COUNT], [constant GC_STEP], [constant GC_SETPAUSE], [constant GC_SETSTEPMUL]. The data is the argument for the option. Returns the result of the option. @@ -36,7 +40,7 @@ Loads a file with luaL_loadfile() passing its absolute path. - Similar to [code].do_string()[/code], this function loads a lua file into the LuaAPI Object and executes it as Lua. [code]FilePath[/code] must be an absolute path, and must exist or an error is returned. + Similar to [code].do_string()[/code], this function loads a lua file into the LuaAPI Object and executes it as Lua. [param FilePath] must be an absolute path, and must exist or an error is returned. @@ -52,86 +56,82 @@ - Returns [code]true[/code] only if [code]LuaFunctionName[/code] is defined in the global environment table as a function. + Returns [code]true[/code] only if [param LuaFunctionName] is defined in the global environment table as a function. - - - - + + - Calls a function inside current Lua state. This can be either a exposed function or a function defined with with Lua. You may want to check if the function actually exists with [code]function_exists(LuaFunctionName)[/code]. This function supports 1 return value from lua. It will be returned as a variant and if Lua returns no value it will be null. If an error occurs while calling this function, a LuaError object will be returned. + Returns the current memory usage of the state in bytes. - + - Will pull a copy of a global Variant from lua. + Will pull a copy of a Variant from lua's registry table. - - - - + + - Will push a copy of a Variant to lua as a global. Returns a error if the type is not supported. - Using [code].PushVariant[/code] in C# to push a function requires wrapping the Method in a [code]Callable[/code] first. In GDScript the wrapper is not needed. + Intended to be called from a lua hook. Returns the current running coroutine. - + + + + This method will create a coroutine that is already bound to this runtime. + + + - Will pull a copy of a Variant from lua's registry table. + Will pull a copy of a global Variant from lua. - + - Will push a copy of a Variant to lua's registry table. Returns a error if the type is not supported. + Will push a copy of a Variant to lua as a global. Returns a error if the type is not supported. + Using [code].PushVariant[/code] in C# to push a function requires wrapping the Method in a [Callable] first. In GDScript the wrapper is not needed. - - - + + + Sets the hook for the state. The hook will be called on the events specified by the mask. The count specifies how many instructions should be executed before the hook is called. If count is 0, the hook will be called on every instruction. The hook will be called with the following arguments: [code]hook(parent, event, line)[/code]. The parent is the LuaAPI object that owns the current state. - - - - - - Controls the garbage collector. The option can be one of the following: [code]GC_STOP[/code], [code]GC_RESTART[/code], [code]GC_COLLECT[/code], [code]GC_COUNT[/code], [code]GC_STEP[/code], [code]GC_SETPAUSE[/code], [code]GC_SETSTEPMUL[/code]. The data is the argument for the option. Returns the result of the option. - - - - + + + + - Returns the current memory usage of the state in bytes. + Will push a copy of a Variant to lua's registry table. Returns a error if the type is not supported. - - This is the default LuaMetatable to use for object which do not define a lua_metatable field. By default it is a LuaDefaultObjectMetatable. You can change this to a custom metatable to change the behavior of all objects. - Sets the memory limit for the state in bytes. If the limit is 0, there is no limit. + + This is the default LuaMetatable to use for object which do not define a lua_metatable field. By default it is a LuaDefaultObjectMetatable. You can change this to a custom metatable to change the behavior of all objects. + When true, Lua functions passed to Godot will use the LuaCallable type. This type is a CallableCustom which has issues currently with GDExtension and C# When false, Lua functions passed to Godot will use the LuaFunctionRef type. This type is a RefCounted which behaves the same as a LuaCallable. But uses Invoke instead of Call. + - - Specifies on which events the hook will be called. + Specifies on which events the hook will be called. @@ -142,9 +142,8 @@ Specifies on which events the hook will be called. - - Stops the garbage collector. + Specifies on which events the hook will be called. Restarts the garbage collector. diff --git a/doc_classes/LuaCallableExtra.xml b/doc_classes/LuaCallableExtra.xml index fdc72043..3958bd23 100644 --- a/doc_classes/LuaCallableExtra.xml +++ b/doc_classes/LuaCallableExtra.xml @@ -1,5 +1,5 @@ - + A tuple. @@ -8,50 +8,50 @@ - - - Whether or not the last argument is a tuple. - - - Whether or not the function wants a reference to the LuaAPI object. - - - The TOTAL number of arguments excluding the tuple if there is one. - - - - - + + + + + - Call the function with a tuple as the last argument. Argc is the TOTAL number of arguments excluding the tuple. + Set CallableExtra info. - + Call the function with a reference to the LuaAPI object as the first argument. - + Call the function with a reference to the LuaAPI object as the first argument and a tuple as the last argument. Argc is the TOTAL number of arguments excluding the tuple. - - - + + + - - - Set CallableExtra info. + Call the function with a tuple as the last argument. Argc is the TOTAL number of arguments excluding the tuple. - \ No newline at end of file + + + The TOTAL number of arguments excluding the tuple if there is one. + + + Whether or not the last argument is a tuple. + + + Whether or not the function wants a reference to the LuaAPI object. + + + diff --git a/doc_classes/LuaCoroutine.xml b/doc_classes/LuaCoroutine.xml index af93680a..ad695840 100644 --- a/doc_classes/LuaCoroutine.xml +++ b/doc_classes/LuaCoroutine.xml @@ -1,5 +1,5 @@ - + A coroutine. @@ -9,46 +9,33 @@ - - - - - Allows a GDScript function being called by a LuaCoroutine to await. It yields the lua state and passes any args to LuaCoroutine.resume() - - - - - - - Must be called from a lua hook. Will yield the lua state and pass arguments to `resume()`. Can be destructive. - - - + Binds the coroutine to a lua object. All coroutines attached to the same object share resources. - - - + + + + - Loads a file into the coroutines state. + Calls a function inside current Lua state. This can be either a exposed function or a function defined with with lua. You may want to check if the function actually exists with [code]function_exists(LuaFunctionName)[/code]. This function supports 1 return value from lua. It will be returned as a variant and if lua returns no value it will be null. - - - + + + - Loads a string into the coroutines state. + Returns [code]true[/code] only if [param LuaFunctionName] is defined in current Lua's state as a function. - + - + - Resumes or starts the coroutine. Will either return a Array of arguments passed by lua in yield() or a LuaError. Arguments are passed to yield() in lua. This is a blocking call, it will not return until the coroutine has yielded or finished. + Will pull a copy of a Variant from lua's registry table. @@ -57,19 +44,18 @@ Returns true if the coroutine is finished executing. - - - + + + - Returns [code]true[/code] only if [code]LuaFunctionName[/code] is defined in current Lua's state as a function. + Loads a file into the coroutines state. - - - - + + + - Calls a function inside current Lua state. This can be either a exposed function or a function defined with with lua. You may want to check if the function actually exists with [code]function_exists(LuaFunctionName)[/code]. This function supports 1 return value from lua. It will be returned as a variant and if lua returns no value it will be null. + Loads a string into the coroutines state. @@ -87,11 +73,20 @@ Will push a copy of a Variant to lua as a global. Returns a error if the type is not supported. - + - + - Will pull a copy of a Variant from lua's registry table. + Resumes or starts the coroutine. Will either return a Array of arguments passed by lua in yield() or a LuaError. Arguments are passed to yield() in lua. This is a blocking call, it will not return until the coroutine has yielded or finished. + + + + + + + + + Sets the hook for the state. The hook will be called on the events specified by the mask. The count specifies how many instructions should be executed before the hook is called. If count is 0, the hook will be called on every instruction. The hook will be called with the following arguments: [code]hook(parent, event, line)[/code]. The parent is the LuaAPI object that owns the current state. @@ -102,14 +97,25 @@ Will push a copy of a Variant to lua's registry table. Returns a error if the type is not supported. - - - - - + + + - Sets the hook for the state. The hook will be called on the events specified by the mask. The count specifies how many instructions should be executed before the hook is called. If count is 0, the hook will be called on every instruction. The hook will be called with the following arguments: [code]hook(parent, event, line)[/code]. The parent is the LuaAPI object that owns the current state. + Allows a GDScript function being called by a LuaCoroutine to await. It yields the lua state and passes any args to LuaCoroutine.resume() + + + + + + + Must be called from a lua hook. Will yield the lua state and pass arguments to `resume()`. Can be destructive. + + + + + + diff --git a/doc_classes/LuaDefaultObjectMetatable.xml b/doc_classes/LuaDefaultObjectMetatable.xml index 612aa7e9..5a562b5c 100644 --- a/doc_classes/LuaDefaultObjectMetatable.xml +++ b/doc_classes/LuaDefaultObjectMetatable.xml @@ -1,17 +1,17 @@ - + - The default LuaObjectMetatable used by the LuaAPI class as the object_metatable value. + The default LuaObjectMetatable used by the LuaAPI class as the object_metatable value. - This metatable by default checks if the object has a lua_fields method. If it does depending on how permissive is set. The listed fields will be allowed or disallowed. + This metatable by default checks if the object has a lua_fields method. If it does depending on how permissive is set. The listed fields will be allowed or disallowed. This metatable also checks if the object overrides any of the metamethods, if it does it will call the overridden method. - Sets weather the Objects lua_fields method is treated as a whitelist or a blacklist. If true, the fields method is treated as a blacklist and returned fields will be disallowed. If false, the fields method is treated as a whitelist and returned fields will be allowed. + Sets weather the Objects lua_fields method is treated as a whitelist or a blacklist. If true, the fields method is treated as a blacklist and returned fields will be disallowed. If false, the fields method is treated as a whitelist and returned fields will be allowed. diff --git a/doc_classes/LuaError.xml b/doc_classes/LuaError.xml index 49393557..4f133801 100644 --- a/doc_classes/LuaError.xml +++ b/doc_classes/LuaError.xml @@ -1,5 +1,5 @@ - + LuaAPI Error. diff --git a/doc_classes/LuaFunctionRef.xml b/doc_classes/LuaFunctionRef.xml index 66a1fcaa..c7e326ca 100644 --- a/doc_classes/LuaFunctionRef.xml +++ b/doc_classes/LuaFunctionRef.xml @@ -1,5 +1,5 @@ - + Lua Function Reference. @@ -11,7 +11,7 @@ - + Invoke the Lua function being referenced. diff --git a/doc_classes/LuaObjectMetatable.xml b/doc_classes/LuaObjectMetatable.xml index 29fd1def..b88c6c53 100644 --- a/doc_classes/LuaObjectMetatable.xml +++ b/doc_classes/LuaObjectMetatable.xml @@ -1,10 +1,11 @@ - + Represents a Lua Object Metatable. This interface class allows for the definition of lua metamethods to be used for an objects metatable. Objects can define a [code]lua_metatable[/code] property that returns a LuaObjectMetatable. This metatable will be used for the object when it is passed to Lua. If one does not exists the luaAPI.object_metatable will be used instead. + @@ -14,7 +15,7 @@ - The addition (+) operation. If any operand for an addition is not a number, Lua will try to call a metamethod. It starts by checking the first operand (even if it is a number); if that operand does not define a metamethod for __add, then Lua will check the second operand. If Lua can find a metamethod, it calls the metamethod with the two operands as arguments, and the result of the call (adjusted to one value) is the result of the operation. Otherwise, if no metamethod is found, Lua raises an error. + The addition (+) operation. If any operand for an addition is not a number, Lua will try to call a metamethod. It starts by checking the first operand (even if it is a number); if that operand does not define a metamethod for __add, then Lua will check the second operand. If Lua can find a metamethod, it calls the metamethod with the two operands as arguments, and the result of the call (adjusted to one value) is the result of the operation. Otherwise, if no metamethod is found, Lua raises an error. @@ -23,7 +24,7 @@ - The bitwise AND (&) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither an integer nor a float coercible to an integer + The bitwise AND (&) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither an integer nor a float coercible to an integer @@ -31,7 +32,7 @@ - The bitwise NOT (unary ~) operation. Behavior similar to the bitwise AND operation. + The bitwise NOT (unary ~) operation. Behavior similar to the bitwise AND operation. @@ -40,7 +41,7 @@ - The bitwise OR (|) operation. Behavior similar to the bitwise AND operation. + The bitwise OR (|) operation. Behavior similar to the bitwise AND operation. @@ -49,7 +50,7 @@ - The bitwise exclusive OR (binary ~) operation. Behavior similar to the bitwise AND operation. + The bitwise exclusive OR (binary ~) operation. Behavior similar to the bitwise AND operation. @@ -58,7 +59,7 @@ - The call operation. Used when the object is called as a function. + The call operation. Used when the object is called as a function. @@ -67,7 +68,7 @@ - The concatenation (..) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither a string nor a number (which is always coercible to a string). + The concatenation (..) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither a string nor a number (which is always coercible to a string). @@ -76,7 +77,7 @@ - The division (/) operation. Behavior similar to the addition operation. + The division (/) operation. Behavior similar to the addition operation. @@ -85,7 +86,7 @@ - The equal (==) operation. Behavior similar to the addition operation, except that Lua will try a metamethod only when the values being compared are either both tables or both full userdata and they are not primitively equal. The result of the call is always converted to a boolean. + The equal (==) operation. Behavior similar to the addition operation, except that Lua will try a metamethod only when the values being compared are either both tables or both full userdata and they are not primitively equal. The result of the call is always converted to a boolean. @@ -93,8 +94,8 @@ - https://www.lua.org/manual/5.4/manual.html#2.5.3 - + https://www.lua.org/manual/5.4/manual.html#2.5.3 + @@ -102,7 +103,7 @@ - The floor division (//) operation. Behavior similar to the addition operation. + The floor division (//) operation. Behavior similar to the addition operation. @@ -111,8 +112,8 @@ - The indexing access operation table[key]. This event happens when table is not a table or when key is not present in table. The metavalue is looked up in the metatable of table. - + The indexing access operation [code]table[key][/code]. This event happens when table is not a table or when key is not present in table. The metavalue is looked up in the metatable of table. + @@ -120,7 +121,7 @@ - The less equal (<=) operation. Behavior similar to the less than operation. + The length (#) operation. If the object is not a string, Lua will try its metamethod. If there is a metamethod, Lua calls it with the object as argument, and the result of the call (always adjusted to one value) is the result of the operation. If there is no metamethod but the object is a table, then Lua uses the table length operation. Otherwise, Lua raises an error. @@ -128,7 +129,6 @@ - The length (#) operation. If the object is not a string, Lua will try its metamethod. If there is a metamethod, Lua calls it with the object as argument, and the result of the call (always adjusted to one value) is the result of the operation. If there is no metamethod but the object is a table, then Lua uses the table length operation. Otherwise, Lua raises an error. @@ -137,7 +137,7 @@ - The less than (<) operation. Behavior similar to the addition operation, except that Lua will try a metamethod only when the values being compared are neither both numbers nor both strings. Moreover, the result of the call is always converted to a boolean. + The modulo (%) operation. Behavior similar to the addition operation. @@ -146,7 +146,6 @@ - The modulo (%) operation. Behavior similar to the addition operation. @@ -155,7 +154,7 @@ - The multiplication (*) operation. Behavior similar to the addition operation. + The multiplication (*) operation. Behavior similar to the addition operation. @@ -165,11 +164,11 @@ - The indexing assignment table[key] = value. Like the index event, this event happens when table is not a table or when key is not present in table. The metavalue is looked up in the metatable of table. + The indexing assignment [code]table[key] = value[/code]. Like the index event, this event happens when table is not a table or when key is not present in table. The metavalue is looked up in the metatable of table. Like with indexing, the metavalue for this event can be either a function, a table, or any value with an __newindex metavalue. If it is a function, it is called with table, key, and value as arguments. Otherwise, Lua repeats the indexing assignment over this metavalue with the same key and value. This assignment is regular, not raw, and therefore can trigger another __newindex metavalue. - Whenever a __newindex metavalue is invoked, Lua does not perform the primitive assignment. If needed, the metamethod itself can call rawset to do the assignment. + Whenever a __newindex metavalue is invoked, Lua does not perform the primitive assignment. If needed, the metamethod itself can call rawset to do the assignment. @@ -178,7 +177,7 @@ - The exponentiation (^) operation. Behavior similar to the addition operation. + The exponentiation (^) operation. Behavior similar to the addition operation. @@ -187,7 +186,7 @@ - The bitwise left shift (<<) operation. Behavior similar to the bitwise AND operation. + The bitwise right shift (>>) operation. Behavior similar to the bitwise AND operation. @@ -196,7 +195,6 @@ - The bitwise right shift (>>) operation. Behavior similar to the bitwise AND operation. @@ -205,7 +203,7 @@ - The subtraction (-) operation. Behavior similar to the addition operation. + The subtraction (-) operation. Behavior similar to the addition operation. @@ -213,7 +211,7 @@ - The tostring operation. Used when tostring is called on the object. + The tostring operation. Used when tostring is called on the object. @@ -221,14 +219,8 @@ - The negation (unary -) operation. Behavior similar to the addition operation. + The negation (unary -) operation. Behavior similar to the addition operation. - - - - - - diff --git a/doc_classes/LuaTuple.xml b/doc_classes/LuaTuple.xml index fb7474f4..8c2809b8 100644 --- a/doc_classes/LuaTuple.xml +++ b/doc_classes/LuaTuple.xml @@ -1,5 +1,5 @@ - + A Lua Tuple. @@ -9,39 +9,24 @@ - - - - - Create a LuaTuple from an array. - - - - - - - Push Variant to back of tuple. - - - + - - Push Variant to front of tuple. + Clear tuple. - - - - + + + - Set value at index. + Create a LuaTuple from an array. - - + + + - Clear tuple. + Get value at index. @@ -62,11 +47,31 @@ Pop Variant from front of tuple. - - - + + + + + Push Variant to back of tuple. + + + + + + + Push Variant to front of tuple. + + + + + + + + Set value at index. + + + + - Get value at index. From cadbb39df39cb19aa82202e8c09cccb9929e2821 Mon Sep 17 00:00:00 2001 From: beicause <1494181792@qq.com> Date: Mon, 3 Jun 2024 19:17:03 +0800 Subject: [PATCH 3/4] luajit: support android and parallel compiling --- external/build_luajit.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/external/build_luajit.py b/external/build_luajit.py index 9e1e4599..09048434 100644 --- a/external/build_luajit.py +++ b/external/build_luajit.py @@ -15,6 +15,7 @@ def run(cmd): sys.exit(code) def build_luajit(env, extension=False): + cpu_count=os.cpu_count() if extension or not env.msvc: os.chdir("luaJIT") @@ -25,41 +26,48 @@ def build_luajit(env, extension=False): if (host_arch != env['arch']): if (host_arch == 'x86_64' and env['arch'] == 'x86_32'): host_cc = env['luaapi_host_cc'] + ' -m32' - run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" TARGET_SYS=Windows' % (host_cc, env['CC'].replace("-gcc", "-").replace("-clang", "-"))) + run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" TARGET_SYS=Windows -j%d' % (host_cc, env['CC'].replace("-gcc", "-").replace("-clang", "-"), cpu_count)) else: print("ERROR: Unsupported cross compile!") sys.exit(-1) else: - run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" TARGET_SYS=Windows' % (env['luaapi_host_cc'], env['CC'].replace("-gcc", "-").replace("-clang", "-"))) + run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" TARGET_SYS=Windows -j%d' % (env['luaapi_host_cc'], env['CC'].replace("-gcc", "-").replace("-clang", "-"), cpu_count)) elif env['platform']=='macos': run("make clean MACOSX_DEPLOYMENT_TARGET=10.12") arch = env['arch'] if arch == "universal": - run('make CC="%s" TARGET_FLAGS="-arch x86_64" MACOSX_DEPLOYMENT_TARGET=10.12' % (env['CC'])) + run('make CC="%s" TARGET_FLAGS="-arch x86_64" MACOSX_DEPLOYMENT_TARGET=10.12 -j%d' % (env['CC'], cpu_count)) run('mv src/libluajit.a src/libluajit64.a') run('make clean MACOSX_DEPLOYMENT_TARGET=10.12') - run('make CC="%s" TARGET_FLAGS="-arch arm64" MACOSX_DEPLOYMENT_TARGET=10.12' % (env['CC'])) + run('make CC="%s" TARGET_FLAGS="-arch arm64" MACOSX_DEPLOYMENT_TARGET=10.12 -j%d' % (env['CC'], cpu_count)) run('lipo -create src/libluajit.a src/libluajit64.a -output src/libluajit.a') run('rm src/libluajit64.a') else: - run('make CC="%s" TARGET_FLAGS="-arch %s" MACOSX_DEPLOYMENT_TARGET=10.12' % (env['CC'], arch)) + run('make CC="%s" TARGET_FLAGS="-arch %s" MACOSX_DEPLOYMENT_TARGET=10.12 -j%d' % (env['CC'], arch, cpu_count)) elif env['platform']=='linuxbsd' or env['platform']=='linux': host_arch = platform.machine() run("make clean") if (host_arch != env['arch']): if (host_arch == 'x86_64' and env['arch'] == 'x86_32'): host_cc = env['luaapi_host_cc'] + ' -m32' - run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static"' % (host_cc, env['CC'].replace("-gcc", "-").replace("-clang", "-"))) + run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" -j%d' % (host_cc, env['CC'].replace("-gcc", "-").replace("-clang", "-"), cpu_count)) else: print("ERROR: Unsupported cross compile!") sys.exit(-1) else: - run('make CC="%s" BUILDMODE="static"' % env['CC']) - + run('make CC="%s" BUILDMODE="static" -j%d' % (env['CC'], cpu_count)) + elif env['platform']=='android' and env['arch']=="arm64": + run("make clean") + # Android/ARM64, aarch64, Android 5.0+ (L) + NDKDIR=env["ANDROID_NDK_ROOT"] + NDKBIN=f"{NDKDIR}/toolchains/llvm/prebuilt/linux-x86_64/bin" + NDKCC=env["CC"] + r=f"""make CC={NDKCC} TARGET_LD={NDKCC} TARGET_STRIP={NDKBIN}/llvm-strip BUILDMODE="static" -j{cpu_count}""" + run(r) else: print("ERROR: Unsupported platform '%s'." % env['platform']) sys.exit(-1) From f11ad0c6a1fb81ee5957b6a4f4058e9fd9bdcfa3 Mon Sep 17 00:00:00 2001 From: beicause <1494181792@qq.com> Date: Mon, 3 Jun 2024 19:17:23 +0800 Subject: [PATCH 4/4] Enable luajit by default --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 4bcd08c0..8db1c0cc 100644 --- a/config.py +++ b/config.py @@ -14,7 +14,7 @@ def configure(env): "LuaJIT builds some tools to assist with the rest of the build. You can set the host CC to be used here in the case of cross compilation.", "gcc", ("gcc", "clang"))) env_vars.Add(EnumVariable("luaapi_luaver", - "Build the LuaAPI module with the following lua VM", "5.4", ("5.4", "5.1", "jit"))) + "Build the LuaAPI module with the following lua VM", "jit", ("5.4", "5.1", "jit"))) env_vars.Update(env) Help(env_vars.GenerateHelpText(env))