Skip to content

Commit

Permalink
chg: pkg: add env support for toolchain file, update windows ci env
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Jan 2, 2021
1 parent cb0d423 commit c6cc1d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ jobs:
python -m pip install --upgrade pip wheel
pip install tox
- name: Set Windows environment variables
if: runner.os == 'Windows'
run: |
.github/workflows/vs_env.bat x64
source env.sh
echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $GITHUB_ENV
- name: Test in place
run: |
tox -e py
Expand Down
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from distutils.dir_util import mkpath
from distutils.errors import DistutilsExecError, DistutilsFileError
from operator import methodcaller
from distutils.file_util import copy_file
from os import environ, unlink
from os.path import dirname, join
from platform import system
Expand All @@ -36,6 +37,19 @@
TRACE = 0


def cmd() -> None:
"""
Construct the cmake command plus args.
:return: cmd_list
"""
cmd_list = ['cmake', '--log-level=WARNING']
toolchain_file = environ.get('CMAKE_TOOLCHAIN_FILE', '')
if toolchain_file:
cmd_list += ['-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_file)]
cmd_list += ['.']
return cmd_list


def src(file: str) -> str:
"""Return path to the given file in src."""
return join(dirname(__file__), 'src', file)
Expand All @@ -45,10 +59,13 @@ class CMakeBuild(build_ext):
"""CMake extension builder and process runner."""
def finalize_options(self) -> None:
super().finalize_options()
cmake_cmd = cmd()
mkpath(self.build_temp)
copy_file(join(dirname(__file__), 'CMakeLists.txt'), self.build_temp)
try:
cmake = run(
['cmake', '../..'], check=True, stdout=DEVNULL, stderr=PIPE,
cmake_cmd, check=True,
stdout=DEVNULL, stderr=PIPE,
cwd=self.build_temp, universal_newlines=True)
except CalledProcessError as e:
log.error(e.stderr.strip())
Expand Down

0 comments on commit c6cc1d7

Please sign in to comment.