sys: get sys to link properly and clean up CMake file

flex and bison aren't actually needed if we don't use opengl
This commit is contained in:
chyyran 2023-02-03 03:14:11 -05:00
parent 4d8dce5eb5
commit 92388514cf
7 changed files with 31 additions and 23 deletions

View file

@ -2,6 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/spirv-to-dxil-sys/build/mesa" vcs="Git" />
<mapping directory="$PROJECT_DIR$/spirv-to-dxil-sys/native/mesa" vcs="Git" />
</component>
</project>

View file

@ -6,7 +6,6 @@ edition = "2021"
[lib]
crate-type = ["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
bindgen = "0.63.0"

View file

@ -15,11 +15,18 @@ fn main() {
let object_dst = cmake_dst.join("build/mesa/lib");
// let vulkan_util_dst = cmake_dst.join("build/mesa/src/mesa/src/vulkan/util");
let header_dst = cmake_dst.join("build/mesa/src/mesa/src/microsoft/spirv_to_dxil");
let header_compiler_dst = cmake_dst.join("build/mesa/src/mesa/src/microsoft/compiler");
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=Version");
println!("cargo:rustc-link-lib=synchronization");
}
println!("cargo:rustc-link-search=native={}", object_dst.display());
println!("cargo:rustc-link-lib=static=spirv_to_dxil");
println!("cargo:rustc-link-lib=static=vulkan_util");
eprintln!("{:?}", cmake_dst);
let bindings = bindgen::Builder::default()

View file

@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.6)
project(native-spirv-to-dxil)
include(ExternalProject)
# need python
find_package(Python COMPONENTS Interpreter REQUIRED)
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX})
@ -11,33 +10,34 @@ else()
set(_pip_args "--user")
endif()
find_program(PIP_EXE pip)
if(PIP_EXE STREQUAL "PIP_EXE-NOTFOUND")
message(FATAL_ERROR "pip required")
endif(PIP_EXE STREQUAL "PIP_EXE-NOTFOUND")
execute_process(COMMAND ${Python_EXECUTABLE} -m pip install mako)
find_program(LEX_EXE
flex
)
if(LEX_EXE STREQUAL "LEX_EXE-NOTFOUND")
message(FATAL_ERROR "flex (lex) required to build NIR and GLSL compiler")
endif(LEX_EXE STREQUAL "LEX_EXE-NOTFOUND")
find_program(YACC_EXE
bison
)
if(YACC_EXE STREQUAL "YACC_EXE-NOTFOUND")
message(FATAL_ERROR "bison (yacc) required to build NIR and GLSL compiler")
endif(YACC_EXE STREQUAL "YACC_EXE-NOTFOUND")
string(TOLOWER ${CMAKE_BUILD_TYPE} MESON_BUILD_TYPE)
set(MESA_EXTRA_FLAGS
-Dbuildtype=release
-Dgallium-drivers=
-Dbuildtype=${MESON_BUILD_TYPE}
# force zink because we want libvulkan_util
-Dgallium-drivers=zink
-Dvulkan-drivers=
-Dopengl=false
-Dglx=disabled
-Dmicrosoft-clc=disabled
-Dgallium-d3d12-video=disabled
-Dmin-windows-version=10
-Dgbm=disabled
-Degl=disabled
-Dgles1=disabled
-Dgles2=disabled
-Dllvm=disabled
-Dshared-llvm=disabled
-Dspirv-to-dxil=true
-Dplatforms=auto
-Dzlib=disabled
)
@ -45,8 +45,8 @@ ExternalProject_Add(mesa
URL file://${CMAKE_CURRENT_LIST_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}
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa-build && ninja src/microsoft/spirv_to_dxil/libspirv_to_dxil.a
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
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/mesa/lib/spirv_to_dxil.lib ${CMAKE_BINARY_DIR}/mesa/lib/libspirv_to_dxil.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
)

View file

@ -1,5 +1,7 @@
file(INSTALL ${MESA_BUILD}/src/microsoft/spirv_to_dxil/libspirv_to_dxil.a DESTINATION ${OUT_DIR}/lib)
file(INSTALL ${MESA_BUILD}/src/vulkan/util/libvulkan_util.a DESTINATION ${OUT_DIR}/lib)
if (WIN32)
file(RENAME ${OUT_DIR}/lib/libvulkan_util.a ${OUT_DIR}/lib/vulkan_util.lib)
file(RENAME ${OUT_DIR}/lib/libspirv_to_dxil.a ${OUT_DIR}/lib/spirv_to_dxil.lib)
endif()

View file

@ -1,2 +1 @@
#include "spirv_to_dxil.h"

View file

@ -16,7 +16,8 @@ mod tests {
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
unsafe {
eprintln!("{:x?}", spirv_to_dxil_get_version());
}
}
}