From 5fab48e2cd0ed0f37cf81816349a61219688436e Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 24 Nov 2020 12:17:39 -0600 Subject: [PATCH] Meta: Update makem.sh, etc. --- .github/workflows/test.yml | 8 ++--- Makefile | 2 +- makem.sh | 65 +++++++++++++++++++++++++++++++++----- 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index edd8dd3..667daa8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ # * test.yml --- Test Emacs packages using makem.sh on GitHub Actions # URL: https://github.com/alphapapa/makem.sh -# Version: 0.2.1 +# Version: 0.3 # * Commentary: @@ -31,8 +31,8 @@ on: pull_request: push: # Comment out this section to enable testing of all branches. - # branches: - # - master + branches: + - master jobs: build: @@ -63,7 +63,7 @@ jobs: - name: Lint # NOTE: Uncomment this line to treat lint failures as passing # so the job doesn't show failure. - continue-on-error: true + # continue-on-error: true run: ./makem.sh -vv --sandbox=$SANDBOX_DIR lint - name: Test diff --git a/Makefile b/Makefile index 4abfce9..9ba1358 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # * makem.sh/Makefile --- Script to aid building and testing Emacs Lisp packages # URL: https://github.com/alphapapa/makem.sh -# Version: 0.2.1 +# Version: 0.3 # * Arguments diff --git a/makem.sh b/makem.sh index 0cc3cbc..b9fc062 100755 --- a/makem.sh +++ b/makem.sh @@ -3,7 +3,7 @@ # * makem.sh --- Script to aid building and testing Emacs Lisp packages # URL: https://github.com/alphapapa/makem.sh -# Version: 0.2.1 +# Version: 0.3 # * Commentary: @@ -80,6 +80,7 @@ Options: -d, --debug Print debug info. -h, --help I need somebody! -v, --verbose Increase verbosity, up to -vv. + --no-color Disable color output. --debug-load-path Print load-path from inside Emacs. @@ -88,8 +89,9 @@ Options: -e, --exclude FILE Exclude FILE from linting and testing. -f, --file FILE Check FILE in addition to discovered files. - --no-color Disable color output. - -C, --no-compile Don't compile files automatically. + -c, --compile-batch Batch-compile files (instead of separately; quicker, but + may hide problems). + -C, --no-compile Don't compile files automatically. Sandbox options: -s[DIR], --sandbox[=DIR] Run Emacs with an empty config in a sandbox DIR. @@ -289,6 +291,18 @@ function batch-byte-compile { "$@" } +function byte-compile-file { + debug "byte-compile: ERROR-ON-WARN:$compile_error_on_warn" + local file="$1" + + [[ $compile_error_on_warn ]] && local error_on_warn=(--eval "(setq byte-compile-error-on-warn t)") + + run_emacs \ + "${error_on_warn[@]}" \ + --eval "(byte-compile-file \"$file\")" \ + || error "Compiling file failed: $file" +} + # ** Files function dirs-project { @@ -684,18 +698,48 @@ function all { tests } -function compile { +function compile-batch { + [[ $compile ]] || return 0 + unset compile # Only compile once. + + verbose 1 "Compiling..." + verbose 2 "Batch-compiling files..." + debug "Byte-compile files: ${files_project_byte_compile[@]}" + + batch-byte-compile "${files_project_byte_compile[@]}" \ + && success "Compiling finished without errors." \ + || error "Compilation failed." +} + +function compile-each { [[ $compile ]] || return 0 unset compile # Only compile once. verbose 1 "Compiling..." debug "Byte-compile files: ${files_project_byte_compile[@]}" - batch-byte-compile "${files_project_byte_compile[@]}" \ + local compile_errors + for file in "${files_project_byte_compile[@]}" + do + verbose 2 "Compiling file: $file..." + byte-compile-file "$file" \ + || compile_errors=t + done + + ! [[ $compile_errors ]] \ && success "Compiling finished without errors." \ || error "Compilation failed." } +function compile { + if [[ $compile = batch ]] + then + compile-batch "$@" + else + compile-each "$@" + fi +} + function batch { # Run Emacs in batch mode with ${args_batch_interactive[@]} and # with project source and test files loaded. @@ -747,7 +791,7 @@ function lint-compile { verbose 1 "Linting compilation..." compile_error_on_warn=true - batch-byte-compile "${files_project_byte_compile[@]}" \ + compile "${files_project_byte_compile[@]}" \ && success "Linting compilation finished without errors." \ || error "Linting compilation failed." unset compile_error_on_warn @@ -880,6 +924,7 @@ errors=0 verbose=0 compile=true arg_batch="--batch" +compile=each # MAYBE: Disable color if not outputting to a terminal. (OTOH, the # colorized output is helpful in CI logs, and I don't know if, @@ -938,8 +983,8 @@ elisp_org_package_archive="(add-to-list 'package-archives '(\"org\" . \"https:// # * Args args=$(getopt -n "$0" \ - -o dhe:E:i:s::vf:CO \ - -l exclude:,emacs:,install-deps,install-linters,debug,debug-load-path,help,install:,verbose,file:,no-color,no-compile,no-org-repo,sandbox:: \ + -o dhce:E:i:s::vf:CO \ + -l compile-batch,exclude:,emacs:,install-deps,install-linters,debug,debug-load-path,help,install:,verbose,file:,no-color,no-compile,no-org-repo,sandbox:: \ -- "$@") \ || { usage; exit 1; } eval set -- "$args" @@ -966,6 +1011,10 @@ do usage exit ;; + -c|--compile-batch) + debug "Compiling files in batch mode" + compile=batch + ;; -E|--emacs) shift emacs_command=($1)