diff --git a/build.zig b/build.zig index 424c00c091..b999631951 100644 --- a/build.zig +++ b/build.zig @@ -408,6 +408,7 @@ pub fn test_config(b: *std.Build, gen_dir: LazyPath) ![]u8 { \\local M = {{}} \\ \\M.include_paths = {{}} + \\M.apple_sysroot = "" \\M.translations_enabled = "$ENABLE_TRANSLATIONS" == "ON" \\M.is_asan = "$ENABLE_ASAN_UBSAN" == "ON" \\M.is_zig_build = true diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index f6112a3c2a..e59be46314 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -481,11 +481,13 @@ foreach(target ${targets}) message(STATUS "${target} props '${prop}'") foreach(gen_include ${prop}) list(APPEND gen_cflags "-I${gen_include}") + list(APPEND TEST_INCLUDE_DIRS "${gen_include}") endforeach() endif() endforeach() list(REMOVE_DUPLICATES gen_cflags) +list(REMOVE_DUPLICATES TEST_INCLUDE_DIRS) if(APPLE AND CMAKE_OSX_SYSROOT) list(APPEND gen_cflags "-isysroot" "${CMAKE_OSX_SYSROOT}") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8db05ac839..1141e6aded 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(functional/fixtures) # compile test programs -get_target_property(TEST_INCLUDE_DIRS main_lib INTERFACE_INCLUDE_DIRECTORIES) +get_directory_property(TEST_INCLUDE_DIRS DIRECTORY ${PROJECT_SOURCE_DIR}/src/nvim DEFINITION TEST_INCLUDE_DIRS) set(TEST_OPTIONS -D BUILD_DIR=${CMAKE_BINARY_DIR} diff --git a/test/cmakeconfig/paths.lua.in b/test/cmakeconfig/paths.lua.in index 56d3257bcf..2984200952 100644 --- a/test/cmakeconfig/paths.lua.in +++ b/test/cmakeconfig/paths.lua.in @@ -4,6 +4,7 @@ M.include_paths = {} for p in ("${TEST_INCLUDE_DIRS}" .. ";"):gmatch("[^;]+") do table.insert(M.include_paths, p) end +M.apple_sysroot = "${CMAKE_OSX_SYSROOT}" M.translations_enabled = "${ENABLE_TRANSLATIONS}" == "ON" M.is_asan = "${ENABLE_ASAN_UBSAN}" == "ON" diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua index 8d481df0d0..6114f43ad7 100644 --- a/test/unit/preprocess.lua +++ b/test/unit/preprocess.lua @@ -146,13 +146,20 @@ end --- @param ... string function Gcc:add_to_include_path(...) + local ef = self.preprocessor_extra_flags for i = 1, select('#', ...) do local path = select(i, ...) - local ef = self.preprocessor_extra_flags ef[#ef + 1] = '-I' .. path end end +function Gcc:add_apple_sysroot(sysroot) + local ef = self.preprocessor_extra_flags + + table.insert(ef, '-isysroot') + table.insert(ef, sysroot) +end + -- returns a list of the headers files upon which this file relies --- @param hdr string --- @return string[]? @@ -278,4 +285,9 @@ function M.add_to_include_path(...) return cc:add_to_include_path(...) end +--- @param ... string +function M.add_apple_sysroot(...) + return cc:add_apple_sysroot(...) +end + return M diff --git a/test/unit/testutil.lua b/test/unit/testutil.lua index a38e602ac8..3c40f7062e 100644 --- a/test/unit/testutil.lua +++ b/test/unit/testutil.lua @@ -19,6 +19,11 @@ for _, p in ipairs(paths.include_paths) do Preprocess.add_to_include_path(p) end +-- add some nonstandard header locations +if paths.apple_sysroot ~= '' then + Preprocess.add_apple_sysroot(paths.apple_sysroot) +end + local child_pid = nil --- @type integer? --- @generic F: function --- @param func F