Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vcpkg #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions bin/polly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed build_dir_option to match the current style of generate_command below.


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
Expand Down Expand Up @@ -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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferred

'-DCMAKE_TOOLCHAIN_FILE={}'.format(args.vcpkg if args.vcpkg else toolchain_path)

over

'-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_path if not args.vcpkg else args.vcpkg)

to avoid negative logic.

]

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))
Expand All @@ -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:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition was removed because toolchain_option (and transitively toolchain_path) was always present.

generate_command.append(toolchain_option)

if args.verbosity == 'full':
generate_command.append('-DCMAKE_VERBOSE_MAKEFILE=ON')
generate_command.append('-DPOLLY_STATUS_DEBUG=ON')
Expand Down