forked from andreypopp/esy-solve-cudf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (94 loc) · 2.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
.DEFAULT_GOAL: bootstrap
.DELETE_ON_ERROR:
PLATFORM = $(shell node -p "process.platform")
VERSION = $(shell node -p "require('./package.json').version")
NPM_RELEASE_TAG ?= latest
ESY_RELEASE_TAG ?= v$(VERSION)
ESY_EXT := $(shell command -v esy 2> /dev/null)
b:: build-dev
build-dev::
@esy b dune build
build::
@esy b
bootstrap::
ifndef ESY_EXT
$(error "esy command is not avaialble, run 'npm install -g esy'")
endif
@git submodule init
@git submodule update
@esy
clean::
@rm -rf _build
#
# Platform Specific Release
#
PLATFORM_RELEASE_NAME = _platformrelease/esy-solve-cudf-$(ESY_RELEASE_TAG)-$(PLATFORM).tgz
PLATFORM_RELEASE_ROOT = _platformrelease/$(PLATFORM)
PLATFORM_RELEASE_FILES = \
esySolveCudfCommand.exe
platform-release: $(PLATFORM_RELEASE_NAME)
$(PLATFORM_RELEASE_NAME)::
@echo "Creating $(PLATFORM_RELEASE_NAME)"
@rm -rf $(PLATFORM_RELEASE_ROOT)
@$(MAKE) $(PLATFORM_RELEASE_FILES:%=$(PLATFORM_RELEASE_ROOT)/%)
@tar czf $(@) -C $(PLATFORM_RELEASE_ROOT) .
@rm -rf $(PLATFORM_RELEASE_ROOT)
$(PLATFORM_RELEASE_ROOT)/esySolveCudfCommand.exe: _esy/default/build/default/bin/esySolveCudfCommand.exe
@mkdir -p $(@D)
@cp $(<) $(@)
#
# Release
#
RELEASE_ROOT = _release
RELEASE_FILES = \
platform-linux \
platform-darwin \
platform-win32 \
esySolveCudfCommand.exe \
postinstall.js \
LICENSE \
README.md \
package.json
release:
@echo "Creating $(ESY_RELEASE_TAG) release"
@rm -rf $(RELEASE_ROOT)
@mkdir -p $(RELEASE_ROOT)
@$(MAKE) -j $(RELEASE_FILES:%=$(RELEASE_ROOT)/%)
$(RELEASE_ROOT)/esySolveCudfCommand.exe:
@mkdir -p $(@D)
@echo "#!/bin/sh\necho 'error: esy-solve-cudf is not installed correctly...'; exit 1" > $(@)
@chmod +x $(@)
$(RELEASE_ROOT)/platform-linux $(RELEASE_ROOT)/platform-darwin $(RELEASE_ROOT)/platform-win32: PLATFORM=$(@:$(RELEASE_ROOT)/platform-%=%)
$(RELEASE_ROOT)/platform-linux $(RELEASE_ROOT)/platform-darwin $(RELEASE_ROOT)/platform-win32:
@mkdir $(@)
@wget \
-q --show-progress \
-O $(RELEASE_ROOT)/$(PLATFORM).tgz \
'https://github.com/andreypopp/esy-solve-cudf/releases/download/$(ESY_RELEASE_TAG)/esy-solve-cudf-$(ESY_RELEASE_TAG)-$(PLATFORM).tgz'
@tar -xzf $(RELEASE_ROOT)/$(PLATFORM).tgz -C $(@)
@rm $(RELEASE_ROOT)/$(PLATFORM).tgz
define MAKE_PACKAGE_JSON
let esyJson = require('./package.json');
console.log(JSON.stringify(Object.assign(
{
"bin": {
"esy-solve-cudf": "esySolveCudfCommand.exe"
},
"scripts": {
"postinstall": "node ./postinstall.js"
}
},
{
name: esyJson.name,
version: esyJson.version,
license: esyJson.license,
description: esyJson.description
}
), null, 2));
endef
export MAKE_PACKAGE_JSON
$(RELEASE_ROOT)/package.json:
@node -e "$$MAKE_PACKAGE_JSON" > $(@)
$(RELEASE_ROOT)/%: $(PWD)/%
@mkdir -p $(@D)
@cp $(<) $(@)