|
1 |
| -# Directories |
| 1 | +all: build |
| 2 | +export EMACS ?= emacs |
| 3 | +EMACSFLAGS = -L . |
| 4 | +CASK = cask |
| 5 | +VERSION = $(shell git describe --tags --abbrev=0 | sed 's/^v//') |
| 6 | +PKG = fsharp-mode |
2 | 7 |
|
3 |
| -base_d = $(abspath .) |
4 |
| -test_d = $(abspath test) |
5 |
| -tmp_d = $(abspath tmp) |
6 |
| -bin_d = $(abspath bin) |
| 8 | +elpa-$(EMACS): |
| 9 | + $(CASK) install |
| 10 | + $(CASK) update |
| 11 | + touch $@ |
7 | 12 |
|
8 |
| -# Elisp files required for tests. |
9 |
| -src_files = $(wildcard ./*.el) |
10 |
| -obj_files = $(patsubst %.el,%.elc,$(src_files)) |
11 |
| -integration_tests = $(test_d)/integration-tests.el |
12 |
| -unit_tests = $(filter-out $(integration_tests), $(wildcard $(test_d)/*tests.el)) |
13 |
| -utils = $(test_d)/test-common.el |
| 13 | +test/eglot-tests.el: |
| 14 | + curl -o eglot-tests.el https://raw.githubusercontent.com/joaotavora/eglot/master/eglot-tests.el |
14 | 15 |
|
15 |
| -# F# fontification test files |
16 |
| -faceup_inputs = $(wildcard $(test_d)/apps/*/*.fs) $(wildcard $(test_d)/apps/*/*.fsx) |
17 |
| -faceup_outputs = $(patsubst %,%.faceup, $(faceup_inputs)) |
| 16 | +elpa: elpa-$(EMACS) |
18 | 17 |
|
19 |
| -# Emacs command format. |
20 |
| -emacs = emacs |
21 |
| -load_files = $(patsubst %,-l %, $(utils)) |
22 |
| -load_unit_tests = $(patsubst %,-l %, $(unit_tests)) |
23 |
| -load_integration_tests = $(patsubst %,-l %, $(integration_tests)) |
| 18 | +build: elpa version |
| 19 | + $(CASK) build |
24 | 20 |
|
25 |
| -# Autocomplete binary distribution. |
26 |
| -ac_name = fsautocomplete |
27 |
| -ac_exe = $(bin_d)/$(ac_name).exe |
28 |
| -ac_version = 0.38.1 |
29 |
| -ac_archive = $(ac_name)-$(ac_version).zip |
30 |
| -ac_url = https://github.com/fsharp/FsAutoComplete/releases/download/$(ac_version)/$(ac_name).zip |
| 21 | +version: |
| 22 | + $(EMACS) --version |
31 | 23 |
|
32 |
| -# Autocomplete commit or branch to build from if not using the binary distribution. |
33 |
| -ac_commit = master |
34 |
| -ac_src_url = https://github.com/fsharp/FsAutoComplete/archive/$(ac_commit).zip |
35 |
| -ac_src_archive = $(ac_name)-$(ac_commit).zip |
36 |
| -ac_from_src = no |
| 24 | +test: version build test/eglot-tests.el |
| 25 | + $(CASK) exec buttercup -L . -L ./test |
37 | 26 |
|
38 |
| -ac_build_dir = $(tmp_d)/FsAutoComplete-$(ac_commit) |
| 27 | +clean: |
| 28 | + rm -f .depend elpa-$(EMACS) $(OBJECTS) $(PKG)-autoloads.el |
39 | 29 |
|
40 |
| -# Installation paths. |
41 |
| -dest_root = $(HOME)/.emacs.d/fsharp-mode/ |
42 |
| -dest_bin = $(HOME)/.emacs.d/fsharp-mode/bin/ |
43 |
| - |
44 |
| -# ---------------------------------------------------------------------------- |
45 |
| - |
46 |
| -.PHONY : test unit-test integration-test packages clean-elc install byte-compile check-compile run update-version release faceup |
47 |
| -.ONESHELL : $(ac_archive) |
48 |
| - |
49 |
| -# Building |
50 |
| - |
51 |
| -$(ac_archive): | $(bin_d) |
52 |
| -ifeq ($(ac_from_src), no) |
53 |
| - curl -L "$(ac_url)" -o "$(ac_archive)" |
54 |
| -else |
55 |
| - curl -L "$(ac_src_url)" -o "$(ac_src_archive)" |
56 |
| - unzip "$(ac_src_archive)" -d "$(tmp_d)" |
57 |
| - sed -i -e 's/"version": ".*"/"version": "'$(dotnet --version)'"/g' $(ac_build_dir)/global.json |
58 |
| - $(ac_build_dir)/build.sh releasearchive |
59 |
| - mv $(ac_build_dir)/bin/pkgs/$(ac_name).zip $(ac_archive) |
60 |
| -endif |
61 |
| - |
62 |
| - |
63 |
| -$(ac_exe) : $(bin_d) $(ac_archive) |
64 |
| - unzip "$(ac_archive)" -d "$(bin_d)" |
65 |
| - touch "$(ac_exe)" |
66 |
| - |
67 |
| -~/.config/.mono/certs: |
68 |
| - mozroots --import --sync --quiet |
69 |
| - |
70 |
| -install : $(ac_exe) $(dest_root) $(dest_bin) |
71 |
| -# Install elisp packages |
72 |
| - $(emacs) $(load_files) --batch -f load-packages |
73 |
| -# Copy files |
74 |
| - for f in $(src_files); do \ |
75 |
| - cp $$f $(dest_root) ;\ |
76 |
| - done |
77 |
| -# Copy bin folder. |
78 |
| - cp -R $(bin_d) $(dest_root) |
79 |
| - |
80 |
| - |
81 |
| -$(dest_root) :; mkdir -p $(dest_root) |
82 |
| -$(dest_bin) :; mkdir -p $(dest_bin) |
83 |
| -$(bin_d) :; mkdir -p $(bin_d) |
84 |
| - |
85 |
| -# Cleaning |
86 |
| - |
87 |
| -clean : clean-elc |
88 |
| - rm -rf $(bin_d) |
89 |
| - rm -rf $(tmp_d) |
90 |
| - rm -f $(ac_archive) |
91 |
| - |
92 |
| -clean-elc : |
93 |
| - rm -f *.elc |
94 |
| - rm -f $(test_d)/*.elc |
95 |
| - |
96 |
| -# Testing |
97 |
| - |
98 |
| -fake-home: export HOME=$(tmp_d) |
99 |
| - |
100 |
| -test unit-test fake-home: |
101 |
| - $(emacs) $(load_files) --batch -f run-fsharp-unit-tests |
102 |
| - |
103 |
| -integration-test : $(ac_exe) packages fake-home |
104 |
| -ifdef test-selector |
105 |
| - $(emacs) $(load_files) --batch --eval "(let ((fsharp--test-selector \"$(test-selector)\"))(run-fsharp-integration-tests))" |
106 |
| -else |
107 |
| - $(emacs) $(load_files) --batch --eval "(run-fsharp-integration-tests)" |
108 |
| -endif |
109 |
| - |
110 |
| -test-all : unit-test integration-test check-compile check-declares |
111 |
| - |
112 |
| -packages : fake-home |
113 |
| - $(emacs) $(load_files) --batch -f load-packages |
114 |
| - |
115 |
| -byte-compile : packages fake-home |
116 |
| - $(emacs) -batch --eval "(package-initialize)"\ |
117 |
| - --eval "(add-to-list 'load-path \"$(base_d)\")" \ |
118 |
| - -f batch-byte-compile $(src_files) |
119 |
| - |
120 |
| -check-declares : packages fake-home |
121 |
| - $(emacs) -batch --eval "(package-initialize)"\ |
122 |
| - --eval "(dolist (file '($(foreach var,$(src_files),\"$(var)\"))) (when (check-declare-file file) (kill-emacs 1)))" |
123 |
| - |
124 |
| -check-compile : packages $(obj_files) |
125 |
| - |
126 |
| -faceup : $(faceup_outputs) |
127 |
| - |
128 |
| -%.faceup : % fsharp-mode-font.el fake-home |
129 |
| - $(emacs) $(load_files) -batch \ |
130 |
| - --eval "(regen-faceup-output \"$<\")" |
131 |
| - |
132 |
| -.el.elc: fake-home |
133 |
| - $(emacs) -batch --eval "(package-initialize)"\ |
134 |
| - --eval "(add-to-list 'load-path \"$(base_d)\")" \ |
135 |
| - --eval '(setq byte-compile-error-on-warn t)' \ |
136 |
| - --eval "(eval-after-load \"bytecomp\" \ |
137 |
| - '(add-to-list \ |
138 |
| - 'byte-compile-not-obsolete-vars \ |
139 |
| - 'find-tag-marker-ring))" \ |
140 |
| - -f batch-byte-compile $< |
141 |
| - |
142 |
| -run : $(ac_exe) packages fake-home |
143 |
| - $(emacs) $(load_files) -f configure-fsharp-tests |
144 |
| - |
145 |
| -# Releasing |
146 |
| - |
147 |
| -cur_release := $(shell grep '\#\#' CHANGELOG.md | cut -d' ' -f2 | head -n 1) |
148 |
| -prev_release := $(shell grep '\#\#' CHANGELOG.md | cut -d' ' -f2 | head -n 2 | tail -n 1) |
149 |
| - |
150 |
| -update-version: |
151 |
| - sed -i -r "s/$(prev_release)/$(cur_release)/" *.el |
152 |
| - git add *.el CHANGELOG.md Makefile |
153 |
| - git commit -m "Bump version number to $(cur_release)" |
154 |
| - git tag -a $(cur_release) -m "Tag release $(cur_release)" |
155 |
| - |
156 |
| -emacs-fsharp-mode-bin: |
157 |
| - git clone [email protected]:/rneatherway/emacs-fsharp-mode-bin |
158 |
| - |
159 |
| -release: update-version emacs-fsharp-mode-bin $(ac_exe) |
160 |
| - cd emacs-fsharp-mode-bin && git pull |
161 |
| - cp $(bin_d)/*.exe $(bin_d)/*.exe.config $(bin_d)/*.dll emacs-fsharp-mode-bin |
162 |
| - cp $(src_files) emacs-fsharp-mode-bin |
163 |
| - cd emacs-fsharp-mode-bin && git checkout FSharp.Core.dll # Do not change this |
164 |
| - cd emacs-fsharp-mode-bin && git add --all |
165 |
| - cd emacs-fsharp-mode-bin && git commit -m "Update to version $(cur_release)" |
166 |
| - cd emacs-fsharp-mode-bin && git tag -a $(cur_release) -m "Tag release $(cur_release)" |
| 30 | +elpaclean: clean |
| 31 | + rm -f elpa* |
| 32 | + rm -rf .cask # Clean packages installed for development |
167 | 33 |
|
| 34 | +run-$(PKG): elpa |
| 35 | + cask exec $(EMACS) -Q -L . --eval "(require '$(PKG))" |
168 | 36 |
|
0 commit comments