head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2010.10.11.17.22.16;	author dim;	state dead;
branches;
next	1.1;

1.1
date	2010.06.09.17.59.52;	author rdivacky;	state Exp;
branches;
next	;


desc
@@


1.2
log
@SVN rev 213695 on 2010-10-11 17:22:16Z by dim

Remove more unneeded files and directories from contrib/llvm.  This
still allows us to build tblgen and clang, and further reduces the
footprint in the tree.

Approved by:	rpaulo (mentor)
@
text
@#!/usr/bin/env python

import subprocess
import difflib

def capture_2(args0, args1):
    import subprocess
    p0 = subprocess.Popen(args0, stdin=None, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    p1 = subprocess.Popen(args1, stdin=p0.stdout, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    out,_ = p1.communicate()
    return out

def normalize_nm(data):    
    lines = data.split('\n')
    lines.sort()

    # FIXME: Ignore common symbols for now.
    lines = [ln for ln in lines
             if not ln.startswith('         C')]

    return lines

def main():
    import sys
    clang = sys.argv[1]
    flags = sys.argv[2:]

    # FIXME: Relax to include undefined symbols.
    nm_args = ["llvm-nm", "-extern-only", "-defined-only"]

    llvmgcc_args = ["llvm-gcc"] + flags + ["-emit-llvm","-c","-o","-"]
    clang_args = [clang] + flags + ["-emit-llvm","-c","-o","-"]

    llvmgcc_nm = capture_2(llvmgcc_args, nm_args)
    clang_nm = capture_2(clang_args, nm_args)

    llvmgcc_nm = normalize_nm(llvmgcc_nm)
    clang_nm = normalize_nm(clang_nm)

    if llvmgcc_nm == clang_nm:
        sys.exit(0)

    print ' '.join(llvmgcc_args), '|', ' '.join(nm_args)
    print ' '.join(clang_args), '|', ' '.join(nm_args)
    for line in difflib.unified_diff(llvmgcc_nm, clang_nm,
                                     fromfile="llvm-gcc symbols",
                                     tofile="clang symbols"):
        print line
    sys.exit(1)

if __name__ == '__main__':
    main()
@


1.1
log
@SVN rev 208954 on 2010-06-09 17:59:52Z by rdivacky

Import LLVM/clang from vendor stripped of docs/ test/ website/ www/ examples/
in llvm/ and/or llvm/contrib/clang/ respectively.

Approved by:	ed (mentor)
Approved by:	core
@
text
@@

