def dtest_it_uses_image_declared_for_target(self, docker): project = Project('Project') target = Target('ubuntu') target.image = 'cpmhub/ubuntu' project.targets.append(target) docker_client = MagicMock() container = MagicMock() container.logs.return_value = [] docker_client.containers.return_value = container docker.from_env.return_value = docker_client self.project_loader.load.return_value = project self.compilation_service.build_target('ubuntu') self.project_loader.load.assert_called_once() docker_client.containers.run.assert_called_once_with( f'cpmhub/ubuntu', 'cpm build', working_dir=f'/{project.name}', volumes={f'{os.getcwd()}': {'bind': f'/{project.name}', 'mode': 'rw'}}, user=f'{os.getuid()}:{os.getgid()}', detach=True )
def compose_target(target_name, project_descriptor): target = Target(target_name) target.cflags = project_descriptor.build.cflags target.ldflags = project_descriptor.build.ldflags target.libraries = project_descriptor.build.libraries target.image = project_descriptor.targets[target_name].image target.dockerfile = project_descriptor.targets[target_name].dockerfile compose_packages(project_descriptor.build.packages, target) for bit_description in project_descriptor.build.bits.values(): adjust_bit_packages_base_path(bit_description, bit_description.build.packages) add_packages_to_target_includes(bit_description.build.packages, target) target.bits.append(compose_target(target_name, bit_description)) return target
def compose_target(target_name, project_descriptor): target = Target(target_name) target_description = project_descriptor.targets.get(target_name, TargetDescription(target_name)) target.cflags = project_descriptor.build.cflags + target_description.build.cflags target.cppflags = project_descriptor.build.cppflags + target_description.build.cppflags target.ldflags = project_descriptor.build.ldflags + target_description.build.ldflags target.libraries = project_descriptor.build.libraries + target_description.build.libraries target.include_directories.update(project_descriptor.build.includes) target.main = target_description.main target.image = target_description.image target.dockerfile = target_description.dockerfile target.test_image = target_description.test_image target.test_dockerfile = target_description.test_dockerfile target.toolchain_prefix = target_description.toolchain_prefix target.post_build = target_description.post_build compose_packages(project_descriptor.build.packages, target) compose_packages(target_description.build.packages, target) for bit_description in project_descriptor.build.bits.values(): compose_bit(bit_description, target) for bit_description in target_description.build.bits.values(): compose_bit(bit_description, target) return target
def with_target(self, target_name): self.target_name = target_name self.target = Target(target_name) self.project.targets[target_name] = self.target return self