comparison mxtool/mx.py @ 10568:070b4a3c56f3

disabled "noisy" log statements unless -v option (i.e. verbose) is specified to mx
author Doug Simon <doug.simon@oracle.com>
date Fri, 28 Jun 2013 11:02:37 +0200
parents 36b75ddac55e
children aee899c96b0b
comparison
equal deleted inserted replaced
10567:7cd21876c116 10568:070b4a3c56f3
1224 Gets an environment variable. 1224 Gets an environment variable.
1225 """ 1225 """
1226 value = os.environ.get(key, default) 1226 value = os.environ.get(key, default)
1227 return value 1227 return value
1228 1228
1229 def logv(msg=None):
1230 if _opts.verbose:
1231 log(msg)
1232
1229 def log(msg=None): 1233 def log(msg=None):
1230 """ 1234 """
1231 Write a message to the console. 1235 Write a message to the console.
1232 All script output goes through this method thus allowing a subclass 1236 All script output goes through this method thus allowing a subclass
1233 to redirect it. 1237 to redirect it.
1526 if not exists(classfile) or os.path.getmtime(javafile) > os.path.getmtime(classfile): 1530 if not exists(classfile) or os.path.getmtime(javafile) > os.path.getmtime(classfile):
1527 mustBuild = True 1531 mustBuild = True
1528 break 1532 break
1529 1533
1530 if not mustBuild: 1534 if not mustBuild:
1531 log('[all class files for {0} are up to date - skipping]'.format(p.name)) 1535 logv('[all class files for {0} are up to date - skipping]'.format(p.name))
1532 continue 1536 continue
1533 1537
1534 if len(javafilelist) == 0: 1538 if len(javafilelist) == 0:
1535 log('[no Java sources for {0} - skipping]'.format(p.name)) 1539 logv('[no Java sources for {0} - skipping]'.format(p.name))
1536 continue 1540 continue
1537 1541
1538 built.add(p.name) 1542 built.add(p.name)
1539 1543
1540 argfileName = join(p.dir, 'javafilelist.txt') 1544 argfileName = join(p.dir, 'javafilelist.txt')
1666 sourceDirs = p.source_dirs() 1670 sourceDirs = p.source_dirs()
1667 1671
1668 batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')) 1672 batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs'))
1669 1673
1670 if not exists(batch.path): 1674 if not exists(batch.path):
1671 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) 1675 if _opts.verbose:
1676 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path))
1672 continue 1677 continue
1673 1678
1674 for sourceDir in sourceDirs: 1679 for sourceDir in sourceDirs:
1675 for root, _, files in os.walk(sourceDir): 1680 for root, _, files in os.walk(sourceDir):
1676 for f in [join(root, name) for name in files if name.endswith('.java')]: 1681 for f in [join(root, name) for name in files if name.endswith('.java')]:
1677 batch.javafiles.append(FileInfo(f)) 1682 batch.javafiles.append(FileInfo(f))
1678 if len(batch.javafiles) == 0: 1683 if len(batch.javafiles) == 0:
1679 log('[no Java sources in {0} - skipping]'.format(p.name)) 1684 logv('[no Java sources in {0} - skipping]'.format(p.name))
1680 continue 1685 continue
1681 1686
1682 res = batches.setdefault(batch.settings(), batch) 1687 res = batches.setdefault(batch.settings(), batch)
1683 if res is not batch: 1688 if res is not batch:
1684 res.javafiles = res.javafiles + batch.javafiles 1689 res.javafiles = res.javafiles + batch.javafiles
1878 for sourceDir in sourceDirs: 1883 for sourceDir in sourceDirs:
1879 javafilelist = [] 1884 javafilelist = []
1880 for root, _, files in os.walk(sourceDir): 1885 for root, _, files in os.walk(sourceDir):
1881 javafilelist += [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java'] 1886 javafilelist += [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java']
1882 if len(javafilelist) == 0: 1887 if len(javafilelist) == 0:
1883 log('[no Java sources in {0} - skipping]'.format(sourceDir)) 1888 logv('[no Java sources in {0} - skipping]'.format(sourceDir))
1884 continue 1889 continue
1885 1890
1886 timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp') 1891 timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp')
1887 if not exists(dirname(timestampFile)): 1892 if not exists(dirname(timestampFile)):
1888 os.makedirs(dirname(timestampFile)) 1893 os.makedirs(dirname(timestampFile))
1914 name, _, suffix = configLocation.lstrip('/').partition('/') 1919 name, _, suffix = configLocation.lstrip('/').partition('/')
1915 config = join(project(name).dir, suffix) 1920 config = join(project(name).dir, suffix)
1916 else: 1921 else:
1917 config = join(p.dir, configLocation) 1922 config = join(p.dir, configLocation)
1918 else: 1923 else:
1919 log('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir)) 1924 logv('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir))
1920 continue 1925 continue
1921 1926
1922 exclude = join(p.dir, '.checkstyle.exclude') 1927 exclude = join(p.dir, '.checkstyle.exclude')
1923 1928
1924 if exists(exclude): 1929 if exists(exclude):
2873 if includeDeps: 2878 if includeDeps:
2874 deps = p.all_deps([], includeLibs=False, includeSelf=False) 2879 deps = p.all_deps([], includeLibs=False, includeSelf=False)
2875 for d in deps: 2880 for d in deps:
2876 assess_candidate(d, projects) 2881 assess_candidate(d, projects)
2877 if not assess_candidate(p, projects): 2882 if not assess_candidate(p, projects):
2878 log('[package-list file exists - skipping {0}]'.format(p.name)) 2883 logv('[package-list file exists - skipping {0}]'.format(p.name))
2879 2884
2880 2885
2881 def find_packages(sourceDirs, pkgs=set()): 2886 def find_packages(sourceDirs, pkgs=set()):
2882 for sourceDir in sourceDirs: 2887 for sourceDir in sourceDirs:
2883 for root, _, files in os.walk(sourceDir): 2888 for root, _, files in os.walk(sourceDir):