diff --git a/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/BUILD.bazel b/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/BUILD.bazel index b774751..a39d247 100644 --- a/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/BUILD.bazel +++ b/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/BUILD.bazel @@ -28,6 +28,15 @@ licenses([ "notice", # MIT from expression "MIT" ]) +filegroup( + name = "luajit2_srcs", + srcs = glob(["luajit2/**"]), + visibility = [ + "//third_party/cargo/vendor:__subpackages__", + ] +) + + # Generated Targets rust_library( @@ -35,6 +44,7 @@ rust_library( srcs = glob(["**/*.rs"]), crate_features = [ ], + compile_data = glob(["luajit2/**"]), crate_root = "src/lib.rs", crate_type = "lib", data = [], diff --git a/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/src/lib.rs b/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/src/lib.rs index abae2fb..c99b8f0 100644 --- a/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/src/lib.rs +++ b/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/src/lib.rs @@ -62,7 +62,9 @@ impl Build { let target = &self.target.as_ref().expect("TARGET not set")[..]; let host = &self.host.as_ref().expect("HOST not set")[..]; let out_dir = self.out_dir.as_ref().expect("OUT_DIR not set"); - let source_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("luajit2"); + // HACK: Bazel: get path to luajit sources as defined by cargo_build_script in mlua. + let luajit2 = std::env::var("LUAJIT2").unwrap(); + let source_dir = Path::new(&luajit2); let build_dir = out_dir.join("build"); let lib_dir = out_dir.join("lib"); let include_dir = out_dir.join("include"); @@ -194,10 +196,10 @@ Error {}: } fn cp_r(src: &Path, dst: &Path) { - for f in fs::read_dir(src).unwrap() { - let f = f.unwrap(); + for f in fs::read_dir(src).expect(&format!("read_dir failed {:?}", src)) { + let f = f.expect("f read filed"); let path = f.path(); - let name = path.file_name().unwrap(); + let name = path.file_name().expect("file_name failed"); // Skip git metadata if name.to_str() == Some(".git") { diff --git a/third_party/cargo/vendor/mlua-0.5.3/BUILD.bazel b/third_party/cargo/vendor/mlua-0.5.3/BUILD.bazel index 0fee76f..54f2d8a 100644 --- a/third_party/cargo/vendor/mlua-0.5.3/BUILD.bazel +++ b/third_party/cargo/vendor/mlua-0.5.3/BUILD.bazel @@ -40,6 +40,7 @@ cargo_build_script( name = "mlua_build_script", srcs = glob(["**/*.rs"]), build_script_env = { + "LUAJIT2": "${pwd}/third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842/luajit2", }, crate_features = [ "lua-src", @@ -48,7 +49,9 @@ cargo_build_script( "vendored", ], crate_root = "build/main.rs", - data = glob(["**"]), + data = glob(["**"]) + [ + "//third_party/cargo/vendor/luajit-src-210.1.3+restyfe08842:luajit2_srcs", + ], edition = "2018", links = "lua", rustc_flags = [