From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyldy-00017E-41 for guix-patches@gnu.org; Thu, 13 Apr 2017 16:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyldu-0004dc-3N for guix-patches@gnu.org; Thu, 13 Apr 2017 16:47:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:47922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cyldt-0004dO-VC for guix-patches@gnu.org; Thu, 13 Apr 2017 16:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cyldt-0007ND-Pb for guix-patches@gnu.org; Thu, 13 Apr 2017 16:47:01 -0400 Subject: bug#26487: Add antlr3 Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyldU-0000vg-2D for guix-patches@gnu.org; Thu, 13 Apr 2017 16:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyldQ-0004Kd-2V for guix-patches@gnu.org; Thu, 13 Apr 2017 16:46:36 -0400 Received: from dau94-h03-89-91-205-84.dsl.sta.abo.bbox.fr ([89.91.205.84]:43243 helo=skaro.lepiller.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cyldP-0004Ja-62 for guix-patches@gnu.org; Thu, 13 Apr 2017 16:46:31 -0400 Received: from localhost (localhost [127.0.0.1]) by skaro.lepiller.eu (Postfix) with ESMTP id CA84681638 for ; Thu, 13 Apr 2017 22:46:27 +0200 (CEST) Received: from skaro.lepiller.eu ([127.0.0.1]) by localhost (lepiller.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qOgkfj7JzaVH for ; Thu, 13 Apr 2017 22:46:18 +0200 (CEST) Received: from localhost (89-93-157-164.hfc.dyn.abo.bbox.fr [89.93.157.164]) by skaro.lepiller.eu (Postfix) with ESMTPSA id 64B4A80BB9 for ; Thu, 13 Apr 2017 22:46:17 +0200 (CEST) Date: Thu, 13 Apr 2017 22:46:13 +0200 From: Julien Lepiller Message-ID: <20170413224513.342184b2@lepiller.eu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/TDsrR4MB0d3cUZA.49kDqy+" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26487@debbugs.gnu.org --MP_/TDsrR4MB0d3cUZA.49kDqy+ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, here are patches to add antlr3, a parser generator. * 0001-guix-ant-build-system-Add-src-dir-parameter.patch: adds a #:src-dir parameter to the ant-build-system, to change the source directory and possibly specify more than one directory. * 0002-gnu-Add-antlr2.patch: Adds antlr2, an older version of antlr, that is required by antlr3 to generate some of its source files, and because parts of it is used by antlr3 (such as the CommonTree class). * 0003-gnu-Add-stringtemplate3.patch: Adds stringtemplate3, a runtime requirement of antlr3. It is a library to generate strings using templates. * 0004-gnu-Add-antlr3-and-stringtemplate4.patch: a big patch that adds antlr3 and stringtemplate4 (ST4). ST4 is a newer version of ST3, is a runtime dependency of antlr3 and needs antlr3 to generate some of its source files. antlr3 depends on ST4 too. I didn't find a way to split this patch further. I wanted to package antlr4, but I'm still working on its dependencies (antlr3 is one of them). --MP_/TDsrR4MB0d3cUZA.49kDqy+ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-guix-ant-build-system-Add-src-dir-parameter.patch >From 9b82f683a34f9179b18e4b6a04652888ba347c68 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 13 Apr 2017 20:18:15 +0200 Subject: [PATCH 1/4] guix: ant-build-system: Add src-dir parameter. * guix/build-system/ant.scm (ant-build): Add src-dir parameter. * guix/build/ant-build-system.scm (configure): Add src-dir parameter. (default-build.xml): Use it. * doc/guix.texi: Document it. --- doc/guix.texi | 6 +++++- guix/build-system/ant.scm | 2 ++ guix/build/ant-build-system.scm | 9 +++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 07f52becf..b9dfc03e1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3321,7 +3321,11 @@ parameters, respectively. When the original package does not provide a suitable Ant build file, the parameter @code{#:jar-name} can be used to generate a minimal Ant build file @file{build.xml} with tasks to build the specified jar -archive. +archive. By default, @file{src} will be used as the source directory. +The parameter @code{#:src-dir} can be used to change the default source +directory. This parameter accepts the ant syntax for @code{srcdir} +parameters, allowing to specify more than one directory by separating +each directory with a semicolon (as in @code{"src1:src2"}). The parameter @code{#:build-target} can be used to specify the Ant task that should be run during the @code{build} phase. By default the diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index 550f92bc7..cd544ad0d 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -98,6 +98,7 @@ (make-flags ''()) (build-target "jar") (jar-name #f) + (src-dir "src") (phases '(@ (guix build ant-build-system) %standard-phases)) (outputs '("out")) @@ -126,6 +127,7 @@ #:test-target ,test-target #:build-target ,build-target #:jar-name ,jar-name + #:src-dir ,src-dir #:phases ,phases #:outputs %outputs #:search-paths ',(map search-path-specification->sexp diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index 00a4a46d8..e2f3d4a9e 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -35,7 +35,7 @@ ;; ;; Code: -(define (default-build.xml jar-name prefix) +(define (default-build.xml jar-name prefix src-dir) "Create a simple build.xml with standard targets for Ant." (call-with-output-file "build.xml" (lambda (port) @@ -58,7 +58,7 @@ (target (@ (name "compile")) (mkdir (@ (dir "${classes.dir}"))) (javac (@ (includeantruntime "false") - (srcdir "src") + (srcdir ,src-dir) (destdir "${classes.dir}") (classpath (@ (refid "classpath")))))) @@ -97,12 +97,13 @@ to the default GNU unpack strategy." ;; Use GNU unpack strategy for things that aren't jar archives. ((assq-ref gnu:%standard-phases 'unpack) #:source source))) -(define* (configure #:key inputs outputs (jar-name #f) +(define* (configure #:key inputs outputs (jar-name #f) (src-dir "src") #:allow-other-keys) (when jar-name (default-build.xml jar-name (string-append (assoc-ref outputs "out") - "/share/java"))) + "/share/java") + src-dir)) (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "CLASSPATH" (generate-classpath inputs))) -- 2.12.2 --MP_/TDsrR4MB0d3cUZA.49kDqy+ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-gnu-Add-antlr2.patch >From eaf67c17273bf82faad4aba1105418a9a5c04435 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 13 Apr 2017 20:03:54 +0200 Subject: [PATCH 2/4] gnu: Add antlr2. * gnu/packages/java.scm (antlr2): New variable. --- gnu/packages/java.scm | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 1d18a0b06..fc9e137b8 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -1178,3 +1178,45 @@ testing frameworks, mocking libraries and UI validation rules.") JUnit provides assertions for testing expected results, test fixtures for sharing common test data, and test runners for running tests.") (license license:epl1.0))) + +(define-public antlr2 + (package + (name "antlr2") + (version "2.7.7") + (source (origin + (method url-fetch) + (uri (string-append "http://www.antlr2.org/download/antlr-" + version ".tar.gz")) + (sha256 + (base32 + "1ffvcwdw73id0dk6pj2mlxjvbg0662qacx4ylayqcxgg381fnfl5")) + (modules '((guix build utils))) + (snippet + '(begin + (delete-file "antlr.jar") + (substitute* "configure" + (("/bin/sh") "sh")))))) + (build-system gnu-build-system) + (arguments + `(#:tests? #f + #:phases + (modify-phases %standard-phases + (add-after 'configure 'fix-bin-ls + (lambda _ + (for-each (lambda (file) + (substitute* file + (("/bin/ls") "ls"))) + (find-files "Makefile"))))))) + (native-inputs + `(("which" ,which) + ("java" ,icedtea "jdk"))) + (inputs + `(("java" ,icedtea))) + (home-page "http://www.antlr2.org") + (synopsis "Framework for constructing recognizers, compilers, and translators") + (description "ANTLR, ANother Tool for Language Recognition, (formerly PCCTS) +is a language tool that provides a framework for constructing recognizers, +compilers, and translators from grammatical descriptions containing Java, C#, +C++, or Python actions. ANTLR provides excellent support for tree construction, +tree walking, and translation.") + (license license:public-domain))) -- 2.12.2 --MP_/TDsrR4MB0d3cUZA.49kDqy+ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0003-gnu-Add-stringtemplate3.patch >From b9488bf5bea2720a8b320ff7009efef665e4be80 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 13 Apr 2017 20:13:14 +0200 Subject: [PATCH 3/4] gnu: Add stringtemplate3. * gnu/packages/java.scm (stringtemplate3): New variable. --- gnu/packages/java.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index fc9e137b8..15b45a5e5 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -1220,3 +1220,41 @@ compilers, and translators from grammatical descriptions containing Java, C#, C++, or Python actions. ANTLR provides excellent support for tree construction, tree walking, and translation.") (license license:public-domain))) + +(define-public stringtemplate3 + (package + (name "stringtemplate3") + (version "3.2.1") + (source (origin + (method url-fetch) + (uri (string-append "https://github.com/antlr/website-st4/raw/" + "gh-pages/download/stringtemplate-" + version ".tar.gz")) + (sha256 + (base32 + "086yj68np1vqhkj7483diz3km6s6y4gmwqswa7524a0ca6vxn2is")))) + (build-system ant-build-system) + (arguments + `(#:jar-name "stringtemplate-3.2.1.jar" + #:tests? #f + #:phases + (modify-phases %standard-phases + (add-before 'build 'generate-grammar + (lambda _ + (let ((dir "src/org/antlr/stringtemplate/language/")) + (for-each (lambda (file) + (display file) + (newline) + (system* "antlr" "-o" dir (string-append dir file))) + '("template.g" "angle.bracket.template.g" "action.g" + "eval.g" "group.g" "interface.g")))))))) + (native-inputs + `(("antlr" ,antlr2))) + (home-page "http://www.stringtemplate.org") + (synopsis "Template engine to generate formatted text output") + (description "StringTemplate is a java template engine (with ports for C#, +Objective-C, JavaScript, Scala) for generating source code, web pages, emails, +or any other formatted text output. StringTemplate is particularly good at +code generators, multiple site skins, and internationalization / localization. +StringTemplate also powers ANTLR.") + (license license:bsd-3))) -- 2.12.2 --MP_/TDsrR4MB0d3cUZA.49kDqy+ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0004-gnu-Add-antlr3-and-stringtemplate4.patch >From cc621531355e3c77c6fcce32cff53ad294d7b549 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 13 Apr 2017 21:57:33 +0200 Subject: [PATCH 4/4] gnu: Add antlr3 and stringtemplate4. * gnu/packages/java.scm (antlr3, stringtemplate4): New variables. --- gnu/packages/java.scm | 337 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 15b45a5e5..d3f75731b 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -1258,3 +1258,340 @@ or any other formatted text output. StringTemplate is particularly good at code generators, multiple site skins, and internationalization / localization. StringTemplate also powers ANTLR.") (license license:bsd-3))) + +;; antlr3 is partially written using antlr3 grammar files. It also depends on +;; ST4 (stringtemplate4), which is also partially written using antlr3 grammar +;; files and uses antlr3 at runtime. The latest version requires a recent version +;; of antlr3 at runtime. +;; Fortunately, ST4 4.0.6 can be built with an older antlr3, and we use antlr3.3. +;; This version of ST4 is sufficient for the latest antlr3. +;; We use ST4 4.0.6 to build a boostrap antlr3 (latest version), and build +;; the latest ST4 with it. Then we build our final antlr3 that will be linked +;; against the latest ST4. +;; antlr3.3 still depends on antlr3 to generate some files, so we use an +;; even older version, antlr3.1, to generate them. Fortunately antlr3.1 uses +;; only grammar files with the antlr2 syntax. +;; So we build antlr3.1 -> antlr3.3 -> ST4.0.6 -> antlr3-bootstrap -> ST4 -> antlr3. + +(define-public stringtemplate4 + (package + (name "stringtemplate4") + (version "4.0.8") + (source (origin + (method url-fetch) + (uri (string-append "https://github.com/antlr/stringtemplate4/archive/" + version ".tar.gz")) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + "1pri8hqa95rfdkjy55icl5q1m09zwp5k67ib14abas39s4v3w087")))) + (build-system ant-build-system) + (arguments + `(#:tests? #f + #:jar-name (string-append ,name "-" ,version ".jar") + #:phases + (modify-phases %standard-phases + (add-before 'build 'generate-grammar + (lambda* (#:key inputs #:allow-other-keys) + (chdir "src/org/stringtemplate/v4/compiler/") + (for-each (lambda (file) + (display file) + (newline) + (system* "antlr3" file)) + '("STParser.g" "Group.g" "CodeGenerator.g")) + (chdir "../../../../..")))))) + (inputs + `(("antlr3" ,antlr3-bootstrap) + ("antlr2" ,antlr2) + ("stringtemplate" ,stringtemplate3))) + (home-page "http://www.stringtemplate.org") + (synopsis "Template engine to generate formatted text output") + (description "StringTemplate is a java template engine (with ports for C#, +Objective-C, JavaScript, Scala) for generating source code, web pages, emails, +or any other formatted text output. StringTemplate is particularly good at +code generators, multiple site skins, and internationalization / localization. +StringTemplate also powers ANTLR.") + (license license:bsd-3))) + +(define stringtemplate4-4.0.6 + (package + (inherit stringtemplate4) + (name "stringtemplate4") + (version "4.0.6") + (source (origin + (method url-fetch) + (uri (string-append "https://github.com/antlr/stringtemplate4/archive/ST-" + version ".tar.gz")) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + "0hjmh1ahdsh3w825i67mli9l4nncc4l6hdbf9ma91jvlj590sljp")))) + (inputs + `(("antlr3" ,antlr3-3.3) + ("antlr2" ,antlr2) + ("stringtemplate" ,stringtemplate3))))) + +(define-public antlr3 + (package + (name "antlr3") + (version "3.5.2") + (source (origin + (method url-fetch) + (uri (string-append "https://github.com/antlr/antlr3/archive/" + version ".tar.gz")) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + "07zff5frmjd53rnqdx31h0pmswz1lv0p2lp28cspfszh25ysz6sj")))) + (build-system ant-build-system) + (arguments + `(#:jar-name (string-append ,name "-" ,version ".jar") + #:src-dir "tool/src/main/java:runtime/Java/src/main/java:tool/src/main/antlr3" + #:tests? #f + #:phases + (modify-phases %standard-phases + (add-after 'install 'bin-install + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((jar (string-append (assoc-ref outputs "out") "/share/java")) + (bin (string-append (assoc-ref outputs "out") "/bin"))) + (mkdir-p bin) + (with-output-to-file (string-append bin "/antlr3") + (lambda _ + (display + (string-append "#!" (which "sh") "\n" + "java -cp " jar "/" ,name "-" ,version ".jar:" + (string-concatenate + (find-files (assoc-ref inputs "stringtemplate") + ".*\\.jar")) + ":" + (string-concatenate + (find-files (assoc-ref inputs "stringtemplate4") + ".*\\.jar")) + ":" + (string-concatenate + (find-files (string-append + (assoc-ref inputs "antlr") + "/lib") + ".*\\.jar")) + " org.antlr.Tool $*")))) + (chmod (string-append bin "/antlr3") #o755)))) + (add-before 'build 'generate-grammar + (lambda _ + (chdir "tool/src/main/antlr3/org/antlr/grammar/v3/") + (for-each (lambda (file) + (display file) + (newline) + (system* "antlr3" file)) + '("ANTLR.g" "ANTLRTreePrinter.g" "ActionAnalysis.g" + "AssignTokenTypesWalker.g" + "ActionTranslator.g" "TreeToNFAConverter.g" + "ANTLRv3.g" "ANTLRv3Tree.g" "LeftRecursiveRuleWalker.g" + "CodeGenTreeWalker.g" "DefineGrammarItemsWalker.g")) + (substitute* "ANTLRParser.java" + (("public Object getTree") "public GrammarAST getTree")) + (substitute* "ANTLRv3Parser.java" + (("public Object getTree") "public CommonTree getTree")) + (chdir "../../../../../java") + (system* "antlr" "-o" "org/antlr/tool" + "org/antlr/tool/serialize.g") + (substitute* "org/antlr/tool/LeftRecursiveRuleAnalyzer.java" + (("import org.antlr.grammar.v3.\\*;") "import org.antlr.grammar.v3.*; +import org.antlr.grammar.v3.ANTLRTreePrinter;")) + (substitute* "org/antlr/tool/ErrorManager.java" + (("case NO_SUCH_ATTRIBUTE_PASS_THROUGH:") "")) + (chdir "../../../.."))) + (add-before 'build 'fix-build-xml + (lambda _ + (substitute* "build.xml" + ((" + + + + + + + + + + + + + + + + + + + + +