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

Added code that copies over setup CMakeLists instructions

parent fe24d072
No related branches found
No related tags found
No related merge requests found
# Generates a CMakeLists.txt file for all generated files in a specific directory
# Input: Arbitrarily long list containing names of all generated files directories
# Ex: alexnet_cifar10_autogenerated_knobs mobilenet_cifar10_autogenerated_knobs
# If inputted 0 parameters: Generates CMakeLists.txt file for all generated files in CURRENT dir
import sys
import os
def get_all_generated_directory_names():
'''
Returns a list of all generated source code directories (<>_autogenerated_knobs)
in the current directory. Called when program is run with 0 args
'''
generated_dir_names = []
for dir_name in os.listdir("."):
if dir_name.endswith("autogenerated_knobs"):
generated_dir_names.append(dir_name)
return generated_dir_names
def generate_cmakelists_setup(cmakelists_file):
'''
Copies over all the setup instructions (ex: finding libraries) from a "base" CMakeLists.txt
file. Ends copyng when we find the first instance of add_executable
Args:
cmakelists_file: File object to write cmake instructions to
Assumption: All setup instructions are being any add_executable instructions
'''
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.find("add_executable") != -1:
break
cmakelists_file.write(line)
base_cmakelists_file.close()
def generate_cmakelists_file(cmakelists_file, source_code_dirs):
generate_cmakelists_setup(cmakelists_file)
for source_code_dir in source_code_dirs:
pass
if __name__ == "__main__":
num_args = len(sys.argv)
if num_args >= 2 and sys.argv[1] == "--usage":
print("python cmakelists_generator.py <names of all generated files directories>")
print("If given no parameters: Generates CMakeLists.txt file for all generated files in CURRENT directory")
exit(1)
cmakelists_file = open("CMakeLists.txt", "w")
if num_args == 1:
generate_cmakelists_file(cmakelists_file, get_all_generated_directory_names())
else:
generate_cmakelists_file(cmakelists_file, sys.argv[1:])
cmakelists_file.close()
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