<commit_before>#!/usr/bin/python

# Copyright 2010 The Native Client Authors.  All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

import glob
import os
import sys

import dirtree
import btarget
import treemappers


script_dir = os.path.abspath(os.path.dirname(__file__))
# This allows "src" to be a symlink pointing to NaCl's "trunk/src".
nacl_src = os.path.join(script_dir, "src")
# Otherwise we expect to live inside the NaCl tree.
if not os.path.exists(nacl_src):
  nacl_src = os.path.normpath(os.path.join(script_dir, "..", "..", ".."))
nacl_dir = os.path.join(nacl_src, "native_client")

subdirs = [
    "third_party/gmp",
    "third_party/mpfr",
    "third_party/gcc",
    "third_party/binutils",
    "third_party/newlib",
    "native_client/tools/patches"]
search_path = [os.path.join(nacl_src, subdir) for subdir in subdirs]


def FindFile(name):
  for dir_path in search_path:
    filename = os.path.join(dir_path, name)
    if os.path.exists(filename):
      return filename
  raise Exception("Couldn't find %r in %r" % (name, search_path))


def PatchGlob(name):
  path = os.path.join(nacl_dir, "tools/patches", name, "*.patch")
  patches = sorted(glob.glob(path))
  if len(patches) == 0:
    raise AssertionError("No patches found matching %r" % path)
  return patches


def GetSources():
  return {
    "gmp": dirtree.TarballTree(FindFile("gmp-4.3.1.tar.bz2")),
    "mpfr": dirtree.TarballTree(FindFile("mpfr-2.4.1.tar.bz2")),
    "binutils": dirtree.PatchedTree(
        dirtree.TarballTree(FindFile("binutils-2.20.1.tar.bz2")),
        PatchGlob("binutils-2.20.1"), strip=2),
    "gcc": dirtree.PatchedTree(
        dirtree.MultiTarballTree(
            [FindFile("gcc-core-4.4.3.tar.bz2"),
             FindFile("gcc-g++-4.4.3.tar.bz2"),
             FindFile("gcc-testsuite-4.4.3.tar.bz2")]),
        PatchGlob("gcc-4.4.3"), strip=2),
    "newlib": dirtree.PatchedTree(
        dirtree.TarballTree(FindFile("newlib-1.18.0.tar.gz")),
        PatchGlob("newlib-1.18.0"), strip=2),
    # For a discussion of why nacl-glibc uses these, see
    # http://code.google.com/p/nativeclient/issues/detail?id=671
    # TODO(mseaborn): Move this repo to git.chromium.org.
    "linux_headers": dirtree.GitTree(
        "http://repo.or.cz/r/linux-headers-for-nacl.git",
        commit_id="2dc04f8190a54defc0d59e693fa6cff3e8a916a9"),
    # TODO(mseaborn): Pin a specific Git commit ID here.
    "glibc": dirtree.GitTree("http://src.chromium.org/git/nacl-glibc.git"),
    }


def GetTargets(src):
  top_dir = os.path.abspath("out")
  src = dict((src_name,
              btarget.SourceTarget("%s-src" % src_name,
                                  os.path.join(top_dir, "source", src_name),
                                  src_tree))
             for src_name, src_tree in src.iteritems())
  modules = {}
  module_list = []

  def MakeInstallPrefix(name, deps):
    return btarget.TreeMapper("%s-input" % name,
                              os.path.join(top_dir, "input-prefix", name),
                              treemappers.CombineInstallTrees,
                              [modules[dep] for dep in deps])
<commit_msg>Update build.py to pull in new linux-headers-for-nacl revision<commit_after>#!/usr/bin/python

# Copyright 2010 The Native Client Authors.  All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

import glob
import os
import sys

import dirtree
import btarget
import treemappers


script_dir = os.path.abspath(os.path.dirname(__file__))
# This allows "src" to be a symlink pointing to NaCl's "trunk/src".
nacl_src = os.path.join(script_dir, "src")
# Otherwise we expect to live inside the NaCl tree.
if not os.path.exists(nacl_src):
  nacl_src = os.path.normpath(os.path.join(script_dir, "..", "..", ".."))
nacl_dir = os.path.join(nacl_src, "native_client")

subdirs = [
    "third_party/gmp",
    "third_party/mpfr",
    "third_party/gcc",
    "third_party/binutils",
    "third_party/newlib",
    "native_client/tools/patches"]
search_path = [os.path.join(nacl_src, subdir) for subdir in subdirs]


def FindFile(name):
  for dir_path in search_path:
    filename = os.path.join(dir_path, name)
    if os.path.exists(filename):
      return filename
  raise Exception("Couldn't find %r in %r" % (name, search_path))


def PatchGlob(name):
  path = os.path.join(nacl_dir, "tools/patches", name, "*.patch")
  patches = sorted(glob.glob(path))
  if len(patches) == 0:
    raise AssertionError("No patches found matching %r" % path)
  return patches


def GetSources():
  return {
    "gmp": dirtree.TarballTree(FindFile("gmp-4.3.1.tar.bz2")),
    "mpfr": dirtree.TarballTree(FindFile("mpfr-2.4.1.tar.bz2")),
    "binutils": dirtree.PatchedTree(
        dirtree.TarballTree(FindFile("binutils-2.20.1.tar.bz2")),
        PatchGlob("binutils-2.20.1"), strip=2),
    "gcc": dirtree.PatchedTree(
        dirtree.MultiTarballTree(
            [FindFile("gcc-core-4.4.3.tar.bz2"),
             FindFile("gcc-g++-4.4.3.tar.bz2"),
             FindFile("gcc-testsuite-4.4.3.tar.bz2")]),
        PatchGlob("gcc-4.4.3"), strip=2),
    "newlib": dirtree.PatchedTree(
        dirtree.TarballTree(FindFile("newlib-1.18.0.tar.gz")),
        PatchGlob("newlib-1.18.0"), strip=2),
    # For a discussion of why nacl-glibc uses these, see
    # http://code.google.com/p/nativeclient/issues/detail?id=671
    "linux_headers": dirtree.GitTree(
        "http://src.chromium.org/git/linux-headers-for-nacl.git",
        commit_id="0014b8d2e052dd3bf4cdc4be999d17e123c50dc2"),
    # TODO(mseaborn): Pin a specific Git commit ID here.
    "glibc": dirtree.GitTree("http://src.chromium.org/git/nacl-glibc.git"),
    }


def GetTargets(src):
  top_dir = os.path.abspath("out")
  src = dict((src_name,
              btarget.SourceTarget("%s-src" % src_name,
                                  os.path.join(top_dir, "source", src_name),
                                  src_tree))
             for src_name, src_tree in src.iteritems())
  modules = {}
  module_list = []

  def MakeInstallPrefix(name, deps):
    return btarget.TreeMapper("%s-input" % name,
                              os.path.join(top_dir, "input-prefix", name),
                              treemappers.CombineInstallTrees,
                              [modules[dep] for dep in deps])

{'fraction_non_alphanumeric': 0.14598654357690502, 'fraction_numerical': 0.023001095290251915, 'mean_word_length': 2.873939393939394, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4911760', 'n_tokens_mistral': 2386, 'n_tokens_neox': 2287, 'n_words': 439}