<commit_before>--[[----------------------------------------------------------------------------
  premake4.lua -- <NAME>
  This file is a part of the snow engine.
------------------------------------------------------------------------------]]


-- Set up snow table
snow = {}

--[[----------------------------------------------------------------------------
  join_arrays

    Joins zero or more arrays into a single array. Discards original keys in
    input tables.
------------------------------------------------------------------------------]]
function snow.join_arrays(...)
  local result = {}
  local inputs = {...}
  for ik,iv in pairs(inputs) do
    for jk,jv in pairs(iv) do
      result[#result + 1] = jv
    end
  end
  return result
end


function snow.tostring(e)
  if e == nil then
    return ""
  elseif type(e) == "function" then
    return snow.tostring(e())
  elseif type(e) == "number" then
    return tostring(e)
  elseif type(e) == "boolean" then
    if e then
      return "1"
    else
      return "0"
    end
  else
    return tostring(e)
  end
end


--[[----------------------------------------------------------------------------
  formatrb_string

    Returns arguments combined for format.rb
------------------------------------------------------------------------------]]
function snow.formatrb_string(t)
  local result = ""
  for k,v in pairs(t) do
    result = result .. " '" .. snow.tostring(k) .. "=" .. snow.tostring(v) .. "'"
  end
  return result
end


--[[----------------------------------------------------------------------------
  get_headers

    Retrieves a list of all headers, excluding any that match the suffixes in
    the excluded_suffixes argument (if provided).
------------------------------------------------------------------------------]]
function snow.get_headers(excluded_suffixes)
  local headers = snow.join_arrays(
    os.matchfiles("include/**.hh"),
    os.matchfiles("include/**.cc"),
    os.matchfiles("include/*.hh"),
    os.matchfiles("include/*.cc") )
  local swap = {}
  for header_k, header_path in pairs(headers) do
    if excluded_suffixes then
      -- Check for exclusions
      for excl_k, excl_suffix in pairs(excluded_suffixes) do
        if string.endswith(header_path, excl_suffix) then
          print(excl_k .. ": Excluding " .. header_path)
          header_path = nil
          break
        end -- if matches excluded header
      end -- for in excluded_suffixes
    end -- if excluded_suffixes

    if header_path then
      swap[header_path] = header_path
    end
  end -- for in headers
  return swap
end


function snow.install(source_path, install_path, verbose)
  if verbose then
    print("Installing '" .. source_path .."' to '" .. install_path .. "'")
  end
  local done, errmsg = os.copyfile(source_path, install_path)
  if not done then
    print("os.copyfile: " .. errms)
    print("Unable to copy " .. source_path, " unable to continue installation")
    return false
  end
  return true
end


function snow.correct_dirsep(str)
  if os.is("windows") then
    return string.gsub(str, "/", "\\")
  else
    return string.gsub(str, "\\", "/")
  end
end


function snow.dirname(str)
  local last = string.findlast(str, "/", true)
  if last ~= nil then
    return string.sub(str, 0, last)
  end
  return str
end


function snow.mkdir_p(path)
  local dirsep = "/"
  if os.is("windows") then
    dirsep = "\\"
  end

  local components = string.explode(path, "/")
  local last_dir = 0

  do -- Make sure nothing along the way is a file
    local dir_build = ""
    for i, v in ipairs(components) do
      if v ~= "" then
        dir_build = dir_build .. dirsep .. v
        if os.isdir(dir_build) == true then
          last_dir = i
        elseif os.isfile(dir_build) then
          return false -- Cannot create dir if file of the same name exists already
        end
      end
    end -- for in components
  end -- do check path

  do
    local dir_build = ""
    for i, v in ipairs(components) do
      if #v > 0 then
        dir_build = dir_build .. dirsep .. v
        if i > last_dir then
          local done, errmsg = os.mkdir(dir_build)
          if not done then
            print("Unable to create directory: " .. dir_build)
            return false
          end -- if not done
        end -- if i > last_dir
      end
    end -- for in components
  end -- do build directory

  return true
end -- mkdir_p



-- Main build configuration

solution "snow"
configurations { "debug", "release" }

project "snow_c_libs"
kind "StaticLib"
targetdir "lib"
language "C"
files { "src/ext/sqlite3.c", "src/ext/stb_image.c" }
buildoptions { "-arch x86_64" }

project "snow"

configuration {}

targetdir "bin"
kind "WindowedApp"

-- links { "lua" }

-- Option defaults
g_exclude_suffixes = {}

-- Build options
newoption {
  trigger = "no-exceptions",
  description = "Disables exceptions in snow-common -- replaces throws with exit(1)"
}

newoption {
  trigger = "no-server",
  description = "Disables the server code in the engine build"
}
<commit_msg>Replace Lua for AngelScript when linking.<commit_after>--[[----------------------------------------------------------------------------
  premake4.lua -- <NAME>
  This file is a part of the snow engine.
------------------------------------------------------------------------------]]


-- Set up snow table
snow = {}

--[[----------------------------------------------------------------------------
  join_arrays

    Joins zero or more arrays into a single array. Discards original keys in
    input tables.
------------------------------------------------------------------------------]]
function snow.join_arrays(...)
  local result = {}
  local inputs = {...}
  for ik,iv in pairs(inputs) do
    for jk,jv in pairs(iv) do
      result[#result + 1] = jv
    end
  end
  return result
end


function snow.tostring(e)
  if e == nil then
    return ""
  elseif type(e) == "function" then
    return snow.tostring(e())
  elseif type(e) == "number" then
    return tostring(e)
  elseif type(e) == "boolean" then
    if e then
      return "1"
    else
      return "0"
    end
  else
    return tostring(e)
  end
end


--[[----------------------------------------------------------------------------
  formatrb_string

    Returns arguments combined for format.rb
------------------------------------------------------------------------------]]
function snow.formatrb_string(t)
  local result = ""
  for k,v in pairs(t) do
    result = result .. " '" .. snow.tostring(k) .. "=" .. snow.tostring(v) .. "'"
  end
  return result
end


--[[----------------------------------------------------------------------------
  get_headers

    Retrieves a list of all headers, excluding any that match the suffixes in
    the excluded_suffixes argument (if provided).
------------------------------------------------------------------------------]]
function snow.get_headers(excluded_suffixes)
  local headers = snow.join_arrays(
    os.matchfiles("include/**.hh"),
    os.matchfiles("include/**.cc"),
    os.matchfiles("include/*.hh"),
    os.matchfiles("include/*.cc") )
  local swap = {}
  for header_k, header_path in pairs(headers) do
    if excluded_suffixes then
      -- Check for exclusions
      for excl_k, excl_suffix in pairs(excluded_suffixes) do
        if string.endswith(header_path, excl_suffix) then
          print(excl_k .. ": Excluding " .. header_path)
          header_path = nil
          break
        end -- if matches excluded header
      end -- for in excluded_suffixes
    end -- if excluded_suffixes

    if header_path then
      swap[header_path] = header_path
    end
  end -- for in headers
  return swap
end


function snow.install(source_path, install_path, verbose)
  if verbose then
    print("Installing '" .. source_path .."' to '" .. install_path .. "'")
  end
  local done, errmsg = os.copyfile(source_path, install_path)
  if not done then
    print("os.copyfile: " .. errms)
    print("Unable to copy " .. source_path, " unable to continue installation")
    return false
  end
  return true
end


function snow.correct_dirsep(str)
  if os.is("windows") then
    return string.gsub(str, "/", "\\")
  else
    return string.gsub(str, "\\", "/")
  end
end


function snow.dirname(str)
  local last = string.findlast(str, "/", true)
  if last ~= nil then
    return string.sub(str, 0, last)
  end
  return str
end


function snow.mkdir_p(path)
  local dirsep = "/"
  if os.is("windows") then
    dirsep = "\\"
  end

  local components = string.explode(path, "/")
  local last_dir = 0

  do -- Make sure nothing along the way is a file
    local dir_build = ""
    for i, v in ipairs(components) do
      if v ~= "" then
        dir_build = dir_build .. dirsep .. v
        if os.isdir(dir_build) == true then
          last_dir = i
        elseif os.isfile(dir_build) then
          return false -- Cannot create dir if file of the same name exists already
        end
      end
    end -- for in components
  end -- do check path

  do
    local dir_build = ""
    for i, v in ipairs(components) do
      if #v > 0 then
        dir_build = dir_build .. dirsep .. v
        if i > last_dir then
          local done, errmsg = os.mkdir(dir_build)
          if not done then
            print("Unable to create directory: " .. dir_build)
            return false
          end -- if not done
        end -- if i > last_dir
      end
    end -- for in components
  end -- do build directory

  return true
end -- mkdir_p



-- Main build configuration

solution "snow"
configurations { "debug", "release" }

project "snow_c_libs"
kind "StaticLib"
targetdir "lib"
language "C"
files { "src/ext/sqlite3.c", "src/ext/stb_image.c" }
buildoptions { "-arch x86_64" }

project "snow"

configuration {}

targetdir "bin"
kind "WindowedApp"

links { "angelscript" }

-- Option defaults
g_exclude_suffixes = {}

-- Build options
newoption {
  trigger = "no-exceptions",
  description = "Disables exceptions in snow-common -- replaces throws with exit(1)"
}

newoption {
  trigger = "no-server",
  description = "Disables the server code in the engine build"
}

{'fraction_non_alphanumeric': 0.22063037249283668, 'fraction_numerical': 0.0025689161150083983, 'mean_word_length': 1.6777777777777778, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1010218', 'n_tokens_mistral': 2955, 'n_tokens_neox': 2869, 'n_words': 919}