From 1c500bd9e239a35891add3cf29783e0ef6d64b89 Mon Sep 17 00:00:00 2001 From: Greg Foss Date: Tue, 10 Mar 2020 13:22:40 -0400 Subject: [PATCH] Adding automated build python script --- bfs/CMakeLists.txt | 6 ++- bfs/bin/.blank | 0 .../breadcrumbs/algos/AlgoBreadcrumbs.cpp | 1 + bfs/scripts/buildbfs.py | 52 +++++++++++++++++-- bfs/scripts/log.txt | 15 ------ 5 files changed, 52 insertions(+), 22 deletions(-) delete mode 100644 bfs/bin/.blank diff --git a/bfs/CMakeLists.txt b/bfs/CMakeLists.txt index 36c1fe9..e406ff1 100644 --- a/bfs/CMakeLists.txt +++ b/bfs/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required (VERSION 2.6) message("Starting CMAKE") +set(MSVC true) project(Bfs) string(TOLOWER ${PROJECT_NAME} ROOT_FOLDER_DIRNAME) # The version number. @@ -12,6 +13,8 @@ message("Setting paths...") set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src) # Code directory set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build) # Object files and such (.o) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) # Compiled executables for execution and test (.exe) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin) # Compiled executables for execution and test (.exe) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin) # Compiled executables for execution and test (.exe) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib) # Compiled libraries (.lib and .dll) set(CMAKE_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) # Publicly accessible header files set(IMPLEMENATION_PATH ${PROJECT_SOURCE_DIR}/implementations) @@ -114,7 +117,7 @@ foreach(IMPL IN LISTS IMPLEMENTAIONS) # configure which files are included in which exe's foreach(X IN LISTS IMPL_EXECS) get_filename_component(N ${X} NAME_WE) - message(STATUS "Generating Executable: ${N}.exe Main File: ${X}"}) + message(STATUS "Generating Executable: ${N}.exe Main File: ${X}") # Including any DLLs or LIBs set(ALL_LIBS "") @@ -130,7 +133,6 @@ foreach(IMPL IN LISTS IMPLEMENTAIONS) message("Adding DLL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DLL_N}") file(COPY ${DLL} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endforeach() - foreach(LIB IN ITEMS ${LIBS}) get_filename_component(LIB_N ${LIB} NAME_WE) find_library(${LIB_N} NAME ${LIB_N}.lib PATHS ${LIB}) diff --git a/bfs/bin/.blank b/bfs/bin/.blank deleted file mode 100644 index e69de29..0000000 diff --git a/bfs/implementations/breadcrumbs/algos/AlgoBreadcrumbs.cpp b/bfs/implementations/breadcrumbs/algos/AlgoBreadcrumbs.cpp index 7bdba8f..9215193 100644 --- a/bfs/implementations/breadcrumbs/algos/AlgoBreadcrumbs.cpp +++ b/bfs/implementations/breadcrumbs/algos/AlgoBreadcrumbs.cpp @@ -4,6 +4,7 @@ void AlgoBreadcrumbs::loop() { + printf("Hello world!\n"); vector* attribs = pollForAttributes(); if (attribs->size() > 0) { diff --git a/bfs/scripts/buildbfs.py b/bfs/scripts/buildbfs.py index fa901d0..466fdff 100644 --- a/bfs/scripts/buildbfs.py +++ b/bfs/scripts/buildbfs.py @@ -1,15 +1,57 @@ import os -os.chdir(os.path.dirname(os.path.abspath(__file__))) +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) + 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" -compile_command = 'C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\2019\\COMMUNITY\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:/Users/Greg/Documents/git/bfs/breadcrumbs/install/basic_build" -DCMAKE_INSTALL_PREFIX:PATH="C:/Users/Greg/Documents/git/bfs/breadcrumbs/install/basic_build" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\2019\\COMMUNITY\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\Ninja\\ninja.exe" "C:\\Users\\Greg\\Documents\\git\\bfs\\bfs" 2>&1' -test_command = "C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO\\2019\\COMMUNITY\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\CMAKE\\CMake\\bin\\cmake.exe -G \"Ninja\" -DCMAKE_INSTALL_PREFIX:PATH=\"C:/Users/Greg/Documents/git/bfs/breadcrumbs/install/basic_build\" -DCMAKE_INSTALL_PREFIX:PATH=\"C:/Users/Greg/Documents/git/bfs/breadcrumbs/install/basic_build\" -DCMAKE_CXX_COMPILER:FILEPATH=\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe\" -DCMAKE_C_COMPILER:FILEPATH=\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe\"" +clean_command = "\"%s\" --clean ..\\.." % cmake_bin +build_command = "\"%s\" --build ." % cmake_bin + def start_program(program): if not isinstance(program, str): raise ValueError("Argument passed to start_program_sync() should be a string") - return os.system("START /wait \""+ program +"\" CMD /c " + program) + print("\n======> Running command: %s <======" % program) + return os.system("CMD /c \"%s\"" % program) + + +# While located in the bfs\build\auto_build directory... + +# cmake --clean ..\.. +start_program(clean_command) -start_program(test_command) +# cmake --build . +start_program(build_command) diff --git a/bfs/scripts/log.txt b/bfs/scripts/log.txt index 50b3eda..8cc0f01 100644 --- a/bfs/scripts/log.txt +++ b/bfs/scripts/log.txt @@ -1,14 +1,9 @@ -Could not acquire mutex to add new client thread -Listening for clients... -Could not acquire mutex to add new client thread 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... -Could not acquire mutex to add new client thread Listening for clients... Hello new client! Listening for clients... @@ -20,19 +15,9 @@ Could not acquire mutex to add new client thread 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... -Could not acquire mutex to add new client thread -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... -Could not acquire mutex to add new client thread Listening for clients... Hello new client! Listening for clients...