From 23743dddc7619e728b47e6c765006d0da2a3aa16 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 15 Aug 2024 14:44:10 +0300 Subject: sanity check --- src/luarocks/build/builtin.lua | 4 +--- src/luarocks/build/builtin.tl | 4 +--- src/luarocks/build/cmake.tl | 21 +++++++++++++++------ src/luarocks/core/cfg.d.tl | 3 +++ src/luarocks/core/types/build.d.tl | 24 +++++++++++++++++++++++- 5 files changed, 43 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 478f45c1..76b50d9f 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -9,10 +9,8 @@ local builtin = {} -local Install = i.Install -local Build = b.Build @@ -240,7 +238,7 @@ function builtin.run(rockspec, no_install) add_flags(extras, "-I%s", incdirs) return execute(variables.CC .. " " .. variables.CFLAGS, "-I" .. variables.LUA_INCDIR, "-c", source, "-o", object, _tl_table_unpack(extras)) end - compile_library = function(library, objects, libraries, libdirs, name) + compile_library = function(library, objects, libraries, libdirs) local extras = { _tl_table_unpack(objects) } add_flags(extras, "-L%s", libdirs) if cfg.gcc_rpath then diff --git a/src/luarocks/build/builtin.tl b/src/luarocks/build/builtin.tl index b0857363..2ab688dc 100644 --- a/src/luarocks/build/builtin.tl +++ b/src/luarocks/build/builtin.tl @@ -9,10 +9,8 @@ local type Rockspec = r.Rockspec local type i = require("luarocks.core.types.installs") local type Installs = i.Installs -local type Install = i.Install local type b = require("luarocks.core.types.build") -local type Build = b.Build local type BuiltinBuild = b.BuiltinBuild local type Module = BuiltinBuild.Module @@ -240,7 +238,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, add_flags(extras, "-I%s", incdirs) return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, table.unpack(extras)) end - compile_library = function (library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string + compile_library = function (library: string, objects: {string}, libraries: {string}, libdirs: {string}): boolean, string, string local extras = { table.unpack(objects) } add_flags(extras, "-L%s", libdirs) if cfg.gcc_rpath then diff --git a/src/luarocks/build/cmake.tl b/src/luarocks/build/cmake.tl index b7a4786e..b0307b08 100644 --- a/src/luarocks/build/cmake.tl +++ b/src/luarocks/build/cmake.tl @@ -6,13 +6,21 @@ local fs = require("luarocks.fs") local util = require("luarocks.util") local cfg = require("luarocks.core.cfg") +local type r = require("luarocks.core.types.rockspec") +local type Rockspec = r.Rockspec + +local type i = require("luarocks.core.types.installs") +local type Installs = i.Installs + +local type b = require("luarocks.core.types.build") +local type CMakeBuild = b.CMakeBuild + --- Driver function for the "cmake" build back-end. -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors occurred, -- nil and an error message otherwise. -function cmake.run(rockspec, no_install) - assert(rockspec:type() == "rockspec") - local build = rockspec.build +function cmake.run(rockspec: Rockspec, no_install: boolean): boolean, string, string + local build = rockspec.build as CMakeBuild local variables = build.variables or {} -- Pass Env variables @@ -28,8 +36,9 @@ function cmake.run(rockspec, no_install) end -- If inline cmake is present create CMakeLists.txt from it. - if type(build.cmake) == "string" then - local cmake_handler = assert(io.open(fs.current_dir().."/CMakeLists.txt", "w")) + local build_cmake = build.cmake + if build_cmake is string then + local cmake_handler = assert((io.open(fs.current_dir().."/CMakeLists.txt", "w"))) cmake_handler:write(build.cmake) cmake_handler:close() end @@ -52,7 +61,7 @@ function cmake.run(rockspec, no_install) return nil, "Failed cmake." end - local do_build, do_install + local do_build, do_install: boolean, boolean if rockspec:format_is_at_least("3.0") then do_build = (build.build_pass == nil) and true or build.build_pass do_install = (build.install_pass == nil) and true or build.install_pass diff --git a/src/luarocks/core/cfg.d.tl b/src/luarocks/core/cfg.d.tl index f87cc1e9..1e03445a 100644 --- a/src/luarocks/core/cfg.d.tl +++ b/src/luarocks/core/cfg.d.tl @@ -83,6 +83,9 @@ local record cfg gcc_rpath: boolean link_lua_explicitly: boolean obj_extension: string + -- cmake + cmake_generator: string + target_cpu: string end return cfg \ No newline at end of file diff --git a/src/luarocks/core/types/build.d.tl b/src/luarocks/core/types/build.d.tl index 98707c0b..061741bb 100644 --- a/src/luarocks/core/types/build.d.tl +++ b/src/luarocks/core/types/build.d.tl @@ -28,10 +28,32 @@ local record build modules: {string: (string | Module)} end + + record CMakeBuild + is Build where self.type == "cmake" + + cmake: string + variables: {string: string} + end + + record CommandBuild + is Build where self.type == "command" + + build_command: string + install_command: string + end + record MakeBuild is Build where self.type == "make" - makefile: string --! + makefile: string + build_target: string + build_pass: boolean + install_target: string + install_pass: boolean + build_variables: {string} --! + install_variables: {string} + variables: {string: string} end end -- cgit v1.2.3-55-g6feb