Skip to content

Commit 0fd5ab7

Browse files
author
Justin Boswell
authored
Always pushd/popd project directory when executing project steps (#128)
* Always pushd/popd project directory when executing project steps * Fixed cmake paths to be absolute * Fixed macos-11
1 parent b3d7410 commit 0fd5ab7

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

.github/workflows/sanity-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
strategy:
8080
fail-fast: false
8181
matrix:
82-
host: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2019]
82+
host: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11, windows-2019]
8383
needs: package
8484
runs-on: ${{ matrix.host }}
8585
steps:

builder/actions/cmake.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ def _project_dirs(env, project):
3434
if not project.resolved():
3535
raise Exception('Project is not resolved: {}'.format(project.name))
3636

37-
source_dir = str(Path(project.path).relative_to(env.root_dir))
38-
build_dir = str(Path(os.path.join(env.build_dir, project.name)).relative_to(env.root_dir))
37+
source_dir = project.path
38+
build_dir = os.path.join(env.build_dir, project.name)
39+
install_dir = env.install_dir
3940

4041
# cross compiles are effectively chrooted to the source_dir, normal builds need absolute paths
4142
# or cmake gets lost because it wants directories relative to source
4243
if env.toolchain.cross_compile:
4344
# all dirs used should be relative to env.source_dir, as this is where the cross
4445
# compilation will be mounting to do its work
45-
install_dir = str(Path(env.install_dir).relative_to(env.root_dir))
46-
else:
47-
install_dir = env.install_dir
46+
source_dir = str(Path(source_dir).relative_to(env.root_dir))
47+
build_dir = str(Path(build_dir).relative_to(env.root_dir))
48+
install_dir = str(Path(install_dir).relative_to(env.root_dir))
4849

4950
return source_dir, build_dir, install_dir
5051

builder/core/project.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,13 @@ def pre_build(self, env):
513513
all_steps = build_imports + build_deps + self.config.get('pre_build_steps', [])
514514
if len(all_steps) == 0:
515515
return None
516-
all_steps = [partial(_pushenv, self, 'pre_build_env'), *all_steps, _popenv]
516+
all_steps = [
517+
partial(_pushd, self.path),
518+
partial(_pushenv, self, 'pre_build_env'),
519+
*all_steps,
520+
_popenv,
521+
_popd
522+
]
517523
return Script(all_steps, name='pre_build {}'.format(self.name))
518524

519525
def build(self, env):
@@ -527,7 +533,13 @@ def build(self, env):
527533

528534
if len(build_project) == 0:
529535
return None
530-
build_project = [partial(_pushenv, self, 'build_env'), *build_project, _popenv]
536+
build_project = [
537+
partial(_pushd, self.path),
538+
partial(_pushenv, self, 'build_env'),
539+
*build_project,
540+
_popenv,
541+
_popd
542+
]
531543
return Script(build_project, name='build project {}'.format(self.name))
532544

533545
def build_consumers(self, env):
@@ -547,7 +559,13 @@ def post_build(self, env):
547559
steps = self.config.get('post_build_steps', [])
548560
if len(steps) == 0:
549561
return None
550-
steps = [partial(_pushenv, self, 'post_build_env'), *steps, _popenv]
562+
steps = [
563+
partial(_pushd, self.path),
564+
partial(_pushenv, self, 'post_build_env'),
565+
*steps,
566+
_popenv,
567+
_popd
568+
]
551569
return Script(steps, name='post_build {}'.format(self.name))
552570

553571
def test(self, env):
@@ -562,7 +580,13 @@ def test(self, env):
562580
steps = _transform_steps(steps, env, self)
563581
if len(steps) == 0:
564582
return None
565-
steps = [partial(_pushenv, self, 'test_env'), *steps, _popenv]
583+
steps = [
584+
partial(_pushd, self.path),
585+
partial(_pushenv, self, 'test_env'),
586+
*steps,
587+
_popenv,
588+
_popd
589+
]
566590
return Script(steps, name='test {}'.format(self.name))
567591

568592
def install(self, env):

0 commit comments

Comments
 (0)