Makefile 2.21 KB
Newer Older
1
2
CWD := $(PWD)/

3
4
5
6
7
8
9
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
	OS_SPEC := linux
	WHEEL_SPEC := manylinux1_x86_64
else ifeq ($(UNAME_S), Darwin)
	OS_SPEC := darwin
	WHEEL_SPEC := macosx_10_9_x86_64
10
else
11
12
13
	$(error platform $(UNAME_S) not supported)
endif

chicm-ms's avatar
chicm-ms committed
14
TIME_STAMP = $(shell date -u "+%y%m%d%H%M")
chicm-ms's avatar
chicm-ms committed
15
16
17
18
19
20
21
NNI_VERSION_VALUE = $(shell git describe --tags --abbrev=0)

# To include time stamp in version value, run:
# make version_ts=true build
ifeq ($(version_ts), true)
	NNI_VERSION_VALUE := $(NNI_VERSION_VALUE).$(TIME_STAMP)
endif
goooxu's avatar
goooxu committed
22
NNI_VERSION_TEMPLATE = 999.0.0-developing
23
24
25
NNI_YARN_TARBALL ?= $(CWD)nni-yarn.tar.gz
NNI_YARN_FOLDER ?= $(CWD)nni-yarn
NNI_YARN := PATH=$(CWD)node-$(OS_SPEC)-x64/bin:$${PATH} $(NNI_YARN_FOLDER)/bin/yarn
26
27
.PHONY: build
build:
Gems Guo's avatar
Gems Guo committed
28
	python3 -m pip install --user --upgrade setuptools wheel
29
	wget -q https://aka.ms/nni/nodejs-download/$(OS_SPEC) -O $(CWD)node-$(OS_SPEC)-x64.tar.xz
30
31
32
	rm -rf $(CWD)node-$(OS_SPEC)-x64
	mkdir $(CWD)node-$(OS_SPEC)-x64
	tar xf $(CWD)node-$(OS_SPEC)-x64.tar.xz -C node-$(OS_SPEC)-x64 --strip-components 1
33
34
35
36
37
38
	wget -q https://aka.ms/yarn-download -O $(NNI_YARN_TARBALL)
	rm -rf $(NNI_YARN_FOLDER)
	mkdir $(NNI_YARN_FOLDER)
	tar -xf $(NNI_YARN_TARBALL) -C $(NNI_YARN_FOLDER) --strip-components 1
	cd $(CWD)../../src/nni_manager && $(NNI_YARN) && $(NNI_YARN) build
	cd $(CWD)../../src/webui && $(NNI_YARN) && $(NNI_YARN) build
SparkSnail's avatar
SparkSnail committed
39
	cd $(CWD)../../src/nasui && $(NNI_YARN) && $(NNI_YARN) build
40
41
	rm -rf $(CWD)nni
	cp -r $(CWD)../../src/nni_manager/dist $(CWD)nni
SparkSnail's avatar
SparkSnail committed
42
	cp -r $(CWD)../../src/nni_manager/config $(CWD)nni
43
	cp -r $(CWD)../../src/webui/build $(CWD)nni/static
SparkSnail's avatar
SparkSnail committed
44
45
	cp -r $(CWD)../../src/nasui/build $(CWD)nni/nasui
	cp $(CWD)../../src/nasui/server.js $(CWD)nni/nasui
46
	cp $(CWD)../../src/nni_manager/package.json $(CWD)nni
goooxu's avatar
goooxu committed
47
	sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' $(CWD)nni/package.json
48
	cd $(CWD)nni && $(NNI_YARN) --prod
goooxu's avatar
goooxu committed
49
	cd $(CWD) && sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && python3 setup.py bdist_wheel -p $(WHEEL_SPEC)
50
	cd $(CWD)
51
52
53

.PHONY: upload
upload:
Gems Guo's avatar
Gems Guo committed
54
	python3 -m pip install --user --upgrade twine
55
56
57
58
	python3 -m twine upload dist/*

.PHONY: clean
clean:
Gems Guo's avatar
Gems Guo committed
59
60
61
62
	rm -rf $(CWD)build
	rm -rf $(CWD)dist
	rm -rf $(CWD)nni
	rm -rf $(CWD)nni.egg-info
63
	rm -rf $(CWD)node-$(OS_SPEC)-x64