build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
def convert_target(target):
  """Converts a Bazel target to a list of CMake targets.

  IREE targets are expected to follow a standard form between Bazel and CMake
  that facilitates conversion. External targets *may* have their own patterns,
  or they may be purely special cases.

  Multiple target in Bazel may map to a single target in CMake and a Bazel
  target may map to multiple CMake targets.

  Returns:
    A list of converted targets if it was successfully converted.

  Raises:
    KeyError: No conversion was found for the target.
  """
  if target in EXPLICIT_TARGET_MAPPING:
    return EXPLICIT_TARGET_MAPPING[target]
  if target.startswith("@llvm-project//llvm"):
    return _convert_llvm_target(target)
  if target.startswith("@llvm-project//mlir"):
    return _convert_mlir_target(target)
  if target.startswith("@"):
    raise KeyError(f"No conversion found for target '{target}'")

  if target.startswith("//llvm-external-projects/iree-dialects"):
    return _convert_iree_dialects_target(target)

  # IREE root paths map to package names based on explicit rules.
  #   * src/iree/ directories (compiler/src/iree/ and runtime/src/iree/)
  #     creating their own root paths by trimming down to just "iree"
  #   * tools/ uses an empty root, for binary targets names like "iree-compile"
  #   * other top level directories add back an 'iree' prefix
  # If changing these, make the corresponding change in iree_macros.cmake
  # (iree_package_ns function).

  # Map //compiler/src/iree/(.*) -> iree::\1 (i.e. iree::compiler::\1)
  m = re.match("^//compiler/src/iree/(.+)", target)
  if m:
    return ["iree::" + _convert_to_cmake_path(m.group(1))]

  # Map //runtime/src/iree/(.*) -> iree::\1
  m = re.match("^//runtime/src/iree/(.+)", target)
  if m:
    return ["iree::" + _convert_to_cmake_path(m.group(1))]

  # Map //tools/(.*) -> \1
  m = re.match("^//tools[/|:](.+)", target)
  if m:
    return [_convert_to_cmake_path(m.group(1))]

  # Pass through package-relative targets
  #   :target_name
  #   file_name.txt
  if target.startswith(":") or ":" not in target:
    return [_convert_to_cmake_path(target)]

  # Default rewrite: prefix with "iree::", without pruning the path.
  return ["iree::" + _convert_to_cmake_path(target)]
Converts a Bazel target to a list of CMake targets.

  IREE targets are expected to follow a standard form between Bazel and CMake
  that facilitates conversion. External targets *may* have their own patterns,
  or they may be purely special cases.

  Multiple target in Bazel may map to a single target in CMake and a Bazel
  target may map to multiple CMake targets.

  Returns:
    A list of converted targets if it was successfully converted.

  Raises:
    KeyError: No conversion was found for the target.
  
Converts a Bazel target to a list of CMake targets.
IREE targets are expected to follow a standard form between Bazel and CMake
that facilitates conversion. External targets *may* have their own patterns,
or they may be purely special cases.

Multiple target in Bazel may map to a single target in CMake and a Bazel
target may map to multiple CMake targets.
Converts a Bazel target to a list of CMake targets . IREE targets are expected to follow a standard form between Bazel and CMake that facilitates conversion . External targets * may * have their own patterns or they may be purely special cases . Multiple target in Bazel may map to a single target in CMake and a Bazel target may map to multiple CMake targets .
def convert_target(target):
  if target in EXPLICIT_TARGET_MAPPING:
    return EXPLICIT_TARGET_MAPPING[target]
  if target.startswith("@llvm-project//llvm"):
    return _convert_llvm_target(target)
  if target.startswith("@llvm-project//mlir"):
    return _convert_mlir_target(target)
  if target.startswith("@"):
    raise KeyError(f"No conversion found for target '{target}'")
  if target.startswith("//llvm-external-projects/iree-dialects"):
    return _convert_iree_dialects_target(target)
  m = re.match("^//compiler/src/iree/(.+)", target)
  if m:
    return ["iree::" + _convert_to_cmake_path(m.group(1))]
  m = re.match("^//runtime/src/iree/(.+)", target)
  if m:
    return ["iree::" + _convert_to_cmake_path(m.group(1))]
  m = re.match("^//tools[/|:](.+)", target)
  if m:
    return [_convert_to_cmake_path(m.group(1))]
  if target.startswith(":") or ":" not in target:
    return [_convert_to_cmake_path(target)]
  return ["iree::" + _convert_to_cmake_path(target)]
def convert_target ( target ) : if target in EXPLICIT_TARGET_MAPPING : return EXPLICIT_TARGET_MAPPING [ target ] if target . startswith ( "@llvm-project//llvm" ) : return _convert_llvm_target ( target ) if target . startswith ( "@llvm-project//mlir" ) : return _convert_mlir_target ( target ) if target . startswith ( "@" ) : raise KeyError ( f"No conversion found for target '{target}'" ) if target . startswith ( "//llvm-external-projects/iree-dialects" ) : return _convert_iree_dialects_target ( target ) m = re . match ( "^//compiler/src/iree/(.+)" , target ) if m : return [ "iree::" + _convert_to_cmake_path ( m . group ( 1 ) ) ] m = re . match ( "^//runtime/src/iree/(.+)" , target ) if m : return [ "iree::" + _convert_to_cmake_path ( m . group ( 1 ) ) ] m = re . match ( "^//tools[/|:](.+)" , target ) if m : return [ _convert_to_cmake_path ( m . group ( 1 ) ) ] if target . startswith ( ":" ) or ":" not in target : return [ _convert_to_cmake_path ( target ) ] return [ "iree::" + _convert_to_cmake_path ( target ) ]
Converts a Bazel target to a list of CMake targets.
Converts a Bazel target to a list of CMake targets .
"""Converts a Bazel target to a list of CMake targets.

  IREE targets are expected to follow a standard form between Bazel and CMake
  that facilitates conversion. External targets *may* have their own patterns,
  or they may be purely special cases.

  Multiple target in Bazel may map to a single target in CMake and a Bazel
  target may map to multiple CMake targets.

  Returns:
    A list of converted targets if it was successfully converted.

  Raises:
    KeyError: No conversion was found for the target.
  """ # IREE root paths map to package names based on explicit rules. #   * src/iree/ directories (compiler/src/iree/ and runtime/src/iree/) #     creating their own root paths by trimming down to just "iree" #   * tools/ uses an empty root, for binary targets names like "iree-compile" #   * other top level directories add back an 'iree' prefix # If changing these, make the corresponding change in iree_macros.cmake # (iree_package_ns function). # Map //compiler/src/iree/(.*) -> iree::\1 (i.e. iree::compiler::\1) # Map //runtime/src/iree/(.*) -> iree::\1 # Map //tools/(.*) -> \1 # Pass through package-relative targets #   :target_name #   file_name.txt # Default rewrite: prefix with "iree::", without pruning the path.
A list of converted targets if it was successfully converted.
A list of converted targets if it was successfully converted .
No conversion was found for the target.
No conversion was found for the target .
KeyError
target