Skip to content

"make prepare" failing on building xamarin-android from source. #1493

@jgold6

Description

@jgold6

Steps to Reproduce

(not reproducible in all environments, but I can reproduce on both of my Macs)

  1. Do a new checkout of xamarin-android d15-6 branch (issue affect master also, but output is different)
  2. Run make prepare

Expected Behavior

make prepare step will succeed

Actual Behavior

make prepare step fails with

build-tools/scripts/jdk.mk:130: *** missing separator.  Stop.
make: *** [prepare-external] Error 2

Notes

After much discussion and testing, it was determined that the command:

_DARWIN_JDK_FALLBACK_DIRS := $(wildcard /Library/Java/JavaVirtualMachines/jdk*)
_DARWIN_JDK_ROOT := $(shell ls -dtr $(_DARWIN_JDK_FALLBACK_DIRS) | sort | tail -1)

in the jdk.mk file was causing some erroneous characters in the path that was later used in JI_JVM_PATH, which is evaluated on line 130 and caused the make prepare step to fail with the "missing separator" error.

After _DARWIN_JDK_ROOT was assigned as above, outputting it with:

echo _DARWIN_JDK_ROOT=$(_DARWIN_JDK_ROOT)

resulted in very odd output:

echo _DARWIN_JDK_ROOT=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk
_DARWIN_JDK_ROOT=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkin/sh: 49m: command not found
make: *** [jonp] Error 127

This strange output causes the jdk.mk file to stop on line 130 (using the d15-6 branch of xamarin-android) as the path was obviously not correct in the JI_JVM_PATH and apparently was deemed as "missing a separator."

That strange output can be reproduced more simply with the following in a makefile:

_DARWIN_JDK_ROOT := $(shell ls -d /path/to/any/folder)
jonp:
        echo _DARWIN_JDK_ROOT=$(_DARWIN_JDK_ROOT)

I have attached a zipped folder that should serve as a complete repro called testmakefile.zip
testmakefile.zip

Neither Jon P nor Alex K were able to reproduce this issue on their systems.

I found an SO post that seems to indicate that using $(shell ls ... ) in a makefile is unreliable and should be avoided, so perhaps we need to modify jdk.mk to avoid using $(shell ls ...) and instead use $(shell find ...) or $(wildcard ...) both of which worked to resolve this issue in the jdk.mk file.

e.g.:

_DARWIN_JDK_ROOT := $(shell find $(_DARWIN_JDK_FALLBACK_DIRS) -depth 0 | sort -n | tail -1)

SO post: https://stackoverflow.com/a/10024479/2913599

Relevant paragraph:

Finally, as a general rule (not really applicable to this example): as esperanto notes in comments, using the output from ls is not completely reliable (some details depend on file names and sometimes even the version of ls; some versions of ls attempt to sanitize output in some cases). Thus, as l0b0 and idelic note, if you're using GNU make you can use $(wildcard) and $(subst ...) to accomplish everything inside make itself (avoiding any "weird characters in file name" issues). (In sh scripts, including the recipe portion of makefiles, another method is to use find ... -print0 | xargs -0 to avoid tripping over blanks, newlines, control characters, and so on.)

Version Information

macOS 10.13.3

Log File

XAd15-6MakePrepareOutput.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions