mirror of
https://github.com/italicsjenga/spirv-to-dxil-rs.git
synced 2024-12-23 11:31:31 +11:00
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:
parent
4d8dce5eb5
commit
92388514cf
|
@ -2,6 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<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>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -6,7 +6,6 @@ edition = "2021"
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = "0.63.0"
|
bindgen = "0.63.0"
|
||||||
|
|
|
@ -15,11 +15,18 @@ fn main() {
|
||||||
|
|
||||||
let object_dst = cmake_dst.join("build/mesa/lib");
|
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_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");
|
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-search=native={}", object_dst.display());
|
||||||
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");
|
||||||
eprintln!("{:?}", cmake_dst);
|
eprintln!("{:?}", cmake_dst);
|
||||||
|
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
|
|
|
@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.6)
|
||||||
project(native-spirv-to-dxil)
|
project(native-spirv-to-dxil)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
|
|
||||||
# need python
|
# need python
|
||||||
find_package(Python COMPONENTS Interpreter REQUIRED)
|
find_package(Python COMPONENTS Interpreter REQUIRED)
|
||||||
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX})
|
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX})
|
||||||
|
@ -11,33 +10,34 @@ else()
|
||||||
set(_pip_args "--user")
|
set(_pip_args "--user")
|
||||||
endif()
|
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)
|
execute_process(COMMAND ${Python_EXECUTABLE} -m pip install mako)
|
||||||
|
|
||||||
find_program(LEX_EXE
|
string(TOLOWER ${CMAKE_BUILD_TYPE} MESON_BUILD_TYPE)
|
||||||
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")
|
|
||||||
|
|
||||||
set(MESA_EXTRA_FLAGS
|
set(MESA_EXTRA_FLAGS
|
||||||
-Dbuildtype=release
|
-Dbuildtype=${MESON_BUILD_TYPE}
|
||||||
-Dgallium-drivers=
|
# force zink because we want libvulkan_util
|
||||||
|
-Dgallium-drivers=zink
|
||||||
|
-Dvulkan-drivers=
|
||||||
|
-Dopengl=false
|
||||||
-Dglx=disabled
|
-Dglx=disabled
|
||||||
|
-Dmicrosoft-clc=disabled
|
||||||
|
-Dgallium-d3d12-video=disabled
|
||||||
|
-Dmin-windows-version=10
|
||||||
-Dgbm=disabled
|
-Dgbm=disabled
|
||||||
-Degl=disabled
|
-Degl=disabled
|
||||||
-Dgles1=disabled
|
-Dgles1=disabled
|
||||||
-Dgles2=disabled
|
-Dgles2=disabled
|
||||||
|
-Dllvm=disabled
|
||||||
-Dshared-llvm=disabled
|
-Dshared-llvm=disabled
|
||||||
-Dspirv-to-dxil=true
|
-Dspirv-to-dxil=true
|
||||||
-Dplatforms=auto
|
-Dplatforms=auto
|
||||||
|
-Dzlib=disabled
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ ExternalProject_Add(mesa
|
||||||
URL file://${CMAKE_CURRENT_LIST_DIR}/mesa
|
URL file://${CMAKE_CURRENT_LIST_DIR}/mesa
|
||||||
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 && 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
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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/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)
|
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)
|
file(RENAME ${OUT_DIR}/lib/libspirv_to_dxil.a ${OUT_DIR}/lib/spirv_to_dxil.lib)
|
||||||
endif()
|
endif()
|
|
@ -1,2 +1 @@
|
||||||
#include "spirv_to_dxil.h"
|
#include "spirv_to_dxil.h"
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
let result = add(2, 2);
|
unsafe {
|
||||||
assert_eq!(result, 4);
|
eprintln!("{:x?}", spirv_to_dxil_get_version());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue