Пример #1
0
    def test_HitsCacheSecondTime(self):
        # Test that the computation is not performed on a second instance.
        with working_directory.TemporaryWorkingDirectory() as work_dir:
            self.GenerateTestData('HitsCacheSecondTime', work_dir)
            self._tally = 0

            def Copy(subst, src, dst):
                self._tally += 1
                shutil.copyfile(subst.SubstituteAbsPaths(src),
                                subst.SubstituteAbsPaths(dst))

            self._url = None

            def stash_url(urls):
                self._url = urls

            o = once.Once(storage=fake_storage.FakeStorage(),
                          print_url=stash_url,
                          system_summary='test')
            o.Run('test', self._input_dirs, self._output_dirs[0],
                  [command.Runnable(Copy, '%(input0)s/in0', '%(output)s/out')])
            initial_url = self._url
            self._url = None
            o.Run('test', self._input_dirs, self._output_dirs[1],
                  [command.Runnable(Copy, '%(input0)s/in0', '%(output)s/out')])
            self.assertEquals(file_tools.ReadFile(self._input_files[0]),
                              file_tools.ReadFile(self._output_files[0]))
            self.assertEquals(file_tools.ReadFile(self._input_files[0]),
                              file_tools.ReadFile(self._output_files[1]))
            self.assertEquals(1, self._tally)
            self.assertEquals(initial_url, self._url)
Пример #2
0
    def test_UseCachedResultsFalse(self):
        # Check that the use_cached_results=False does indeed cause computations
        # to be redone, even when present in the cache.
        with pynacl.working_directory.TemporaryWorkingDirectory() as work_dir:
            self.GenerateTestData('UseCachedResultsFalse', work_dir)
            self._tally = 0

            def Copy(logger, subst, src, dst):
                self._tally += 1
                shutil.copyfile(subst.SubstituteAbsPaths(src),
                                subst.SubstituteAbsPaths(dst))

            o = once.Once(storage=pynacl.fake_storage.FakeStorage(),
                          use_cached_results=False,
                          system_summary='test')
            o.Run('test', self._input_dirs, self._output_dirs[0], [
                command.Runnable(None, Copy, '%(input0)s/in0',
                                 '%(output)s/out')
            ])
            o.Run('test', self._input_dirs, self._output_dirs[1], [
                command.Runnable(None, Copy, '%(input0)s/in0',
                                 '%(output)s/out')
            ])
            self.assertEquals(2, self._tally)
            self.assertEquals(
                pynacl.file_tools.ReadFile(self._input_files[0]),
                pynacl.file_tools.ReadFile(self._output_files[0]))
            self.assertEquals(
                pynacl.file_tools.ReadFile(self._input_files[0]),
                pynacl.file_tools.ReadFile(self._output_files[1]))
Пример #3
0
 def GetGitSyncCmds(component):
     return [
         command.SyncGitRepo(GIT_BASE_URL + GIT_REPOS[component],
                             '%(output)s', revisions[component]),
         command.Runnable(pnacl_commands.CmdCheckoutGitBundleForTrybot,
                          component, '%(output)s')
     ]
Пример #4
0
    def test_NumCores(self):
        # Test that the core count is substituted. Since we don't know how many
        # cores the test machine will have, just check that it's an integer.
        with working_directory.TemporaryWorkingDirectory() as work_dir:
            self.GenerateTestData('NumCores', work_dir)
            o = once.Once(storage=fake_storage.FakeStorage(),
                          system_summary='test')

            def CheckCores(subst):
                self.assertNotEquals(0, int(subst.Substitute('%(cores)s')))

            o.Run('test', {}, self._output_dirs[0],
                  [command.Runnable(CheckCores)])
def CopyDriverForTargetLib(host):
    return [
        command.RemoveDirectory('driver'),
        command.Mkdir('driver'),
        command.Runnable(
            pnacl_commands.InstallDriverScripts,
            '%(driver)s',
            '%(cwd)s/driver',
            host_windows=TripleIsWindows(host),
            host_64bit=fnmatch.fnmatch(host, '*x86_64*'),
            extra_config=[
                'BPREFIXES=%(abs_' + Mangle('llvm', host) + ')s %(abs_' +
                Mangle('binutils_pnacl', host) + ')s'
            ])
    ]
Пример #6
0
def HostTools(host, options):
    def H(component_name):
        # Return a package name for a component name with a host triple.
        return component_name + '_' + pynacl.gsd_storage.LegalizeName(host)

    def IsHost64(host):
        return fnmatch.fnmatch(host, 'x86_64*')

    def HostSubdir(host):
        return 'host_x86_64' if IsHost64(host) else 'host_x86_32'

    def BinSubdir(host):
        return 'bin64' if host == 'x86_64-linux' else 'bin'

    # Return the file name with the appropriate suffix for an executable file.
    def Exe(file):
        if TripleIsWindows(host):
            return file + '.exe'
        else:
            return file

    tools = {
        H('binutils_pnacl'): {
            'dependencies': ['binutils_pnacl_src'],
            'type':
            'build',
            'output_subdir':
            HostSubdir(host),
            'commands': [
                command.SkipForIncrementalCommand([
                    'sh', '%(binutils_pnacl_src)s/configure'
                ] + ConfigureHostArchFlags(host) + [
                    '--prefix=', '--disable-silent-rules',
                    '--target=arm-pc-nacl', '--program-prefix=le32-nacl-',
                    '--enable-targets=arm-pc-nacl,i686-pc-nacl,x86_64-pc-nacl,'
                    + 'mipsel-pc-nacl', '--enable-deterministic-archives',
                    '--enable-shared=no', '--enable-gold=default',
                    '--enable-ld=no', '--enable-plugins', '--without-gas',
                    '--without-zlib', '--with-sysroot=/arm-pc-nacl'
                ]),
                command.Command(MakeCommand(host)),
                command.Command(MAKE_DESTDIR_CMD + ['install-strip'])
            ] + [
                command.RemoveDirectory(os.path.join('%(output)s', dir))
                for dir in ('arm-pc-nacl', 'lib', 'lib32')
            ]
        },
        H('driver'): {
            'type':
            'build',
            'output_subdir':
            BinSubdir(host),
            'inputs': {
                'src': os.path.join(NACL_DIR, 'pnacl', 'driver')
            },
            'commands': [
                command.Runnable(pnacl_commands.InstallDriverScripts,
                                 '%(src)s',
                                 '%(output)s',
                                 host_windows=TripleIsWindows(host),
                                 host_64bit=IsHost64(host))
            ],
        },
    }
    llvm_cmake = {
        H('llvm'): {
            'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src'],
            'type':
            'build',
            'output_subdir':
            HostSubdir(host),
            'commands': [
                command.SkipForIncrementalCommand([
                    'cmake', '-G', 'Ninja'
                ] + CmakeHostArchFlags(host, options) + [
                    '-DCMAKE_BUILD_TYPE=RelWithDebInfo',
                    '-DCMAKE_INSTALL_PREFIX=%(output)s',
                    '-DCMAKE_INSTALL_RPATH=$ORIGIN/../lib',
                    '-DBUILD_SHARED_LIBS=ON', '-DLLVM_ENABLE_ASSERTIONS=ON',
                    '-DLLVM_ENABLE_ZLIB=OFF', '-DLLVM_BUILD_TESTS=ON',
                    '-DLLVM_APPEND_VC_REV=ON',
                    '-DLLVM_BINUTILS_INCDIR=%(abs_binutils_pnacl_src)s/include',
                    '-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=%(clang_src)s',
                    '%(llvm_src)s'
                ]),
                command.Command(['ninja', '-v']),
                command.Command(['ninja', 'install']),
            ],
        },
    }
    llvm_autoconf = {
        H('llvm'): {
            'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src'],
            'type':
            'build',
            'output_subdir':
            HostSubdir(host),
            'commands': [
                command.SkipForIncrementalCommand([
                    'sh', '%(llvm_src)s/configure'
                ] + ConfigureHostArchFlags(host) + [
                    '--prefix=/',
                    '--enable-shared',
                    '--disable-zlib',
                    '--disable-terminfo',
                    '--disable-jit',
                    '--disable-bindings',  # ocaml is currently the only binding.
                    '--with-binutils-include=%(abs_binutils_pnacl_src)s/include',
                    '--enable-targets=x86,arm,mips',
                    '--program-prefix=',
                    '--enable-optimized',
                    '--with-clang-srcdir=%(abs_clang_src)s'
                ]),
                command.Command(
                    MakeCommand(host) +
                    ['VERBOSE=1', 'NACL_SANDBOX=0', 'all']),
                command.Command(MAKE_DESTDIR_CMD + ['install']),
                command.Remove(*[
                    os.path.join('%(output)s', 'lib', f)
                    for f in '*.a', '*Hello.*', 'BugpointPasses.*'
                ]),
                command.Remove(*[
                    os.path.join('%(output)s', 'bin', f)
                    for f in Exe('clang-format'),
                    Exe('clang-check'),
                    Exe('c-index-test'),
                    Exe('clang-tblgen'),
                    Exe('llvm-tblgen')
                ])
            ] + CopyWindowsHostLibs(host),
        },
    }
    if options.cmake:
        tools.update(llvm_cmake)
    else:
        tools.update(llvm_autoconf)
    if TripleIsWindows(host):
        tools[H('binutils_pnacl')]['dependencies'].append('libdl')
        tools[H('llvm')]['dependencies'].append('libdl')
    return tools
def HostTools(host):
  def H(component_name):
    # Return a package name for a component name with a host triple.
    return component_name + '_' + gsd_storage.LegalizeName(host)
  def IsHost64(host):
    return fnmatch.fnmatch(host, 'x86_64*')
  def HostSubdir(host):
    return 'host_x86_64' if IsHost64(host) else 'host_x86_32'
  def BinSubdir(host):
    return 'bin64' if host == 'x86_64-linux' else 'bin'
  tools = {
      H('binutils_pnacl'): {
          'dependencies': ['binutils_pnacl_src'],
          'type': 'build',
          'output_subdir': HostSubdir(host),
          'commands': [
              command.SkipForIncrementalCommand([
                  'sh',
                  '%(binutils_pnacl_src)s/configure'] +
                  ConfigureHostArchFlags(host) +
                  ['--prefix=',
                  '--disable-silent-rules',
                  '--target=arm-pc-nacl',
                  '--program-prefix=le32-nacl-',
                  '--enable-targets=arm-pc-nacl,i686-pc-nacl,x86_64-pc-nacl,' +
                  'mipsel-pc-nacl',
                  '--enable-deterministic-archives',
                  '--enable-shared=no',
                  '--enable-gold=default',
                  '--enable-ld=no',
                  '--enable-plugins',
                  '--without-gas',
                  '--without-zlib',
                  '--with-sysroot=/arm-pc-nacl']),
              command.Command(MakeCommand(host)),
              command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] +
              [command.RemoveDirectory(os.path.join('%(output)s', dir))
               for dir in ('arm-pc-nacl', 'lib', 'lib32')]
          },
      H('llvm'): {
          'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src'],
          'type': 'build',
          'output_subdir': HostSubdir(host),
          'commands': [
              command.SkipForIncrementalCommand([
                  'sh',
                  '%(llvm_src)s/configure'] +
                  ConfigureHostArchFlags(host) +
                  ['--prefix=/',
                   '--enable-shared',
                   '--disable-zlib',
                   '--disable-jit',
                   '--disable-bindings', # ocaml is currently the only binding.
                   '--with-binutils-include=%(abs_binutils_pnacl_src)s/include',
                   '--enable-targets=x86,arm,mips',
                   '--program-prefix=',
                   '--enable-optimized',
                   '--with-clang-srcdir=%(abs_clang_src)s']),
              command.Command(MakeCommand(host) + [
                  'VERBOSE=1',
                  'NACL_SANDBOX=0',
                  'all']),
              command.Command(MAKE_DESTDIR_CMD + ['install'])] +
              CopyWindowsHostLibs(host),
      },
      H('driver'): {
        'type': 'build',
        'output_subdir': BinSubdir(host),
        'inputs': { 'src': os.path.join(NACL_DIR, 'pnacl', 'driver')},
        'commands': [
            command.Runnable(pnacl_commands.InstallDriverScripts,
                             '%(src)s', '%(output)s',
                             host_windows=TripleIsWindows(host),
                             host_64bit=IsHost64(host))
        ],
      },
  }
  if TripleIsWindows(host) and not command.Runnable.use_cygwin:
    tools[H('binutils_pnacl')]['dependencies'].append('libdl')
    tools[H('llvm')]['dependencies'].append('libdl')
  return tools