summaryrefslogtreecommitdiff
path: root/xmake/includes/check_csnippets.lua
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 /xmake/includes/check_csnippets.lua
parent06b2019d196040f2825be5eab174f57f098c8ae2 (diff)
add builtin includes
Diffstat (limited to 'xmake/includes/check_csnippets.lua')
-rw-r--r--xmake/includes/check_csnippets.lua65
1 files changed, 65 insertions, 0 deletions
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