Rename main source files used directly in cc binaries (#3249)
These naming diffs are frequently confusing, I find. This consistently
names the file after the primary binary in which it is used (if
applicable) suffixed with `main.cc` separated with a dash or an
underscore depending on what is used in that binary.
This is also motivated by absl flags behavior. Absl uses the name of
the binary to determine which flags to include in `--help` by default:
those from source files whose basename match the binary name with an
optional (`-main` or `_main` suffix) get included.
We do have the option of customizing the absl behavior instead if we
have strong feelings about alternative naming schemes.
Part of https://github.com/google/iree/issues/3247
diff --git a/build_tools/cmake/iree_cc_binary.cmake b/build_tools/cmake/iree_cc_binary.cmake
index a3ca951..2c76d2d 100644
--- a/build_tools/cmake/iree_cc_binary.cmake
+++ b/build_tools/cmake/iree_cc_binary.cmake
@@ -53,7 +53,7 @@
# OUT
# awesome-tool
# SRCS
-# "awesome_tool_main.cc"
+# "awesome-tool-main.cc"
# DEPS
# iree::awesome
# )
diff --git a/build_tools/embed_data/BUILD b/build_tools/embed_data/BUILD
index 593f874..57cf2a2 100644
--- a/build_tools/embed_data/BUILD
+++ b/build_tools/embed_data/BUILD
@@ -24,7 +24,7 @@
cc_binary(
name = "generate_cc_embed_data",
- srcs = ["generate_cc_embed_data.cc"],
+ srcs = ["generate_cc_embed_data_main.cc"],
deps = [
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
diff --git a/build_tools/embed_data/CMakeLists.txt b/build_tools/embed_data/CMakeLists.txt
index 4efad40..ed9a879 100644
--- a/build_tools/embed_data/CMakeLists.txt
+++ b/build_tools/embed_data/CMakeLists.txt
@@ -16,7 +16,7 @@
iree_declare_host_excutable(generate_cc_embed_data)
else()
add_executable(generate_cc_embed_data)
- target_sources(generate_cc_embed_data PRIVATE generate_cc_embed_data.cc)
+ target_sources(generate_cc_embed_data PRIVATE generate_cc_embed_data_main.cc)
set_target_properties(generate_cc_embed_data PROPERTIES OUTPUT_NAME generate_cc_embed_data)
target_link_libraries(generate_cc_embed_data
diff --git a/build_tools/embed_data/generate_cc_embed_data.cc b/build_tools/embed_data/generate_cc_embed_data_main.cc
similarity index 100%
rename from build_tools/embed_data/generate_cc_embed_data.cc
rename to build_tools/embed_data/generate_cc_embed_data_main.cc
diff --git a/integrations/tensorflow/compiler/BUILD b/integrations/tensorflow/compiler/BUILD
index e5f9111..adba6af 100644
--- a/integrations/tensorflow/compiler/BUILD
+++ b/integrations/tensorflow/compiler/BUILD
@@ -56,7 +56,7 @@
cc_binary(
name = "iree-tf-opt",
- srcs = ["tf_opt_main.cc"],
+ srcs = ["iree-tf-opt-main.cc"],
deps = [
":tensorflow",
"//integrations/tensorflow/compiler/dialect/tf_strings/ir:dialect",
diff --git a/integrations/tensorflow/compiler/tf_opt_main.cc b/integrations/tensorflow/compiler/iree-tf-opt-main.cc
similarity index 100%
rename from integrations/tensorflow/compiler/tf_opt_main.cc
rename to integrations/tensorflow/compiler/iree-tf-opt-main.cc
diff --git a/iree/modules/check/BUILD b/iree/modules/check/BUILD
index 2a8911d..ef7e64d 100644
--- a/iree/modules/check/BUILD
+++ b/iree/modules/check/BUILD
@@ -50,7 +50,7 @@
iree_cc_binary(
name = "iree-check-module",
testonly = True,
- srcs = ["check_module_main.cc"],
+ srcs = ["iree-check-module-main.cc"],
deps = [
":native_module",
"@com_google_absl//absl/flags:flag",
diff --git a/iree/modules/check/CMakeLists.txt b/iree/modules/check/CMakeLists.txt
index 0f6ef68..84a23d0 100644
--- a/iree/modules/check/CMakeLists.txt
+++ b/iree/modules/check/CMakeLists.txt
@@ -45,7 +45,7 @@
OUT
iree-check-module
SRCS
- "check_module_main.cc"
+ "iree-check-module-main.cc"
DEPS
::native_module
absl::flags
diff --git a/iree/modules/check/check_module_main.cc b/iree/modules/check/iree-check-module-main.cc
similarity index 100%
rename from iree/modules/check/check_module_main.cc
rename to iree/modules/check/iree-check-module-main.cc
diff --git a/iree/samples/custom_modules/dialect/BUILD b/iree/samples/custom_modules/dialect/BUILD
index c5e2353..6a2ad1f 100644
--- a/iree/samples/custom_modules/dialect/BUILD
+++ b/iree/samples/custom_modules/dialect/BUILD
@@ -91,7 +91,7 @@
iree_cc_binary(
name = "custom-opt",
- srcs = ["custom_opt.cc"],
+ srcs = ["custom-opt-main.cc"],
deps = [
":init_dialect",
"//iree/compiler/Conversion:init_conversions",
@@ -136,7 +136,7 @@
iree_cc_binary(
name = "custom-translate",
- srcs = ["custom_translate.cc"],
+ srcs = ["custom-translate-main.cc"],
deps = [
":init_dialect",
"//iree/compiler/Conversion:init_conversions",
diff --git a/iree/samples/custom_modules/dialect/CMakeLists.txt b/iree/samples/custom_modules/dialect/CMakeLists.txt
index 9813c66..92edb07 100644
--- a/iree/samples/custom_modules/dialect/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/CMakeLists.txt
@@ -83,7 +83,7 @@
OUT
custom-opt
SRCS
- "custom_opt.cc"
+ "custom-opt-main.cc"
DEPS
::init_dialect
LLVMSupport
@@ -130,7 +130,7 @@
OUT
custom-translate
SRCS
- "custom_translate.cc"
+ "custom-translate-main.cc"
DEPS
::init_dialect
LLVMSupport
diff --git a/iree/samples/custom_modules/dialect/custom_opt.cc b/iree/samples/custom_modules/dialect/custom-opt-main.cc
similarity index 98%
rename from iree/samples/custom_modules/dialect/custom_opt.cc
rename to iree/samples/custom_modules/dialect/custom-opt-main.cc
index 70cc975..d5066d7 100644
--- a/iree/samples/custom_modules/dialect/custom_opt.cc
+++ b/iree/samples/custom_modules/dialect/custom-opt-main.cc
@@ -13,7 +13,7 @@
// limitations under the License.
// Main entry function for custom-opt.
-// Based on the iree-opt main entry function (opt_main.cc).
+// Based on the iree-opt main entry function (iree-opt-main.cc).
//
// We need this entry function because we want to register the custom
// dialect, which is missing in IREE's opt main entry function.
diff --git a/iree/samples/custom_modules/dialect/custom_translate.cc b/iree/samples/custom_modules/dialect/custom-translate-main.cc
similarity index 97%
rename from iree/samples/custom_modules/dialect/custom_translate.cc
rename to iree/samples/custom_modules/dialect/custom-translate-main.cc
index 2b75b50..5954800 100644
--- a/iree/samples/custom_modules/dialect/custom_translate.cc
+++ b/iree/samples/custom_modules/dialect/custom-translate-main.cc
@@ -13,7 +13,7 @@
// limitations under the License.
// Custom translation main entry function.
-// Based on the iree-translate main entry function (translate_main.cc).
+// Based on the iree-translate main entry function (iree-translate-main.cc).
//
// We need this entry function because we want to register the custom
// dialect, which is missing in IREE's translation main entry function.
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index 14e6c17..530e835 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -36,7 +36,7 @@
iree_cc_binary(
name = "iree-benchmark-module",
testonly = True,
- srcs = ["benchmark_module_main.cc"],
+ srcs = ["iree-benchmark-module-main.cc"],
deps = [
":vm_util",
"@com_google_absl//absl/flags:flag",
@@ -54,7 +54,7 @@
iree_cc_binary(
name = "iree-dump-module",
- srcs = ["dump_module_main.cc"],
+ srcs = ["iree-dump-module-main.cc"],
deps = [
"//iree/base:file_io", # build-cleaner: keep
"//iree/base:flatbuffer_util",
@@ -180,7 +180,7 @@
cc_library(
name = "iree_opt_main",
- srcs = ["opt_main.cc"],
+ srcs = ["iree-opt-main.cc"],
deps = [
":init_compiler_modules",
":init_iree_passes_and_dialects",
@@ -233,7 +233,7 @@
iree_cc_binary(
name = "iree-run-mlir",
- srcs = ["run_mlir_main.cc"],
+ srcs = ["iree-run-mlir-main.cc"],
tags = ["hostonly"],
deps = [
":init_compiler_modules",
@@ -270,7 +270,7 @@
iree_cc_binary(
name = "iree-run-module",
- srcs = ["run_module_main.cc"],
+ srcs = ["iree-run-module-main.cc"],
deps = [
":vm_util",
"@com_google_absl//absl/flags:flag",
@@ -299,7 +299,7 @@
cc_library(
name = "iree_translate_main",
- srcs = ["translate_main.cc"],
+ srcs = ["iree-translate-main.cc"],
deps = [
":init_compiler_modules",
":init_iree_passes_and_dialects",
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index a0a78e0..9a073c6 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -55,7 +55,7 @@
OUT
iree-benchmark-module
SRCS
- "benchmark_module_main.cc"
+ "iree-benchmark-module-main.cc"
DEPS
::vm_util
absl::flags
@@ -78,7 +78,7 @@
OUT
iree-dump-module
SRCS
- "dump_module_main.cc"
+ "iree-dump-module-main.cc"
DEPS
flatbuffers
iree::base::file_io
@@ -93,7 +93,7 @@
OUT
iree-run-module
SRCS
- "run_module_main.cc"
+ "iree-run-module-main.cc"
DEPS
::vm_util
absl::flags
@@ -236,7 +236,7 @@
NAME
iree_opt_main
SRCS
- "opt_main.cc"
+ "iree-opt-main.cc"
DEPS
::init_compiler_modules
::init_iree_passes_and_dialects
@@ -282,7 +282,7 @@
NAME
iree_translate_main
SRCS
- "translate_main.cc"
+ "iree-translate-main.cc"
DEPS
::init_compiler_modules
::init_iree_passes_and_dialects
@@ -320,7 +320,7 @@
OUT
iree-run-mlir
SRCS
- "run_mlir_main.cc"
+ "iree-run-mlir-main.cc"
DEPS
::init_compiler_modules
::init_iree_passes_and_dialects
diff --git a/iree/tools/benchmark_module_main.cc b/iree/tools/iree-benchmark-module-main.cc
similarity index 100%
rename from iree/tools/benchmark_module_main.cc
rename to iree/tools/iree-benchmark-module-main.cc
diff --git a/iree/tools/dump_module_main.cc b/iree/tools/iree-dump-module-main.cc
similarity index 100%
rename from iree/tools/dump_module_main.cc
rename to iree/tools/iree-dump-module-main.cc
diff --git a/iree/tools/opt_main.cc b/iree/tools/iree-opt-main.cc
similarity index 100%
rename from iree/tools/opt_main.cc
rename to iree/tools/iree-opt-main.cc
diff --git a/iree/tools/run_mlir_main.cc b/iree/tools/iree-run-mlir-main.cc
similarity index 100%
rename from iree/tools/run_mlir_main.cc
rename to iree/tools/iree-run-mlir-main.cc
diff --git a/iree/tools/run_module_main.cc b/iree/tools/iree-run-module-main.cc
similarity index 100%
rename from iree/tools/run_module_main.cc
rename to iree/tools/iree-run-module-main.cc
diff --git a/iree/tools/translate_main.cc b/iree/tools/iree-translate-main.cc
similarity index 100%
rename from iree/tools/translate_main.cc
rename to iree/tools/iree-translate-main.cc