Skip to content

Commit ad7dc14

Browse files
committed
Use authoring tools only when available
For example, perldocker installs Dist::Zilla only from Perl v5.20 onwards. Authoring tools are executed when their config file exists and either: - the authoring tool is available, or - no Build.PL or Makefile.PL is available
1 parent 1050024 commit ad7dc14

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

bin/build-dist

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,44 @@ set -e -u -o pipefail
44

55
: "${BUILD_DIR:=build_dir}"
66

7+
[[ -e Build.PL -o -e Makefile.PL ]] && requires_build=false || requires_build=true
8+
79
main() (
8-
if [[ -e dist.ini ]]; then dzil-build
9-
elif [[ -e minil.toml ]]; then minil-build
10+
if can-run-dzil-build; then dzil-build
11+
elif can-run-minil-build; then minil-build
1012
elif [[ -e Build.PL ]]; then build-pl
1113
elif [[ -e Makefile.PL ]]; then std-perl-build
1214
fi
1315
)
1416

17+
SUCCESS=0
18+
FAILURE=1
19+
20+
can-run-authoring-tool () {
21+
local file="$1"
22+
local tool="$2"
23+
24+
# file doesn't exist ? => don't
25+
# is authoring tool available ? => run
26+
# does build file exist ? => don't
27+
# othwerwise run and fail
28+
29+
[[ -e "$file" ]] || return $FAILURE
30+
which "$tool" && return $SUCCESS
31+
[[ -e Build.PL ]] && return $FAILURE
32+
[[ -e Makefile.PL ]] && return $FAILURE
33+
34+
return $SUCCESS
35+
}
36+
37+
can-run-dzil-build() {
38+
can-run-dzil-build dist.ini dzil
39+
}
40+
41+
can-run-minil-build() {
42+
can-run-dzil-build minil.toml minil
43+
}
44+
1545
dzil-build() (
1646
dzil build --no-tgz --in "$BUILD_DIR"
1747
)

0 commit comments

Comments
 (0)