-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bat file to run Apalache on Windows #2980
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
db26c3b
Add bat file to easily run Apalache on Windows
bugarela 2048a73
Fix typo
bugarela cce9b89
Delete file that is not used in the distribution
bugarela 2d4df36
Update installation instructions
bugarela 585ced5
Fix typos
bugarela 5c58646
Merge branch 'main' into gabriela/bat-file
bugarela File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@echo off | ||
rem Run the APALACHE model checker | ||
rem | ||
rem NOTE: The primary intended use for this script is to be copied into the | ||
rem packaged produced. | ||
rem | ||
rem Gabriela Moreira, 2024 | ||
|
||
rem Set the directory where the script is run from | ||
set "DIR=%~dp0" | ||
|
||
rem Set the path to the APALACHE JAR file | ||
set "APALACHE_JAR=%DIR%\..\lib\apalache.jar" | ||
|
||
rem Set JVM arguments | ||
set "JVM_ARGS=" | ||
|
||
rem Check if the APALACHE JAR file exists | ||
if not exist "%APALACHE_JAR%" ( | ||
echo ERROR: No file found at %APALACHE_JAR% | ||
echo Ensure you have run 'make package' and are running the script from the | ||
echo distribution package, or else set APALACHE_JAR to point to your custom | ||
echo build jar. | ||
exit /b 1 | ||
) | ||
|
||
rem Check if the heap size is already set | ||
echo %JVM_ARGS% | findstr /C:"-Xmx" >nul || echo %JVM_ARGS% | findstr /C:"-XX:MaxRAMPercentage" >nul || set "JVM_ARGS=-Xmx4096m" | ||
|
||
rem Check whether the command-line arguments contain the debug flag | ||
echo %* | find "--debug" >nul && ( | ||
echo # Tool home: %DIR% | ||
echo # Package: %APALACHE_JAR% | ||
echo # JVM args: %JVM_ARGS% | ||
echo # | ||
) | ||
|
||
rem Run the Java command | ||
java %JVM_ARGS% -jar "%APALACHE_JAR%" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
@echo off | ||||||
rem Run the APALACHE model checker | ||||||
rem | ||||||
rem NOTE: The primary intended use for this script is to be copied into the | ||||||
rem packaged produced. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
rem | ||||||
rem Gabriela Moreira, 2024 | ||||||
|
||||||
rem Set the directory where the script is run from | ||||||
set "DIR=%~dp0" | ||||||
|
||||||
rem Set the path to the APALACHE JAR file | ||||||
set "APALACHE_JAR=%DIR%\..\lib\apalache.jar" | ||||||
|
||||||
rem Set JVM arguments | ||||||
set "JVM_ARGS=" | ||||||
|
||||||
rem Check if the APALACHE JAR file exists | ||||||
if not exist "%APALACHE_JAR%" ( | ||||||
echo ERROR: No file found at %APALACHE_JAR% | ||||||
echo Ensure you have run 'make package' and are running the script from the | ||||||
echo distribution package, or else set APALACHE_JAR to point to your custom | ||||||
echo build jar. | ||||||
exit /b 1 | ||||||
) | ||||||
|
||||||
rem Check if the heap size is already set | ||||||
echo %JVM_ARGS% | findstr /C:"-Xmx" >nul || echo %JVM_ARGS% | findstr /C:"-XX:MaxRAMPercentage" >nul || set "JVM_ARGS=-Xmx4096m" | ||||||
|
||||||
rem Check whether the command-line arguments contain the debug flag | ||||||
echo %* | find "--debug" >nul && ( | ||||||
echo # Tool home: %DIR% | ||||||
echo # Package: %APALACHE_JAR% | ||||||
echo # JVM args: %JVM_ARGS% | ||||||
echo # | ||||||
) | ||||||
|
||||||
rem Run the Java command | ||||||
java %JVM_ARGS% -jar "%APALACHE_JAR%" %* |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would fail to locate the jar when the script is located in ./bin
Are you including this script twice because there's no symlinks on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I don't get why it would fail, and also I've tested it in Windows and it works (I've put it alongside the bash file in the
bin
folder, which is a sibling oflib
).I haven't noticed that one of the bash files was actually a symlink 🤦. I guess it should be fine if the bat is a symlink as well, since these get copied at the release. I'm looking at my apalache distribution downloaded by Quint and the bash in it is a proper file (not symlink), and that is what Windows will be using. So I'll fix this so this
bat
under comment is a symlink.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaiu, the script in src/universal/bin is the one that's copied to the distribution?
The relative lookup via ../lib will only work relative to src/universal/bin
The reason it works in bash is that ${BASH_SOURCE[0]} gives you the path of the bash file that's executing (i.e., the target of the symlink)
So I would suggest to only keep one batch file, the one that's copied to the distribution. The other one (the symlink in ./bin) only exists to facilitate running a custom build from the source tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, last time I checked, Windows didn't understand symlinks (or at least not the one produced by ln on Linux)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I get what you mean. I think this is doing the same thing because of how
DIR
is defined 3 lines above this. See https://stackoverflow.com/questions/112055/what-does-d0-mean-in-a-windows-batch-file, this also will five the path of the bat file itself.Unless you mean that this will only work if this file is a symlink to the one in
src/universal/bin
- of course, I'll fix that as I said above. Since the bash is a symlink, this should also be a symlink - I just failed to notice that this was the case before you brought it up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant before was: we only need the distribution to include the bat file in order to use it on Windows, and with the bash, this is currently a proper file, not a symlink. We don't need to be able to package Apalache on Windows, so I think it will be fine to only have the one in
universal
which I think is the one that gets distributed anyway.I have to test this out, but I have to run right now, so I'll do it tomorrow and let you know if it works as I expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was also only typing on my phone and had no way to confirm 😅
Yeah, that's what I meant. There is no
..\lib
relative to%DIR%
for/bin/apalache-mc.bat
.The one included in the packaged distribution is taken from
/src/universal/bin/
, so I think we should just keep this one, and drop the duplicate in/bin
.