<commit_before>require "Build"
require "Utils"
require "../Helpers"

local llvm = path.getabsolute(basedir .. "/../deps/llvm")

-- If we are inside vagrant then clone and build LLVM outside the shared folder,
-- otherwise file I/O performance will be terrible.
if is_vagrant() then
	llvm = os.getenv("HOME") .. "/llvm"
end

function get_llvm_rev()
	return cat(basedir .. "/LLVM-commit")
end

function get_clang_rev()
	return cat(basedir .. "/Clang-commit")
end

function clone_llvm()
  local llvm_release = get_llvm_rev()
  print("LLVM release: " .. llvm_release)

  local clang_release = get_clang_rev()
  print("Clang release: " .. clang_release)

  if os.isdir(llvm) and not os.isdir(llvm .. "/.git") then
    error("LLVM directory is not a git repository.")
  end

  if not os.isdir(llvm) then
    git.clone(llvm, "https://github.com/llvm-mirror/llvm.git")
  else
    git.reset_hard(llvm, "HEAD")
    git.pull_rebase(llvm)
  end

  local clang = llvm .. "/tools/clang"
  if not os.isdir(clang) then
    git.clone(clang, "https://github.com/llvm-mirror/clang.git")
  else
    git.reset_hard(clang, "HEAD")
    git.pull_rebase(clang)
  end

  git.reset_hard(llvm, llvm_release)
  git.reset_hard(clang, clang_release)
end

function get_toolset_configuration_name()
  if os.is("windows") then
    local function get_vs_version(ver)
      if     ver == "19" then return "vs2015"
      elseif ver == "18" then return "vs2013"
      elseif ver == "17" then return "vs2012"
      else error("Unknown MSVC compiler version, run in VS command prompt.") end
    end

    local vsver = _ACTION
    local arch = "x86"

    if not string.starts(vsver, "vs") then
      local out = outputof("cl")
      local ver, arch = string.match(out, 'Version (%d+)%.%d+%.%d+%.?%d* for (%w+)')
      vsver = get_vs_version(ver)
    end<commit_msg>Fixed DownloadDeps.bat with Visual Studio<commit_after>require "Build"
require "Utils"
require "../Helpers"

local llvm = path.getabsolute(basedir .. "/../deps/llvm")

-- If we are inside vagrant then clone and build LLVM outside the shared folder,
-- otherwise file I/O performance will be terrible.
if is_vagrant() then
	llvm = os.getenv("HOME") .. "/llvm"
end

function get_llvm_rev()
	return cat(basedir .. "/LLVM-commit")
end

function get_clang_rev()
	return cat(basedir .. "/Clang-commit")
end

function clone_llvm()
  local llvm_release = get_llvm_rev()
  print("LLVM release: " .. llvm_release)

  local clang_release = get_clang_rev()
  print("Clang release: " .. clang_release)

  if os.isdir(llvm) and not os.isdir(llvm .. "/.git") then
    error("LLVM directory is not a git repository.")
  end

  if not os.isdir(llvm) then
    git.clone(llvm, "https://github.com/llvm-mirror/llvm.git")
  else
    git.reset_hard(llvm, "HEAD")
    git.pull_rebase(llvm)
  end

  local clang = llvm .. "/tools/clang"
  if not os.isdir(clang) then
    git.clone(clang, "https://github.com/llvm-mirror/clang.git")
  else
    git.reset_hard(clang, "HEAD")
    git.pull_rebase(clang)
  end

  git.reset_hard(llvm, llvm_release)
  git.reset_hard(clang, clang_release)
end

function get_toolset_configuration_name()
  if os.is("windows") then
    local function get_vs_version(ver)
      if     ver == "19" then return "vs2015"
      elseif ver == "18" then return "vs2013"
      elseif ver == "17" then return "vs2012"
      else error("Unknown MSVC compiler version, run in VS command prompt.") end
    end

    local vsver = _ACTION
    local arch = "x86"

    if not string.starts(vsver, "vs") then
      local out = outputof("cl")
      local ver, arch = string.match(out, '(%d+).%d+.%d+.?%d*%s+%w*%s+(%w+)')
      vsver = get_vs_version(ver)
    end
{'fraction_non_alphanumeric': 0.13791223766693922, 'fraction_numerical': 0.010902153175252113, 'mean_word_length': 3.374255065554231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1421435', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1291, 'n_words': 346}