blob: 75c327501ab3d37d1c07ce41ea3b272d3533ad2b [file] [log] [blame]
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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.
*/
{namespace cxx_lua_extension}
/***/
{template .soyweb}
{call buck.page}
{param title: 'cxx_lua_extension()' /}
{param navid: 'rule_cxx_lua_extension' /}
{param prettify: true /}
{param description}
A cxx_lua_extension() rule builds a native Lua extension module from C/C++ source files.
{/param}
{param content}
{call buck.rule}
{param status: 'UNFROZEN' /}
{param overview}
A cxx_lua_extension() rule is a variant of a C/C++ library which is built as a Lua module. As such,
it has a module name formed by the <code>base_module</code> parameter and the rule name and implictly
depends on Lua C library (configured via the {call buckconfig.lua_cxx_library /} parameter.
{/param}
{param args}
{call buck.name_arg /}
{call lua_common.base_module_arg /}
{call cxx_common.srcs_arg /}
{call cxx_common.platform_srcs_arg /}
{call cxx_common.headers_arg /}
{call cxx_common.platform_headers_arg /}
{call cxx_common.header_namespace_arg /}
{call cxx_common.preprocessor_flags_arg /}
{call cxx_common.platform_preprocessor_flags_arg /}
{call cxx_common.compiler_flags_arg /}
{call cxx_common.platform_compiler_flags_arg /}
{call cxx_common.linker_flags_arg /}
{call cxx_common.platform_linker_flags_arg /}
{call buck.tests_arg /}
{/param} // close args
{param examples}
{literal}<pre class="prettyprint lang-py">
# A rule that builds a Lua extension from a single .cpp file.
cxx_lua_extension(
name = 'mymodule',
base_module = 'foo.bar',
srcs = [
'mymodule.cpp',
],
compiler_flags = [
'-fno-omit-frame-pointer',
],
)
# A library rule which has a single source importing the above extension.
lua_library(
name = 'utils',
srcs = [
'utils.lua',
],
deps = [
':mymodule',
],
)
</pre>{/literal}
{literal}<pre class="prettyprint lang-lua">
-- The `utils.lua` source, wrapped by the `utils` rule above.
-- Import the C/C++ extension build above.
require "foo.bar.mymodule"
...
</pre>{/literal}
{/param}
{/call} // close buck.rule
{/param}
{/call}
{/template}