[m-rev.] for review: make it possible to run the installed Java version of the compiler

Julien Fischer jfischer at opturion.com
Fri Sep 4 13:53:02 AEST 2015


Hi Peter,

On Fri, 4 Sep 2015, Peter Wang wrote:

> On Fri, 4 Sep 2015 11:42:14 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
>> +# If the compiler is built in the Java grade then we need to install Java
>> +# archive containing its class files (currently called top_level.jar), but
>> +# *not* the generated wrapper script 'mercury_compile' from this directory.
>> +# The latter will set the CLASSPATH variable relative to this directory and
>> +# won't work when moved to the installation directory.  Instead we use the
>> +# version of the wrapper script from the scripts directory and leave the
>> +# one here alone.
>> +#
>>   .PHONY: install_compiler
>> -install_compiler: mercury_compile install_dirs
>> -	cp `vpath_find mercury_compile$(EXT_FOR_EXE)` $(INSTALL_MERC_BIN_DIR)
>>   ifeq ($(findstring java,$(GRADE)),java)
>> +install_compiler: mercury_compile install_dirs
>>   	cp `vpath_find top_level.jar` $(INSTALL_MERC_BIN_DIR)
>> +else
>> +install_compiler: mercury_compile install_dirs
>> +	cp `vpath_find mercury_compile$(EXT_FOR_EXE)` $(INSTALL_MERC_BIN_DIR)
>>   endif
>>
>>   #-----------------------------------------------------------------------------#
>
> Use a variable of files to install instead of duplicating the rule.

Done.

>> diff --git a/mfilterjavac/Mmakefile b/mfilterjavac/Mmakefile
>> index 01122af..f758c0c 100644
>> --- a/mfilterjavac/Mmakefile
>> +++ b/mfilterjavac/Mmakefile
>> @@ -135,13 +135,19 @@ realclean_local:
>>
>>   # Installation target
>>
>> +# See the comment above the 'install_compiler' target in compiler/Mmakefile
>> +# for the reasons why we handle the java grade specially here.
>> +#
>>   .PHONY: install
>> +ifeq ($(findstring java,$(GRADE)),java)
>> +install: mfilterjavac
>> +	-[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
>> +	cp `vpath_find mfilterjavac.jar` $(INSTALL_MERC_BIN_DIR)
>> +else
>>   install: mfilterjavac
>>   	-[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
>>   	cp `vpath_find mfilterjavac$(EXT_FOR_EXE)` \
>>   		$(INSTALL_MERC_BIN_DIR)/mfilterjavac$(EXT_FOR_EXE)
>> -ifeq ($(findstring java,$(GRADE)),java)
>> -	cp `vpath_find mfilterjavac.jar` $(INSTALL_MERC_BIN_DIR)
>>   endif
>>
>>   #-----------------------------------------------------------------------------#
>
> Also here.

Also done.

>
>> diff --git a/scripts/Mmakefile b/scripts/Mmakefile
>> index bbf2813..8cd6bf6 100644
>> --- a/scripts/Mmakefile
>> +++ b/scripts/Mmakefile
>> @@ -137,6 +137,12 @@ install_scripts: $(SCRIPTS) install_dirs
>>   	done
>>   	cp *.in *.sh-subr $(SCRIPTS) $(INSTALL_RECONF_DIR)/scripts
>>   	-rm -f $(INSTALL_BINDIR)/mmake.old
>> +ifeq ($(findstring java,$(GRADE)),java)
>> +	cp mercury_compile.sh-java $(INSTALL_MERC_BIN_DIR)/mercury_compile
>> +	cp mfilterjavac.sh-java $(INSTALL_MERC_BIN_DIR)/mfilterjavac
>> +	chmod a+x $(INSTALL_MERC_BIN_DIR)/mercury_compile \
>> +		$(INSTALL_MERC_BIN_DIR)/mfilterjavac
>> +endif
>
> Do we need the chmod if the files have the executable bit set in the
> repository?

No, I have deleted that line.

>> diff --git a/scripts/mfilterjavac.sh-java b/scripts/mfilterjavac.sh-java
>> index e69de29..f818364 100755
>> --- a/scripts/mfilterjavac.sh-java
>> +++ b/scripts/mfilterjavac.sh-java
>> @@ -0,0 +1,16 @@
>> +#!/bin/sh
>> +
>> +# This script invokes the _installed_ version of the mfilterjavac when it
>> +# is built in the Java grade.
>> +
>> +DIR=${0%/*}
>> +DIR=$( cd "${DIR}" && pwd -P )
>> +case $WINDIR in
>> +   '') SEP=':' ;;
>> +   *)  SEP=';' ;;
>> +esac
>> +JARDIR="$DIR/../lib/mercury/lib/java"
>> +CLASSPATH="$DIR/mfilterjavac.jar"${SEP}$CLASSPATH${SEP}$JARDIR/mer_rt.jar${SEP}$JARDIR/mer_std.jar${SEP}$JARDIR/mer_browser.jar${SEP}$JARDIR/mer_mdbcomp.jar
>> +export CLASSPATH
>> +JAVA=${JAVA:-/usr/bin/java}
>> +exec "$JAVA" jmercury.mfilterjavac "$@"
>
> Default to JAVA=java.

Done.

I have also altered the scripts/Mmakefile to read the list of wrapper
scripts from a variable.

Julien.



More information about the reviews mailing list