From: Graham Knop Date: Tue, 11 Aug 2020 00:40:51 +0000 (+0200) Subject: revise makefile additions to remove literal tabs from source X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDistar.git;a=commitdiff_plain;h=66243909818eed370753bb73865165d17cdff805 revise makefile additions to remove literal tabs from source Rather than adding raw text blobs, allow providing arrayrefs for commands to add to Makefile. Content in arrayrefs will automatically be tab indented. This allows the raw tabs to be removed from the source, as well as making it easier to add calculated content to command lists. --- diff --git a/lib/Distar.pm b/lib/Distar.pm index 97dda68..c597b9a 100644 --- a/lib/Distar.pm +++ b/lib/Distar.pm @@ -224,73 +224,101 @@ END_FRAG my @out; - push @out, <<'END'; -preflight: check-version check-manifest check-cpan-upload - $(ABSPERLRUN) $(HELPERS)/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH) -check-version: - $(ABSPERLRUN) $(HELPERS)/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES) -check-manifest: - $(ABSPERLRUN) $(HELPERS)/check-manifest -check-cpan-upload: - $(NOECHO) cpan-upload -h $(DEV_NULL_STDOUT) -releasetest: - $(MAKE) disttest RELEASE_TESTING=1 DISTTEST_MAKEFILE_PARAMS="PREREQ_FATAL=1" PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\"" - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(ECHO) "Failed to generate $(DISTVNAME)/LICENSE!" >&2 - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE -release: preflight - $(MAKE) releasetest - $(GET_CHANGELOG) -p"Release commit for $(VERSION)" | git commit -a -F - - $(GET_CHANGELOG) -p"release v$(VERSION)" | git tag -a -F - "v$(VERSION)" - $(RM_RF) $(DISTVNAME) - $(MAKE) $(DISTVNAME).tar$(SUFFIX) - $(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE) -pushrelease :: - $(NOECHO) $(NOOP) -pushrelease$(FAKE_RELEASE) :: - cpan-upload $(DISTVNAME).tar$(SUFFIX) - git push origin v$(VERSION) HEAD -distdir: readmefile licensefile -readmefile: create_distdir - $(NOECHO) $(TEST_F) $(DISTVNAME)/README || $(MAKE) $(DISTVNAME)/README -$(DISTVNAME)/README: $(VERSION_FROM) - $(NOECHO) $(MKPATH) $(DISTVNAME) - pod2text $(VERSION_FROM) >$(DISTVNAME)/README - $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) README -distsignature: readmefile licensefile -licensefile: create_distdir - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(MAKE) $(DISTVNAME)/LICENSE || $(TRUE) -$(DISTVNAME)/LICENSE: Makefile.PL - $(NOECHO) $(MKPATH) $(DISTVNAME) - $(ABSPERLRUN) $(HELPERS)/generate-license -o $(DISTVNAME)/LICENSE $(AUTHORS) $(LICENSES) - $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) LICENSE -disttest: distmanicheck -distmanicheck: create_distdir - cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck" -nextrelease: - $(ABSPERLRUN) $(HELPERS)/add-changelog-heading --git $(VERSION) $(CHANGELOG) -refresh: - $(UPDATE_DISTAR) - $(RM_F) $(FIRST_MAKEFILE) - $(REMAKE) -END + push @out, ( + 'preflight: check-version check-manifest check-cpan-upload' => [ + '$(ABSPERLRUN) $(HELPERS)/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH)', + ], + 'check-version:' => [ + '$(ABSPERLRUN) $(HELPERS)/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES)', + ], + 'check-manifest:' => [ + '$(ABSPERLRUN) $(HELPERS)/check-manifest', + ], + 'check-cpan-upload:' => [ + '$(NOECHO) cpan-upload -h $(DEV_NULL_STDOUT)', + ], + 'releasetest:' => [ + '$(MAKE) disttest RELEASE_TESTING=1 DISTTEST_MAKEFILE_PARAMS="PREREQ_FATAL=1" PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\""', + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(ECHO) "Failed to generate $(DISTVNAME)/LICENSE!" >&2', + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE', + ], + 'release: preflight' => [ + '$(MAKE) releasetest', + '$(GET_CHANGELOG) -p"Release commit for $(VERSION)" | git commit -a -F -', + '$(GET_CHANGELOG) -p"release v$(VERSION)" | git tag -a -F - "v$(VERSION)"', + '$(RM_RF) $(DISTVNAME)', + '$(MAKE) $(DISTVNAME).tar$(SUFFIX)', + '$(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE)', + ], + 'pushrelease ::' => [ + '$(NOECHO) $(NOOP)', + ], + 'pushrelease$(FAKE_RELEASE) ::' => [ + 'cpan-upload $(DISTVNAME).tar$(SUFFIX)', + 'git push origin v$(VERSION) HEAD', + ], + 'distdir: readmefile licensefile', + 'readmefile: create_distdir' => [ + '$(NOECHO) $(TEST_F) $(DISTVNAME)/README || $(MAKE) $(DISTVNAME)/README', + ], + '$(DISTVNAME)/README: $(VERSION_FROM)' => [ + '$(NOECHO) $(MKPATH) $(DISTVNAME)', + 'pod2text $(VERSION_FROM) >$(DISTVNAME)/README', + '$(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) README', + ], + 'distsignature: readmefile licensefile', + 'licensefile: create_distdir' => [ + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(MAKE) $(DISTVNAME)/LICENSE || $(TRUE)', + ], + '$(DISTVNAME)/LICENSE: Makefile.PL' => [ + '$(NOECHO) $(MKPATH) $(DISTVNAME)', + '$(ABSPERLRUN) $(HELPERS)/generate-license -o $(DISTVNAME)/LICENSE $(AUTHORS) $(LICENSES)', + '$(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) LICENSE', + ], + 'disttest: distmanicheck', + 'distmanicheck: create_distdir' => [ + $self->cd('$(DISTVNAME)', + '$(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"', + ), + ], + 'nextrelease:' => [ + '$(ABSPERLRUN) $(HELPERS)/add-changelog-heading --git $(VERSION) $(CHANGELOG)', + ], + 'refresh:' => [ + '$(UPDATE_DISTAR)', + '$(RM_F) $(FIRST_MAKEFILE)', + '$(REMAKE)', + ], + ); + my @bump_targets = grep { $include !~ /^bump$_(?: +\w+)*:/m } ('', 'minor', 'major'); - for my $target (@bump_targets) { - push @out, sprintf <<'END', "bump$target", ($target || '$(V)'); -%s: - $(ABSPERLRUN) $(HELPERS)/bump-version --git $(VERSION) %s - $(RM_F) $(FIRST_MAKEFILE) - $(REMAKE) -END - } + push @out, map +( + "bump$_:" => [ + '$(ABSPERLRUN) $(HELPERS)/bump-version --git $(VERSION) '.($_ || '$(V)'), + '$(RM_F) $(FIRST_MAKEFILE)', + '$(REMAKE)', + ], + ), @bump_targets; join('', $dist_test, "\n\n# --- Distar section:\n\n", (map "$_ = $vars{$_}\n", sort keys %vars), "\n", - @out, + (map { + my @lines; + if (ref) { + @lines = @$_; + s/^\t?/\t/mg for @lines; + } + else { + @lines = $_; + } + s/\n?\z/\n/ for @lines; + @lines; + } @out), ($include ? ( "\n", "# --- Makefile.include:\n",