Skip to content

Commit

Permalink
Fix premake#1628 failing macOS os.findlib() test
Browse files Browse the repository at this point in the history
  • Loading branch information
starkos committed Oct 27, 2021
1 parent 6c9fda8 commit 324e40a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
23 changes: 19 additions & 4 deletions src/base/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,25 @@
return path
end

function os.findlib(libname, libdirs)
-- libname: library name with or without prefix and suffix
-- libdirs: (array or string): A set of additional search paths

---
-- Attempt to locate and return the path to a shared library.
--
-- This function does not work on macOS: _"New in macOS Big Sur 11.0.1, the system ships with
-- a built-in dynamic linker cache of all system-provided libraries. As part of this change,
-- copies of dynamic libraries are no longer present on the filesystem. Code that attempts to
-- check for dynamic library presence by looking for a file at a path or enumerating a directory
-- will fail."
-- https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
--
-- @param libname
-- The library name with or without prefix and suffix.
-- @param libdirs
-- An array of paths to be searched.
-- @returns
-- The full path to the library if found; `nil` otherwise.
---
function os.findlib(libname, libdirs)
local path = get_library_search_path()
local formats

Expand Down Expand Up @@ -458,7 +473,7 @@
--
-- @param cmd Command to execute
-- @param streams Standard stream(s) to output
-- Must be one of
-- Must be one of
-- - "both" (default)
-- - "output" Return standard output stream content only
-- - "error" Return standard error stream content only
Expand Down
11 changes: 7 additions & 4 deletions tests/base/test_os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
--

function suite.findlib_FindSystemLib()
if os.istarget("windows") then
if os.istarget("macosx") then
-- macOS no longer stores system libraries on filesystem; see
-- https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
elseif os.istarget("windows") then
test.istrue(os.findlib("user32"))
elseif os.istarget("haiku") then
test.istrue(os.findlib("root"))
Expand Down Expand Up @@ -184,7 +187,7 @@
end
end
end

-- Check outputof content
function suite.outputof_streams_output()
if (os.istarget("macosx")
Expand All @@ -198,12 +201,12 @@
test.isequal (oo, ob)
local s, e = string.find (oo, "test_os.lua")
test.istrue(s ~= nil)

local o, e = os.outputof ("ls " .. cwd .. "/base", "error")
test.istrue(o == nil or #o == 0)
end
end

--
-- os.translateCommand() tests
--
Expand Down

0 comments on commit 324e40a

Please sign in to comment.