aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-22 17:48:59 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-10-21 13:30:51 -0300
commite308cb2fb7a3f960e9289464c46264faec9e6edb (patch)
tree3a20b888d19c0fc20ff83eebf6d7e4b564ba176b
parent55450f45af0eb730a679aa2c016a5282c22882eb (diff)
downloadluarocks-e308cb2fb7a3f960e9289464c46264faec9e6edb.tar.gz
luarocks-e308cb2fb7a3f960e9289464c46264faec9e6edb.tar.bz2
luarocks-e308cb2fb7a3f960e9289464c46264faec9e6edb.zip
Teal: convert luarocks.build.make
-rw-r--r--src/luarocks/build/make.tl (renamed from src/luarocks/build/make.lua)39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.tl
index 4345ddff..512357f7 100644
--- a/src/luarocks/build/make.lua
+++ b/src/luarocks/build/make.tl
@@ -1,13 +1,28 @@
1 1
2--- Build back-end for using Makefile-based packages. 2local type Build = require("luarocks.core.types.build").Build
3local make = {}
4 3
5local unpack = unpack or table.unpack 4--- Build back-end for using Makefile-based packages.
5local record make
6 record MakeBuild
7 is Build where self.type == "make"
8
9 makefile: string
10 build_target: string
11 build_pass: boolean
12 install_target: string
13 install_pass: boolean
14 build_variables: {string: string}
15 install_variables: {string: string}
16 variables: {string: string}
17 end
18end
6 19
7local fs = require("luarocks.fs") 20local fs = require("luarocks.fs")
8local util = require("luarocks.util") 21local util = require("luarocks.util")
9local cfg = require("luarocks.core.cfg") 22local cfg = require("luarocks.core.cfg")
10 23
24local type Rockspec = require("luarocks.core.types.rockspec").Rockspec
25
11--- Call "make" with given target and variables 26--- Call "make" with given target and variables
12-- @param make_cmd string: the make command to be used (typically 27-- @param make_cmd string: the make command to be used (typically
13-- configured through variables.MAKE in the config files, or 28-- configured through variables.MAKE in the config files, or
@@ -18,17 +33,13 @@ local cfg = require("luarocks.core.cfg")
18-- @param variables table: A table containing string-string key-value 33-- @param variables table: A table containing string-string key-value
19-- pairs representing variable assignments to be passed to make. 34-- pairs representing variable assignments to be passed to make.
20-- @return boolean: false if any errors occurred, true otherwise. 35-- @return boolean: false if any errors occurred, true otherwise.
21local function make_pass(make_cmd, pass, target, variables) 36local function make_pass(make_cmd: string, pass: boolean, target: string, variables: {string: string}): boolean, string, string
22 assert(type(pass) == "boolean") 37 local assignments: {string} = {}
23 assert(type(target) == "string")
24 assert(type(variables) == "table")
25
26 local assignments = {}
27 for k,v in pairs(variables) do 38 for k,v in pairs(variables) do
28 table.insert(assignments, k.."="..v) 39 table.insert(assignments, k.."="..v)
29 end 40 end
30 if pass then 41 if pass then
31 return fs.execute(make_cmd.." "..target, unpack(assignments)) 42 return fs.execute(make_cmd.." "..target, table.unpack(assignments))
32 else 43 else
33 return true 44 return true
34 end 45 end
@@ -38,10 +49,9 @@ end
38-- @param rockspec table: the loaded rockspec. 49-- @param rockspec table: the loaded rockspec.
39-- @return boolean or (nil, string): true if no errors occurred, 50-- @return boolean or (nil, string): true if no errors occurred,
40-- nil and an error message otherwise. 51-- nil and an error message otherwise.
41function make.run(rockspec, not_install) 52function make.run(rockspec: Rockspec, not_install: boolean): boolean, string, string
42 assert(rockspec:type() == "rockspec")
43 53
44 local build = rockspec.build 54 local build = rockspec.build as make.MakeBuild
45 55
46 if build.build_pass == nil then build.build_pass = true end 56 if build.build_pass == nil then build.build_pass = true end
47 if build.install_pass == nil then build.install_pass = true end 57 if build.install_pass == nil then build.install_pass = true end
@@ -64,13 +74,12 @@ function make.run(rockspec, not_install)
64 end 74 end
65 75
66 util.warn_if_not_used(build.build_variables, { CFLAGS=true }, "variable %s was not passed in build_variables") 76 util.warn_if_not_used(build.build_variables, { CFLAGS=true }, "variable %s was not passed in build_variables")
67
68 util.variable_substitutions(build.build_variables, rockspec.variables) 77 util.variable_substitutions(build.build_variables, rockspec.variables)
69 util.variable_substitutions(build.install_variables, rockspec.variables) 78 util.variable_substitutions(build.install_variables, rockspec.variables)
70 79
71 local auto_variables = { "CC" } 80 local auto_variables = { "CC" }
72 81
73 for _, variable in pairs(auto_variables) do 82 for _, variable in ipairs(auto_variables) do
74 if not build.build_variables[variable] then 83 if not build.build_variables[variable] then
75 build.build_variables[variable] = rockspec.variables[variable] 84 build.build_variables[variable] = rockspec.variables[variable]
76 end 85 end