view src/semicongine/vulkan/utils.nim @ 103:1e2027dfc642

add: finally working initial approach for shader definitions
author Sam <sam@basx.dev>
date Mon, 20 Mar 2023 10:25:50 +0700
parents e872cf354110
children 2d0351a68a4e
line wrap: on
line source

import std/strutils
import std/os
import std/strformat

func cleanString*(str: openArray[char]): string =
  for i in 0 ..< len(str):
    if str[i] == char(0):
      result = join(str[0 ..< i])
      break

func toCPointer*[T](list: var seq[T]): ptr T =
  if list.len > 0: addr list[0] else: nil

proc staticExecChecked*(command: string, input = ""): string {.compileTime.} =
  let (output, exitcode) = gorgeEx(
      command = command,
      input = input)
  if exitcode != 0:
    raise newException(Exception, &"Running '{command}' produced exit code: {exitcode}" & output)
  return output