Start handling hot reload game lib in build dir
This commit is contained in:
parent
04133ef95a
commit
875ff96f4a
@ -8,6 +8,8 @@ import "core:fmt"
|
|||||||
import "core:log"
|
import "core:log"
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
|
import "core:os/os2"
|
||||||
|
import "core:path/filepath"
|
||||||
import "libs:tracy"
|
import "libs:tracy"
|
||||||
|
|
||||||
when ODIN_OS == .Windows {
|
when ODIN_OS == .Windows {
|
||||||
@ -22,15 +24,9 @@ TRACY_ENABLE :: #config(TRACY_ENABLE, false)
|
|||||||
|
|
||||||
// We copy the DLL because using it directly would lock it, which would prevent
|
// We copy the DLL because using it directly would lock it, which would prevent
|
||||||
// the compiler from writing to it.
|
// the compiler from writing to it.
|
||||||
copy_dll :: proc(to: string) -> bool {
|
copy_dll :: proc(bin_dir, to: string) -> bool {
|
||||||
exit: i32
|
err := os2.copy_file(filepath.join({bin_dir, to}, context.temp_allocator), filepath.join({bin_dir, "game" + DLL_EXT}, context.temp_allocator), )
|
||||||
when ODIN_OS == .Windows {
|
if err != nil {
|
||||||
exit = libc.system(fmt.ctprintf("copy game.dll {0}", to))
|
|
||||||
} else {
|
|
||||||
exit = libc.system(fmt.ctprintf("cp game" + DLL_EXT + " {0}", to))
|
|
||||||
}
|
|
||||||
|
|
||||||
if exit != 0 {
|
|
||||||
fmt.printfln("Failed to copy game" + DLL_EXT + " to {0}", to)
|
fmt.printfln("Failed to copy game" + DLL_EXT + " to {0}", to)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -64,11 +60,22 @@ load_game_api :: proc(api_version: int) -> (api: Game_API, ok: bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cwd, err := os2.getwd(context.temp_allocator)
|
||||||
|
if err != nil {
|
||||||
|
log.panicf("getcwd: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: this needs to be a relative path for Linux to work.
|
// NOTE: this needs to be a relative path for Linux to work.
|
||||||
game_dll_name := fmt.tprintf(
|
game_dll_name := filepath.join(
|
||||||
"{0}game_{1}" + DLL_EXT,
|
{
|
||||||
"./" when ODIN_OS != .Windows else "",
|
cwd,
|
||||||
api_version,
|
fmt.tprintf(
|
||||||
|
"{0}game_{1}" + DLL_EXT,
|
||||||
|
"./" when ODIN_OS != .Windows else "",
|
||||||
|
api_version,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
context.temp_allocator,
|
||||||
)
|
)
|
||||||
copy_dll(game_dll_name) or_return
|
copy_dll(game_dll_name) or_return
|
||||||
|
|
||||||
@ -238,3 +245,4 @@ NvOptimusEnablement: u32 = 1
|
|||||||
|
|
||||||
@(export)
|
@(export)
|
||||||
AmdPowerXpressRequestHighPerformance: i32 = 1
|
AmdPowerXpressRequestHighPerformance: i32 = 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user