summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-03 23:50:52 +0800
committerruki <[email protected]>2019-02-03 23:50:52 +0800
commit7727560c9fd20ae2d6f9d39eab2084e4225f59e1 (patch)
tree0fd895bb63ace8857a1d4f17306e745fdcf7133c
parent06b2019d196040f2825be5eab174f57f098c8ae2 (diff)
add builtin includes
-rw-r--r--tests/apis/check_xxx/config.h.in7
-rw-r--r--tests/apis/check_xxx/main.c5
-rw-r--r--tests/apis/check_xxx/test.lua3
-rw-r--r--tests/apis/check_xxx/xmake.lua18
-rw-r--r--xmake/core/base/interpreter.lua13
-rw-r--r--xmake/core/project/target.lua2
-rw-r--r--xmake/includes/check_cfuncs.lua73
-rw-r--r--xmake/includes/check_cincludes.lua53
-rw-r--r--xmake/includes/check_csnippets.lua65
-rw-r--r--xmake/includes/check_ctypes.lua53
-rw-r--r--xmake/includes/check_cxxfuncs.lua73
-rw-r--r--xmake/includes/check_cxxincludes.lua53
-rw-r--r--xmake/includes/check_cxxsnippets.lua51
-rw-r--r--xmake/includes/check_cxxtypes.lua53
-rw-r--r--xmake/includes/check_links.lua53
-rw-r--r--xmake/languages/c++/api.lua20
16 files changed, 580 insertions, 15 deletions
diff --git a/tests/apis/check_xxx/config.h.in b/tests/apis/check_xxx/config.h.in
new file mode 100644
index 000000000..03f493f57
--- /dev/null
+++ b/tests/apis/check_xxx/config.h.in
@@ -0,0 +1,7 @@
+${define HAS_STRING_H}
+${define HAS_STRING_AND_STDIO_H}
+${define HAS_WCHAR}
+${define HAS_WCHAR_AND_FLOAT}
+${define HAS_PTHREAD}
+${define HAS_STATIC_ASSERT}
+${define HAS_SETJMP}
diff --git a/tests/apis/check_xxx/main.c b/tests/apis/check_xxx/main.c
new file mode 100644
index 000000000..5549c309f
--- /dev/null
+++ b/tests/apis/check_xxx/main.c
@@ -0,0 +1,5 @@
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
diff --git a/tests/apis/check_xxx/test.lua b/tests/apis/check_xxx/test.lua
new file mode 100644
index 000000000..a4a38b0ce
--- /dev/null
+++ b/tests/apis/check_xxx/test.lua
@@ -0,0 +1,3 @@
+function main()
+ os.exec("xmake")
+end
diff --git a/tests/apis/check_xxx/xmake.lua b/tests/apis/check_xxx/xmake.lua
new file mode 100644
index 000000000..e67147d48
--- /dev/null
+++ b/tests/apis/check_xxx/xmake.lua
@@ -0,0 +1,18 @@
+includes("check_links.lua")
+includes("check_ctypes.lua")
+includes("check_cfuncs.lua")
+includes("check_csnippets.lua")
+includes("check_cincludes.lua")
+
+target("test")
+ set_kind("binary")
+ add_files("*.c")
+ add_configfiles("config.h.in")
+
+ check_ctypes("HAS_WCHAR", "wchar_t")
+ check_cincludes("HAS_STRING_H", "string.h")
+ configvar_check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
+ configvar_check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
+ configvar_check_links("HAS_PTHREAD", {"pthread", "m", "dl"})
+ configvar_check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");")
+ configvar_check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}})
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 4cf4dc307..4938a8ce1 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1593,16 +1593,23 @@ function interpreter:api_builtin_includes(...)
-- get all subpathes
local subpathes = table.join(...)
- -- match all subpathes
+ -- find all files
local subpathes_matched = {}
for _, subpath in ipairs(subpathes) do
+ -- find the given files from the project directory
local files = os.match(subpath, not subpath:endswith(".lua"))
- if files then
+ if files and #files > 0 then
table.join2(subpathes_matched, files)
+ elseif not path.is_absolute(subpath) then
+ -- attempt to find files from programdir/includes/*.lua
+ files = os.files(path.join(os.programdir(), "includes", subpath))
+ if files and #files > 0 then
+ table.join2(subpathes_matched, files)
+ end
end
end
- -- done
+ -- includes all files
for _, subpath in ipairs(subpathes_matched) do
if subpath and type(subpath) == "string" then
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 7c3e3ac15..43ebb8c23 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -768,8 +768,6 @@ function target:dependir()
if not dependir then
dependir = path.join(config.buildir(), ".deps", self:name())
end
-
- -- ok?
return dependir
end
diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check_cfuncs.lua
new file mode 100644
index 000000000..9e108ad68
--- /dev/null
+++ b/xmake/includes/check_cfuncs.lua
@@ -0,0 +1,73 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cfuncs.lua
+--
+
+-- check c funcs and add macro definition
+--
+-- the function syntax
+-- - sigsetjmp
+-- - sigsetjmp((void*)0, 0)
+-- - sigsetjmp{sigsetjmp((void*)0, 0);}
+-- - sigsetjmp{int a = 0; sigsetjmp((void*)a, a);}
+--
+-- e.g.
+--
+-- check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}})
+-- check_cfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"})
+--
+function check_cfuncs(definition, funcs, opt)
+ opt = opt or {}
+ option(definition)
+ add_cfuncs(funcs)
+ add_defines(definition)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
+
+-- check c funcs and add macro definition to the configuration files
+--
+-- e.g.
+--
+-- configvar_check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}})
+-- configvar_check_cfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"})
+--
+function configvar_check_cfuncs(definition, funcs, opt)
+ opt = opt or {}
+ option(definition)
+ add_cfuncs(funcs)
+ set_configvar(definition, 1)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check_cincludes.lua
new file mode 100644
index 000000000..a2ddba601
--- /dev/null
+++ b/xmake/includes/check_cincludes.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cincludes.lua
+--
+
+-- check include c files and add macro definition
+--
+-- e.g.
+--
+-- check_cincludes("HAS_STRING_H", "string.h")
+-- check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
+--
+function check_cincludes(definition, includes)
+ option(definition)
+ add_cincludes(includes)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check include c files and add macro definition to the configuration files
+--
+-- e.g.
+--
+-- configvar_check_cincludes("HAS_STRING_H", "string.h")
+-- configvar_check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
+--
+function configvar_check_cincludes(definition, includes)
+ option(definition)
+ add_cincludes(includes)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check_csnippets.lua
new file mode 100644
index 000000000..8eb972656
--- /dev/null
+++ b/xmake/includes/check_csnippets.lua
@@ -0,0 +1,65 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_csnippets.lua
+--
+
+-- check c snippets and add macro definition
+--
+-- e.g.
+--
+-- check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");", {includes = "stdio.h"})
+--
+function check_csnippets(definition, snippets, opt)
+ opt = opt or {}
+ option(definition)
+ add_csnippets(definition, snippets)
+ add_defines(definition)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
+
+-- check c snippets and add macro definition to the configuration snippets
+--
+-- e.g.
+--
+-- configvar_check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");", {includes = "stdio.h"})
+--
+function configvar_check_csnippets(definition, snippets, opt)
+ opt = opt or {}
+ option(definition)
+ add_csnippets(definition, snippets)
+ set_configvar(definition, 1)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check_ctypes.lua
new file mode 100644
index 000000000..e06bd3ef0
--- /dev/null
+++ b/xmake/includes/check_ctypes.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_ctypes.lua
+--
+
+-- check c types and add macro definition
+--
+-- e.g.
+--
+-- check_ctypes("HAS_WCHAR", "wchar_t")
+-- check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
+--
+function check_ctypes(definition, types)
+ option(definition)
+ add_ctypes(types)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check c types and add macro definition to the configuration types
+--
+-- e.g.
+--
+-- configvar_check_ctypes("HAS_WCHAR", "wchar_t")
+-- configvar_check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
+--
+function configvar_check_ctypes(definition, types)
+ option(definition)
+ add_ctypes(types)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check_cxxfuncs.lua
new file mode 100644
index 000000000..8fd3efd0b
--- /dev/null
+++ b/xmake/includes/check_cxxfuncs.lua
@@ -0,0 +1,73 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cxxfuncs.lua
+--
+
+-- check c++ funcs and add macro definition
+--
+-- the function syntax
+-- - sigsetjmp
+-- - sigsetjmp((void*)0, 0)
+-- - sigsetjmp{sigsetjmp((void*)0, 0);}
+-- - sigsetjmp{int a = 0; sigsetjmp((void*)a, a);}
+--
+-- e.g.
+--
+-- check_cxxfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}})
+-- check_cxxfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"})
+--
+function check_cxxfuncs(definition, funcs, opt)
+ opt = opt or {}
+ option(definition)
+ add_cxxfuncs(funcs)
+ add_defines(definition)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
+
+-- check c++ funcs and add macro definition to the configuration files
+--
+-- e.g.
+--
+-- configvar_check_cxxfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}})
+-- configvar_check_cxxfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"})
+--
+function configvar_check_cxxfuncs(definition, funcs, opt)
+ opt = opt or {}
+ option(definition)
+ add_cxxfuncs(funcs)
+ set_configvar(definition, 1)
+ if opt.links then
+ add_links(opt.links)
+ end
+ if opt.includes then
+ add_cincludes(opt.includes)
+ end
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check_cxxincludes.lua
new file mode 100644
index 000000000..3db806a09
--- /dev/null
+++ b/xmake/includes/check_cxxincludes.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cxxincludes.lua
+--
+
+-- check include c++ files and add macro definition
+--
+-- e.g.
+--
+-- check_cxxincludes("HAS_STRING_H", "string.h")
+-- check_cxxincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
+--
+function check_cxxincludes(definition, includes)
+ option(definition)
+ add_cxxincludes(includes)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check include c++ files and add macro definition to the configuration files
+--
+-- e.g.
+--
+-- configvar_check_cxxincludes("HAS_STRING_H", "string.h")
+-- configvar_check_cxxincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
+--
+function configvar_check_cxxincludes(definition, includes)
+ option(definition)
+ add_cxxincludes(includes)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check_cxxsnippets.lua
new file mode 100644
index 000000000..9d9a2ded2
--- /dev/null
+++ b/xmake/includes/check_cxxsnippets.lua
@@ -0,0 +1,51 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cxxsnippets.lua
+--
+
+-- check c++ snippets and add macro definition
+--
+-- e.g.
+--
+-- check_cxxsnippets("HAS_STATIC_ASSERT", "static_assert(1, \"\");")
+--
+function check_cxxsnippets(definition, snippets)
+ option(definition)
+ add_cxxsnippets(definition, snippets)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check c++ snippets and add macro definition to the configuration snippets
+--
+-- e.g.
+--
+-- configvar_check_cxxsnippets("HAS_STATIC_ASSERT", "static_assert(1, \"\");")
+--
+function configvar_check_cxxsnippets(definition, snippets)
+ option(definition)
+ add_cxxsnippets(definition, snippets)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check_cxxtypes.lua
new file mode 100644
index 000000000..fd98acf1b
--- /dev/null
+++ b/xmake/includes/check_cxxtypes.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_cxxtypes.lua
+--
+
+-- check c++ types and add macro definition
+--
+-- e.g.
+--
+-- check_cxxtypes("HAS_WCHAR", "wchar_t")
+-- check_cxxtypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
+--
+function check_cxxtypes(definition, types)
+ option(definition)
+ add_cxxtypes(types)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check c++ types and add macro definition to the configuration types
+--
+-- e.g.
+--
+-- configvar_check_cxxtypes("HAS_WCHAR", "wchar_t")
+-- configvar_check_cxxtypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
+--
+function configvar_check_cxxtypes(definition, types)
+ option(definition)
+ add_cxxtypes(types)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/includes/check_links.lua b/xmake/includes/check_links.lua
new file mode 100644
index 000000000..4b9ca49c2
--- /dev/null
+++ b/xmake/includes/check_links.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_links.lua
+--
+
+-- check links and add macro definition
+--
+-- e.g.
+--
+-- check_links("HAS_PTHREAD", "pthread")
+-- check_links("HAS_PTHREAD", {"pthread", "m", "dl"})
+--
+function check_links(definition, links)
+ option(definition)
+ add_links(links)
+ add_defines(definition)
+ option_end()
+ add_options(definition)
+end
+
+-- check links and add macro definition to the configuration files
+--
+-- e.g.
+--
+-- configvar_check_links("HAS_PTHREAD", "pthread")
+-- configvar_check_links("HAS_PTHREAD", {"pthread", "m", "dl"})
+--
+function configvar_check_links(definition, links)
+ option(definition)
+ add_links(links)
+ set_configvar(definition, 1)
+ option_end()
+ add_options(definition)
+end
diff --git a/xmake/languages/c++/api.lua b/xmake/languages/c++/api.lua
index dfbdb02e2..3b4506abd 100644
--- a/xmake/languages/c++/api.lua
+++ b/xmake/languages/c++/api.lua
@@ -196,26 +196,26 @@ function apis()
, "option.add_arflags"
, "option.add_shflags"
, "option.add_defines"
- , "option.add_defines_h"
- , "option.add_defines_if_ok"
- , "option.add_defines_h_if_ok"
+ , "option.add_defines_h" -- TODO deprecated
+ , "option.add_defines_if_ok" -- TODO deprecated
+ , "option.add_defines_h_if_ok" -- TODO deprecated
, "option.add_undefines"
- , "option.add_undefines_h"
- , "option.add_undefines_if_ok"
- , "option.add_undefines_h_if_ok"
+ , "option.add_undefines_h" -- TODO deprecated
+ , "option.add_undefines_if_ok" -- TODO deprecated
+ , "option.add_undefines_h_if_ok"-- TODO deprecated
, "option.add_frameworks"
, "option.add_rpathdirs"
}
_g.pathes =
{
-- target.set_xxx
- "target.set_headerdir" -- TODO deprecated
- , "target.set_config_h" -- TODO deprecated
- , "target.set_config_header"
+ "target.set_headerdir" -- TODO deprecated
+ , "target.set_config_h" -- TODO deprecated
+ , "target.set_config_header" -- TODO deprecated
, "target.set_pcheader"
, "target.set_pcxxheader"
-- target.add_xxx
- , "target.add_headers" -- TODO deprecated
+ , "target.add_headers" -- TODO deprecated
, "target.add_headerdirs"
, "target.add_headerfiles"
, "target.add_linkdirs"