idl2k: read copyright from profile and put it in the generated files

Also reword autogenerated warning a bit.
This commit is contained in:
Ilya Gorbunov
2018-04-23 21:25:54 +03:00
parent 8e91f31182
commit 40cd02bba6
15 changed files with 93 additions and 58 deletions
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.khronos.webgl
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom.css
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom.events
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom.parsing
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom.svg
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.dom.url
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.fetch
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.files
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.notifications
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.performance
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.workers
@@ -1,10 +1,11 @@
/*
* Generated file
* DO NOT EDIT
*
* See libraries/tools/idl2k for details
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
// See libraries/tools/idl2k for details
@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
package org.w3c.xhr
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.idl2k.util
import org.xml.sax.InputSource
import java.io.File
import javax.xml.xpath.XPathFactory
fun readCopyrightNoticeFromProfile(copyrightProfile: File): String {
val template = copyrightProfile.reader().use { reader ->
XPathFactory.newInstance().newXPath().evaluate("/component/copyright/option[@name='notice']/@value", InputSource(reader))
}
val yearTemplate = "$today.year"
val year = java.time.LocalDate.now().year.toString()
assert(yearTemplate in template)
return template.replace(yearTemplate, year).lines().joinToString("", prefix = "/*\n", postfix = " */\n") { " * $it\n" }
}
@@ -1,6 +1,7 @@
package org.jetbrains.idl2k
import org.antlr.v4.runtime.ANTLRFileStream
import org.jetbrains.idl2k.util.readCopyrightNoticeFromProfile
import java.io.*
import java.net.*
import java.util.*
@@ -16,6 +17,8 @@ fun main(args: Array<String>) {
return
}
val copyrightNotice = readCopyrightNoticeFromProfile(File("../../../.idea/copyright/apache.xml"))
val repositoryPre = srcDir.walkTopDown().filter { it.isDirectory || it.extension == "idl" }.asSequence().filter { it.isFile }.toList().sortedBy { it.absolutePath }.fold(Repository(emptyMap(), emptyMap(), emptyMap(), emptyMap())) { acc, e ->
System.err.flush()
System.err.println("Parsing ${e.absolutePath}")
@@ -82,12 +85,10 @@ fun main(args: Array<String>) {
File(outDir, pkg + ".kt").bufferedWriter().use { w ->
println("Generating for package $pkg...")
w.appendln("/*")
w.appendln(" * Generated file")
w.appendln(" * DO NOT EDIT")
w.appendln(" * ")
w.appendln(" * See libraries/tools/idl2k for details")
w.appendln(" */")
w.appendln(copyrightNotice)
w.appendln("// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!")
w.appendln("// See libraries/tools/idl2k for details")
w.appendln()
w.appendln("@file:Suppress(\"NESTED_CLASS_IN_EXTERNAL_INTERFACE\")")