import platform


def get_vcpkg_triplet(arch, msvc_runtime_library='static'):
  """Get vcpkg target triplet (platform definition).

  Args:
    arch (str): Architecture (eg: 'x86', 'x64').
    msvc_runtime_library (str): Runtime library for MSVC.
                                (eg: 'static', 'dynamic').

  Raises:
    ValueError: If current OS is not win, mac or linux.

  Returns:
    (str): Triplet name.
       Eg: "x64-windows-static".
  """
  triplet_name = [arch]
  if platform.system() == 'Windows':
    triplet_name.append('windows')
    triplet_name.append('static')
    if msvc_runtime_library == 'dynamic':
      triplet_name.append('md')
  elif platform.system() == 'Darwin':
    triplet_name.append('osx')
  elif platform.system() == 'Linux':
    triplet_name.append('linux')
  else:
    raise ValueError('Unsupported platform. This function works only on '
                     'Windows, Linux or Mac platforms.')

  triplet_name = '-'.join(triplet_name)
  print('Using vcpkg triplet: {0}'.format(triplet_name))
  return triplet_name