def get_image_path(parameters, name): return ( parameters['//releases:root'] / \ foreman.get_relpath() / name / ASSERT.not_none(parameters['%s/version' % name]) / shipyard2.IMAGE_DIR_IMAGE_FILENAME )
def get_output_dir_path(parameters, name, version): """Get pod or xar dir path under release repo.""" return ( parameters['//releases:root'] / \ foreman.get_relpath() / name / version )
def rule2(parameters): relpath = get_relpath() if relpath != Path('pkg1/pkg2'): raise AssertionError(relpath) par2 = parameters['par2'] if par2 != Path('pkg1/pkg2'): raise AssertionError(par2)
def git_clone(parameters): repo_path = parameters['//bases:drydock'] / foreman.get_relpath() repo_path /= repo_path.name git_dir_path = repo_path / '.git' if git_dir_path.is_dir(): LOG.info('skip: git clone: %s', repo_url) return LOG.info('git clone: %s', repo_url) scripts.git_clone(repo_url, repo_path=repo_path, treeish=treeish) ASSERT.predicate(git_dir_path, Path.is_dir)
def build(parameters): src_path = find_package( parameters, foreman.get_relpath(), sub_directory_path, ) LOG.info('build first-party package: %s', src_path) with scripts.using_cwd(src_path): scripts.run(['npm', 'install']) scripts.run(['npm', 'run', 'build'])
def setup(parameters): src_path = ASSERT.predicate( _find_project(parameters, foreman.get_relpath()), _is_root_project, ) if (src_path / 'gradlew').exists(): LOG.info('skip: generate gradle wrapper') return LOG.info('generate gradle wrapper') with scripts.using_cwd(src_path): scripts.run(['gradle', 'wrapper'])
def _should_mount_image_data(image_data_path, name, rules): """True if we should mount image-data directory. Check presence of the following directories: * <image-data>/images/<image-path>/<image-name>. * <image-data>/<rule-path>. """ if (image_data_path / foreman.get_relpath() / name).is_dir(): return True for rule in rules: if (image_data_path / rule.path).is_dir(): return True return False
def build(parameters): src_path = parameters['//bases:drydock'] / foreman.get_relpath() src_path /= src_path.name if (src_path / 'capnpc-java').exists(): LOG.info('skip: build capnproto-java') return LOG.info('build capnproto-java') bin_path = _get_var_path('exec_prefix') / 'bin' header_path = _get_var_path('includedir') / 'capnp' with scripts.using_cwd(src_path): scripts.make() with scripts.using_sudo(): scripts.cp('capnpc-java', bin_path) scripts.cp('compiler/src/main/schema/capnp/java.capnp', header_path)
def build(parameters): src_path = parameters['//bases:drydock'] / foreman.get_relpath() src_path /= src_path.name if (src_path / 'c++/.libs/libcapnp.so').exists(): LOG.info('skip: build capnproto') return LOG.info('build capnproto') with scripts.using_cwd(src_path / 'c++'): scripts.run(['autoreconf', '-i']) scripts.run(['./configure']) # Skip `make check` for now. scripts.make() with scripts.using_sudo(): scripts.make(['install']) scripts.run(['ldconfig'])
def ops_db_client_build(parameters): src_path = ASSERT.predicate( shipyard2.rules.pythons\ .find_package(parameters, foreman.get_relpath()) / 'scripts' / 'ops-db-client', Path.is_file, ) dst_path = Path('/usr/local/bin/ops-db-client') if dst_path.exists(): LOG.info('skip: install ops-db-client') return LOG.info('install ops-db-client') with scripts.using_sudo(): scripts.cp(src_path, dst_path)
def rule1(parameters): relpath = get_relpath() if relpath != Path('pkg1'): raise AssertionError(relpath) par1 = parameters['par1'] if par1 != Path('pkg1'): raise AssertionError(par1) par2 = parameters['//pkg1/pkg2:par2'] if par2 != Path('pkg1/pkg2'): raise AssertionError(par2) # test_build() will check this foreman._test_ran = True
def build(parameters): src_path = _find_project(parameters, foreman.get_relpath()) root_path = _find_root_project(src_path) ASSERT.false(src_path.samefile(root_path)) output_path = src_path / ('build/libs/%s-all.jar' % src_path.name) task = ':'.join(src_path.relative_to(root_path).parts) task = ':%s:shadowJar' % task target_dir_path = parameters[root_project + ':packages'] if (target_dir_path / output_path.name).exists(): LOG.info('skip: run task %s', task) return LOG.info('run task %s', task) with scripts.using_cwd(root_path): scripts.run(['./gradlew', task]) with scripts.using_sudo(): scripts.mkdir(target_dir_path) scripts.cp(output_path, target_dir_path)
def build(parameters): src_path = parameters['//bases:drydock'] / foreman.get_relpath() src_path /= src_path.name build_dir_path = src_path / 'build' if build_dir_path.exists(): LOG.info('skip: build nng') return LOG.info('build nng') scripts.mkdir(build_dir_path) with scripts.using_cwd(build_dir_path): scripts.run([ 'cmake', *('-D', 'BUILD_SHARED_LIBS:BOOL=ON'), *('-G', 'Ninja'), '..', ]) scripts.run(['ninja']) # Skip `ninja test` for now. with scripts.using_sudo(): scripts.run(['ninja', 'install']) scripts.run(['ldconfig'])
def _get_src_path(parameters): src_parent_path = parameters['//bases:drydock'] / foreman.get_relpath() return src_parent_path / src_parent_path.name
def build(parameters): src_path = parameters['//bases:drydock'] / foreman.get_relpath() src_path /= src_path.name scripts.export_path('PATH', src_path) with scripts.using_cwd(src_path): scripts.run(['gclient']) # This updates depot_tools.
def _archive_get_output_path(parameters, archive): return (parameters['//bases:drydock'] / foreman.get_relpath() / archive.output)
def _archive_get_archive_path(parameters, archive): return (parameters['//bases:drydock'] / foreman.get_relpath() / archive.filename)
from pathlib import Path from foreman import define_parameter, rule, get_relpath if __name__ != 'pkg1.pkg2': raise AssertionError(__name__) if not __file__.endswith( 'foreman/tests/testdata/test_command/pkg1/pkg2/build.py'): raise AssertionError(__file__) relpath = get_relpath() if relpath != Path('pkg1/pkg2'): raise AssertionError(relpath) define_parameter('par2').with_derive(lambda ps: get_relpath()) @rule def rule2(parameters): relpath = get_relpath() if relpath != Path('pkg1/pkg2'): raise AssertionError(relpath) par2 = parameters['par2'] if par2 != Path('pkg1/pkg2'): raise AssertionError(par2)
def build(parameters): scripts.export_path( 'PATH', parameters['//bases:drydock'] / foreman.get_relpath() / parameters['archive'].output / 'bin', )
def get_output_label(name): return foreman.Label.parse( '//%s:%s' % ('/'.join(foreman.get_relpath().parts[1:]), name))
def build(parameters): src_path = find_package(parameters, foreman.get_relpath()) LOG.info('export first-party host package: %s', src_path) scripts.export_path('PYTHONPATH', src_path)
def build(parameters): src_path = find_package(parameters, foreman.get_relpath()) LOG.info('build first-party package: %s', src_path) with scripts.using_cwd(src_path): _build(parameters, make_global_options)
from foreman import define_parameter, define_rule, get_relpath if __name__ != 'pkg1.pkg2': raise AssertionError('incorrect __name__: %s' % __name__) if not __file__.endswith('tests/testdata/path1/pkg1/pkg2/build.py'): raise AssertionError('incorrect __file__: %s' % __file__) if str(get_relpath()) != 'pkg1/pkg2': raise AssertionError('incorrect relpath: %s' % get_relpath()) COUNT = 0 if COUNT > 0: raise AssertionError('load more than once') COUNT += 1 define_parameter('par_x') define_rule('rule_x').depend('//pkg1:pkg1')
def _get_src_path(parameters): return (parameters['//bases:drydock'] / foreman.get_relpath() / parameters['archive'].output)
def _get_config_path(ps): return ps['//bases:drydock'] / foreman.get_relpath() / 'config.json'