diff --git a/bin/polly.py b/bin/polly.py index 0002103f..b8def948 100755 --- a/bin/polly.py +++ b/bin/polly.py @@ -238,6 +238,18 @@ def PositiveInt(string): help="Print the corresponding CMake command and quit" ) +vcpkg_cmake_relative_path = 'scripts/buildsystems/vcpkg.cmake' +vcpkg_cmake_pwd = '{}/vcpkg/{}'.format(os.environ['PWD'], vcpkg_cmake_relative_path) +vcpkg_cmake_env_vcpkg_root = '{}/{}'.format(os.environ['VCPKG_ROOT'], vcpkg_cmake_relative_path) +vcpkg_cmake_path = vcpkg_cmake_pwd if os.path.exists(vcpkg_cmake_pwd) else vcpkg_cmake_env_vcpkg_root + +parser.add_argument( + '--vcpkg', + nargs='?', + const=vcpkg_cmake_path, + help='Enables vcpkg using on ${PWD}/vcpkg, if exists, or $VCPKG_ROOT followed by /scripts/buildsystems/vcpkg.cmake or given argument' +) + args = parser.parse_args() polly_toolchain = detail.toolchain_name.get(args.toolchain) @@ -296,7 +308,6 @@ def PositiveInt(string): toolchain_path = os.path.join(polly_root, "{}.cmake".format(polly_toolchain)) if not os.path.exists(toolchain_path): sys.exit("Toolchain file not found: {}".format(toolchain_path)) -toolchain_option = "-DCMAKE_TOOLCHAIN_FILE={}".format(toolchain_path) if args.output: if not os.path.isdir(args.output): @@ -307,9 +318,17 @@ 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) install_dir = os.path.join(cdir, '_install', polly_toolchain) local_install = args.install or args.strip or args.framework or args.framework_device or args.archive @@ -373,16 +392,16 @@ 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), - build_dir_option + '-B{}'.format(build_dir), + '-DCMAKE_TOOLCHAIN_FILE={}'.format(args.vcpkg if args.vcpkg else toolchain_path) ] +if args.vcpkg: + generate_command.append('-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE={}'.format(toolchain_path)) + if args.cache: if not os.path.isfile(args.cache): sys.exit("Specified cache file does not exist: {}".format(args.cache)) @@ -403,9 +422,6 @@ def PositiveInt(string): toolset = 'v{}0_xp'.format(toolchain_entry.vs_version) generate_command.append('-T{}'.format(toolset)) -if toolchain_option: - generate_command.append(toolchain_option) - if args.verbosity == 'full': generate_command.append('-DCMAKE_VERBOSE_MAKEFILE=ON') generate_command.append('-DPOLLY_STATUS_DEBUG=ON')