jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 1 | # 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 | |
| 17 | SHELL := /bin/bash |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 18 | SRC_DIR := . |
| 19 | DST_DIR := . |
| 20 | PROTO_SRC_FILE := stress_test.proto |
| 21 | PROTOC_DIR := ./env |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 22 | |
| 23 | ifeq ($(OS),Windows_NT) |
| 24 | detected_OS := Windows |
| 25 | USER_NAME ?= |
| 26 | else |
| 27 | detected_OS := $(shell uname) |
| 28 | USER_NAME ?= $(shell whoami) |
| 29 | ENV_PATH ?= $(shell pwd) |
| 30 | endif |
| 31 | |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 32 | ifeq ($(detected_OS),Darwin) |
| 33 | PROTOC_FILE := protoc-3.11.4-osx-x86_64.zip |
| 34 | endif |
| 35 | ifeq ($(detected_OS),Linux) |
| 36 | PROTOC_FILE := protoc-3.11.4-linux-x86_64.zip |
| 37 | endif |
| 38 | |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 39 | .DEFAULT: help |
| 40 | help: |
| 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 | |
| 48 | start: |
| 49 | ifeq ($(detected_OS),Windows) |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 50 | @echo "please install python3.7.5 and pytyon3-pip manually" |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 51 | py -m pip install --upgrade pip |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 52 | python -m venv .\env |
| 53 | endif |
| 54 | ifeq ($(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 |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 58 | brew install sox |
| 59 | python -m venv env |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 60 | endif |
| 61 | ifeq ($(detected_OS),Linux) |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 62 | sudo apt-get install sox |
| 63 | python -m venv env |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 64 | endif |
| 65 | |
| 66 | proto-compile: ${PROTO_SRC_FILE} |
| 67 | ifeq ($(detected_OS),Windows) |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 68 | @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} |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 72 | else |
jschung | da7edd0 | 2020-07-20 18:18:34 +0900 | [diff] [blame] | 73 | 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} |
jschung | 25850f0 | 2020-06-17 14:38:11 +0900 | [diff] [blame] | 78 | endif |
| 79 | |
| 80 | clean: |
| 81 | ifeq ($(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" |
| 85 | else |
| 86 | @rm -rf __pycache__ |
| 87 | @rm -rf dsp_* |
| 88 | @rm -rf enroll* |
| 89 | endif |
| 90 | @echo "cleanning completed" |