cargo -> bazel
parent
77c88aa27a
commit
5565a77ac4
|
@ -1,3 +1,4 @@
|
|||
/target
|
||||
**/*.rs.bk
|
||||
**swp
|
||||
bazel-*
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "threepy"
|
||||
version = "0.1.0"
|
||||
authors = ["Sergiusz Bazanski <q3k@q3k.org>"]
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.6.1"
|
||||
log = "0.4.6"
|
||||
vulkano = "0.11.1"
|
||||
vulkano-win = "0.11.1"
|
||||
winit = "0.18.0"
|
|
@ -0,0 +1,33 @@
|
|||
workspace(name = "abrasion")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_rust",
|
||||
sha256 = "71bcdc2d56adf2cf71e53ad453ae19757d2d52704c2f598b73339fe9b9326fcf",
|
||||
strip_prefix = "rules_rust-92f56af72f2929089d00116c12d5d6bc029d839d",
|
||||
urls = [
|
||||
# Need https://github.com/bazelbuild/rules_rust/pull/285 for rusttype
|
||||
"https://github.com/GregBowyer/rules_rust/archive/92f56af72f2929089d00116c12d5d6bc029d839d.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "9a737999532daca978a158f94e77e9af6a6a169709c0cee274f0a4c3359519bd",
|
||||
strip_prefix = "bazel-skylib-1.0.0",
|
||||
url = "https://github.com/bazelbuild/bazel-skylib/archive/1.0.0.tar.gz",
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repository_set")
|
||||
#rust_repositories()
|
||||
rust_repository_set(
|
||||
name = "rust_linux_x86_64",
|
||||
exec_triple = "x86_64-unknown-linux-gnu",
|
||||
extra_target_triples = [],
|
||||
version = "nightly",
|
||||
iso_date = "2020-01-17",
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
|
||||
bazel_version(name = "bazel_version")
|
|
@ -0,0 +1,21 @@
|
|||
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
|
||||
|
||||
rust_binary(
|
||||
name = "engine",
|
||||
edition = "2018",
|
||||
srcs = [
|
||||
"src/main.rs",
|
||||
"src/render/mod.rs",
|
||||
"src/render/vulkan/mod.rs",
|
||||
"src/render/vulkan/binding.rs",
|
||||
"src/render/vulkan/qfi.rs",
|
||||
"src/render/vulkan/swapchains.rs",
|
||||
],
|
||||
deps = [
|
||||
"//third_party/cargo:winit",
|
||||
"//third_party/cargo:log",
|
||||
"//third_party/cargo:env_logger",
|
||||
"//third_party/cargo:vulkano",
|
||||
"//third_party/cargo:vulkano_win",
|
||||
],
|
||||
)
|
|
@ -24,7 +24,7 @@ pub struct Renderer {
|
|||
|
||||
impl Renderer {
|
||||
pub fn initialize() -> Self {
|
||||
let mut instance = vulkan::Instance::new("threepy".to_string());
|
||||
let mut instance = vulkan::Instance::new("abrasion".to_string());
|
||||
let (events_loop, surface) = Self::init_window(instance.get_vulkan());
|
||||
instance.use_surface(&surface);
|
||||
Self {
|
||||
|
@ -36,7 +36,7 @@ impl Renderer {
|
|||
fn init_window(instance: Arc<vi::Instance>) -> (EventsLoop, Arc<vs::Surface<Window>>) {
|
||||
let events_loop = EventsLoop::new();
|
||||
let surface = WindowBuilder::new()
|
||||
.with_title("threepy")
|
||||
.with_title("abrasion")
|
||||
.with_dimensions(LogicalSize::new(f64::from(WIDTH), f64::from(HEIGHT)))
|
||||
.build_vk_surface(&events_loop, instance.clone())
|
||||
.expect("could not create surface");
|
|
@ -3,6 +3,7 @@ use log;
|
|||
|
||||
use vulkano::instance as vi;
|
||||
use vulkano::swapchain as vs;
|
||||
use std::ops::Deref;
|
||||
|
||||
mod binding;
|
||||
mod swapchains;
|
||||
|
@ -10,6 +11,12 @@ mod qfi;
|
|||
|
||||
const VERSION: vi::Version = vi::Version { major: 1, minor: 0, patch: 0};
|
||||
|
||||
fn required_instance_extensions() -> vi::InstanceExtensions {
|
||||
let mut exts = vulkano_win::required_extensions();
|
||||
exts.ext_debug_report = true;
|
||||
exts
|
||||
}
|
||||
|
||||
pub struct Instance<WT> {
|
||||
debug_callback: vi::debug::DebugCallback,
|
||||
vulkan: Arc<vi::Instance>,
|
||||
|
@ -27,7 +34,7 @@ impl<WT> Instance<WT> {
|
|||
engine_version: Some(VERSION),
|
||||
};
|
||||
|
||||
let exts = Self::required_instance_extensions();
|
||||
let exts = required_instance_extensions();
|
||||
let layers = ["VK_LAYER_LUNARG_standard_validation"];
|
||||
let vulkan = vi::Instance::new(Some(&ai), &exts, layers.iter().cloned()).expect("could not create vulkan instance");
|
||||
let debug_callback = Self::init_debug_callback(&vulkan);
|
||||
|
@ -53,12 +60,6 @@ impl<WT> Instance<WT> {
|
|||
log::info!("Bound to Vulkan Device: {}", self.binding.as_ref().unwrap().physical_device().name());
|
||||
}
|
||||
|
||||
fn required_instance_extensions() -> vi::InstanceExtensions {
|
||||
let mut exts = vulkano_win::required_extensions();
|
||||
exts.ext_debug_report = true;
|
||||
exts
|
||||
}
|
||||
|
||||
|
||||
fn init_debug_callback(instance: &Arc<vi::Instance>) -> vi::debug::DebugCallback {
|
||||
let mt = vi::debug::MessageTypes {
|
|
@ -0,0 +1,30 @@
|
|||
"""
|
||||
cargo-raze workspace build file.
|
||||
|
||||
DO NOT EDIT! Replaced on runs of cargo-raze
|
||||
"""
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses([
|
||||
"notice" # See individual crates for specific licenses
|
||||
])
|
||||
alias(
|
||||
name = "env_logger",
|
||||
actual = "//third_party/cargo/vendor/env_logger-0.6.2:env_logger",
|
||||
)
|
||||
alias(
|
||||
name = "log",
|
||||
actual = "//third_party/cargo/vendor/log-0.4.8:log",
|
||||
)
|
||||
alias(
|
||||
name = "vulkano",
|
||||
actual = "//third_party/cargo/vendor/vulkano-0.11.1:vulkano",
|
||||
)
|
||||
alias(
|
||||
name = "vulkano_win",
|
||||
actual = "//third_party/cargo/vendor/vulkano-win-0.11.1:vulkano_win",
|
||||
)
|
||||
alias(
|
||||
name = "winit",
|
||||
actual = "//third_party/cargo/vendor/winit-0.18.1:winit",
|
||||
)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "compile_with_bazel"
|
||||
version = "1.33.7"
|
||||
|
||||
[lib]
|
||||
path = "fake_lib.rs"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.6.1"
|
||||
log = "0.4.6"
|
||||
vulkano = "0.11.1"
|
||||
vulkano-win = "0.11.1"
|
||||
winit = "0.18.0"
|
||||
|
||||
[raze]
|
||||
workspace_path = "//third_party/cargo"
|
||||
target = "x86_64-unknown-linux-gnu"
|
||||
|
||||
[raze.crates.andrew.'0.2.1']
|
||||
skipped_deps = ['rusttype-0.7.9']
|
||||
additional_deps = ['//third_party/cargo/vendor/rusttype-0.8.2:rusttype']
|
||||
|
||||
[raze.crates.x11-dl.'2.18.4']
|
||||
gen_buildrs = true
|
||||
|
||||
[raze.crates.wayland-client.'0.21.13']
|
||||
gen_buildrs = true
|
||||
|
||||
[raze.crates.wayland-protocols.'0.21.13']
|
||||
gen_buildrs = true
|
||||
|
||||
[raze.crates.log.'0.4.8']
|
||||
additional_flags = [
|
||||
"--cfg=atomic_cas"
|
||||
]
|
||||
|
||||
[raze.crates.libloading.'0.5.2']
|
||||
additional_deps = ['//third_party/cargo/patches:libloading_global_static']
|
|
@ -0,0 +1,10 @@
|
|||
To do Rust vendoring first run:
|
||||
|
||||
cargo install cargo-vendor
|
||||
cargo install cargo-raze
|
||||
|
||||
After changing Rust deps in Cargo.toml do:
|
||||
|
||||
cargo generate-lockfile
|
||||
cargo-vendor vendor -x
|
||||
cargo raze
|
|
@ -0,0 +1,6 @@
|
|||
cc_library(
|
||||
name = "libloading_global_static",
|
||||
srcs = ["libloading/global_static.c"],
|
||||
copts = ["-fPIC"],
|
||||
visibility = ["//third_party/cargo/vendor/libloading-0.5.2:__pkg__"],
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
pthread_mutex_t __attribute__((weak)) rust_libloading_dlerror_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
void __attribute__((weak))
|
||||
rust_libloading_dlerror_mutex_lock(void)
|
||||
{
|
||||
if (pthread_mutex_lock(&rust_libloading_dlerror_mutex) != 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void __attribute__((weak))
|
||||
rust_libloading_dlerror_mutex_unlock(void)
|
||||
{
|
||||
if (pthread_mutex_unlock(&rust_libloading_dlerror_mutex) != 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue