Skip to content

improvement(build): add -Dlibrary_name for change name *.dll, *.so, *… #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn build(b: *Build) void {
const optimize = b.standardOptimizeOption(.{});

const lang = b.option(Language, "lang", "Lua language version to build") orelse .lua54;
const library_name = b.option([]const u8, "library_name", "Library name for lua linking, default is `lua`") orelse null;
const shared = b.option(bool, "shared", "Build shared library instead of static") orelse false;
const luau_use_4_vector = b.option(bool, "luau_use_4_vector", "Build Luau to use 4-vectors instead of the default 3-vector.") orelse false;

Expand All @@ -31,6 +32,7 @@ pub fn build(b: *Build) void {
// Expose build configuration to the ziglua module
const config = b.addOptions();
config.addOption(Language, "lang", lang);
config.addOption(?[]const u8, "library_name", library_name);
config.addOption(bool, "luau_use_4_vector", luau_use_4_vector);
zlua.addOptions("config", config);

Expand All @@ -43,7 +45,7 @@ pub fn build(b: *Build) void {
const lib = switch (lang) {
.luajit => luajit_setup.configure(b, target, optimize, upstream, shared),
.luau => luau_setup.configure(b, target, optimize, upstream, luau_use_4_vector),
else => lua_setup.configure(b, target, optimize, upstream, lang, shared),
else => lua_setup.configure(b, target, optimize, upstream, lang, shared, library_name),
};

// Expose the Lua artifact, and get an install step that header translation can refer to
Expand Down
6 changes: 3 additions & 3 deletions build/lua.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const Language = enum {
luau,
};

pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, lang: Language, shared: bool) *Step.Compile {
pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, lang: Language, shared: bool, library_name: ?[]const u8) *Step.Compile {
const version: std.SemanticVersion = switch (lang) {
.lua51 => .{ .major = 5, .minor = 1, .patch = 5 },
.lua52 => .{ .major = 5, .minor = 2, .patch = 4 },
Expand All @@ -23,14 +23,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.

const lib = if (shared)
b.addSharedLibrary(.{
.name = "lua",
.name = library_name orelse "lua",
.target = target,
.optimize = optimize,
.version = version,
})
else
b.addStaticLibrary(.{
.name = "lua",
.name = library_name orelse "lua",
.target = target,
.optimize = optimize,
.version = version,
Expand Down