Skip to content

cross-platform I/Q Makefile#233

Open
edoput wants to merge 1 commit into
awslabs:mainfrom
edoput:main
Open

cross-platform I/Q Makefile#233
edoput wants to merge 1 commit into
awslabs:mainfrom
edoput:main

Conversation

@edoput

@edoput edoput commented May 21, 2026

Copy link
Copy Markdown

Dear all,

I am building I/Q on Linux and found that the makefile assumes macos specific paths.

This commit sources the correct environment variables for the build process in the makefile from isabelle itself, making the makefile portable between macos and linux.

Description of changes:

Environment variables like JEDIT_DIR or JEDIT_JAR are documented in isabelle getenv itself and can be sourced from there. This commit changes the makefile to do so and, as a result, makes the makefile portable between linux and macos.

I have used AI to make these changes but I confirm that it works on my linux machine. This is the current output of the debug recipe. As you can see it sources correctly paths such as JAVA_HOME from isabelle getenv -b JAVA_HOME

sh-5.2$ ISABELLE_HOME=/app/ make debug
Build configuration:
  PLUGIN_DIR    = /home/edoput/repo/AutoCorrode/iq
  ISABELLE_HOME = /app/
  JEDIT_JAR     = /app/contrib/jedit-20250215/jedit5.7.0-patched/jedit.jar
  JAVA_HOME     = /app/contrib/jdk-21.0.6/x86_64-linux
  SCALA_HOME    = /app/contrib/scala-3.3.4
  SCALAC        = /app/contrib/scala-3.3.4/bin/scalac
  SCALA         = /app/contrib/scala-3.3.4/bin/scala
  ISABELLE_JAR  = /app/lib/classes/isabelle.jar
  SCALA_PARSER_JAR = /app/contrib/scala-3.3.4/lib/scala-parser-combinators_3-2.4.0.jar
  XZ_JAR        = /app/contrib/xz-java-1.10/lib/xz-1.10.jar
  ZSTD_JAR      = /app/contrib/zstd-jni-1.5.6-8/zstd-jni-1.5.6-8.jar
  JAVA          = /app/contrib/jdk-21.0.6/x86_64-linux/bin/java
  JAR           = /app/contrib/jdk-21.0.6/x86_64-linux/bin/jar
  BUILD_DIR     = /home/edoput/repo/AutoCorrode/iq/build
  CLASSES_DIR   = /home/edoput/repo/AutoCorrode/iq/build/classes
  JAR_FILE      = /home/edoput/repo/AutoCorrode/iq/build/iq_plugin.jar
  INSTALL_DIR   = /.isabelle/Isabelle2025-2/jedit/jars
  SCALA_SOURCES = src/ErrorCodes.scala src/Extended_Query_Operation.scala src/IQCapabilities.scala src/IQExploreDockable.scala src/IQLogDockable.scala src/IQNormalization.scala src/IQOptions.scala src/IQPlugin.scala src/IQProtocol.scala src/IQSecurity.scala src/IQServer.scala src/IQUISettings.scala src/IQUtils.scala src/IRClient.scala
  RESOURCE_FILES = resources/dockables.xml resources/plugin.props
  TEST_SOURCES  = test/IQArgumentUtilsTest.scala test/IQLineOffsetUtilsTest.scala test/IQUtilsPathResolutionTest.scala src/test/scala/IQNormalizationTest.scala src/test/scala/IQSecurityTest.scala src/test/scala/IQServerAuthTest.scala src/test/scala/IQUISettingsTest.scala

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@hanno-becker hanno-becker added the bug Something isn't working label May 29, 2026

@hanno-becker hanno-becker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @edoput! I tested it on Mac and Linux and it works. One should error out early if the Isabelle binary is not found, but this can be follow-up.

@hanno-becker

Copy link
Copy Markdown
Collaborator

The CI failures in ip-test are unrelated and attempted to be addressed in #234

Comment thread iq/Makefile
Comment thread iq/Makefile

@hanno-becker hanno-becker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second look, noted a probably unintentional change in the scala flags. Can you restore the original, and while at it also add a check if the Isabelle binary has been found, and otherwise nudge the user to set ISABELLE_HOME appropriately?

Comment thread iq/Makefile Outdated
ISABELLE_BIN ?= $(if $(wildcard $(ISABELLE_HOME)/bin/isabelle),$(ISABELLE_HOME)/bin/isabelle,isabelle)
ifeq ($(wildcard $(ISABELLE_BIN)),)
$(error Isabelle binary not found at $(ISABELLE_BIN). \
Set ISABELLE_HOME correctly, e.g. make ISABELLE_HOME=/path/to/Isabelle/bin)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISABELLE_HOME is assumed to be the root directory here, not bin

Comment thread iq/Makefile
ZSTD_JAR := $(firstword $(wildcard $(ISABELLE_HOME)/contrib/zstd-jni-*/lib/zstd-jni-*.jar))
ISABELLE_JAR ?= $(ISABELLE_HOME)/lib/classes/isabelle.jar
JAVA_HOME ?= $(shell $(ISABELLE) getenv -b JAVA_HOME 2>/dev/null)
ISABELLE_BIN ?= $(if $(wildcard $(ISABELLE_HOME)/bin/isabelle),$(ISABELLE_HOME)/bin/isabelle,isabelle)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This renames $ISABELLE to $ISABELLE_BIN but does not adjust all usages, specifically make test below.

@hanno-becker hanno-becker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor issues still need fixing, see comments

@edoput

edoput commented Jun 1, 2026

Copy link
Copy Markdown
Author

I should have addressed the last issues. The isabelle binary is only addressed using ISABELLE_BIN and I have introduced a check that it is a real command.

In the test command ISABELLE was only used in one test.

$(ISABELLE_BIN) scala \
                -classpath "$(CLASSES_DIR):$(TEST_CLASSES_DIR)" \
                IQNormalizationTest

While the rest of the recipe uses a different pattern.

JAVA_HOME="$(JAVA_HOME)" PATH="$(JAVA_HOME)/bin:$$PATH" $(SCALA)

Which one is appropriate and should be kept?

Comment thread iq/Makefile Outdated
Comment on lines +13 to +17
ifeq ($(shell command -v "$(ISABELLE_BIN)" > /dev/null 2>&1 && echo yes),)
$(error Isabelle binary not found or not executable at $(ISABELLE_BIN). \
Set ISABELLE_HOME correctly, e.g. make ISABELLE_HOME=/path/to/Isabelle, or ensure
'isabelle' is in your PATH)
endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for not thinking of this earlier, but this will prevent a plain make help if you haven't yet figured out the ISABELLE_HOME.

Consider this:

  # Verify Isabelle binary is available (only required for build/test/install)
  .PHONY: check-isabelle
  check-isabelle:
        @command -v "$(ISABELLE_BIN)" > /dev/null 2>&1 || { \
                echo "Error: Isabelle binary not found or not executable at $(ISABELLE_BIN)." >&2; \
                echo "Set ISABELLE_HOME correctly, e.g. make ISABELLE_HOME=/path/to/Isabelle," >&2; \
                echo "or ensure 'isabelle' is in your PATH." >&2; \
                echo "Run 'make help' for more information." >&2; \
                exit 1; \
        }

and then add check-isabelle to the targets that actually run Isabelle.

Comment thread iq/Makefile
Comment on lines -95 to +104
JAVA_HOME="$(JAVA_HOME)" PATH="$(JAVA_HOME)/bin:$$PATH" cd $(CLASSES_DIR) && $(JAR) cf $(JAR_FILE) .
cd $(CLASSES_DIR) && $(JAVA_ENV) $(JAR) cf $(JAR_FILE) .

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more instances of this pattern where $(JAVA_ENV) could be used. Can you apply it uniformly?

@hanno-becker hanno-becker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small issues, and could you also squash the commits? Thanks!

This sources the correct environment variables for the build process in
the makefile from isabelle itself.
Comment thread iq/Makefile
Comment on lines -68 to 83
$(ISABELLE) scala \
$(JAVA_ENV) $(SCALA) \
-classpath "$(CLASSES_DIR):$(TEST_CLASSES_DIR)" \
IQNormalizationTest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the test -- the isabelle invocation must remain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants