@@ -11,10 +11,10 @@ UNAME := $(shell uname)
11
11
ROOT_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
12
12
13
13
GHC_VERSION ?=
14
- TARBALL_ARCHIVE_SUFFIX ?=
14
+ ARTIFACT ?= unknown-platform
15
15
16
16
HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }')
17
- TARBALL ?= haskell-language-server-$(HLS_VERSION ) -$(TARBALL_ARCHIVE_SUFFIX ) .tar.xz
17
+ TARBALL ?= haskell-language-server-$(HLS_VERSION ) -$(ARTIFACT ) .tar.xz
18
18
19
19
CHMOD := chmod
20
20
CHMOD_X := $(CHMOD ) 755
@@ -29,7 +29,6 @@ MKDIR_P := $(MKDIR) -p
29
29
TAR := tar
30
30
TAR_MK := $(TAR ) caf
31
31
CABAL := cabal
32
- AWK := awk
33
32
STRIP := strip
34
33
ifeq ($(UNAME ) , Darwin)
35
34
STRIP_S := strip
39
38
RM := rm
40
39
RM_RF := $(RM ) -rf
41
40
CD := cd
41
+ CP := cp
42
42
43
43
# by default don't run ghcup
44
- GHCUP ?= echo
44
+ GHCUP ?= echo
45
+ GHCUP_GC ?= $(GHCUP ) gc
46
+
47
+ CABAL_CACHE_BIN ?= echo
45
48
46
49
ifeq ($(UNAME ) , Darwin)
47
50
DLL := *.dylib
@@ -51,13 +54,18 @@ endif
51
54
52
55
INSTALL_NAME_TOOL := install_name_tool
53
56
54
- STORE_DIR := store
55
- BINDIST_BASE_DIR := out/bindist
57
+ STORE_DIR := store/ $( ARTIFACT )
58
+ BINDIST_BASE_DIR := out/bindist/ $( ARTIFACT )
56
59
BINDIST_OUT_DIR := $(BINDIST_BASE_DIR ) /haskell-language-server-$(HLS_VERSION )
57
60
58
- CABAL_ARGS ?= --store-dir=$(ROOT_DIR ) /$(STORE_DIR )
59
- CABAL_INSTALL_ARGS ?= --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy
60
- CABAL_INSTALL := $(CABAL ) $(CABAL_ARGS ) v2-install
61
+ CABAL_BASE_ARGS ?= --store-dir=$(ROOT_DIR ) /$(STORE_DIR )
62
+ CABAL_ARGS ?= --disable-tests --disable-profiling -O2
63
+ CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy
64
+ CABAL_INSTALL := $(CABAL ) $(CABAL_BASE_ARGS ) v2-install
65
+ PROJECT_FILE := cabal.project
66
+
67
+ S3_HOST ?=
68
+ S3_KEY ?=
61
69
62
70
# set rpath relative to the current executable
63
71
# TODO: on darwin, this doesn't overwrite rpath, but just adds to it,
@@ -66,15 +74,42 @@ define set_rpath
66
74
$(if $(filter Darwin,$(UNAME ) ) , $(INSTALL_NAME_TOOL ) -add_rpath "@executable_path/$(1 ) " "$(2 ) ", $(PATCHELF ) --force-rpath --set-rpath "\$$ORIGIN/$(1 ) " "$(2 ) ")
67
75
endef
68
76
77
+ define sync_from
78
+ $(CABAL_CACHE_BIN ) sync-from-archive --host-name-override=$(S3_HOST ) --host-port-override=443 --host-ssl-override=True --region us-west-2 --store-path="$(ROOT_DIR ) /$(STORE_DIR ) " --archive-uri "s3://haskell-language-server/$(S3_KEY ) "
79
+ endef
80
+
81
+ define sync_to
82
+ $(CABAL_CACHE_BIN ) sync-to-archive --host-name-override=$(S3_HOST ) --host-port-override=443 --host-ssl-override=True --region us-west-2 --store-path="$(ROOT_DIR ) /$(STORE_DIR ) " --archive-uri "s3://haskell-language-server/$(S3_KEY ) "
83
+ endef
84
+
85
+ hls :
86
+ @if test -z " $( GHCS) " ; then echo >&2 " GHCS is not set" ; false ; fi
87
+ for ghc in $( GHCS) ; do \
88
+ $(GHCUP ) install ghc ` echo $$ ghc` && \
89
+ $(GHCUP_GC ) -p -s -c -t && \
90
+ $(MAKE ) GHC_VERSION=` echo $$ ghc` hls-ghc || exit 1 ; \
91
+ done
92
+
69
93
hls-ghc :
70
- $(MKDIR_P ) out/
94
+ $(MKDIR_P ) out/$(ARTIFACT )
95
+ $(MKDIR_P ) out/plan.json
71
96
@if test -z " $( GHC_VERSION) " ; then echo >&2 " GHC_VERSION is not set" ; false ; fi
72
- @if test -z " $( CABAL_PROJECT) " ; then echo >&2 " CABAL_PROJECT is not set" ; false ; fi
73
- $(CABAL_INSTALL ) --project-file=" $( CABAL_PROJECT) " -w " ghc-$( GHC_VERSION) " $(CABAL_INSTALL_ARGS ) --installdir=" $( ROOT_DIR) /out/$( GHC_VERSION) " exe:haskell-language-server exe:haskell-language-server-wrapper
74
- $(STRIP_S ) " $( ROOT_DIR) /out/$( GHC_VERSION) /haskell-language-server"
75
- $(STRIP_S ) " $( ROOT_DIR) /out/$( GHC_VERSION) /haskell-language-server-wrapper"
97
+ $(CABAL ) $(CABAL_BASE_ARGS ) configure --project-file=" $( PROJECT_FILE) " -w " ghc-$( GHC_VERSION) " $(CABAL_ARGS ) exe:haskell-language-server exe:haskell-language-server-wrapper
98
+ $(CABAL ) $(CABAL_BASE_ARGS ) build --project-file=" $( PROJECT_FILE) " -w " ghc-$( GHC_VERSION) " $(CABAL_ARGS ) --dependencies-only --dry-run exe:haskell-language-server exe:haskell-language-server-wrapper
99
+ $(call sync_from)
100
+ $(CP ) dist-newstyle/cache/plan.json " $( ROOT_DIR) /out/plan.json/$( ARTIFACT) -ghc-$( GHC_VERSION) -plan.json"
101
+ $(CABAL_INSTALL ) --project-file=" $( PROJECT_FILE) " -w " ghc-$( GHC_VERSION) " $(CABAL_ARGS ) $(CABAL_INSTALL_ARGS ) --installdir=" $( ROOT_DIR) /out/$( ARTIFACT) /$( GHC_VERSION) " exe:haskell-language-server exe:haskell-language-server-wrapper
102
+ $(call sync_to)
103
+ $(STRIP_S ) " $( ROOT_DIR) /out/$( ARTIFACT) /$( GHC_VERSION) /haskell-language-server"
104
+ $(STRIP_S ) " $( ROOT_DIR) /out/$( ARTIFACT) /$( GHC_VERSION) /haskell-language-server-wrapper"
76
105
77
106
bindist :
107
+ @if test -z " $( GHCS) " ; then echo >&2 " GHCS is not set" ; false ; fi
108
+ for ghc in $( GHCS) ; do \
109
+ $(GHCUP ) install ghc ` echo $$ ghc` && \
110
+ $(GHCUP_GC ) -p -s -c -t && \
111
+ $(MAKE ) GHC_VERSION=` echo $$ ghc` bindist-ghc || exit 1 ; \
112
+ done
78
113
$(SED ) -e " s/@@HLS_VERSION@@/$( HLS_VERSION) /" \
79
114
bindist/GNUmakefile.in > " $( BINDIST_OUT_DIR) /GNUmakefile"
80
115
$(INSTALL_D ) " $( BINDIST_OUT_DIR) /scripts/"
@@ -88,7 +123,7 @@ bindist-ghc:
88
123
$(MKDIR_P ) " $( BINDIST_OUT_DIR) /bin"
89
124
$(MKDIR_P ) " $( BINDIST_OUT_DIR) /lib/$( GHC_VERSION) "
90
125
$(INSTALL_D ) " $( BINDIST_OUT_DIR) /bin/"
91
- $(INSTALL_X ) " out/$( GHC_VERSION) /haskell-language-server" " $( BINDIST_OUT_DIR) /bin/haskell-language-server-$( GHC_VERSION) "
126
+ $(INSTALL_X ) " out/$( ARTIFACT ) / $( GHC_VERSION) /haskell-language-server" " $( BINDIST_OUT_DIR) /bin/haskell-language-server-$( GHC_VERSION) "
92
127
$(call set_rpath,../lib/$(GHC_VERSION ) ,$(BINDIST_OUT_DIR ) /bin/haskell-language-server-$(GHC_VERSION ) )
93
128
$(SED ) \
94
129
-e " s/@@EXE_NAME@@/haskell-language-server-$( GHC_VERSION) /" \
@@ -98,7 +133,7 @@ bindist-ghc:
98
133
bindist/wrapper.in > " $( BINDIST_OUT_DIR) /haskell-language-server-$( GHC_VERSION) .in"
99
134
$(CHMOD_X ) " $( BINDIST_OUT_DIR) /haskell-language-server-$( GHC_VERSION) .in"
100
135
$(INSTALL_D ) " $( BINDIST_OUT_DIR) /bin/"
101
- $(INSTALL_X ) " out/$( GHC_VERSION) /haskell-language-server-wrapper" " $( BINDIST_OUT_DIR) /bin/haskell-language-server-wrapper"
136
+ $(INSTALL_X ) " out/$( ARTIFACT ) / $( GHC_VERSION) /haskell-language-server-wrapper" " $( BINDIST_OUT_DIR) /bin/haskell-language-server-wrapper"
102
137
$(INSTALL_D ) " $( ROOT_DIR) /$( BINDIST_OUT_DIR) /lib/$( GHC_VERSION) "
103
138
$(FIND ) " $( STORE_DIR) /ghc-$( GHC_VERSION) " -type f -name " $( DLL) " -execdir $(INSTALL_X ) " {}" " $( ROOT_DIR) /$( BINDIST_OUT_DIR) /lib/$( GHC_VERSION) /{}" \;
104
139
$(FIND ) " $( ROOT_DIR) /$( BINDIST_OUT_DIR) /lib/$( GHC_VERSION) " -type f -name ' $(DLL)' -execdir $(call set_rpath,,{}) \;
@@ -109,7 +144,13 @@ version:
109
144
clean :
110
145
$(RM_RF ) out/*
111
146
112
- clean-all :
147
+ clean-ghcs :
148
+ @if test -z " $( GHCS) " ; then echo >&2 " GHCS is not set" ; false ; fi
149
+ for ghc in $( GHCS) ; do \
150
+ $(GHCUP ) rm ghc ` echo $$ ghc` ; \
151
+ done
152
+
153
+ clean-all : clean-ghcs
113
154
$(RM_RF ) out/* $(STORE_DIR )
114
155
115
- .PHONY : hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs version
156
+ .PHONY : hls hls -ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs version
0 commit comments