Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding optional build argument to startbfs script
  • Loading branch information
grf14003 committed Mar 10, 2020
1 parent 1c500bd commit b5004ca
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ bfs/build/*
bfs/bin/*
!bfs/bin/.blank
*.log
*__pycache__*
95 changes: 52 additions & 43 deletions bfs/scripts/buildbfs.py
Expand Up @@ -2,56 +2,65 @@
import os
import glob

root_bfs_dir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
print("Root BFS directory at:", root_bfs_dir)
build_dir = os.path.join(root_bfs_dir, "build")
print("Build directory at:", build_dir)
auto_build_dir = os.path.join(build_dir, "auto_build")
if not os.path.exists(auto_build_dir):
os.mkdir(auto_build_dir)
print("Creating auto build directory...")
print("Auto build directory at:", auto_build_dir)

print("Changing direcory to auto build dir...")
os.chdir(auto_build_dir)

cmake_bin = None

vs_cmake_path_pattern = "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\*\\*\\COMMON*\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe"
print("Searching for cmake installation in visual studio install location at %s" % vs_cmake_path_pattern)
possible_paths = glob.glob(vs_cmake_path_pattern)
if len(possible_paths) > 0:
cmake_bin = possible_paths[0]

if cmake_bin is None:
sys_cmake_path_pattern = "C:\\Program Files (x86)\\CMake*\\bin\\cmake.exe"
print("cmake bin\\ not found, searching for system installation at %s" % sys_cmake_bin_directory)
possible_paths = glob.glob(sys_cmake_path_pattern)
def build_bfs():

root_bfs_dir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
print("Root BFS directory at:", root_bfs_dir)
build_dir = os.path.join(root_bfs_dir, "build")
print("Build directory at:", build_dir)
auto_build_dir = os.path.join(build_dir, "auto_build")
if not os.path.exists(auto_build_dir):
os.mkdir(auto_build_dir)
print("Creating auto build directory...")
print("Auto build directory at:", auto_build_dir)

print("Changing direcory to auto build dir...")
prev_cur_dir = os.getcwd()
os.chdir(auto_build_dir)

cmake_bin = None

vs_cmake_path_pattern = "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\*\\*\\COMMON*\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe"
print("Searching for cmake installation in visual studio install location at %s" % vs_cmake_path_pattern)
possible_paths = glob.glob(vs_cmake_path_pattern)
if len(possible_paths) > 0:
cmake_bin = possible_paths[0]

if cmake_bin is None:
print("No cmake directory found, try installing it through visual studio or through your system and retrying!")
quit()
else:
print("Cmake binary location found at: %s" % cmake_bin)
cmake_installation = "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\2019\\COMMUNITY\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe"
if cmake_bin is None:
sys_cmake_path_pattern = "C:\\Program Files (x86)\\CMake*\\bin\\cmake.exe"
print("cmake bin\\ not found, searching for system installation at %s" % sys_cmake_bin_directory)
possible_paths = glob.glob(sys_cmake_path_pattern)
if len(possible_paths) > 0:
cmake_bin = possible_paths[0]

if cmake_bin is None:
print("No cmake directory found, try installing it through visual studio or through your system and retrying!")
quit()
else:
print("Cmake binary location found at: %s" % cmake_bin)
cmake_installation = "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\2019\\COMMUNITY\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe"

clean_command = "\"%s\" --clean ..\\.." % cmake_bin
build_command = "\"%s\" --build ." % cmake_bin


def start_build_program(program):
if not isinstance(program, str):
raise ValueError("Argument passed to start_program_sync() should be a string")
print("\n======> Running command: %s <======" % program)
return os.system("CMD /c \"%s\"" % program)

clean_command = "\"%s\" --clean ..\\.." % cmake_bin
build_command = "\"%s\" --build ." % cmake_bin

# While located in the bfs\build\auto_build directory...

def start_program(program):
if not isinstance(program, str):
raise ValueError("Argument passed to start_program_sync() should be a string")
print("\n======> Running command: %s <======" % program)
return os.system("CMD /c \"%s\"" % program)
# cmake --clean ..\..
start_build_program(clean_command)

# cmake --build .
start_build_program(build_command)

# While located in the bfs\build\auto_build directory...
os.chdir(prev_cur_dir)

# cmake --clean ..\..
start_program(clean_command)

# cmake --build .
start_program(build_command)
if __name__ == "__main__":
build_bfs()
17 changes: 17 additions & 0 deletions bfs/scripts/log.txt
Expand Up @@ -21,3 +21,20 @@ Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Could not acquire mutex to add new client thread
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Could not acquire mutex to add new client thread
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
8 changes: 8 additions & 0 deletions bfs/scripts/startbfs.py
Expand Up @@ -4,6 +4,8 @@ import argparse
import subprocess
import multiprocessing as mp

from buildbfs import build_bfs

os.chdir(os.path.dirname(os.path.abspath(__file__)))


Expand All @@ -17,6 +19,7 @@ def start_program_async(program):
# TODO: This needs to account for the number of cores...
# Add another function called start_programs_async that takes a list
# of programs and starts them on the proper cores.
print("\n======> Starting ASYNC: %s <======" % program)
p = mp.Process(target=start_program, args=(program,))
p.start()
return p
Expand Down Expand Up @@ -60,8 +63,13 @@ processors to run. It can also specify settings for the individual IO Processors
config file will be divided up into smaller config files (one for each process run) that the respective processes
will read and adjust their settings accordingly. That way, each process only has access to their own config settings.
Note: this can be used in conjunction with -a and -p, but care is necessary to not produce any duplicate proceses.""")
parser.add_argument("-b", "--build", help="If specified, run buildbfs.py before proceeding.", action="store_true")
args = parser.parse_args()

if args.build:
print("=====> Building BFS")
build_bfs()

binary_path = os.path.abspath("..\\bin")
exe_ending = ".exe"
exe_names = get_exe_names(args.algorithm, args.io_processor, args.config)
Expand Down

0 comments on commit b5004ca

Please sign in to comment.