diff options
-rw-r--r-- | openjdk/AssemblyInfo.java.in | 25 | ||||
-rw-r--r-- | openjdk/openjdk.build | 8 | ||||
-rw-r--r-- | tools/SourceLicenseAnalyzer.cs | 209 | ||||
-rw-r--r-- | tools/tools.build | 6 |
4 files changed, 224 insertions, 24 deletions
diff --git a/openjdk/AssemblyInfo.java.in b/openjdk/AssemblyInfo.java.in index ca079f26..37ae9b91 100644 --- a/openjdk/AssemblyInfo.java.in +++ b/openjdk/AssemblyInfo.java.in @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2009 Jeroen Frijters + Copyright (C) 2006-2013 Jeroen Frijters This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,28 +25,7 @@ @cli.System.Reflection.AssemblyCopyrightAttribute.Annotation( "This software is licensed under the GNU General Public License version 2 + \"Classpath\" exception.\r\n" + "See http://www.gnu.org/software/classpath/license.html for details.\r\n" + - "Copyright (C) 1988 AT&T\r\n" + - "Copyright (C) 2004 BEA Systems\r\n" + - "Copyright (C) 1995 Colin Plumb\r\n" + - "Copyright (C) 1999-2008 Free Software Foundation, Inc.\r\n" + - "Copyright (C) 2001-2005 freebxml.org\r\n" + - "Copyright (C) 1998 FundsXpress, Inc.\r\n" + - "Copyright (C) 2008-2011 i-net software\r\n" + - "Copyright (C) 2000-2007 INRIA, France Telecom\r\n" + - "Copyright (C) 1993-2005 International Business Machines, Inc.\r\n" + - "Copyright (C) 2002-2011 Jeroen Frijters\r\n" + - "Copyright (C) 1993-2010 Oracle and/or its affiliates\r\n" + - "Copyright (C) 2007 Red Hat, Inc.\r\n" + - "Copyright (C) 1996-1998 Taligent, Inc.\r\n" + - "Copyright (C) 2001-2002 Thai Open Source Software Center Ltd\r\n" + - "Copyright (C) 1999-2006 The Apache Software Foundation\r\n" + - "Copyright (C) 1995-2000 The Cryptix Foundation Limited\r\n" + - "Copyright (C) 1997 The Open Group Research Institute\r\n" + - "Copyright (C) 1991-2007 Unicode, Inc.\r\n" + - "Copyright (C) 1999 Visual Numerics Inc.\r\n" + - "Copyright (C) 2003 Wily Technology, Inc.\r\n" + - "Copyright (C) 2000-2004 World Wide Web Consortium" -) +@COPYRIGHT@) @cli.System.Reflection.AssemblyTitleAttribute.Annotation("IKVM.NET OpenJDK Library for .NET") @cli.System.Reflection.AssemblyProductAttribute.Annotation("IKVM.NET") diff --git a/openjdk/openjdk.build b/openjdk/openjdk.build index 72a0bae2..37f23b2d 100644 --- a/openjdk/openjdk.build +++ b/openjdk/openjdk.build @@ -17,6 +17,11 @@ <property name="VERSION" value="${assemblyname::get-version(assemblyname::get-assembly-name(path::combine(project::get-base-directory(), '../bin/IKVM.Runtime.dll')))}" /> </target> + <target name="copyright" depends="allsources.gen.lst"> + <exec program="${project::get-base-directory()}/../tools/SourceLicenseAnalyzer.exe" output="copyright.txt" useruntimeengine="true" /> + <loadfile file="copyright.txt" property="COPYRIGHT" /> + </target> + <target name="allsources.gen.lst"> <copy file="allsources.lst" tofile="allsources.gen.lst" outputencoding="ascii" overwrite="true"> <filterchain> @@ -65,7 +70,7 @@ </delete> </target> - <target name="classes" depends="version allsources.gen.lst System.Core"> + <target name="classes" depends="version copyright allsources.gen.lst System.Core"> <delete> <fileset basedir="../classpath"> <include name="**.class"/> @@ -104,6 +109,7 @@ <replacetokens> <token key="RUNTIME" value="${IKVM.Runtime}" /> <token key="VERSION" value="${VERSION}" /> + <token key="COPYRIGHT" value="${COPYRIGHT}" /> </replacetokens> </filterchain> </copy> diff --git a/tools/SourceLicenseAnalyzer.cs b/tools/SourceLicenseAnalyzer.cs new file mode 100644 index 00000000..e21d5343 --- /dev/null +++ b/tools/SourceLicenseAnalyzer.cs @@ -0,0 +1,209 @@ +/* + Copyright (C) 2013 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +using System; +using System.IO; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace SourceLicenseAnalyzer +{ + class Years + { + internal static Years Dummy = new Years(); + internal int min = Int32.MaxValue; + internal int max = Int32.MinValue; + internal string name; + } + + class Program + { + static Dictionary<string, string> aliases = new Dictionary<string, string>(); + static Dictionary<string, Years> copyrights = new Dictionary<string, Years>(); + static int errorCount; + + static void Def(string name, params string[] aliasesList) + { + Years y = new Years(); + y.name = name; + copyrights.Add(name, y); + aliases.Add(name, name); + foreach (string s in aliasesList) + { + aliases.Add(s, name); + } + } + + static int Main(string[] args) + { + Def("Free Software Foundation", "Free Software Foundation", "Free Software Foundation", "Free Software Fonudation, Inc."); + Def("Sun Microsystems, Inc.", "Sun Microsystems Inc"); + Def("Jeroen Frijters"); + Def("Thai Open Source Software Center Ltd"); + Def("World Wide Web Consortium"); + Def("International Business Machines, Inc.", "IBM Corp.", "IBM Corporation", "International Business Machines.", "International Business Machines Corporation"); + Def("Wily Technology, Inc."); + Def("Unicode, Inc."); + Def("Colin Plumb"); + Def("Taligent, Inc."); + Def("Red Hat, Inc."); + Def("The Open Group Research Institute"); + Def("FundsXpress, INC."); + Def("AT&T"); + Def("The Apache Software Foundation"); + Def("freebxml.org"); + Def("The Cryptix Foundation Limited"); + Def("Visual Numerics Inc."); + Def("INRIA, France Telecom"); + Def("Oracle and/or its affiliates", "Oracle Corporation"); + Def("i-net software"); + Def("Google Inc."); + + + // these are false positives + copyrights.Add("dummy", Years.Dummy); + aliases.Add("icSigCopyrightTag", "dummy"); + aliases.Add("Copyright notice to stick into built-in-profile files.", "dummy"); + aliases.Add("AssemblyCopyrightAttribute", "dummy"); + aliases.Add("getVersionAndCopyrightInfo()", "dummy"); + aliases.Add("Copyright by IBM and others and distributed under the * distributed under MIT/X", "dummy"); + aliases.Add("* Copyright Office. *", "dummy"); + aliases.Add("* Copyright office. *", "dummy"); + aliases.Add("Your Corporation", "dummy"); + aliases.Add("but I wrote that code so I co-own the copyright", "dummy"); + aliases.Add("identifying information: \"Portions Copyrighted [year] * [name of copyright owner]\"", "dummy"); + + using (StreamReader rdr = new StreamReader("allsources.gen.lst")) + { + string file; + while ((file = rdr.ReadLine()) != null) + { + if (file != "AssemblyInfo.java") + { + ProcessFile(file); + } + } + } + + Years[] years = new Years[copyrights.Count]; + copyrights.Values.CopyTo(years, 0); + + Array.Sort(years, delegate(Years x, Years y) { return x.name == null ? 0 : x.name.CompareTo(y.name); }); + + bool first = true; + foreach (Years y in years) + { + if (y != Years.Dummy) + { + if (!first) + { + Console.WriteLine("\\r\\n\" +"); + } + first = false; + Console.Write(" \""); + if (y.min != y.max) + { + Console.Write("{0}-{1} {2}", y.min, y.max, y.name); + } + else + { + Console.Write("{0} {1}", y.min, y.name); + } + } + } + Console.WriteLine("\""); + + return errorCount; + } + + static void ProcessFile(string filePath) + { + bool gpl = false; + bool classpathException = false; + using (StreamReader rdr = new StreamReader(filePath)) + { + string line; + string nextline = null; + while ((line = rdr.ReadLine()) != null) + { + gpl |= line.Contains("GNU General Public License"); + classpathException |= line.Contains("subject to the \"Classpath\" exception") || line.Contains("permission to link this library with independent modules"); + while (line != null && line.IndexOf("Copyright") != -1) + { + Years y = null; + foreach (KeyValuePair<string, string> kv in aliases) + { + if (line.IndexOf(kv.Key) != -1) + { + y = copyrights[kv.Value]; + break; + } + } + if (y == null) + { + if (nextline == null) + { + nextline = rdr.ReadLine(); + if (nextline.IndexOf("Copyright") == -1) + { + line += nextline; + continue; + } + } + if (filePath.Contains("/impsrc/com/sun/xml/internal/rngom/") && line.Contains("* Copyright (C) 2004-2011 *")) + { + // HACK ignore bogus copyright line + } + else + { + Error(filePath + ":" + Environment.NewLine + line); + } + } + else + { + foreach (Match m in Regex.Matches(line, "[0-9][0-9][0-9][0-9]")) + { + int v = Int32.Parse(m.Value); + y.min = Math.Min(y.min, v); + y.max = Math.Max(y.max, v); + } + } + line = nextline; + nextline = null; + } + } + } + if (gpl && !classpathException) + { + Error("GPL without Classpath exception: {0}", filePath); + } + } + + static void Error(string message, params object[] args) + { + errorCount++; + Console.Error.WriteLine(message, args); + } + } +} diff --git a/tools/tools.build b/tools/tools.build index 5e45aa67..4107e551 100644 --- a/tools/tools.build +++ b/tools/tools.build @@ -37,5 +37,11 @@ </sources> </csc> <exec program="writeappconfig.exe" useruntimeengine="true" /> + + <csc target="exe" output="SourceLicenseAnalyzer.exe" rebuild="true"> + <sources> + <include name="SourceLicenseAnalyzer.cs" /> + </sources> + </csc> </target> </project> |