Skip to content

Commit daf69f8

Browse files
committed
Minor lua52compat code refactor
1 parent 3dc208a commit daf69f8

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ impl Build {
4747
self
4848
}
4949

50-
pub fn lua52compat(&mut self, status: bool) -> &mut Build {
51-
self.options.lua52compat = status;
50+
pub fn lua52compat(&mut self, enabled: bool) -> &mut Build {
51+
self.options.lua52compat = enabled;
5252
self
5353
}
5454

@@ -145,8 +145,9 @@ impl Build {
145145
pub fn build_msvc(&mut self) -> Artifacts {
146146
let target = &self.target.as_ref().expect("TARGET not set")[..];
147147
let out_dir = self.out_dir.as_ref().expect("OUT_DIR not set");
148-
let source_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("luajit2");
149-
let extras_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("extras");
148+
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
149+
let source_dir = manifest_dir.join("luajit2");
150+
let extras_dir = manifest_dir.join("extras");
150151
let build_dir = out_dir.join("build");
151152
let lib_dir = out_dir.join("lib");
152153
let include_dir = out_dir.join("include");
@@ -160,16 +161,16 @@ impl Build {
160161
.unwrap_or_else(|e| panic!("cannot create {}: {}", dir.display(), e));
161162
}
162163
cp_r(&source_dir, &build_dir);
163-
cp_r(&extras_dir, &build_dir.join("src"));
164164

165165
let mut msvcbuild = Command::new(build_dir.join("src").join("msvcbuild.bat"));
166166
msvcbuild.current_dir(build_dir.join("src"));
167167
if self.options.lua52compat {
168+
cp_r(&extras_dir, &build_dir.join("src"));
168169
msvcbuild.arg("lua52c");
169170
}
170171
msvcbuild.arg("static");
171172

172-
let cl = cc::windows_registry::find_tool(&target, "cl.exe").expect("failed to find cl");
173+
let cl = cc::windows_registry::find_tool(target, "cl.exe").expect("failed to find cl");
173174
for (k, v) in cl.env() {
174175
msvcbuild.env(k, v);
175176
}

testcrate/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
fn main() {
22
println!("cargo:rerun-if-changed=build.rs");
33
let mut builder = luajit_src::Build::new();
4-
if cfg!(feature = "lua52compat") {
5-
builder.lua52compat(true);
6-
}
4+
builder.lua52compat(cfg!(feature = "lua52compat"));
75
let artifacts = builder.build();
86
artifacts.print_cargo_metadata();
97
}

0 commit comments

Comments
 (0)