# HG changeset patch # User Doug Simon # Date 1325590651 -3600 # Node ID fa6b78681c540f90a03626e9e0ded9730d6734cd # Parent 9e0c1b4cfef5b73d8b7d3ca2d3d7c5ab06a308fa Added copyright check to the gate. diff -r 9e0c1b4cfef5 -r fa6b78681c54 graal/com.oracle.max.base/.copyright.regex.hash --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.base/.copyright.regex.hash Tue Jan 03 12:37:31 2012 +0100 @@ -0,0 +1,1 @@ +(?:.*)?# Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates. All rights reserved.\n# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n#\n# This code is free software; you can redistribute it and/or modify it\n# under the terms of the GNU General Public License version 2 only, as\n# published by the Free Software Foundation.\n#\n# This code is distributed in the hope that it will be useful, but WITHOUT\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n# version 2 for more details \(a copy is included in the LICENSE file that\n# accompanied this code\).\n#\n# You should have received a copy of the GNU General Public License version\n# 2 along with this work; if not, write to the Free Software Foundation,\n# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n#\n# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n# or visit www.oracle.com if you need additional information or have any\n# questions.\n#\n.* diff -r 9e0c1b4cfef5 -r fa6b78681c54 graal/com.oracle.max.base/.copyright.regex.star --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.base/.copyright.regex.star Tue Jan 03 12:37:31 2012 +0100 @@ -0,0 +1,1 @@ +/\*\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates. All rights reserved.\n \* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n \*\n \* This code is free software; you can redistribute it and/or modify it\n \* under the terms of the GNU General Public License version 2 only, as\n \* published by the Free Software Foundation.\n \*\n \* This code is distributed in the hope that it will be useful, but WITHOUT\n \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n \* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n \* version 2 for more details \(a copy is included in the LICENSE file that\n \* accompanied this code\).\n \*\n \* You should have received a copy of the GNU General Public License version\n \* 2 along with this work; if not, write to the Free Software Foundation,\n \* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n \*\n \* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n \* or visit www.oracle.com if you need additional information or have any\n \* questions.\n \*/\n.* diff -r 9e0c1b4cfef5 -r fa6b78681c54 graal/com.oracle.max.base/src/com/sun/max/ide/JavaProject.java --- a/graal/com.oracle.max.base/src/com/sun/max/ide/JavaProject.java Mon Jan 02 17:39:20 2012 -0800 +++ b/graal/com.oracle.max.base/src/com/sun/max/ide/JavaProject.java Tue Jan 03 12:37:31 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,18 +35,15 @@ public final class JavaProject { /** - * System property name specifying the Maxine workspace directory. + * System property name specifying a directory containing a Mercurial repository. */ - public static final String MAX_WORKSPACE_PROPERTY = "max.workspace"; + public static final String HG_ROOT_PROPERTY = "hg.root"; /** - * Determines if a given directory is Maxine workspace directory. - * - * @param dir a directory to test - * @return {@code true} if {@code dir} is a directory containing a file named "projects.properties" + * Determines if a given directory contains a Mercurial repository. */ - public static boolean isWorkspace(File dir) { - return new File(dir, "projects.properties").exists(); + public static boolean isHgRoot(File dir) { + return new File(dir, ".hg").isDirectory(); } private JavaProject() { @@ -88,18 +85,18 @@ return new Classpath(classPathEntries); } - static class WorkspaceFinder extends ClasspathTraversal { + static class HgRootFinder extends ClasspathTraversal { - File workspace; + File hgRoot; File project; - boolean deriveWorkspace(File start) { + boolean deriveHgRoot(File start) { File dir = start; File child = null; while (dir != null) { - if (isWorkspace(dir)) { - workspace = dir; + if (isHgRoot(dir)) { + hgRoot = dir; project = child; return true; } @@ -113,7 +110,7 @@ protected boolean visitFile(File parent, String resource) { String classFile = JavaProject.class.getName().replace('.', File.separatorChar) + ".class"; if (resource.equals(classFile)) { - if (deriveWorkspace(parent)) { + if (deriveHgRoot(parent)) { return false; } } @@ -124,7 +121,7 @@ String classFile = JavaProject.class.getName().replace('.', File.separatorChar) + ".class"; if (resource.equals(classFile)) { File archiveFile = new File(archive.getName()); - if (deriveWorkspace(archiveFile)) { + if (deriveHgRoot(archiveFile)) { return false; } } @@ -133,23 +130,20 @@ } /** - * Gets Maxine workspace directory (i.e. the parent of all the {@linkplain #WORKSPACE_PROJECTS representative project directories}). - * This can be specified explicitly with the {@value JavaProject#MAX_WORKSPACE_PROPERTY} - * or is derived from the {@linkplain Classpath#fromSystem() system class path}. - * - * @return the Maxine workspace directory + * Gets the directory containing a Mercurial repository based on the {@value JavaProject#HG_ROOT_PROPERTY} + * if it exists otherwise from the {@linkplain Classpath#fromSystem() system class path}. */ - public static File findWorkspaceDirectory() { - final String prop = System.getProperty(JavaProject.MAX_WORKSPACE_PROPERTY); + public static File findHgRoot() { + final String prop = System.getProperty(JavaProject.HG_ROOT_PROPERTY); if (prop != null) { File dir = new File(prop); - ProgramError.check(isWorkspace(dir), prop + " is not a Maxine workspace directory"); + ProgramError.check(isHgRoot(dir), prop + " does not contain a Mercurial repository"); return dir; } - WorkspaceFinder finder = new WorkspaceFinder(); + HgRootFinder finder = new HgRootFinder(); finder.run(Classpath.fromSystem()); - ProgramError.check(finder.workspace != null, "failed to find the Maxine workspace directory"); - return finder.workspace; + ProgramError.check(finder.hgRoot != null, "failed to find a directory containing a Mercurial repository"); + return finder.hgRoot; } /** @@ -164,8 +158,8 @@ final Classpath classPath = getClassPath(projClass, includeDependencies); final List sourcePath = new LinkedList<>(); for (Entry entry : classPath.entries()) { - WorkspaceFinder finder = new WorkspaceFinder(); - finder.deriveWorkspace(entry.file()); + HgRootFinder finder = new HgRootFinder(); + finder.deriveHgRoot(entry.file()); final File projectDirectory = finder.project; if (projectDirectory != null) { final File srcDirectory = new File(projectDirectory, SOURCE_DIRECTORY_NAME); diff -r 9e0c1b4cfef5 -r fa6b78681c54 graal/com.oracle.max.base/src/com/sun/max/tools/CheckCopyright.java --- a/graal/com.oracle.max.base/src/com/sun/max/tools/CheckCopyright.java Mon Jan 02 17:39:20 2012 -0800 +++ b/graal/com.oracle.max.base/src/com/sun/max/tools/CheckCopyright.java Tue Jan 03 12:37:31 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,8 +80,7 @@ HASH("hash"); private static Map copyrightMap; - private static final String COPYRIGHT_REGEX = "com.oracle.max.base/.copyright.regex"; - private static String copyrightFiles = "bin/max|.*/makefile|.*/Makefile|.*\\.sh|.*\\.bash|.*\\.mk|.*\\.java|.*\\.c|.*\\.h"; + private static String copyrightFiles = "bin/max|.*/makefile|.*/Makefile|.*\\.sh|.*\\.py|.*\\.bash|.*\\.mk|.*\\.java|.*\\.c|.*\\.h"; private static Pattern copyrightFilePattern; private final String suffix; private String copyright; @@ -96,8 +95,12 @@ } void readCopyright() throws IOException { - final File file = new File(workSpaceDirectory, COPYRIGHT_REGEX + "." + suffix); - assert file.exists(); + String cfp = COPYRIGHT_FILE_PREFIX.getValue() + "." + suffix; + File file = new File(cfp); + if (!file.isAbsolute()) { + file = new File(hgRoot, cfp); + } + assert file.exists() : file; byte[] b = new byte[(int) file.length()]; FileInputStream is = new FileInputStream(file); is.read(b); @@ -121,6 +124,7 @@ copyrightMap.put("h", CopyrightKind.STAR); copyrightMap.put("mk", CopyrightKind.HASH); copyrightMap.put("sh", CopyrightKind.HASH); + copyrightMap.put("py", CopyrightKind.HASH); copyrightMap.put("bash", CopyrightKind.HASH); copyrightMap.put("", CopyrightKind.HASH); } @@ -168,10 +172,11 @@ private static final Option REPORT_ERRORS = options.newBooleanOption("reporterrors", true, "report non-fatal errors"); private static final Option CONTINUE_ON_ERROR = options.newBooleanOption("continueonerror", false, "continue after normally fatal error"); private static final Option HG_PATH = options.newStringOption("hgpath", "hg", "path to hg executable"); + private static final Option COPYRIGHT_FILE_PREFIX = options.newStringOption("cfp", "com.oracle.max.base/.copyright.regex", "path to hg executable"); private static final String NON_EXISTENT_FILE = "abort: cannot follow nonexistent file:"; private static String hgPath; private static boolean error; - private static File workSpaceDirectory; + private static File hgRoot; public static void main(String[] args) { @@ -185,7 +190,7 @@ hgPath = HG_PATH.getValue(); - workSpaceDirectory = JavaProject.findWorkspaceDirectory(); + hgRoot = JavaProject.findHgRoot(); if (FILE_PATTERN.getValue() != null) { CopyrightKind.addCopyrightFilesPattern(FILE_PATTERN.getValue()); @@ -284,7 +289,7 @@ assert s.startsWith("changeset"); s = logInfo.get(ix++); // process every entry in a given change set - if (s.startsWith("tag")) { + while (s.startsWith("tag")) { s = logInfo.get(ix++); } if (s.startsWith("branch")) { @@ -293,7 +298,7 @@ while (s.startsWith("parent")) { s = logInfo.get(ix++); } - assert s.startsWith("user"); + assert s.startsWith("user") : logInfo; s = logInfo.get(ix++); assert s.startsWith("date"); final int csYear = getYear(s); diff -r 9e0c1b4cfef5 -r fa6b78681c54 mx/commands.py --- a/mx/commands.py Mon Jan 02 17:39:20 2012 -0800 +++ b/mx/commands.py Tue Jan 03 12:37:31 2012 +0100 @@ -43,6 +43,10 @@ os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make')) +def copyrightcheck(args): + """run copyright check on the Mercurial controlled source files""" + mx.run_java(['-cp', mx.classpath('com.oracle.max.base', resolve=False), 'com.sun.max.tools.CheckCopyright', '-cfp=' + join(mx.project('com.oracle.max.base').dir, '.copyright.regex')] + args) + def export(args): """create a GraalVM zip file for distribution""" @@ -545,15 +549,26 @@ mx.log(time.strftime('%d %b %Y %H:%M:%S - Build...')) build([]) - # 5. Bootstrap with system assertions enabled + # 5 Copyright check + mx.log(time.strftime('%d %b %Y %H:%M:%S - Running copyright check...')) + hgNode = mx.get_env('hg_node') + if hgNode is None: + copyrightcheck(['-modified', '-reporterrors=true', '-continueonerror']) + else: + revTip = int(subprocess.check_output(['hg', 'tip', '--template', "'{rev}'"]).strip("'")) + revLast = int(subprocess.check_output(['hg', 'log', '-r', hgNode, '--template', "'{rev}'"]).strip("'")) + changesetCount = revTip - revLast + 1 + copyrightcheck(['-last=' + str(changesetCount), '-reporterrors=true', '-continueonerror']) + + # 6. Bootstrap with system assertions enabled mx.log(time.strftime('%d %b %Y %H:%M:%S - Bootstrap with -esa...')) vm(['-esa', '-version']) - # 6. Run unittests + # 7. Run unittests mx.log(time.strftime('%d %b %Y %H:%M:%S - Running unit tests...')) unittest([]) - # 7. Run selected DaCapo benchmarks + # 8. Run selected DaCapo benchmarks mx.log(time.strftime('%d %b %Y %H:%M:%S - Running DaCapo benchmarks...')) dacapo(['eclipse']) #dacapo(['tradesoap']) @@ -569,6 +584,7 @@ commands = { 'build': [build, ''], 'clean': [clean, ''], + 'copyrightcheck': [copyrightcheck, ''], 'dacapo': [dacapo, '[benchmark] [VM options|DaCapo options]'], 'example': [example, '[-v] example names...'], 'gate' : [gate, ''],