From 7a9a1e91a5d3bbeb24bccf362e0e4c9d9ce673ef Mon Sep 17 00:00:00 2001 From: Iskra Vitaly Date: Sun, 10 Mar 2019 21:06:51 +0300 Subject: [PATCH 1/2] Support multiple includes in HDF5_INCLUDE_PATH --- luasrc/ffi.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/luasrc/ffi.lua b/luasrc/ffi.lua index 7659d28..9162338 100644 --- a/luasrc/ffi.lua +++ b/luasrc/ffi.lua @@ -36,12 +36,26 @@ end local function loadHDF5Header(includePath) -- Pass the header file through the C preprocessor once - local headerPath = path.join(includePath, "hdf5.h") + local headerPath = nil + -- Some hdf5 installations (e.g. brew's 1.10) are going to have several include dirs, search them all + local includes = {} + for dir in string.gmatch(includePath, '[^;]+') do + local headerCandidate = path.join(dir, "hdf5.h") + if path.isfile(headerCandidate) then + headerPath = headerCandidate + end + table.insert(includes, dir) + end hdf5._logger.debug("Processing header " .. headerPath) - if not path.isfile(headerPath) then + if headerPath == nil or not path.isfile(headerPath) then error("Error: unable to locate HDF5 header file at " .. headerPath) end - local process = io.popen("gcc -E " .. headerPath .. " -I " .. includePath) + local include_opts = "" + for _,dir in ipairs(includes) do + include_opts = include_opts .. " -I" .. dir + end + + local process = io.popen("gcc -E " .. headerPath .. include_opts) local contents = process:read("*all") local success, errorMsg, returnCode = process:close() if returnCode ~= 0 then From 80106283975ec05bcd3a4575170557bea3d38379 Mon Sep 17 00:00:00 2001 From: Iskra Vitaly Date: Sun, 10 Mar 2019 21:08:29 +0300 Subject: [PATCH 2/2] Remove _Nullable from gcc output --- luasrc/ffi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/ffi.lua b/luasrc/ffi.lua index 9162338..f7b9a9c 100644 --- a/luasrc/ffi.lua +++ b/luasrc/ffi.lua @@ -55,7 +55,7 @@ local function loadHDF5Header(includePath) include_opts = include_opts .. " -I" .. dir end - local process = io.popen("gcc -E " .. headerPath .. include_opts) + local process = io.popen("gcc -D '_Nullable=' -E " .. headerPath .. include_opts) local contents = process:read("*all") local success, errorMsg, returnCode = process:close() if returnCode ~= 0 then