From 9d56fce973f186c09587077f8650f0b24592e8de Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:48:59 -0300 Subject: Teal: convert luarocks.build.command --- src/luarocks/build/command.lua | 41 --------------------------------- src/luarocks/build/command.tl | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 41 deletions(-) delete mode 100644 src/luarocks/build/command.lua create mode 100644 src/luarocks/build/command.tl diff --git a/src/luarocks/build/command.lua b/src/luarocks/build/command.lua deleted file mode 100644 index b0c4aa79..00000000 --- a/src/luarocks/build/command.lua +++ /dev/null @@ -1,41 +0,0 @@ - ---- Build back-end for raw listing of commands in rockspec files. -local command = {} - -local fs = require("luarocks.fs") -local util = require("luarocks.util") -local cfg = require("luarocks.core.cfg") - ---- Driver function for the "command" 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 command.run(rockspec, not_install) - assert(rockspec:type() == "rockspec") - - local build = rockspec.build - - util.variable_substitutions(build, rockspec.variables) - - local env = { - CC = cfg.variables.CC, - --LD = cfg.variables.LD, - --CFLAGS = cfg.variables.CFLAGS, - } - - if build.build_command then - util.printout(build.build_command) - if not fs.execute_env(env, build.build_command) then - return nil, "Failed building." - end - end - if build.install_command and not not_install then - util.printout(build.install_command) - if not fs.execute_env(env, build.install_command) then - return nil, "Failed installing." - end - end - return true -end - -return command diff --git a/src/luarocks/build/command.tl b/src/luarocks/build/command.tl new file mode 100644 index 00000000..10f8bb94 --- /dev/null +++ b/src/luarocks/build/command.tl @@ -0,0 +1,51 @@ + +local type Build = require("luarocks.core.types.build").Build + +--- Build back-end for raw listing of commands in rockspec files. +local record command + record CommandBuild + is Build where self.type == "command" + + build_command: string + install_command: string + end +end + +local fs = require("luarocks.fs") +local util = require("luarocks.util") +local cfg = require("luarocks.core.cfg") + +local type Rockspec = require("luarocks.core.types.rockspec").Rockspec + +--- Driver function for the "command" 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 command.run(rockspec: Rockspec, not_install: boolean): boolean, string, string + + local build = rockspec.build as command.CommandBuild + + util.variable_substitutions(build as {string: string}, rockspec.variables) + + local env: {string: string} = { + CC = cfg.variables.CC, + --LD = cfg.variables.LD, + --CFLAGS = cfg.variables.CFLAGS, + } + + if build.build_command then + util.printout(build.build_command) + if not fs.execute_env(env, build.build_command) then + return nil, "Failed building." + end + end + if build.install_command and not not_install then + util.printout(build.install_command) + if not fs.execute_env(env, build.install_command) then + return nil, "Failed installing." + end + end + return true +end + +return command -- cgit v1.2.3-55-g6feb