Skip to content

Commit

Permalink
Merge branch '974_re_split_build' of https://github.com/Tilix4/rez in…
Browse files Browse the repository at this point in the history
…to Tilix4-974_re_split_build
  • Loading branch information
ajohns committed Jun 1, 2021
2 parents 3f08334 + c4ebde1 commit cb33db0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/rez/build_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,7 @@ def add_standard_build_actions(cls, executor, context, variant, build_type,
This includes:
- Setting a standard list on env-vars;
- Executing pre_build_commands(), if the package has one.
"""
from rez.utils.data_utils import RO_AttrDictWrapper

# set env vars
env_vars = cls.get_standard_vars(
context=context,
Expand All @@ -301,6 +298,16 @@ def add_standard_build_actions(cls, executor, context, variant, build_type,
for var, value in env_vars.items():
executor.env[var] = value

@classmethod
def add_pre_build_commands(cls, executor, variant, build_type,
install, build_path, install_path=None):
"""Perform build commands common to every build system.
This includes:
- Executing pre_build_commands(), if the package has one.
"""
from rez.utils.data_utils import RO_AttrDictWrapper

# bind build-related values into a 'build' namespace
build_ns = {
"build_type": build_type.name,
Expand Down
19 changes: 14 additions & 5 deletions src/rezplugins/build_system/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _pr(s):
build_path = os.path.join(self.working_dir, build_path)
build_path = os.path.realpath(build_path)

callback = functools.partial(self._add_build_actions,
actions_callback = functools.partial(self._add_build_actions,
context=context,
package=self.package,
variant=variant,
Expand All @@ -162,11 +162,19 @@ def _pr(s):
build_path=build_path,
install_path=install_path)

post_actions_callback = functools.partial(self.add_pre_build_commands,
variant=variant,
build_type=build_type,
install=install,
build_path=build_path,
install_path=install_path)

# run the build command and capture/print stderr at the same time
retcode, _, _ = context.execute_shell(command=cmd,
block=True,
cwd=build_path,
post_actions_callback=callback)
actions_callback=actions_callback,
post_actions_callback=post_actions_callback)
ret = {}
if retcode:
ret["success"] = False
Expand Down Expand Up @@ -214,7 +222,8 @@ def _pr(s):
retcode, _, _ = context.execute_shell(command=cmd,
block=True,
cwd=build_path,
post_actions_callback=callback)
actions_callback=actions_callback,
post_actions_callback=post_actions_callback)

if not retcode and install and "install" not in cmd:
cmd.append("install")
Expand All @@ -224,7 +233,8 @@ def _pr(s):
retcode, _, _ = context.execute_shell(command=cmd,
block=True,
cwd=build_path,
post_actions_callback=callback)
actions_callback=actions_callback,
post_actions_callback=post_actions_callback)

ret["success"] = (not retcode)
return ret
Expand All @@ -250,7 +260,6 @@ def _add_build_actions(cls, executor, context, package, variant,
executor.env.REZ_BUILD_DOXYFILE = os.path.join(template_path, 'Doxyfile')
executor.env.REZ_BUILD_INSTALL_PYC = '1' if settings.install_pyc else '0'


def _FWD__spawn_build_shell(working_dir, build_path, variant_index, install,
install_path=None):
# This spawns a shell that the user can run 'make' in directly
Expand Down
13 changes: 10 additions & 3 deletions src/rezplugins/build_system/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def _add_build_actions(cls, executor, context, package, variant,
install_path=install_path
)


def _FWD__spawn_build_shell(working_dir, build_path, variant_index, install,
install_path=None):
# This spawns a shell that the user can run the build command in directly
Expand All @@ -216,7 +215,7 @@ def _FWD__spawn_build_shell(working_dir, build_path, variant_index, install,
variant = package.get_variant(variant_index)
config.override("prompt", "BUILD>")

callback = functools.partial(CustomBuildSystem._add_build_actions,
actions_callback = functools.partial(CustomBuildSystem._add_build_actions,
context=context,
package=package,
variant=variant,
Expand All @@ -225,8 +224,16 @@ def _FWD__spawn_build_shell(working_dir, build_path, variant_index, install,
build_path=build_path,
install_path=install_path)

post_actions_callback = functools.partial(CustomBuildSystem.add_pre_build_commands,
variant=variant,
build_type=BuildType.local,
install=install,
build_path=build_path,
install_path=install_path)

retcode, _, _ = context.execute_shell(block=True, cwd=build_path,
post_actions_callback=callback)
actions_callback=actions_callback,
post_actions_callback=post_actions_callback)
sys.exit(retcode)


Expand Down

0 comments on commit cb33db0

Please sign in to comment.