added run step

This commit is contained in:
Jacob Stannix 2024-08-15 12:23:27 -06:00
parent a08e3ddb24
commit 5727c0bc04

View file

@ -11,16 +11,20 @@ const version = std.SemanticVersion{
const lib_name = "lua"; const lib_name = "lua";
const exe_name = lib_name; const exe_name = lib_name;
const compiler_name = "luac"; const compiler_name = "luac";
pub fn build(b: *Build) !void { pub fn build(b: *Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast }); const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast });
const build_shared = b.option(bool, "shared", "build as shared library") orelse target.result.isMinGW(); const build_shared = b.option(bool, "shared", "build as shared library") orelse target.result.isMinGW();
const use_readline = const use_readline =
if (target.result.os.tag == .linux) if (target.result.os.tag == .linux)
b.option(bool, "use_readline", "readline support for linux") orelse false b.option(bool, "use_readline", "readline support for linux") orelse false
else else
null; null;
const lua_src = b.dependency("lua", .{}); const lua_src = b.dependency("lua", .{});
const lib = if (!build_shared) const lib = if (!build_shared)
b.addStaticLibrary(artifactOptions( b.addStaticLibrary(artifactOptions(
.{ .shared = false }, .{ .shared = false },
@ -49,8 +53,8 @@ pub fn build(b: *Build) !void {
exe, exe,
exec, exec,
}; };
// Common compile flags
for (&build_targets) |t| { for (&build_targets) |t| {
t.addIncludePath(lua_src.path("src"));
t.linkLibC(); t.linkLibC();
switch (target.result.os.tag) { switch (target.result.os.tag) {
.aix => { .aix => {
@ -94,11 +98,13 @@ pub fn build(b: *Build) !void {
exe.defineCMacro("LUA_BUILD_AS_DLL", null); exe.defineCMacro("LUA_BUILD_AS_DLL", null);
} }
lib.addIncludePath(lua_src.path("src"));
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.root = lua_src.path("src"), .root = lua_src.path("src"),
.files = &base_src, .files = &base_src,
.flags = &cflags, .flags = &cflags,
}); });
lib.installHeadersDirectory( lib.installHeadersDirectory(
lua_src.path("src"), lua_src.path("src"),
"", "",
@ -127,6 +133,10 @@ pub fn build(b: *Build) !void {
.install_dir = .{ .custom = "man" }, .install_dir = .{ .custom = "man" },
.install_subdir = "man1", .install_subdir = "man1",
}); });
const run_step = b.step("run", "run lua interpreter");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
} }
const ArtifactTarget = union(enum) { const ArtifactTarget = union(enum) {
// True if shared options // True if shared options