Skip to content
Snippets Groups Projects
Commit 642e5039 authored by Elizabeth's avatar Elizabeth
Browse files

Implemented instructions generation for source code files

parent fc8fcc2a
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ def get_all_generated_directory_names():
'''
generated_dir_names = []
for dir_name in os.listdir("."):
print(dir_name)
if dir_name.endswith("autogenerated_knobs"):
generated_dir_names.append(dir_name)
return generated_dir_names
......@@ -31,17 +32,34 @@ def generate_cmakelists_setup(cmakelists_file):
BASE_CMAKELISTS_PATH = "/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/CMakeLists.txt"
base_cmakelists_file = open(BASE_CMAKELISTS_PATH, "r")
for line in base_cmakelists_file:
if line.startswith("#"):
continue
if line.find("add_executable") != -1:
break
cmakelists_file.write(line)
base_cmakelists_file.close()
def generate_cmakelists_file(cmakelists_file, source_code_dirs):
def generate_cmakelists_file(cmakelists_file, source_file_dirs):
generate_cmakelists_setup(cmakelists_file)
for source_code_dir in source_code_dirs:
pass
LIBRARIES = "tensor_runtime ${GPU_PROFILER_LIB} ${SOC_SIMULATOR_LIB}"
cmake_instrs = []
for source_file_dir in source_file_dirs:
cmake_instrs.append("# %s" % source_file_dir)
for source_file in os.listdir(source_file_dir):
# Executable name = name of source code file without file extension
file_ext_ind = source_file.find(".cc")
if file_ext_ind == -1:
print("WARNING: Found file with wrong extension. Skipping. %s" % source_file)
continue
exec_name = source_file[ : file_ext_ind]
source_file_path = os.path.join(source_file_dir, source_file)
cmake_instrs.append("add_executable(%s %s)" % (exec_name, source_file_path))
cmake_instrs.append("target_link_libraries(%s %s)\n" % (exec_name, LIBRARIES))
cmake_instrs.append("\n")
cmakelists_file.write('\n'.join(cmake_instrs))
if __name__ == "__main__":
num_args = len(sys.argv)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment