aboutsummaryrefslogtreecommitdiff
path: root/autoconf/clang.lua
blob: fdb5f40515ba868b026ec8e8bc09743734b61b1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
-- Autoconfiguration.
-- Copyright (c) 2016 Blizzard Entertainment
---
local p = premake
local clang = p.tools.clang

function clang.try_compile(cfg, text, parameters)
	-- write the text to a temporary file.
	local cppFile = path.join(cfg.objdir, "temp.cpp")
	if not io.writefile(cppFile, text) then
		return nil
	end
	
	if parameters == nil then
		parameters = ""
	end

	local outFile = path.join(cfg.objdir, "temp.out")

	-- compile that text file.
	if os.execute('clang "' .. cppFile .. '" ' .. parameters .. ' -o "' .. outFile ..'" &> /dev/null') then
		return outFile
	else
		return nil
	end
end