mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	build: allow comment after #include for required header (#29722)
And also check in .c files, as the attributes may be silently missing there as well.
This commit is contained in:
		@@ -545,7 +545,6 @@ foreach(sfile ${NVIM_SOURCES}
 | 
				
			|||||||
    set(f "${d}/${f}")
 | 
					    set(f "${d}/${f}")
 | 
				
			||||||
    set(r "${d}/${r}")
 | 
					    set(r "${d}/${r}")
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
  set (gf_basename "")
 | 
					 | 
				
			||||||
  if ("${ext}" STREQUAL ".c.h")
 | 
					  if ("${ext}" STREQUAL ".c.h")
 | 
				
			||||||
    continue() # .c.h files are sussy baka, skip
 | 
					    continue() # .c.h files are sussy baka, skip
 | 
				
			||||||
  elseif(${sfile} IN_LIST NVIM_HEADERS)
 | 
					  elseif(${sfile} IN_LIST NVIM_HEADERS)
 | 
				
			||||||
@@ -554,6 +553,7 @@ foreach(sfile ${NVIM_SOURCES}
 | 
				
			|||||||
    set(gf_h_h "SKIP")
 | 
					    set(gf_h_h "SKIP")
 | 
				
			||||||
    set(gf_h_h_out "")
 | 
					    set(gf_h_h_out "")
 | 
				
			||||||
  else()
 | 
					  else()
 | 
				
			||||||
 | 
					    set(gf_basename "${r}.c.generated.h")
 | 
				
			||||||
    set(gf_c_h "${GENERATED_DIR}/${r}.c.generated.h")
 | 
					    set(gf_c_h "${GENERATED_DIR}/${r}.c.generated.h")
 | 
				
			||||||
    set(gf_h_h "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
 | 
					    set(gf_h_h "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
 | 
				
			||||||
    set(gf_h_h_out "${gf_h_h}")
 | 
					    set(gf_h_h_out "${gf_h_h}")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -208,6 +208,10 @@ if fname:find('.*/src/nvim/.*%.c$') then
 | 
				
			|||||||
// IWYU pragma: private, include "%s"
 | 
					// IWYU pragma: private, include "%s"
 | 
				
			||||||
]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static
 | 
					]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					elseif fname:find('.*/src/nvim/.*%.h$') then
 | 
				
			||||||
 | 
					  static = ([[
 | 
				
			||||||
 | 
					// IWYU pragma: private, include "%s"
 | 
				
			||||||
 | 
					]]):format(fname:gsub('.*/src/nvim/', 'nvim/')) .. static
 | 
				
			||||||
elseif non_static_fname:find('/include/api/private/dispatch_wrappers%.h%.generated%.h$') then
 | 
					elseif non_static_fname:find('/include/api/private/dispatch_wrappers%.h%.generated%.h$') then
 | 
				
			||||||
  non_static = [[
 | 
					  non_static = [[
 | 
				
			||||||
// IWYU pragma: private, include "nvim/api/private/dispatch.h"
 | 
					// IWYU pragma: private, include "nvim/api/private/dispatch.h"
 | 
				
			||||||
@@ -308,15 +312,18 @@ F = io.open(static_fname, 'w')
 | 
				
			|||||||
F:write(static)
 | 
					F:write(static)
 | 
				
			||||||
F:close()
 | 
					F:close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if non_static_fname == 'SKIP' then
 | 
					if any_static then
 | 
				
			||||||
  F = io.open(fname, 'r')
 | 
					  F = io.open(fname, 'r')
 | 
				
			||||||
  if any_static then
 | 
					  local orig_text = F:read('*a')
 | 
				
			||||||
    local orig_text = F:read('*a')
 | 
					  local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
 | 
				
			||||||
    local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
 | 
					  local pat_comment = '\n#%s?include%s+"' .. static_basename .. '"%s*//'
 | 
				
			||||||
    if not string.find(orig_text, pat) then
 | 
					  if not string.find(orig_text, pat) and not string.find(orig_text, pat_comment) then
 | 
				
			||||||
      error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
 | 
					    error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					  F:close()
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if non_static_fname == 'SKIP' then
 | 
				
			||||||
  return -- only want static declarations
 | 
					  return -- only want static declarations
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -329,7 +336,7 @@ if F ~= nil then
 | 
				
			|||||||
  if F:read('*a') == non_static then
 | 
					  if F:read('*a') == non_static then
 | 
				
			||||||
    os.exit(0)
 | 
					    os.exit(0)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  io.close(F)
 | 
					  F:close()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
F = io.open(non_static_fname, 'w')
 | 
					F = io.open(non_static_fname, 'w')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user