aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-14 19:28:13 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-14 19:28:13 +0300
commitbf7deae888904a7f9c35024217fe356c44cf000e (patch)
tree6abe73637c91ecfd8306af26b46a734886a6392b
parent572f059ddc5c80e036956ad157fc4ea3175ce349 (diff)
downloadluarocks-bf7deae888904a7f9c35024217fe356c44cf000e.tar.gz
luarocks-bf7deae888904a7f9c35024217fe356c44cf000e.tar.bz2
luarocks-bf7deae888904a7f9c35024217fe356c44cf000e.zip
Build and Variables
-rw-r--r--src/luarocks/build.tl8
-rw-r--r--src/luarocks/build/builtin.tl13
-rw-r--r--src/luarocks/core/cfg.d.tl3
-rw-r--r--src/luarocks/core/types/build.d.tl16
-rw-r--r--src/luarocks/core/types/installs.d.tl15
-rw-r--r--src/luarocks/core/types/rockspec.tl56
-rw-r--r--src/luarocks/deps.tl9
-rw-r--r--src/luarocks/rockspecs.tl5
8 files changed, 58 insertions, 67 deletions
diff --git a/src/luarocks/build.tl b/src/luarocks/build.tl
index ccb894a4..5494a84d 100644
--- a/src/luarocks/build.tl
+++ b/src/luarocks/build.tl
@@ -31,8 +31,10 @@ local deplocks = require("luarocks.deplocks")
31 31
32local type r = require("luarocks.core.types.rockspec") 32local type r = require("luarocks.core.types.rockspec")
33local type Rockspec = r.Rockspec 33local type Rockspec = r.Rockspec
34local type Installs = r.Installs 34
35local type Install = r.Install 35local type i = require("luarocks.core.types.installs")
36local type Installs = i.Installs
37local type Install = i.Install
36 38
37local type t = require("luarocks.core.types.tree") 39local type t = require("luarocks.core.types.tree")
38local type Tree = t.Tree 40local type Tree = t.Tree
@@ -95,7 +97,7 @@ end
95local function check_macosx_deployment_target(rockspec: Rockspec): boolean, string 97local function check_macosx_deployment_target(rockspec: Rockspec): boolean, string
96 local target = rockspec.build.macosx_deployment_target 98 local target = rockspec.build.macosx_deployment_target
97 local function patch_variable(var: string) 99 local function patch_variable(var: string)
98 local rockspec_variables = rockspec.variables as {string: string} 100 local rockspec_variables = rockspec.variables
99 if rockspec_variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then 101 if rockspec_variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then
100 rockspec_variables[var] = (rockspec_variables[var]):gsub("MACOSX_DEPLOYMENT_TARGET=[^ ]*", "MACOSX_DEPLOYMENT_TARGET="..target) 102 rockspec_variables[var] = (rockspec_variables[var]):gsub("MACOSX_DEPLOYMENT_TARGET=[^ ]*", "MACOSX_DEPLOYMENT_TARGET="..target)
101 else 103 else
diff --git a/src/luarocks/build/builtin.tl b/src/luarocks/build/builtin.tl
index c778c2bb..e26ca5a4 100644
--- a/src/luarocks/build/builtin.tl
+++ b/src/luarocks/build/builtin.tl
@@ -6,8 +6,9 @@ end
6 6
7local type r = require("luarocks.core.types.rockspec") 7local type r = require("luarocks.core.types.rockspec")
8local type Rockspec = r.Rockspec 8local type Rockspec = r.Rockspec
9local type Variables = r.Variables 9
10local type Installs = r.Installs 10local type i = require("luarocks.core.types.installs")
11local type Installs = i.Installs
11 12
12-- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, 13-- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand,
13-- so that pure-Lua rocks don't need to have development headers 14-- so that pure-Lua rocks don't need to have development headers
@@ -23,7 +24,7 @@ local cfg = require("luarocks.core.cfg")
23local dir = require("luarocks.dir") 24local dir = require("luarocks.dir")
24local deps = require("luarocks.deps") 25local deps = require("luarocks.deps")
25 26
26local function autoextract_libs(external_dependencies: {string: {string: string}}, variables: Variables): {string}, {string}, {string} 27local function autoextract_libs(external_dependencies: {string: {string: string}}, variables: {string: string}): {string}, {string}, {string}
27 if not external_dependencies then 28 if not external_dependencies then
28 return nil, nil, nil 29 return nil, nil, nil
29 end 30 end
@@ -33,8 +34,8 @@ local function autoextract_libs(external_dependencies: {string: {string: string}
33 for name, data in pairs(external_dependencies) do 34 for name, data in pairs(external_dependencies) do
34 if data.library then 35 if data.library then
35 table.insert(libs, data.library) 36 table.insert(libs, data.library)
36 table.insert(incdirs, (variables as {string: string})[name .. "_INCDIR"]) 37 table.insert(incdirs, variables[name .. "_INCDIR"])
37 table.insert(libdirs, (variables as {string: string})[name .. "_LIBDIR"]) 38 table.insert(libdirs, variables[name .. "_LIBDIR"])
38 end 39 end
39 end 40 end
40 return libs, incdirs, libdirs 41 return libs, incdirs, libdirs
@@ -134,7 +135,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean)
134 local compile_object, compile_library, compile_static_library 135 local compile_object, compile_library, compile_static_library
135 136
136 local build = rockspec.build 137 local build = rockspec.build
137 local variables = rockspec.variables as {string: string} 138 local variables = rockspec.variables
138 local checked_lua_h = false 139 local checked_lua_h = false
139 140
140 for _, var in ipairs{ "CC", "CFLAGS", "LDFLAGS" } do 141 for _, var in ipairs{ "CC", "CFLAGS", "LDFLAGS" } do
diff --git a/src/luarocks/core/cfg.d.tl b/src/luarocks/core/cfg.d.tl
index 82b7c502..a342fe35 100644
--- a/src/luarocks/core/cfg.d.tl
+++ b/src/luarocks/core/cfg.d.tl
@@ -1,6 +1,5 @@
1local type r = require("luarocks.core.types.rockspec") 1local type r = require("luarocks.core.types.rockspec")
2local type Rockspec = r.Rockspec 2local type Rockspec = r.Rockspec
3local type Variables = r.Variables
4 3
5local type t = require("luarocks.core.types.tree") 4local type t = require("luarocks.core.types.tree")
6local type Tree = t.Tree 5local type Tree = t.Tree
@@ -32,7 +31,7 @@ local record cfg
32 rocks_provided: {string: string} --? right type? infered from src/luarocks/util 31 rocks_provided: {string: string} --? right type? infered from src/luarocks/util
33 end 32 end
34 33
35 variables: Variables 34 variables: {string: string}
36 rocks_provided: {Rockspec} 35 rocks_provided: {Rockspec}
37 -- persist 36 -- persist
38 home: string 37 home: string
diff --git a/src/luarocks/core/types/build.d.tl b/src/luarocks/core/types/build.d.tl
new file mode 100644
index 00000000..82d3dba9
--- /dev/null
+++ b/src/luarocks/core/types/build.d.tl
@@ -0,0 +1,16 @@
1local type i = require("luarocks.core.types.installs")
2local type Installs = i.Installs
3
4local record build
5 record Build
6 type: string
7 modules: {string: {string: string | {string}}}
8 copy_directories: string
9 install: Installs
10 extra_files: {string : string}
11 patches: {string : string}
12 macosx_deployment_target: string
13 end
14end
15
16return build \ No newline at end of file
diff --git a/src/luarocks/core/types/installs.d.tl b/src/luarocks/core/types/installs.d.tl
new file mode 100644
index 00000000..9e919233
--- /dev/null
+++ b/src/luarocks/core/types/installs.d.tl
@@ -0,0 +1,15 @@
1local record installs
2 record Install
3 name: string
4 is_module_path: boolean
5 perms: string
6 end
7
8 record Installs
9 lua: Install
10 lib: Install
11 conf: Install
12 bin: Install
13 end
14end
15return installs \ No newline at end of file
diff --git a/src/luarocks/core/types/rockspec.tl b/src/luarocks/core/types/rockspec.tl
index 6cd708cf..ca12bf94 100644
--- a/src/luarocks/core/types/rockspec.tl
+++ b/src/luarocks/core/types/rockspec.tl
@@ -1,6 +1,12 @@
1local type q = require("luarocks.core.types.query") 1local type q = require("luarocks.core.types.query")
2local type Query = q.Query 2local type Query = q.Query
3 3
4local type b = require("luarocks.core.types.build")
5local type Build = b.Build
6
7local type i = require("luarocks.core.types.installs")
8local type Installs = i.Installs
9
4local record rockspec 10local record rockspec
5 record Description 11 record Description
6 summary: string 12 summary: string
@@ -12,31 +18,6 @@ local record rockspec
12 labels: any --! 18 labels: any --!
13 end 19 end
14 20
15 record Variables
16 HG: string
17 CVS: string
18 LUA: string
19 GPG: string
20 GIT: string
21 SVN: string
22 CURL: string
23 SSCM: string
24 PREFIX: string
25 LUADIR: string
26 LIBDIR: string
27 CONFDIR: string
28 BINDIR: string
29 DOCDIR: string
30 CURLNOCERTFLAG: string
31 LUA_INCDIR_OK: string
32 LUA_INCDIR: string
33 LUA_DIR: string
34 LUA_LIBDIR_OK: string
35 LUA_LIBDIR: string
36 LUA_LIBDIR_FILE: string
37 LUALIB: string
38 end
39
40 record Source 21 record Source
41 url: string 22 url: string
42 module: string 23 module: string
@@ -60,29 +41,6 @@ local record rockspec
60 busted_executable: string 41 busted_executable: string
61 flags: {string} 42 flags: {string}
62 end 43 end
63
64 record Install
65 name: string
66 is_module_path: boolean
67 perms: string
68 end
69
70 record Installs
71 lua: Install
72 lib: Install
73 conf: Install
74 bin: Install
75 end
76
77 record Build
78 type: string
79 modules: {string: {string: string | {string}}}
80 copy_directories: string
81 install: Installs
82 extra_files: {string : string}
83 patches: {string : string}
84 macosx_deployment_target: string
85 end
86 44
87 record Dependencies 45 record Dependencies
88 {string} 46 {string}
@@ -114,7 +72,7 @@ local record rockspec
114 test_dependencies: Dependencies 72 test_dependencies: Dependencies
115 supported_platforms: {string} 73 supported_platforms: {string}
116 external_dependencies: {string: {string: string}} 74 external_dependencies: {string: {string: string}}
117 variables: Variables 75 variables: {string: string}
118 hooks: Hooks 76 hooks: Hooks
119 test: Test 77 test: Test
120 deploy: Deploy 78 deploy: Deploy
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl
index 97f051d1..1ce163c3 100644
--- a/src/luarocks/deps.tl
+++ b/src/luarocks/deps.tl
@@ -15,9 +15,10 @@ local deplocks = require("luarocks.deplocks")
15 15
16local type r = require("luarocks.core.types.rockspec") 16local type r = require("luarocks.core.types.rockspec")
17local type Rockspec = r.Rockspec 17local type Rockspec = r.Rockspec
18local type Build = r.Build
19local type Dependencies = r.Dependencies 18local type Dependencies = r.Dependencies
20local type Variables = r.Variables 19
20local type b = require("luarocks.core.types.build")
21local type Build = b.Build
21 22
22local type t = require("luarocks.core.types.tree") 23local type t = require("luarocks.core.types.tree")
23local type Tree = t.Tree 24local type Tree = t.Tree
@@ -759,7 +760,7 @@ local function find_lua_incdir(prefix: string, luaver: string, luajitver: string
759 return nil, mainerr 760 return nil, mainerr
760end 761end
761 762
762function deps.check_lua_incdir(vars: Variables): boolean | string, string, string 763function deps.check_lua_incdir(vars: {string: string}): boolean | string, string, string
763 if vars.LUA_INCDIR_OK == "ok" 764 if vars.LUA_INCDIR_OK == "ok"
764 then return true 765 then return true
765 end 766 end
@@ -787,7 +788,7 @@ function deps.check_lua_incdir(vars: Variables): boolean | string, string, strin
787 return nil, "Failed finding Lua headers; neither LUA_DIR or LUA_INCDIR are set. You may need to install them or configure LUA_INCDIR.", "dependency" 788 return nil, "Failed finding Lua headers; neither LUA_DIR or LUA_INCDIR are set. You may need to install them or configure LUA_INCDIR.", "dependency"
788end 789end
789 790
790function deps.check_lua_libdir(vars: Variables): boolean, string, string, {string : {string}} 791function deps.check_lua_libdir(vars: {string: string}): boolean, string, string, {string : {string}}
791 if vars.LUA_LIBDIR_OK == "ok" --! fix later 792 if vars.LUA_LIBDIR_OK == "ok" --! fix later
792 then return true 793 then return true
793 end 794 end
diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl
index e532c6c7..1c01e043 100644
--- a/src/luarocks/rockspecs.tl
+++ b/src/luarocks/rockspecs.tl
@@ -13,7 +13,6 @@ local vers = require("luarocks.core.vers")
13local rock = require("luarocks.core.types.rockspec") 13local rock = require("luarocks.core.types.rockspec")
14local type Dependencies = rock.Dependencies 14local type Dependencies = rock.Dependencies
15local type Rockspec = rock.Rockspec 15local type Rockspec = rock.Rockspec
16local type Variables = rock.Variables
17 16
18local type q = require("luarocks.core.types.query") 17local type q = require("luarocks.core.types.query")
19local type Query = q.Query 18local type Query = q.Query
@@ -84,7 +83,7 @@ end
84-- @param rockspec table: The rockspec table. 83-- @param rockspec table: The rockspec table.
85local function configure_paths(rockspec: Rockspec) 84local function configure_paths(rockspec: Rockspec)
86 local vars: {string: string} = {} 85 local vars: {string: string} = {}
87 for k,v in pairs(cfg.variables as {string: string}) do 86 for k,v in pairs(cfg.variables) do
88 vars[k] = v 87 vars[k] = v
89 end 88 end
90 local name, version = rockspec.name, rockspec.version 89 local name, version = rockspec.name, rockspec.version
@@ -94,7 +93,7 @@ local function configure_paths(rockspec: Rockspec)
94 vars.CONFDIR = path.conf_dir(name, version) 93 vars.CONFDIR = path.conf_dir(name, version)
95 vars.BINDIR = path.bin_dir(name, version) 94 vars.BINDIR = path.bin_dir(name, version)
96 vars.DOCDIR = path.doc_dir(name, version) 95 vars.DOCDIR = path.doc_dir(name, version)
97 rockspec.variables = vars as Variables 96 rockspec.variables = vars
98end 97end
99 98
100function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, globals?: {string: any}, quick?: boolean): Rockspec, string 99function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, globals?: {string: any}, quick?: boolean): Rockspec, string