diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-17 19:49:17 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-22 17:10:21 -0300 |
| commit | c52a5c57ccffa5a0929593cd94fa5f87e795efd7 (patch) | |
| tree | f476f43eddad0e04e24631b9d7fd638b6650103a /src | |
| parent | d1a32ba6b1fd5a829aa551aeb37a0c558b09660f (diff) | |
| download | luarocks-c52a5c57ccffa5a0929593cd94fa5f87e795efd7.tar.gz luarocks-c52a5c57ccffa5a0929593cd94fa5f87e795efd7.tar.bz2 luarocks-c52a5c57ccffa5a0929593cd94fa5f87e795efd7.zip | |
Check version of lua.h to ensure it matches
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/config.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index 5e92634a..2573876d 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
| @@ -240,8 +240,8 @@ end | |||
| 240 | --- Driver function for "config" command. | 240 | --- Driver function for "config" command. |
| 241 | -- @return boolean: True if succeeded, nil on errors. | 241 | -- @return boolean: True if succeeded, nil on errors. |
| 242 | function config_cmd.command(args) | 242 | function config_cmd.command(args) |
| 243 | deps.check_lua_incdir(cfg.variables) | 243 | deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) |
| 244 | deps.check_lua_libdir(cfg.variables) | 244 | deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) |
| 245 | 245 | ||
| 246 | -- deprecated flags | 246 | -- deprecated flags |
| 247 | if args.lua_incdir then | 247 | if args.lua_incdir then |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index d935a5c8..e1ecacee 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -649,13 +649,20 @@ function deps.scan_deps(results, manifest, name, version, deps_mode) | |||
| 649 | end | 649 | end |
| 650 | end | 650 | end |
| 651 | 651 | ||
| 652 | local function lua_h_exists(d) | 652 | local function lua_h_exists(d, luaver) |
| 653 | local n = tonumber(luaver) | ||
| 654 | local major = math.floor(n) | ||
| 655 | local minor = (n - major) * 10 | ||
| 656 | local luanum = math.floor(major * 100 + minor) | ||
| 657 | |||
| 653 | local lua_h = dir.path(d, "lua.h") | 658 | local lua_h = dir.path(d, "lua.h") |
| 654 | local fd = io.open(lua_h) | 659 | local fd = io.open(lua_h) |
| 655 | if fd then | 660 | if fd then |
| 656 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | 661 | local data = fd:read("*a") |
| 657 | fd:close() | 662 | fd:close() |
| 658 | return d | 663 | if data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then |
| 664 | return d | ||
| 665 | end | ||
| 659 | end | 666 | end |
| 660 | end | 667 | end |
| 661 | 668 | ||
| @@ -672,7 +679,7 @@ local function find_lua_incdir(prefix, luaver, luajitver) | |||
| 672 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), | 679 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), |
| 673 | } | 680 | } |
| 674 | for _, d in ipairs(incdirs) do | 681 | for _, d in ipairs(incdirs) do |
| 675 | if lua_h_exists(d) then | 682 | if lua_h_exists(d, luaver) then |
| 676 | return d | 683 | return d |
| 677 | end | 684 | end |
| 678 | end | 685 | end |
| @@ -685,7 +692,7 @@ function deps.check_lua_incdir(vars) | |||
| 685 | local ljv = util.get_luajit_version() | 692 | local ljv = util.get_luajit_version() |
| 686 | 693 | ||
| 687 | if vars.LUA_INCDIR then | 694 | if vars.LUA_INCDIR then |
| 688 | return lua_h_exists(vars.LUA_INCDIR) | 695 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) |
| 689 | end | 696 | end |
| 690 | 697 | ||
| 691 | if vars.LUA_DIR then | 698 | if vars.LUA_DIR then |
| @@ -713,7 +720,9 @@ function deps.check_lua_libdir(vars) | |||
| 713 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) | 720 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) |
| 714 | end | 721 | end |
| 715 | local cache = {} | 722 | local cache = {} |
| 723 | local save_LUA_INCDIR = vars.LUA_INCDIR | ||
| 716 | local ok = check_external_dependency("LUA", { library = libnames }, vars, "build", cache) | 724 | local ok = check_external_dependency("LUA", { library = libnames }, vars, "build", cache) |
| 725 | vars.LUA_INCDIR = save_LUA_INCDIR | ||
| 717 | if ok then | 726 | if ok then |
| 718 | vars.LUALIB = vars.LUA_LIBDIR_FILE | 727 | vars.LUALIB = vars.LUA_LIBDIR_FILE |
| 719 | return true | 728 | return true |
