blob: ed22b8cea33494399613d8c1bfd3d97a57939c29 [file] [log] [blame]
jschung25850f02020-06-17 14:38:11 +09001# Copyright 2020 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.PHONY: help start
16
17SHELL := /bin/bash
jschungda7edd02020-07-20 18:18:34 +090018SRC_DIR := .
19DST_DIR := .
20PROTO_SRC_FILE := stress_test.proto
21PROTOC_DIR := ./env
jschung25850f02020-06-17 14:38:11 +090022
23ifeq ($(OS),Windows_NT)
24 detected_OS := Windows
25 USER_NAME ?=
26else
27 detected_OS := $(shell uname)
28 USER_NAME ?= $(shell whoami)
29 ENV_PATH ?= $(shell pwd)
30endif
31
jschungda7edd02020-07-20 18:18:34 +090032ifeq ($(detected_OS),Darwin)
33 PROTOC_FILE := protoc-3.11.4-osx-x86_64.zip
34endif
35ifeq ($(detected_OS),Linux)
36 PROTOC_FILE := protoc-3.11.4-linux-x86_64.zip
37endif
38
jschung25850f02020-06-17 14:38:11 +090039.DEFAULT: help
40help:
41 @echo "make start"
42 @echo " prepare development environment, use only once"
43 @echo "make proto-compile"
44 @echo " compile protubuf"
45 @echo "make clean"
46 @echo " delete test result and cache directories"
47
48start:
49ifeq ($(detected_OS),Windows)
jschungda7edd02020-07-20 18:18:34 +090050 @echo "please install python3.7.5 and pytyon3-pip manually"
jschung25850f02020-06-17 14:38:11 +090051 py -m pip install --upgrade pip
jschung25850f02020-06-17 14:38:11 +090052 python -m venv .\env
53endif
54ifeq ($(detected_OS),Darwin)
55 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
56 sudo chown -R $(USER_NAME) /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share
57 chmod u+w /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share
jschungda7edd02020-07-20 18:18:34 +090058 brew install sox
59 python -m venv env
jschung25850f02020-06-17 14:38:11 +090060endif
61ifeq ($(detected_OS),Linux)
jschungda7edd02020-07-20 18:18:34 +090062 sudo apt-get install sox
63 python -m venv env
jschung25850f02020-06-17 14:38:11 +090064endif
65
66proto-compile: ${PROTO_SRC_FILE}
67ifeq ($(detected_OS),Windows)
jschungda7edd02020-07-20 18:18:34 +090068 @echo "Download protoc-3.11.4-win64.zip from https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-win64.zip"
69 @echo "Decompress protoc-3.11.4-win64.zip and save proto.exe under env/bin folder"
70 @echo "Decompress protoc-3.11.4-win64.zip and copy include/* under env/include folder"
71 $(PROTOC_DIR)/protoc.exe -I=${SRC_DIR} --proto_path=$(PROTOC_DIR)/include --python_out=${DST_DIR} ${SRC_DIR}/${PROTO_SRC_FILE}
jschung25850f02020-06-17 14:38:11 +090072else
jschungda7edd02020-07-20 18:18:34 +090073 curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/$(PROTOC_FILE)
74 sudo unzip -o $(PROTOC_FILE) -d $(PROTOC_DIR) bin/protoc
75 sudo unzip -o $(PROTOC_FILE) -d $(PROTOC_DIR) 'include/*'
76 rm -f $(PROTOC_FILE)
77 $(PROTOC_DIR)/bin/protoc -I=${SRC_DIR} --proto_path=$(PROTOC_DIR)/include --python_out=${DST_DIR} ${SRC_DIR}/${PROTO_SRC_FILE}
jschung25850f02020-06-17 14:38:11 +090078endif
79
80clean:
81ifeq ($(detected_OS),Windows)
82 @for /d %%x in (dsp_*) do rd /s /q "%%x"
83 @for /d %%x in (enroll_*) do rd /s /q "%%x"
84 @for /d %%x in (__pycache*) do rd /s /q "%%x"
85else
86 @rm -rf __pycache__
87 @rm -rf dsp_*
88 @rm -rf enroll*
89endif
90 @echo "cleanning completed"