diff options
| author | Renato Maia <maia.renato@gmail.com> | 2025-04-21 11:16:38 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2025-05-19 11:30:51 -0300 |
| commit | 4d7b546602b906f924ac91a01276cd3b2569ca9f (patch) | |
| tree | 6bf4b9927c543723d42c8777459e02e278d37896 | |
| parent | 9b4ab564387e925a830e24b35dee46621a842f39 (diff) | |
| download | luarocks-4d7b546602b906f924ac91a01276cd3b2569ca9f.tar.gz luarocks-4d7b546602b906f924ac91a01276cd3b2569ca9f.tar.bz2 luarocks-4d7b546602b906f924ac91a01276cd3b2569ca9f.zip | |
feat: add LUA_VERSION build variable for rockspecs
| -rw-r--r-- | docs/creating_a_makefile_that_plays_nice_with_luarocks.md | 1 | ||||
| -rw-r--r-- | spec/build_spec.lua | 46 | ||||
| -rw-r--r-- | src/luarocks/rockspecs.lua | 3 | ||||
| -rw-r--r-- | src/luarocks/rockspecs.tl | 3 | ||||
| -rw-r--r-- | src/luarocks/type/rockspec.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/type/rockspec.tl | 7 |
6 files changed, 62 insertions, 3 deletions
diff --git a/docs/creating_a_makefile_that_plays_nice_with_luarocks.md b/docs/creating_a_makefile_that_plays_nice_with_luarocks.md index 6d9ff2af..a6187659 100644 --- a/docs/creating_a_makefile_that_plays_nice_with_luarocks.md +++ b/docs/creating_a_makefile_that_plays_nice_with_luarocks.md | |||
| @@ -21,6 +21,7 @@ For building: | |||
| 21 | * `LUA_INCDIR` - where to find the Lua headers | 21 | * `LUA_INCDIR` - where to find the Lua headers |
| 22 | * `LUALIB` - the name of the Lua library. This is not available nor needed on all platforms. | 22 | * `LUALIB` - the name of the Lua library. This is not available nor needed on all platforms. |
| 23 | * `LUA` - the name of the Lua interpreter | 23 | * `LUA` - the name of the Lua interpreter |
| 24 | * `LUA_VERSION` - the version of Lua | ||
| 24 | 25 | ||
| 25 | For installing: | 26 | For installing: |
| 26 | 27 | ||
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 034c70d7..ad6f4d42 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
| @@ -373,6 +373,52 @@ describe("LuaRocks build #integration", function() | |||
| 373 | end) | 373 | end) |
| 374 | end) | 374 | end) |
| 375 | 375 | ||
| 376 | describe("rockspec format 3.1", function() | ||
| 377 | it("version of Lua is not provided for old format", function() | ||
| 378 | test_env.run_in_tmp(function(tmpdir) | ||
| 379 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", test_env.lua_version)) | ||
| 380 | write_file("uses_luaversion_variable-3.1-11.rockspec", [[ | ||
| 381 | package = "uses_luaversion_variable" | ||
| 382 | version = "3.1-11" | ||
| 383 | source = { | ||
| 384 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
| 385 | } | ||
| 386 | dependencies = { | ||
| 387 | "lua >= 5.1" | ||
| 388 | } | ||
| 389 | build = { | ||
| 390 | type = "command", | ||
| 391 | build_command = "$(LUA) verify_argument.lua $(LUA_VERSION)", | ||
| 392 | } | ||
| 393 | ]]) | ||
| 394 | assert.is_false(run.luarocks_bool("build uses_luaversion_variable-3.1-11.rockspec")) | ||
| 395 | end, finally) | ||
| 396 | end) | ||
| 397 | |||
| 398 | it("version of Lua is provided as variable", function() | ||
| 399 | test_env.run_in_tmp(function(tmpdir) | ||
| 400 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", test_env.lua_version)) | ||
| 401 | write_file("uses_luaversion_variable-3.1-11.rockspec", [[ | ||
| 402 | rockspec_format = "3.1" | ||
| 403 | package = "uses_luaversion_variable" | ||
| 404 | version = "3.1-11" | ||
| 405 | source = { | ||
| 406 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
| 407 | } | ||
| 408 | dependencies = { | ||
| 409 | "lua >= 5.1" | ||
| 410 | } | ||
| 411 | build = { | ||
| 412 | type = "command", | ||
| 413 | build_command = "$(LUA) verify_argument.lua $(LUA_VERSION)", | ||
| 414 | } | ||
| 415 | ]]) | ||
| 416 | assert.is_truthy(run.luarocks_bool("build uses_luaversion_variable-3.1-11.rockspec")) | ||
| 417 | assert.is.truthy(run.luarocks("show uses_luaversion_variable")) | ||
| 418 | end, finally) | ||
| 419 | end) | ||
| 420 | end) | ||
| 421 | |||
| 376 | describe("#mock external dependencies", function() | 422 | describe("#mock external dependencies", function() |
| 377 | lazy_setup(function() | 423 | lazy_setup(function() |
| 378 | test_env.setup_specs(nil, "mock") | 424 | test_env.setup_specs(nil, "mock") |
diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index 6a9a376c..8a1a528e 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua | |||
| @@ -83,6 +83,9 @@ local function configure_paths(rockspec) | |||
| 83 | vars.CONFDIR = path.conf_dir(name, version) | 83 | vars.CONFDIR = path.conf_dir(name, version) |
| 84 | vars.BINDIR = path.bin_dir(name, version) | 84 | vars.BINDIR = path.bin_dir(name, version) |
| 85 | vars.DOCDIR = path.doc_dir(name, version) | 85 | vars.DOCDIR = path.doc_dir(name, version) |
| 86 | if rockspec:format_is_at_least("3.1") then | ||
| 87 | vars.LUA_VERSION = cfg.lua_version | ||
| 88 | end | ||
| 86 | rockspec.variables = vars | 89 | rockspec.variables = vars |
| 87 | end | 90 | end |
| 88 | 91 | ||
diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl index a34c0dbf..9f12649c 100644 --- a/src/luarocks/rockspecs.tl +++ b/src/luarocks/rockspecs.tl | |||
| @@ -83,6 +83,9 @@ local function configure_paths(rockspec: Rockspec) | |||
| 83 | vars.CONFDIR = path.conf_dir(name, version) | 83 | vars.CONFDIR = path.conf_dir(name, version) |
| 84 | vars.BINDIR = path.bin_dir(name, version) | 84 | vars.BINDIR = path.bin_dir(name, version) |
| 85 | vars.DOCDIR = path.doc_dir(name, version) | 85 | vars.DOCDIR = path.doc_dir(name, version) |
| 86 | if rockspec:format_is_at_least("3.1") then | ||
| 87 | vars.LUA_VERSION = cfg.lua_version | ||
| 88 | end | ||
| 86 | rockspec.variables = vars | 89 | rockspec.variables = vars |
| 87 | end | 90 | end |
| 88 | 91 | ||
diff --git a/src/luarocks/type/rockspec.lua b/src/luarocks/type/rockspec.lua index cd4044f6..10b06690 100644 --- a/src/luarocks/type/rockspec.lua +++ b/src/luarocks/type/rockspec.lua | |||
| @@ -11,7 +11,7 @@ local type_check = require("luarocks.type_check") | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | type_rockspec.rockspec_format = "3.0" | 14 | type_rockspec.rockspec_format = "3.1" |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| @@ -174,6 +174,9 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
| 174 | }, | 174 | }, |
| 175 | }, | 175 | }, |
| 176 | }, | 176 | }, |
| 177 | |||
| 178 | ["3.1"] = {}, | ||
| 179 | |||
| 177 | }) | 180 | }) |
| 178 | 181 | ||
| 179 | 182 | ||
diff --git a/src/luarocks/type/rockspec.tl b/src/luarocks/type/rockspec.tl index 599c13ce..52ad7909 100644 --- a/src/luarocks/type/rockspec.tl +++ b/src/luarocks/type/rockspec.tl | |||
| @@ -11,7 +11,7 @@ local type_check = require("luarocks.type_check") | |||
| 11 | 11 | ||
| 12 | -- local type TableSchema = type_check.TableSchema | 12 | -- local type TableSchema = type_check.TableSchema |
| 13 | 13 | ||
| 14 | type_rockspec.rockspec_format = "3.0" | 14 | type_rockspec.rockspec_format = "3.1" |
| 15 | 15 | ||
| 16 | -- Syntax for type-checking tables: | 16 | -- Syntax for type-checking tables: |
| 17 | -- | 17 | -- |
| @@ -173,7 +173,10 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
| 173 | _more = true, | 173 | _more = true, |
| 174 | }, | 174 | }, |
| 175 | } | 175 | } |
| 176 | } | 176 | }, |
| 177 | |||
| 178 | ["3.1"] = {}, | ||
| 179 | |||
| 177 | }) | 180 | }) |
| 178 | 181 | ||
| 179 | -- type_rockspec.order = {"rockspec_format", "package", "version", | 182 | -- type_rockspec.order = {"rockspec_format", "package", "version", |
