-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added toolchain and examples * Final touches for first release * Update README * minor fix
- Loading branch information
Showing
9 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SublimeText | ||
*.sublime-project | ||
*.sublime-workspace | ||
|
||
# Visual Studio Code | ||
.vscode/ | ||
|
||
# Vulkan | ||
*.spv | ||
|
||
# Bazel | ||
bazel-* | ||
|
||
# CLion | ||
.clwb/ | ||
|
||
local/ | ||
|
||
# Bazel | ||
bazel-bin | ||
bazel-rules_lua | ||
bazel-out | ||
bazel-testlogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# rules_lua | ||
Bazel rules for the Lua programming language | ||
|
||
Bazel rules for using the [Lua language](https://www.lua.org/). | ||
|
||
## Configuration | ||
|
||
Include the following configuration in your project's `WORKSPACE` file. | ||
|
||
```python | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
git_repository( | ||
name = "rules_lua", | ||
remote = "https://github.com/jadarve/rules_lua.git", | ||
tag = "v0.0.1" | ||
) | ||
|
||
load("@rules_lua//toolchains:repositories.bzl", "lua_repositories") | ||
lua_repositories() | ||
``` | ||
|
||
## Available targets | ||
|
||
### Lua interpreter | ||
|
||
It's possible to run the Lua interpreter directly: | ||
|
||
```bash | ||
bazel run @rules_lua//toolchains:lua | ||
``` | ||
|
||
### Lua compiler | ||
|
||
The compiler is avaialble as: | ||
|
||
```bash | ||
bazel run @rules_lua//toolchains:luac -- <compile options> | ||
``` | ||
|
||
### Lua C library | ||
|
||
Additionally, the C library is available as a dependency as `@rules_lua//cc:lua_cc_library` | ||
|
||
## Examples | ||
|
||
See the [examples](examples) folder to see how to use the rules. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
workspace( | ||
name = "rules_lua" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
""" | ||
|
||
alias( | ||
name = "lua_cc_library", | ||
# TODO: select according to target lua version | ||
actual = "@remote_lua53_repository//:lua_cc_library", | ||
visibility = ["//visibility:public"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
workspace( | ||
name = "rules_lua_examples" | ||
) | ||
|
||
local_repository( | ||
name = "rules_lua", | ||
path = ".." | ||
) | ||
|
||
load("@rules_lua//toolchains:repositories.bzl", "lua_repositories") | ||
lua_repositories() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
""" | ||
|
||
alias( | ||
name = "lua", | ||
# FIXME: select according to target lua version | ||
actual = "@remote_lua53_repository//:lua" | ||
) | ||
|
||
alias( | ||
name = "luac", | ||
# FIXME: select according to target lua version | ||
actual = "@remote_lua53_repository//:luac" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
""" | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary") | ||
|
||
cc_library ( | ||
name = "lua_cc_library", | ||
srcs = glob( | ||
["src/*.c", "src/*.h", "src/*.hpp"], | ||
exclude = ["src/lua.c", "src/luac.c"], | ||
), | ||
hdrs = glob(["src/*.h", "src/*.hpp"]), | ||
strip_include_prefix = "src", | ||
linkstatic = True, | ||
local_defines = select({ | ||
"@platforms//os:linux": [ | ||
"LUA_USE_LINUX" | ||
], | ||
"//conditions:default": [ | ||
] | ||
}), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_binary ( | ||
name = "lua", | ||
srcs = ["src/lua.c"], | ||
deps = [ | ||
":lua_cc_library" | ||
], | ||
linkstatic = True, | ||
linkopts = select({ | ||
"@platforms//os:linux": [ | ||
"-lm", | ||
"-ldl" | ||
], | ||
"//conditions:default": [ | ||
] | ||
}), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_binary ( | ||
name = "luac", | ||
srcs = ["src/luac.c"], | ||
deps = [ | ||
":lua_cc_library" | ||
], | ||
linkstatic = True, | ||
linkopts = select({ | ||
"@platforms//os:linux": [ | ||
"-lm", | ||
"-ldl" | ||
], | ||
"//conditions:default": [ | ||
|
||
] | ||
}), | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
""" | ||
|
||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
|
||
def lua_repositories(): | ||
|
||
maybe ( | ||
repo_rule = http_archive, | ||
name = "remote_lua53_repository", | ||
urls = [ | ||
"https://www.lua.org/ftp/lua-5.3.6.tar.gz" | ||
], | ||
sha256 = "fc5fd69bb8736323f026672b1b7235da613d7177e72558893a0bdcd320466d60", | ||
strip_prefix = "lua-5.3.6", | ||
build_file = "@rules_lua//toolchains:lua.BUILD", | ||
) | ||
|
||
maybe ( | ||
repo_rule = http_archive, | ||
name = "remote_lua54_repository", | ||
urls = [ | ||
"https://www.lua.org/ftp/lua-5.4.4.tar.gz" | ||
], | ||
sha256 = "164c7849653b80ae67bec4b7473b884bf5cc8d2dca05653475ec2ed27b9ebf61", | ||
strip_prefix = "lua-5.4.4", | ||
build_file = "@rules_lua//toolchains:lua.BUILD", | ||
) |