unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Mike Gerwitz <mtg@gnu.org>
To: 47789@debbugs.gnu.org
Subject: [bug#47789] [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 00:27:27 -0400	[thread overview]
Message-ID: <fc94440ebc83044f49813f58633ccaa6b1becc65.1618460451.git.mtg@gnu.org> (raw)
In-Reply-To: <cover.1618460450.git.mtg@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 13805 bytes --]

This introduces tla2tools.jar, which contains the TLA+ model checker
and simulator (TLC); a TLA+ REPL; a semantic analyzer (SANY); the TLATeX
typesetting system; PlusCal translator; and more.  I have added five
wrapper scripts for convenience, rather than invoking `java' manually.
The wrapper scripts are not comprehensive; users who are familiar with
tla2tools.jar, or have read the book Specifying Systems, may still
invoke the commands in the traditional way.

The minimum JDK version is 11.  I chose to stick with that rather than
bumping it to 14 (which is the largest version currently in Guix)
because each OpenJDK version in Guix depends on the version before it,
and so it needlessly results in many 100s of MiB of unnecessary
dependencies.

Note that this is _not_ the TLA+ Toolbox, which is the GUI commonly used
with TLA+.

* gnu/packages/java.scm (tla2tools): New variable.
* gnu/packages/patches/tla2tools-build-xml.patch: New patch.
---
 gnu/packages/java.scm                         | 134 ++++++++++++++++++
 .../patches/tla2tools-build-xml.patch         | 109 ++++++++++++++
 2 files changed, 243 insertions(+)
 create mode 100644 gnu/packages/patches/tla2tools-build-xml.patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 4d6befe511..087f411258 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -14040,3 +14040,137 @@ can be interpreted by IDEs and static analysis tools to improve code analysis.")
                ;; either lgpl or asl
                license:lgpl3+
                license:asl2.0))))
+
+(define-public tla2tools
+  (let* ((version "1.8.0")
+         (tag (string-append "v" version)))
+    (package
+      (name "tla2tools")
+      (version version)
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/tlaplus/tlaplus")
+                      (commit tag)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1503ljw32mbgw1mzkyk31sxdyggli9jf5sa31chfy5g5ccaphz9b"))
+                (patches
+                 (search-patches "tla2tools-build-xml.patch"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(begin
+                    ;; Remove packaged libraries (see 'replace-libs below)
+                    (for-each delete-file (find-files "." ".*.jar$"))
+                    #t))))
+      (build-system ant-build-system)
+      (arguments
+       (let* ((tlatools "tlatools/org.lamport.tlatools/")
+              (build-xml (string-append tlatools "customBuild.xml")))
+         `(#:jdk ,openjdk11
+           #:modules ((guix build ant-build-system)
+                      (guix build utils)
+                      (ice-9 match)
+                      (srfi srfi-26))
+           #:make-flags '("-f" ,build-xml)
+           #:phases
+           (modify-phases %standard-phases
+            ;; Replace packed libs with references to jars in store
+             (add-after 'unpack 'replace-libs
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (define (input-jar input)
+                   (car (find-files (assoc-ref inputs input) "\\.jar$")))
+                 (for-each
+                  (match-lambda
+                    ((file . input)
+                     (symlink (input-jar input)
+                              (string-append ,tlatools "/lib/" file))))
+                  '(("gson/gson-2.8.6.jar" . "java-gson")
+                    ("javax.mail/mailapi-1.6.3.jar" . "java-javax-mail")
+                    ("jline/jline-terminal-3.14.1.jar" . "java-jline-terminal")
+                    ("jline/jline-reader-3.14.1.jar" . "java-jline-reader")
+                    ("lsp/org.eclipse.lsp4j.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-debug")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc-debug")
+                    ("junit-4.12.jar" . "java-junit")
+                    ("easymock-3.3.1.jar" . "java-easymock")))
+                 ;; Retain a tiny subset of the original X-Git-*
+                 ;; manifest values just to aid in debugging
+                 (substitute* ,build-xml
+                   (("\\$\\{git.tag\\}") ,tag))
+                 #t))
+             (add-before 'check 'prepare-tests
+               (lambda _
+                 ;; pcal tests write to cfg files
+                 (for-each (cut chmod <> #o644)
+                           (find-files (string-append ,tlatools
+                                                      "/test-model/pcal")
+                                       "\\.cfg$"))
+                 #t))
+             (replace 'install
+               (lambda _
+                 (let* ((share (string-append %output "/share/java"))
+                        (jar-name "tla2tools.jar"); set in project.properties
+                        (jar (string-append ,tlatools
+                                            "/dist/" jar-name))
+                        (java-cp (string-append share "/" jar-name))
+                        (bin (string-append %output "/bin")))
+                   (install-file jar share)
+                   (mkdir-p bin)
+                   ;; Generate wrapper scripts for bin/, which invoke common
+                   ;; commands within tla2tools.jar.  Users can still invoke
+                   ;; tla2tools.jar for the rest.
+                   (for-each
+                    (match-lambda
+                      ((wrapper . class)
+                       (let ((file (string-append bin "/" wrapper)))
+                         (begin
+                           (with-output-to-file file
+                             (lambda _
+                               (display
+                                (string-append
+                                 "#!" (which "sh") "\n"
+                                 "java -cp " java-cp " " class " \"$@\""))))
+                           (chmod file #o755)))))
+                    ;; bin/wrapper . java-class
+                    '(("pcal" . "pcal.trans")
+                      ("tlatex" . "tla2tex.TLA")
+                      ("tla2sany" . "tla2sany.SANY")
+                      ("tlc2" . "tlc2.TLC")
+                      ("tlc2-repl" . "tlc2.REPL"))))
+                 #t))))))
+      (native-inputs
+       `(("java-junit" ,java-junit)
+         ("java-easymock" ,java-easymock)))
+      (inputs
+       `(("java-javax-mail" ,java-javax-mail)
+         ("java-gson" ,java-gson-2.8.6)
+         ("java-jline-terminal" ,java-jline-terminal)
+         ("java-jline-reader" ,java-jline-reader)
+         ("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+         ("java-eclipse-lsp4j-jsonrpc-debug" ,java-eclipse-lsp4j-jsonrpc-debug)
+         ("java-eclipse-lsp4j-debug" ,java-eclipse-lsp4j-debug)))
+      (home-page "https://lamport.azurewebsites.net/tla/tools.html")
+      (synopsis "TLA+ tools (analyzer, TLC, TLATeX, PlusCal translator)")
+      (description "TLA+ is a high-level language for modeling programs and
+systems---especially concurrent and distributed ones.  It's based on the idea
+that the best way to describe things precisely is with simple
+mathematics.  TLA+ and its tools are useful for eliminating fundamental design
+errors, which are hard to find and expensive to correct in code.
+
+The following TLA+ tools are available in this distribution:
+
+@itemize
+@item The Syntactic Analyzer: A parser and syntax checker for
+  TLA+ specifications;
+@item TLC: A model checker and simulator for a subclass of \"executable\" TLA+
+  specifications;
+@item TLATeX: A program for typesetting TLA+ specifications;
+@item Beta test versions of 1-3 for the TLA+2 language; and
+@item The PlusCal translator.
+@end itemize")
+      (license license:expat))))
diff --git a/gnu/packages/patches/tla2tools-build-xml.patch b/gnu/packages/patches/tla2tools-build-xml.patch
new file mode 100644
index 0000000000..0bba82072a
--- /dev/null
+++ b/gnu/packages/patches/tla2tools-build-xml.patch
@@ -0,0 +1,109 @@
+tla2tools comes packaged with three separate javax.mail JARs, which it
+expects to be available to include in the JAR produced by the `dist' target.
+However, the `java-javax-mail' packaged with Guix contains all of these
+dependencies in a single JAR, so the other two are unneeded.  This patch
+removes references to them.
+
+The JAR also was expected to contain classes that are built as part of the
+test suite.  That does not seem useful, nor is it available during the
+`compile' phase, so that portion is removed.
+
+There are a number of Git attributes that are set in the final manifest.
+The branch name is kept, but the others are removed.  The build user is set
+statically to "guix".
+
+Finally, since we already have a patch, two targets `jar' and `check' are
+added to satisfy `ant-build-system' and keep the package definition more
+lean.
+
+diff --git a/tlatools/org.lamport.tlatools/customBuild.xml b/tlatools/org.lamport.tlatools/customBuild.xml
+index f0ba77cb7..748e60d95 100644
+--- a/tlatools/org.lamport.tlatools/customBuild.xml
++++ b/tlatools/org.lamport.tlatools/customBuild.xml
+@@ -36,6 +36,17 @@
+ 		<istrue value="${maven.test.halt}"/>
+ 	</condition>
+ 
++  <!-- `jar' and `check' added for Guix -->
++  <target name="jar">
++		<antcall target="compile" inheritall="true" inheritrefs="true" />
++		<antcall target="compile-aj" inheritall="true" inheritrefs="true" />
++		<antcall target="dist" inheritall="true" inheritrefs="true" />
++  </target>
++  <target name="check">
++		<antcall target="compile-test" inheritall="true" inheritrefs="true" />
++		<antcall target="test" inheritall="true" inheritrefs="true" />
++  </target>
++
+ 	<!-- https://github.com/alx3apps/jgit-buildnumber -->
+ 	<target name="git-revision">
+ 	    <taskdef name="jgit-buildnumber" classname="ru.concerteza.util.buildnumber.JGitBuildNumberAntTask">
+@@ -217,17 +228,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="${class.dir}/META-INF" />
+ 		<touch file="${class.dir}/META-INF/javamail.default.address.map"/>
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="${class.dir}">
+ 			<patternset>
+@@ -259,17 +260,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="target/classes/META-INF" />
+ 		<touch file="target/classes/META-INF/javamail.default.address.map"/>
+ 
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="target/classes">
+@@ -373,14 +364,8 @@
+ 					src/tla2sany/parser/Token.09-09-07,
+ 					src/tla2sany/parser/TokenMgrError.09-09-07"/>
+ 			<fileset dir="${doc.dir}" includes="License.txt"/>
+-			<fileset dir="${test.class.dir}">
+-				<include name="**/tlc2/tool/CommonTestCase*.class" />
+-				<include name="**/tlc2/tool/liveness/ModelCheckerTestCase*.class" />
+-				<include name="**/tlc2/TestMPRecorder*.class" />
+-				<include name="**/util/IsolatedTestCaseRunner*.class" />
+-			</fileset>
+ 			<manifest>
+-				<attribute name="Built-By" value="${user.name}" />
++				<attribute name="Built-By" value="guix" />
+ 				<attribute name="Build-Tag" value="${env.BUILD_TAG}" />
+ 				<attribute name="Build-Rev" value="${Build-Rev}" />
+ 				<attribute name="Implementation-Title" value="TLA+ Tools" />
+@@ -389,14 +374,8 @@
+ 				<!-- The jar files contains many main classes (SANY, TEX, pcal, ...) --> 
+                 <!-- but lets consider TLC the one users primarily use. --> 
+ 				<attribute name="Main-class" value="tlc2.TLC" />
+-				<attribute name="Class-Path" value="CommunityModules-deps.jar CommunityModules.jar" />
+ 				<!-- Git revision -->
+-				<attribute name="X-Git-Branch" value="${git.branch}" />
+ 				<attribute name="X-Git-Tag" value="${git.tag}" />
+-				<attribute name="X-Git-Revision" value="${git.revision}" />
+-				<attribute name="X-Git-ShortRevision" value="${git.shortRevision}" />
+-				<attribute name="X-Git-BuildNumber" value="${git.branch}_${git.tag}_${git.shortRevision}" />
+-				<attribute name="X-Git-Commits-Count" value="${git.commitsCount}" />
+ 				<!-- App-Name and Permissions is required by Java Webstart used by distributed TLC -->
+ 				<!-- Depending on security level, the user will see a warning otherwise. -->
+ 				<!-- http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/security/manifest.html -->
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  parent reply	other threads:[~2021-04-15  4:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  4:22 [bug#47789] [PATCH 0/6] Add TLA+ Tools (tla2tools) Mike Gerwitz
2021-04-15  4:25 ` [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6 Mike Gerwitz
2021-04-15  8:06   ` Maxime Devos
2021-04-16  1:13     ` Mike Gerwitz
2021-04-15 10:46   ` Julien Lepiller
2021-04-16  0:27     ` Mike Gerwitz
2021-04-15  4:26 ` [bug#47789] [PATCH 2/6] gnu: Add java-eclipse-xtext-xbase-lib Mike Gerwitz
2021-04-15  4:26 ` [bug#47789] [PATCH 3/6] gnu: Add java-eclipse-lsp4j packages Mike Gerwitz
2021-04-15  4:26 ` [bug#47789] [PATCH 4/6] gnu: Add java-jline-terminal Mike Gerwitz
2021-04-15  8:13   ` Maxime Devos
2021-04-16  0:55     ` Mike Gerwitz
2021-04-15  4:27 ` [bug#47789] [PATCH 5/6] gnu: Add java-jline-reader Mike Gerwitz
2021-04-15  4:27 ` Mike Gerwitz [this message]
2021-04-15  8:17   ` [bug#47789] [PATCH 6/6] gnu: Add tla2tools Maxime Devos
2021-04-16  0:57     ` Mike Gerwitz
2021-04-16  1:12     ` Mike Gerwitz
2021-04-16  1:23 ` [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6 Mike Gerwitz
2021-04-16  1:23 ` [bug#47789] [PATCH 2/6] gnu: Add java-eclipse-xtext-xbase-lib Mike Gerwitz
2021-04-16  1:24 ` [bug#47789] [PATCH 3/6] gnu: Add java-eclipse-lsp4j packages Mike Gerwitz
2021-04-16  1:24 ` [bug#47789] [PATCH 4/6] gnu: Add java-jline-terminal Mike Gerwitz
2021-04-16  1:24 ` [bug#47789] [PATCH 5/6] gnu: Add java-jline-reader Mike Gerwitz
2021-04-16  1:24 ` [bug#47789] [PATCH 6/6] gnu: Add tla2tools Mike Gerwitz
2021-05-05 15:02   ` bug#47789: [PATCH 0/6] Add TLA+ Tools (tla2tools) Ludovic Courtès
2021-04-16  1:29 ` [bug#47789] " Mike Gerwitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc94440ebc83044f49813f58633ccaa6b1becc65.1618460451.git.mtg@gnu.org \
    --to=mtg@gnu.org \
    --cc=47789@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).