diff --git a/Makefile b/Makefile index 9ba1358..64c4516 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.3 +# Version: 0.5 # * Arguments @@ -38,7 +38,9 @@ endif verbose = $(v) -ifneq (,$(findstring vv,$(verbose))) +ifneq (,$(findstring vvv,$(verbose))) + VERBOSE = "-vvv" +else ifneq (,$(findstring vv,$(verbose))) VERBOSE = "-vv" else ifneq (,$(findstring v,$(verbose))) VERBOSE = "-v" diff --git a/makem.sh b/makem.sh index b9fc062..d06bca3 100755 --- a/makem.sh +++ b/makem.sh @@ -3,11 +3,11 @@ # * makem.sh --- Script to aid building and testing Emacs Lisp packages # URL: https://github.com/alphapapa/makem.sh -# Version: 0.3 +# Version: 0.6-pre # * Commentary: -# makem.sh is a script helps to build, lint, and test Emacs Lisp +# makem.sh is a script that helps to build, lint, and test Emacs Lisp # packages. It aims to make linting and testing as simple as possible # without requiring per-package configuration. @@ -79,7 +79,7 @@ Rules: Options: -d, --debug Print debug info. -h, --help I need somebody! - -v, --verbose Increase verbosity, up to -vv. + -v, --verbose Increase verbosity, up to -vvv. --no-color Disable color output. --debug-load-path Print load-path from inside Emacs. @@ -136,6 +136,27 @@ EOF echo $file } +function elisp-elint-file { + local file=$(mktemp) + cat >$file <"$file" </dev/null) if [[ $file_pkg ]] @@ -496,6 +570,8 @@ function sandbox { args_sandbox=( --title "makem.sh: $(basename $(pwd)) (sandbox: $sandbox_dir)" --eval "(setq user-emacs-directory (file-truename \"$sandbox_dir\"))" + --load package + --eval "(setq package-user-dir (expand-file-name \"elpa\" user-emacs-directory))" --eval "(setq user-init-file (file-truename \"$init_file\"))" ) @@ -658,7 +734,8 @@ function verbose { if [[ $verbose -ge $1 ]] then [[ $1 -eq 1 ]] && local color_name=blue - [[ $1 -ge 2 ]] && local color_name=cyan + [[ $1 -eq 2 ]] && local color_name=cyan + [[ $1 -ge 3 ]] && local color_name=white shift log_color $color_name "$@" >&2 @@ -706,9 +783,7 @@ function compile-batch { 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." + batch-byte-compile "${files_project_byte_compile[@]}" } function compile-each { @@ -726,9 +801,7 @@ function compile-each { || compile_errors=t done - ! [[ $compile_errors ]] \ - && success "Compiling finished without errors." \ - || error "Compilation failed." + [[ ! $compile_errors ]] } function compile { @@ -738,6 +811,18 @@ function compile { else compile-each "$@" fi + local status=$? + + if [[ $compile_error_on_warn ]] + then + # Linting: just return status code, because lint rule will print messages. + [[ $status = 0 ]] + else + # Not linting: print messages here. + [[ $status = 0 ]] \ + && success "Compiling finished without errors." \ + || error "Compiling failed." + fi } function batch { @@ -752,12 +837,15 @@ function batch { function interactive { # Run Emacs interactively. Most useful with --sandbox and --install-deps. + local load_file_args=$(args-load-files "${files_project_feature[@]}" "${files_project_test[@]}") verbose 1 "Running Emacs interactively..." - verbose 2 "Loading files:" "${files_project_feature[@]}" "${files_project_test[@]}" + verbose 2 "Loading files: ${load_file_args//--load /}" + + [[ $compile ]] && compile unset arg_batch run_emacs \ - $(args-load-files "${files_project_feature[@]}" "${files_project_test[@]}") \ + $load_file_args \ --eval "(load user-init-file)" \ "${args_batch_interactive[@]}" arg_batch="--batch" @@ -769,6 +857,9 @@ function lint { lint-checkdoc lint-compile lint-declare + # NOTE: Elint doesn't seem very useful at the moment. See comment + # in lint-elint function. + # lint-elint lint-indent lint-package lint-regexps @@ -825,6 +916,28 @@ function lint-elsa { || error "Linting with Elsa failed." } +function lint-elint { + # NOTE: Elint gives a lot of spurious warnings, apparently because it doesn't load files + # that are `require'd, so its output isn't very useful. But in case it's improved in + # the future, and since this wrapper code already works, we might as well leave it in. + verbose 1 "Linting with Elint..." + + local errors=0 + for file in "${files_project_feature[@]}" + do + verbose 2 "Linting with Elint: $file..." + run_emacs \ + --load "$(elisp-elint-file)" \ + --eval "(makem-elint-file \"$file\")" \ + && verbose 3 "Linting with Elint found no errors." \ + || { error "Linting with Elint failed: $file"; ((errors++)) ; } + done + + [[ $errors = 0 ]] \ + && success "Linting with Elint finished without errors." \ + || error "Linting with Elint failed." +} + function lint-indent { verbose 1 "Linting indentation..."