Ejemplo n.º 1
0
def generate_binaries_depending_ninjas(root_dir_install_all_targets):
  n = ninja_generator.NinjaGenerator('readonly_fs_image')
  rule_name = 'gen_readonly_fs_image'
  encoded_symlink_map = ','.join([x + ':' + y for x, y in
                                  _SYMLINK_MAP.iteritems()])
  encoded_empty_dirs = ','.join(_EMPTY_DIRECTORIES)
  encoded_empty_files = ','.join(_EMPTY_FILES)

  n.rule(rule_name,
         command=_CREATE_READONLY_FS_IMAGE_SCRIPT + ' -o $out ' +
         '-s "' + encoded_symlink_map + '" '
         '-d "' + encoded_empty_dirs + '" '
         '-f "' + encoded_empty_files + '" '
         '$in', description=rule_name)
  gen_img = build_common.get_posix_translation_readonly_fs_image_file_path()

  my_dependencies = sorted(root_dir_install_all_targets)
  # The configure options file is a dependency as symlinks in the read-only
  # file system image changes per the configure options.
  implicit = [_CREATE_READONLY_FS_IMAGE_SCRIPT,
              OPTIONS.get_configure_options_file()]
  n.build([gen_img], rule_name, my_dependencies,
          implicit=implicit)
Ejemplo n.º 2
0
def generate_test_ninjas():
  n = ninja_generator.PpapiTestNinjaGenerator(
      'posix_translation_test',
      base_path='src/posix_translation',
      force_compiler='clang',
      enable_cxx11=True)
  # Build a rootfs image for tests.
  rule_name = 'gen_test_fs_image'
  script_path = 'src/posix_translation/scripts/create_test_fs_image.py'

  gen_prod_image = (
      build_common.get_posix_translation_readonly_fs_image_file_path())

  # This is a little odd, but we use the documented path to the production image
  # to also store a test image in the same location for simplicity.
  out_path = os.path.dirname(gen_prod_image)
  gen_test_image = os.path.join(out_path, 'test_readonly_fs_image.img')

  n.rule(rule_name,
         command=script_path + ' $out_path',
         description=rule_name + ' $in_real_path')
  n.add_ppapi_compile_flags()
  n.build([gen_test_image], rule_name,
          variables={'out_path': out_path},
          # The script calls create_readonly_fs_image.py.
          implicit=[script_path,
                    _CREATE_READONLY_FS_IMAGE_SCRIPT,
                    ])
  all_files = n.find_all_contained_test_sources()

  n.build_default(all_files, base_path=None)
  n.add_compiler_flags('-Werror')
  n.add_library_deps('libposix_translation_static.a',
                     'libchromium_base.a',
                     'libcommon.a',
                     'libgccdemangle_static.a')
  if build_common.use_ndk_direct_execution():
    n.add_defines('USE_NDK_DIRECT_EXECUTION')
  implicit = [gen_test_image]
  if open_source.is_open_source_repo():
    implicit.append(gen_prod_image)
    n.add_defines('PROD_READONLY_FS_IMAGE="%s"' % gen_prod_image)
  else:
    # Add runtime to implicit dependencies because ReadonlyFsReaderTest uses
    # the readonly FS image in runtime.
    implicit.append(build_common.get_runtime_build_stamp())
    n.add_defines('PROD_READONLY_FS_IMAGE="%s"' % os.path.join(
                  build_common.get_runtime_platform_specific_path(
                      build_common.get_runtime_out_dir(), OPTIONS.target()),
                  os.path.basename(gen_prod_image)))
    n.run(n.link(), implicit=implicit)

  # To be able to refer mock implementation from outside of posix_translation.
  # Setting instance count is zero because usage count verifier doesn't check
  # the reference from test executable. See verify_usage_counts in
  # ninja_generator.py
  n = ninja_generator.ArchiveNinjaGenerator(
      'mock_posix_translation',
      instances=0,
      force_compiler='clang',
      enable_cxx11=True)
  n.add_libchromium_base_compile_flags()
  n.add_compiler_flags('-Werror')
  all_files = ['src/posix_translation/test_util/mock_virtual_file_system.cc']
  n.build_default(all_files).archive()