Marcel Telka
2023-07-21 4d1e4691a89280c6f94dc62af1c27bb8c40866f4
makemaker.mk: get configure requirements from META.json/META.yml too

2 files modified
38 ■■■■■ changed files
make-rules/makemaker.mk 18 ●●●● patch | view | raw | blame | history
tools/perl-meta-deps 20 ●●●●● patch | view | raw | blame | history
make-rules/makemaker.mk
@@ -212,12 +212,20 @@
                | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
                | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
        fi > $@ ; \
    else \
        $(TOUCH) $@ ; \
    fi
    fi ; \
    $(TOUCH) $@
$(BUILD_DIR)/%/.depend-build:    $(BUILD_DIR)/%/MYMETA.json
    $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) build $(PERL_VERSION) < $< > $@
    $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure build $(PERL_VERSION) < $< > $@
    # Get configure requirements from META.json/META.yml too
    if [ -e $(@D)/META.json ] ; then \
        $(CAT) $(@D)/META.json ; \
    elif [ -e $(@D)/META.yml ] ; then \
        $(CAT) $(@D)/META.yml \
            | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
            | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
    fi | $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure $(PERL_VERSION) >> $@ ; \
    $(TOUCH) $@
$(BUILD_DIR)/%/.depend-runtime:    $(BUILD_DIR)/%/MYMETA.json
    $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) runtime $(PERL_VERSION) < $< > $@
$(BUILD_DIR)/%/.depend-test:    $(BUILD_DIR)/%/MYMETA.json
@@ -230,7 +238,7 @@
$(BUILD_DIR)/META.depend-test.res:    $(BUILD_$(MK_BITS):%.built=%.depend-test)
    $(CAT) $^ | $(SORT) -u > $@
# jq is needed for perl-meta-deps and to convert META.yml to MYMETA.json
# jq is needed for perl-meta-deps and to convert META.yml to JSON format
USERLAND_REQUIRED_PACKAGES += text/jq
# pyyaml is needed to convert META.yml to MYMETA.json
USERLAND_REQUIRED_PACKAGES += library/python/pyyaml
tools/perl-meta-deps
@@ -18,7 +18,7 @@
function usage
{
    [[ -n "$1" ]] && printf "ERROR: %s\n\n" "$1"
    printf "Usage: perl-meta-deps WS_MACH BUILD_DIR [build|test|runtime] PERL_VERSION\n" >&2
    printf "Usage: perl-meta-deps WS_MACH BUILD_DIR [configure|build|test|runtime]... PERL_VERSION\n" >&2
    [[ -n "$1" ]] && exit 1
    exit 0
}
@@ -32,18 +32,22 @@
BUILD_DIR="$1"
[[ -d "$BUILD_DIR" ]] && shift || usage "BUILD_DIR does not exist"
PHASES=".configure,.build,.test,.runtime"
case "$1" in
    "build")    PHASES=".configure,.build" && shift ;;
    "test")        PHASES=".test" && shift ;;
    "runtime")    PHASES=".runtime" && shift ;;
esac
PHASES=
while true ; do
    case "$1" in
        configure|build|test|runtime)
            PHASES="$PHASES,.$1" && shift ;;
        *)    break ;;
    esac
done
PHASES=${PHASES/#,}
[[ -z "$PHASES" ]] && PHASES=".configure,.build,.test,.runtime"
(($# == 0)) && usage "PERL_VERSION missing"
PERLVER=$1 && shift
PLV=${PERLVER//.}
PERL=/usr/perl5/$PERLVER/bin/perl
[[ -x "$PERL" ]] || usage "perl $PERLVER not found"
[[ -x "$PERL" ]] || usage "Perl $PERLVER not found"
PERL_ARCH=$($PERL -e 'use Config; print $Config{archname}')
(($# != 0)) && usage "Too many arguments"