From b2c78ca7c096eeac3dc7d4ae1ee652864a37f411 Mon Sep 17 00:00:00 2001 From: Nicolas Stalder Date: Thu, 3 Jan 2019 14:24:34 +0100 Subject: [PATCH] Start some cleanup - add an editorconfig - fix requirements.txt and the UTF-8 issue (lost in pull/47) - two clean environments - make black usable - two test targets (wink2/wink3) --- .editorconfig | 19 +++++++++++++++++++ .gitignore | 3 ++- Makefile | 38 +++++++++++++++++++++----------------- tools/requirements.txt | 2 +- tools/solotool.py | 1 + 5 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0d06da3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties + +# editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +tab_width = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitignore b/.gitignore index e0bddba..4e3c5c5 100644 --- a/.gitignore +++ b/.gitignore @@ -74,7 +74,8 @@ tools/python-fido2/* *.key site/ _site/ -venv/ +env2/ +env3/ .project .tags* targets/*/docs/ diff --git a/Makefile b/Makefile index 4b9b8f2..c6398db 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ #define uECC_arm64 6 #define uECC_avr 7 -platform=2 +ecc_platform=2 EFM32_DEBUGGER= -s 440083537 --device EFM32JG1B200F128GM32 #EFM32_DEBUGGER= -s 440121060 #dev board @@ -29,7 +29,7 @@ INCLUDES = -I./tinycbor/src -I./crypto/sha256 -I./crypto/micro-ecc/ -Icrypto/tin CFLAGS += $(INCLUDES) # for crypto/tiny-AES-c -CFLAGS += -DAES256=1 -DAPP_CONFIG=\"app.h\" +CFLAGS += -DAES256=1 -DAPP_CONFIG=\"app.h\" name = main @@ -68,29 +68,33 @@ $(name): $(obj) $(LIBCBOR) $(CC) $(LDFLAGS) -o $@ $(obj) $(LDFLAGS) uECC.o: ./crypto/micro-ecc/uECC.c - $(CC) -c -o $@ $^ -O2 -fdata-sections -ffunction-sections -DuECC_PLATFORM=$(platform) -I./crypto/micro-ecc/ + $(CC) -c -o $@ $^ -O2 -fdata-sections -ffunction-sections -DuECC_PLATFORM=$(ecc_platform) -I./crypto/micro-ecc/ +env2: + virtualenv env2 + env2/bin/pip install -r tools/requirements.txt -# python virtualenv +env3: + python3 -m venv env3 + env3/bin/pip install -r tools/requirements.txt + env3/bin/pip install black -venv: - @if ! which virtualenv >/dev/null ; then \ - echo "ERR: Sorry, no python virtualenv found. Please consider installing " ;\ - echo " it via something like:" ;\ - echo " sudo apt install python-virtualenv" ;\ - echo " or maybe:" ;\ - echo " pip install virtualenv" ;\ - fi - virtualenv venv - ./venv/bin/pip install wheel +# selectively reformat our own code +black: env3 + env3/bin/black -S tools/ +wink2: env2 + env2/bin/python tools/solotool.py solo --wink -.PHONY: fido2-test -fido2-test: - ./venv/bin/python tools/ctap_test.py +wink3: env3 + env3/bin/python tools/solotool.py solo --wink + +fido2-test: env3 + env3/bin/python tools/ctap_test.py clean: rm -f *.o main.exe main $(obj) + rm -rf env2 env3 for f in crypto/tiny-AES-c/Makefile tinycbor/Makefile ; do \ if [ -f "$$f" ]; then \ (cd `dirname $$f` ; git checkout -- .) ;\ diff --git a/tools/requirements.txt b/tools/requirements.txt index 2d1726d..7b71a23 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,5 +1,5 @@ ecdsa intelhex pyserial -python-fido2 +fido2 pyusb diff --git a/tools/solotool.py b/tools/solotool.py index cd95195..3823c56 100644 --- a/tools/solotool.py +++ b/tools/solotool.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # # Copyright (C) 2018 SoloKeys, Inc. #