build: clone mesa directly from gitlab

If we don't do this, the crate is too big for crates.io.
This commit is contained in:
chyyran 2023-02-04 03:18:34 -05:00
parent fddf8aab2a
commit 3261a3c54f
4 changed files with 22 additions and 21 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "spirv-to-dxil-sys/vendor/mesa"]
path = spirv-to-dxil-sys/native/mesa
url = https://gitlab.freedesktop.org/mesa/mesa

View file

@ -1,6 +1,8 @@
use cmake::Config; use cmake::Config;
use std::{env, fs::File, path::PathBuf}; use std::{env, fs::File, path::PathBuf};
const MESA_HASH: &str = "5678fbe010fb8ba9ac6188c5ec7368fb55a98319";
fn main() { fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
if env::var("DOCS_RS").is_ok() { if env::var("DOCS_RS").is_ok() {
@ -10,6 +12,7 @@ fn main() {
} }
let cmake_dst = Config::new("native") let cmake_dst = Config::new("native")
.define("MESA_HASH", MESA_HASH)
.build_target("mesa") .build_target("mesa")
.build(); .build();
@ -26,18 +29,16 @@ fn main() {
println!("cargo:rustc-link-lib=static=spirv_to_dxil"); println!("cargo:rustc-link-lib=static=spirv_to_dxil");
println!("cargo:rustc-link-lib=static=vulkan_util"); println!("cargo:rustc-link-lib=static=vulkan_util");
if !cfg!(feature = "included-bindings") { let bindings = bindgen::Builder::default()
let bindings = bindgen::Builder::default() .header("native/wrapper.h")
.header("native/wrapper.h") .clang_arg(format!("-F{}", header_dst.display()))
.clang_arg(format!("-F{}", header_dst.display())) .clang_arg(format!("-F{}", header_compiler_dst.display()))
.clang_arg(format!("-F{}", header_compiler_dst.display())) .clang_arg(format!("-I{}", header_dst.display()))
.clang_arg(format!("-I{}", header_dst.display())) .clang_arg(format!("-I{}", header_compiler_dst.display()))
.clang_arg(format!("-I{}", header_compiler_dst.display())) .parse_callbacks(Box::new(bindgen::CargoCallbacks))
.parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate()
.generate() .expect("Unable to generate bindings");
.expect("Unable to generate bindings"); bindings
bindings .write_to_file(out_dir.join("bindings.rs"))
.write_to_file(out_dir.join("bindings.rs")) .expect("Couldn't write bindings!");
.expect("Couldn't write bindings!");
}
} }

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6) cmake_minimum_required(VERSION 3.8)
project(native-spirv-to-dxil) project(native-spirv-to-dxil)
include(ExternalProject) include(ExternalProject)
@ -46,10 +46,14 @@ set(MESA_EXTRA_FLAGS
ExternalProject_Add(mesa ExternalProject_Add(mesa
URL file://${CMAKE_CURRENT_LIST_DIR}/mesa GIT_REPOSITORY https://gitlab.freedesktop.org/mesa/mesa
GIT_TAG ${MESA_HASH}
GIT_SHALLOW true
GIT_PROGRESS true
GIT_CONFIG core.symlinks=false
PREFIX ${CMAKE_BINARY_DIR}/mesa PREFIX ${CMAKE_BINARY_DIR}/mesa
CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa && meson setup ${CMAKE_BINARY_DIR}/mesa/src/mesa-build ${MESA_EXTRA_FLAGS} CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa && meson setup ${CMAKE_BINARY_DIR}/mesa/src/mesa-build ${MESA_EXTRA_FLAGS}
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa-build && meson compile src/vulkan/util/vulkan_util:static_library && meson compile src/microsoft/spirv_to_dxil/spirv_to_dxil:static_library BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa-build && ninja src/vulkan/util/libvulkan_util.a && ninja src/microsoft/spirv_to_dxil/libspirv_to_dxil.a
INSTALL_COMMAND cmake -DOUT_DIR=${CMAKE_BINARY_DIR}/mesa -DMESA_BUILD=${CMAKE_BINARY_DIR}/mesa/src/mesa-build -P ${CMAKE_CURRENT_LIST_DIR}/install_spirv_to_dxil.cmake INSTALL_COMMAND cmake -DOUT_DIR=${CMAKE_BINARY_DIR}/mesa -DMESA_BUILD=${CMAKE_BINARY_DIR}/mesa/src/mesa-build -P ${CMAKE_CURRENT_LIST_DIR}/install_spirv_to_dxil.cmake
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/mesa/lib/spirv_to_dxil.lib ${CMAKE_BINARY_DIR}/mesa/lib/libspirv_to_dxil.a ${CMAKE_BINARY_DIR}/mesa/lib/vulkan_util.lib ${CMAKE_BINARY_DIR}/mesa/lib/libvulkan_util.a BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/mesa/lib/spirv_to_dxil.lib ${CMAKE_BINARY_DIR}/mesa/lib/libspirv_to_dxil.a ${CMAKE_BINARY_DIR}/mesa/lib/vulkan_util.lib ${CMAKE_BINARY_DIR}/mesa/lib/libvulkan_util.a
) )

@ -1 +0,0 @@
Subproject commit 60d7e15a7e61c6d51c3fa8e26839793782a12fb4