File tree Expand file tree Collapse file tree 9 files changed +195
-1
lines changed
Expand file tree Collapse file tree 9 files changed +195
-1
lines changed Original file line number Diff line number Diff line change 1+ # SublimeText
2+ * .sublime-project
3+ * .sublime-workspace
4+
5+ # Visual Studio Code
6+ .vscode /
7+
8+ # Vulkan
9+ * .spv
10+
11+ # Bazel
12+ bazel- *
13+
14+ # CLion
15+ .clwb /
16+
17+ local /
18+
19+ # Bazel
20+ bazel-bin
21+ bazel-rules_lua
22+ bazel-out
23+ bazel-testlogs
Original file line number Diff line number Diff line change 11# rules_lua
2- Bazel rules for the Lua programming language
2+
3+ Bazel rules for using the [ Lua language] ( https://www.lua.org/ ) .
4+
5+ ## Configuration
6+
7+ Include the following configuration in your project's ` WORKSPACE ` file.
8+
9+ ``` python
10+ load(" @bazel_tools//tools/build_defs/repo:git.bzl" , " git_repository" )
11+
12+ git_repository(
13+ name = " rules_lua" ,
14+ remote = " https://github.com/jadarve/rules_lua.git" ,
15+ tag = " v0.0.1"
16+ )
17+
18+ load(" @rules_lua//toolchains:repositories.bzl" , " lua_repositories" )
19+ lua_repositories()
20+ ```
21+
22+ ## Available targets
23+
24+ ### Lua interpreter
25+
26+ It's possible to run the Lua interpreter directly:
27+
28+ ``` bash
29+ bazel run @rules_lua//toolchains:lua
30+ ```
31+
32+ ### Lua compiler
33+
34+ The compiler is avaialble as:
35+
36+ ``` bash
37+ bazel run @rules_lua//toolchains:luac -- < compile options>
38+ ```
39+
40+ ### Lua C library
41+
42+ Additionally, the C library is available as a dependency as ` @rules_lua//cc:lua_cc_library `
43+
44+ ## Examples
45+
46+ See the [ examples] ( examples ) folder to see how to use the rules.
Original file line number Diff line number Diff line change 1+ workspace (
2+ name = "rules_lua"
3+ )
Original file line number Diff line number Diff line change 1+ """
2+ """
3+
4+ alias (
5+ name = "lua_cc_library" ,
6+ # TODO: select according to target lua version
7+ actual = "@remote_lua53_repository//:lua_cc_library" ,
8+ visibility = ["//visibility:public" ]
9+ )
Original file line number Diff line number Diff line change 1+ workspace (
2+ name = "rules_lua_examples"
3+ )
4+
5+ local_repository (
6+ name = "rules_lua" ,
7+ path = ".."
8+ )
9+
10+ load ("@rules_lua//toolchains:repositories.bzl" , "lua_repositories" )
11+ lua_repositories ()
Original file line number Diff line number Diff line change 1+ """
2+ """
3+
4+ alias (
5+ name = "lua" ,
6+ # FIXME: select according to target lua version
7+ actual = "@remote_lua53_repository//:lua"
8+ )
9+
10+ alias (
11+ name = "luac" ,
12+ # FIXME: select according to target lua version
13+ actual = "@remote_lua53_repository//:luac"
14+ )
Original file line number Diff line number Diff line change 1+ """
2+ """
3+
4+ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary")
5+
6+ cc_library (
7+ name = "lua_cc_library",
8+ srcs = glob(
9+ ["src/*.c", "src/*.h", "src/*.hpp"],
10+ exclude = ["src/lua.c", "src/luac.c"],
11+ ),
12+ hdrs = glob(["src/*.h", "src/*.hpp"]),
13+ strip_include_prefix = "src",
14+ linkstatic = True,
15+ local_defines = select({
16+ "@platforms//os:linux": [
17+ "LUA_USE_LINUX"
18+ ],
19+ "//conditions:default": [
20+ ]
21+ }),
22+ visibility = ["//visibility:public"],
23+ )
24+
25+ cc_binary (
26+ name = "lua",
27+ srcs = ["src/lua.c"],
28+ deps = [
29+ ":lua_cc_library"
30+ ],
31+ linkstatic = True,
32+ linkopts = select({
33+ "@platforms//os:linux": [
34+ "-lm",
35+ "-ldl"
36+ ],
37+ "//conditions:default": [
38+ ]
39+ }),
40+ visibility = ["//visibility:public"],
41+ )
42+
43+ cc_binary (
44+ name = "luac",
45+ srcs = ["src/luac.c"],
46+ deps = [
47+ ":lua_cc_library"
48+ ],
49+ linkstatic = True,
50+ linkopts = select({
51+ "@platforms//os:linux": [
52+ "-lm",
53+ "-ldl"
54+ ],
55+ "//conditions:default": [
56+
57+ ]
58+ }),
59+ visibility = ["//visibility:public"],
60+ )
Original file line number Diff line number Diff line change 1+ """
2+ """
3+
4+ load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
5+ load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
6+
7+
8+ def lua_repositories ():
9+
10+ maybe (
11+ repo_rule = http_archive ,
12+ name = "remote_lua53_repository" ,
13+ urls = [
14+ "https://www.lua.org/ftp/lua-5.3.6.tar.gz"
15+ ],
16+ sha256 = "fc5fd69bb8736323f026672b1b7235da613d7177e72558893a0bdcd320466d60" ,
17+ strip_prefix = "lua-5.3.6" ,
18+ build_file = "@rules_lua//toolchains:lua.BUILD" ,
19+ )
20+
21+ maybe (
22+ repo_rule = http_archive ,
23+ name = "remote_lua54_repository" ,
24+ urls = [
25+ "https://www.lua.org/ftp/lua-5.4.4.tar.gz"
26+ ],
27+ sha256 = "164c7849653b80ae67bec4b7473b884bf5cc8d2dca05653475ec2ed27b9ebf61" ,
28+ strip_prefix = "lua-5.4.4" ,
29+ build_file = "@rules_lua//toolchains:lua.BUILD" ,
30+ )
You can’t perform that action at this time.
0 commit comments