forked from salesforce/o4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
102 lines (80 loc) · 2.97 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
PYTHON:=venv/bin/python
VULTURE:=venv/bin/vulture
YAPF:=venv/bin/yapf
PYFLAKES:=venv/bin/pyflakes
PIP:=venv/bin/pip
PYS:=$(shell find . -name '*.py'|grep -v '^./build/' | grep -v ^'./venv/'|grep -v '/version.py$$')
O4_SRC:=o4/requirements.txt $(shell find o4 -name '*.py'|grep -v version.py)
GATLING_SRC:=gatling/requirements.txt $(shell find gatling -name '*.py'|grep -v '/version.py$$')
MANIFOLD_SRC:=$(shell find manifold -name '*.py'|grep -v version.py)
ifeq (,$(wildcard venv))
X:=$(shell python3 -m venv venv)
Y:=$(shell ${PIP} install --upgrade pip)
Z:=$(shell ${PIP} install -r requirements.txt)
endif
PYTHON_MAJ:=$(shell ${PYTHON} -c 'import sys; print(sys.version_info.major)')
PYTHON_MIN:=$(shell ${PYTHON} -c 'import sys; print(sys.version_info.minor)')
ifneq ($(PYTHON_MAJ), 3)
$(error "*** ERROR: Python must be version 3.")
endif
ZA_C:=$(if $(filter 0 1 2 3 4 5 6, $(PYTHON_MIN)),,-c)
LINTS:=$(foreach py, $(PYS), $(dir $(py)).$(basename $(notdir $(py))).lint)
EXES:=build/o4 build/gatling build/manifold
SHELL:=/bin/bash
.PHONY: clean lint install uninstall aws aws-staging
all: lint $(EXES)
o4/version.py: $(O4_SRC) versioning.py
${PYTHON} versioning.py -r $< -o $@ $^
gatling/version.py: $(GATLING_SRC) versioning.py
${PYTHON} versioning.py -r $< -o $@ $^
manifold/version.py: $(GATLING_SRC) $(MANIFOLD_SRC) versioning.py
${PYTHON} versioning.py -r $< -o $@ $^
build/o4.za: $(O4_SRC) o4/version.py
mkdir -p $@
${PIP} install -U -r $< --target $@
cp -a $^ $@
build/gatling.za: $(GATLING_SRC) gatling/version.py
mkdir -p $@
${PIP} install -U -r $< --target $@
cp -a $^ $@
build/manifold.za: $(GATLING_SRC) $(MANIFOLD_SRC) manifold/version.py
mkdir -p $@
${PIP} install -U -r $< --target $@
cp -a $^ $@
build/%: build/%.za
rm -fr $</*.dist-info
find $< -type d -name __pycache__ | xargs rm -fr
# Only python3.7 has compress, but it's backwards compatible
${PYTHON} -m zipapp $(ZA_C) -p '/usr/bin/env python3' -m $(notdir $@):main $< -o $@
.%.lint: %.py venv
${PYFLAKES} $< || true
${VULTURE} $< || true
${YAPF} -i $<
@touch $@
install: $(EXES)
install -d /usr/local/bin
install $^ /usr/local/bin
uninstall: $(EXES)
rm -f $(foreach exe, $^, /usr/local/bin/$(notdir $(exe)))
aws:
@echo "Uploading artifacts to PRODUCTION."
@$(foreach path, o4/o4_pyforce.py build/o4 build/manifold build/gatling,\
aws s3 cp $(path) s3://sfdc-ansible/o4/$(notdir $(path));)
aws-staging:
@echo "Uploading artifacts to STAGING."
@$(foreach path, o4/o4_pyforce.py build/o4 build/manifold build/gatling,\
aws s3 cp $(path) s3://sfdc-ansible/o4-staging/$(notdir $(path));)
lint: $(LINTS)
venv:
python3 -m venv venv
${PIP} install --upgrade pip
${PIP} install -U -r requirements.txt
clean:
@echo "CLEAN --------------------------------------------"
rm -f $(LINTS)
rm -fr build
##
# Copyright (c) 2018, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause