Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8218431

Improved platform checking in makefiles

XMLWordPrintable

    • b08

        To check for various aspects of the build or target platform, we do a lot of checks like:
        ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin)
        ...

        The naming of those platform information variables is a bit unfortunate. Yes, we know we're building OpenJDK, so why the OPENJDK_ prefix? I've been wanting for a long time to do something about this odd prefix, and it became more urgent after the recent fix of JDK-8160926, which pushes the matter about unifying the naming of build/target variables.

        The solution in this patch is not to rename the variables per se, but to introduce an abstraction layer in terms of function calls for checking platform aspects.

        This *really* shines when it comes to testing for multiple platforms. Previously, we were required to resort to constructs such as:

        ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )

        but this can now be expressed as:

        ifeq ($(call isTargetOs, windows solaris), true)

        Or this (actually technically broken) horrible example:

        ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx))

        which I had to read three times before being sure that this was the correct way to replace it:

        ifeq ($(call isTargetOs, linux macosx), true)

              ihse Magnus Ihse Bursie
              ihse Magnus Ihse Bursie
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: