From 8bcad5d23da92eedf8fc5bc42c20ef1562136747 Mon Sep 17 00:00:00 2001 From: Manu Evans Date: Tue, 31 Jan 2017 16:54:46 +1000 Subject: [PATCH] Detect native source files. --- src/base/oven.lua | 2 +- src/base/path.lua | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/base/oven.lua b/src/base/oven.lua index c0f12849..5a308e85 100644 --- a/src/base/oven.lua +++ b/src/base/oven.lua @@ -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 diff --git a/src/base/path.lua b/src/base/path.lua index 28aa8b3f..785d2927 100644 --- a/src/base/path.lua +++ b/src/base/path.lua @@ -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.