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:mem"
|
||||
import "core:os"
|
||||
import "core:os/os2"
|
||||
import "core:path/filepath"
|
||||
import "libs:tracy"
|
||||
|
||||
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
|
||||
// the compiler from writing to it.
|
||||
copy_dll :: proc(to: string) -> bool {
|
||||
exit: i32
|
||||
when ODIN_OS == .Windows {
|
||||
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 {
|
||||
copy_dll :: proc(bin_dir, to: string) -> bool {
|
||||
err := os2.copy_file(filepath.join({bin_dir, to}, context.temp_allocator), filepath.join({bin_dir, "game" + DLL_EXT}, context.temp_allocator), )
|
||||
if err != nil {
|
||||
fmt.printfln("Failed to copy game" + DLL_EXT + " to {0}", to)
|
||||
return false
|
||||
}
|
||||
@ -64,11 +60,22 @@ load_game_api :: proc(api_version: int) -> (api: Game_API, ok: bool) {
|
||||
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.
|
||||
game_dll_name := fmt.tprintf(
|
||||
"{0}game_{1}" + DLL_EXT,
|
||||
"./" when ODIN_OS != .Windows else "",
|
||||
api_version,
|
||||
game_dll_name := filepath.join(
|
||||
{
|
||||
cwd,
|
||||
fmt.tprintf(
|
||||
"{0}game_{1}" + DLL_EXT,
|
||||
"./" when ODIN_OS != .Windows else "",
|
||||
api_version,
|
||||
),
|
||||
},
|
||||
context.temp_allocator,
|
||||
)
|
||||
copy_dll(game_dll_name) or_return
|
||||
|
||||
@ -238,3 +245,4 @@ NvOptimusEnablement: u32 = 1
|
||||
|
||||
@(export)
|
||||
AmdPowerXpressRequestHighPerformance: i32 = 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user