Skip to content

Commit

Permalink
windows cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SogoCZE committed Aug 13, 2024
1 parent 5b8d9b3 commit 154058c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions examples/hello_triangle/main.jai
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ main :: () {
adapter := request_adapter(instance, surface, powerPreference = .HighPerformance);
assert(adapter != null, "Adapter is not created correctly");

adapter_info: wgpu.AdapterInfo;
wgpu.AdapterGetInfo(adapter, *adapter_info);
assert(adapter != null, "Adapter info is not created correctly");

log("Backend: %", adapter_info.backendType);

device := request_device(adapter);
assert(device != null, "Device is not created correctly");

Expand Down
19 changes: 14 additions & 5 deletions wgpu/generate.jai
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ ANDROID_BUILD_TARGET :: "";
exit(1);
}

if !copy_file(get_builded_lib_path(.WINDOWS, WINDOWS_BUILD_TARGET, release, "lib"), "./windows/libwgpu_native.lib") {
log_error("Failed to copy library.");
exit(1);
}

generate();
case .LINUX;
build(.LINUX);
Expand All @@ -94,21 +99,25 @@ run_cmd :: (command: [] string, working_directory: string, print_live := false)
return output_string, true;
}

get_builded_lib_path :: (platform: Operating_System_Tag, target: string, release: bool) -> string {
get_builded_lib_path :: (platform: Operating_System_Tag, target: string, release: bool, custom_extension := "") -> string {
extension: string;
name: string;
if platform == .MACOS || platform == .IOS {
extension = "libwgpu_native.dylib";
name = "libwgpu_native";
extension = "dylib";
}

if platform == .WINDOWS {
extension = "wgpu_native.dll";
name = "wgpu_native";
extension = "dll";
}

if platform == .LINUX || platform == .ANDROID {
extension = "libwgpu_native.so";
name = "libwgpu_native";
extension = "so";
}

return sprint("./wgpu-native/target/%/%/%", target, ifx release then "release" else "debug", extension);
return sprint("./wgpu-native/target/%/%/%.%", target, ifx release then "release" else "debug", name, ifx custom_extension.count > 0 then custom_extension else extension);
}

build :: (platform: Operating_System_Tag, release := true) -> bool {
Expand Down
Binary file added wgpu/windows/libwgpu_native.lib
Binary file not shown.

0 comments on commit 154058c

Please sign in to comment.