From 584755c41c6930c505ce7b3c8d4748fab0b1eb6f Mon Sep 17 00:00:00 2001 From: Nick P Date: Thu, 23 May 2024 13:54:28 -0600 Subject: [PATCH] Stops the creation of _build and _logs directories if CMakeLists.txt is not found This provides a better user experience for new users who run the tool outside of a CMake source tree, who would later have to clean up those directories. --- bin/polly.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/polly.py b/bin/polly.py index 0002103f..5688e926 100755 --- a/bin/polly.py +++ b/bin/polly.py @@ -307,6 +307,15 @@ def PositiveInt(string): else: cdir = os.getcwd() +home = '.' +if args.home: + home = args.home + +# Check the existence of CMakeLists.txt and exit before creating any directories +cmakelists_path = '{}/CMakeLists.txt'.format(home) +if not os.path.exists(cmakelists_path): + sys.exit('Specified path for CMakeList does not exist: {}'.format(cmakelists_path)) + build_dir = os.path.join(cdir, '_builds', build_tag) print("Build dir: {}".format(build_dir)) build_dir_option = "-B{}".format(build_dir) @@ -373,10 +382,6 @@ def PositiveInt(string): detail.call.call(['which', cmake_bin], logging) detail.call.call([cmake_bin, '--version'], logging) -home = '.' -if args.home: - home = args.home - generate_command = [ cmake_bin, '-H{}'.format(home),