Detect native source files.

This commit is contained in:
Manu Evans 2017-01-31 16:54:46 +10:00
parent 51be6befcf
commit 8bcad5d23d
2 changed files with 35 additions and 6 deletions

View File

@ -678,7 +678,7 @@
-- Only consider sources that actually generate object files
if not path.iscppfile(file.abspath) then
if not path.isnativefile(file.abspath) then
return
end

View File

@ -142,17 +142,31 @@
--
-- Returns true if the filename represents a C/C++ source code file. This check
-- is used to prevent passing non-code files to the compiler in makefiles. It is
-- not foolproof, but it has held up well. I'm open to better suggestions.
-- Returns true if the filename represents various source languages.
--
function path.isasmfile(fname)
return path.hasextension(fname, { ".s" })
end
function path.iscfile(fname)
return path.hasextension(fname, { ".c", ".s", ".m" })
return path.hasextension(fname, { ".c" })
or path.isasmfile(fname) -- is this really right?
or path.isobjcfile(fname) -- there is code that depends on this behaviour, which would need to change
end
function path.iscppfile(fname)
return path.hasextension(fname, { ".cc", ".cpp", ".cxx", ".c", ".s", ".m", ".mm" })
return path.hasextension(fname, { ".cc", ".cpp", ".cxx" })
or path.isobjcppfile(fname) -- is this really right?
or path.iscfile(fname)
end
function path.isobjcfile(fname)
return path.hasextension(fname, { ".m" })
end
function path.isobjcppfile(fname)
return path.hasextension(fname, { ".mm" })
end
function path.iscppheader(fname)
@ -160,6 +174,21 @@
end
--
-- Returns true if the filename represents a native language source file.
-- These checks are used to prevent passing non-code files to the compiler
-- in makefiles. It is not foolproof, but it has held up well. I'm open to
-- better suggestions.
--
function path.isnativefile(fname)
return path.iscfile(fname)
or path.iscppfile(fname)
or path.isasmfile(fname)
or path.isobjcfile(fname)
or path.isobjcppfile(fname)
end
--
-- Returns true if the filename represents an OS X framework.