From f7d41cbbd732e82ef6724f1ea83b715b4768c0f7 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 15 May 2019 19:39:11 +0200 Subject: [PATCH] core+legacy: drop NOUI and HEADLESS, SDL_VIDEODRIVER works fine --- ci/Dockerfile | 3 ++- ci/core.yml | 22 ++++++++++++-------- ci/legacy.yml | 9 +++++--- core/Makefile | 6 ------ core/SConscript.unix | 5 +---- core/docker/emulator/Dockerfile | 2 +- core/docker/emulator/run.sh | 1 + core/embed/extmod/modtrezorui/display-unix.h | 15 +------------ core/embed/unix/touch.c | 6 +----- legacy/Makefile.include | 6 ------ legacy/emulator/buttons.c | 4 ---- legacy/emulator/oled.c | 10 --------- 12 files changed, 26 insertions(+), 63 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index a8e71e60a..6260f680b 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -9,7 +9,8 @@ ENV TOOLCHAIN_FLAVOR=$TOOLCHAIN_FLAVOR RUN apt-get update && apt-get install -y \ build-essential wget git libsodium-dev graphviz \ - valgrind check libssl-dev libusb-1.0-0-dev libudev-dev zlib1g-dev + valgrind check libssl-dev libusb-1.0-0-dev libudev-dev zlib1g-dev \ + libsdl2-dev libsdl2-image-dev # install clang-format 6 from backports RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list diff --git a/ci/core.yml b/ci/core.yml index e0d6a469f..47b5f5baa 100644 --- a/ci/core.yml +++ b/ci/core.yml @@ -1,5 +1,9 @@ image: registry.corp.sldev.cz/trezor/trezor-firmware/environment +variables: + SDL_VIDEODRIVER: "dummy" + XDG_RUNTIME_DIR: "/var/tmp" + build core firmware: stage: build script: @@ -21,24 +25,24 @@ build core unix: stage: build script: - cd core - - pipenv run make build_unix_noui - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" - untracked: true - expire_in: 1 day + - pipenv run make build_unix build core unix frozen: stage: build script: - cd core - - pipenv run make build_unix_noui_frozen + - pipenv run make build_unix_frozen + artifacts: + name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" + untracked: true + expire_in: 1 day test core unix unit: stage: test variables: GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules dependencies: - - build core unix + - build core unix frozen script: - cd core - pipenv run make test @@ -48,7 +52,7 @@ test core unix device: variables: GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules dependencies: - - build core unix + - build core unix frozen script: - cd core - pipenv run make test_emu @@ -58,7 +62,7 @@ test core unix monero: variables: GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules dependencies: - - build core unix + - build core unix frozen script: - cd core - pipenv run make test_emu_monero diff --git a/ci/legacy.yml b/ci/legacy.yml index 8af8aebb0..67f50fa3b 100644 --- a/ci/legacy.yml +++ b/ci/legacy.yml @@ -1,5 +1,9 @@ image: registry.corp.sldev.cz/trezor/trezor-firmware/environment +variables: + SDL_VIDEODRIVER: "dummy" + XDG_RUNTIME_DIR: "/var/tmp" + build legacy firmware: stage: build script: @@ -31,9 +35,8 @@ build legacy firmware bitcoinonly: build legacy emu: stage: build variables: - HEADLESS: "1" - EMULATOR: "1" DEBUG_LINK: "1" + EMULATOR: "1" script: - cd legacy - pipenv run script/cibuild @@ -53,4 +56,4 @@ test legacy emu: EMULATOR: "1" script: - cd legacy - - pipenv run script/test \ No newline at end of file + - pipenv run script/test diff --git a/core/Makefile b/core/Makefile index 325659da6..b250e4b9a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -108,12 +108,6 @@ build_unix: res ## build unix port build_unix_frozen: res build_cross ## build unix port with frozen modules $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_FROZEN=1 -build_unix_noui: res ## build unix port without UI support - $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 - -build_unix_noui_frozen: res build_cross ## build unix port without UI support with frozen modules - $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 TREZOR_EMULATOR_FROZEN=1 - build_unix_raspi: res ## build unix port for Raspberry Pi $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1 diff --git a/core/SConscript.unix b/core/SConscript.unix index 45e802a43..68e6d7c44 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -134,8 +134,6 @@ SOURCE_MOD += [ 'embed/extmod/modtrezorui/modtrezorui.c', 'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c', ] -if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0): - CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI'] if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0): CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI'] if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0): @@ -341,8 +339,7 @@ env.Replace( ] + CPPDEFINES_MOD, ASPPFLAGS='$CFLAGS $CCFLAGS', ) -if not ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0): - env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image || :') +env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image') env.Replace( PYTHON='python', diff --git a/core/docker/emulator/Dockerfile b/core/docker/emulator/Dockerfile index f2267c091..292bcd9ed 100644 --- a/core/docker/emulator/Dockerfile +++ b/core/docker/emulator/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update RUN apt-get install libusb-1.0-0 RUN pip3 install scons trezor -RUN make build_unix_noui +RUN make build_unix ENTRYPOINT ["emulator/run.sh"] EXPOSE 21324/udp 21325 diff --git a/core/docker/emulator/run.sh b/core/docker/emulator/run.sh index a4eceba8d..5dd0f48da 100755 --- a/core/docker/emulator/run.sh +++ b/core/docker/emulator/run.sh @@ -2,6 +2,7 @@ cd "$(dirname "$0")" cd .. +export SDL_VIDEODRIVER=dummy export TREZOR_UDP_IP=0.0.0.0 source emu.sh diff --git a/core/embed/extmod/modtrezorui/display-unix.h b/core/embed/extmod/modtrezorui/display-unix.h index 87b53236f..bb261b990 100644 --- a/core/embed/extmod/modtrezorui/display-unix.h +++ b/core/embed/extmod/modtrezorui/display-unix.h @@ -17,10 +17,9 @@ * along with this program. If not, see . */ -#include -#ifndef TREZOR_EMULATOR_NOUI #include #include +#include #define EMULATOR_BORDER 16 @@ -90,12 +89,8 @@ void PIXELDATA(uint16_t c) { PIXELWINDOW.pos.y++; } } -#else -#define PIXELDATA(X) (void)(X) -#endif void display_init(void) { -#ifndef TREZOR_EMULATOR_NOUI if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("%s\n", SDL_GetError()); ensure(secfalse, "SDL_Init error"); @@ -166,12 +161,10 @@ void display_init(void) { #else DISPLAY_ORIENTATION = 0; #endif -#endif } static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { -#ifndef TREZOR_EMULATOR_NOUI if (!RENDERER) { display_init(); } @@ -181,11 +174,9 @@ static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, PIXELWINDOW.end.y = y1; PIXELWINDOW.pos.x = x0; PIXELWINDOW.pos.y = y0; -#endif } void display_refresh(void) { -#ifndef TREZOR_EMULATOR_NOUI if (!RENDERER) { display_init(); } @@ -208,7 +199,6 @@ void display_refresh(void) { SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0); } SDL_RenderPresent(RENDERER); -#endif } static void display_set_orientation(int degrees) { display_refresh(); } @@ -216,7 +206,6 @@ static void display_set_orientation(int degrees) { display_refresh(); } static void display_set_backlight(int val) { display_refresh(); } const char *display_save(const char *prefix) { -#ifndef TREZOR_EMULATOR_NOUI if (!RENDERER) { display_init(); } @@ -243,6 +232,4 @@ const char *display_save(const char *prefix) { IMG_SavePNG(crop, filename); prev = crop; return filename; -#endif - return NULL; } diff --git a/core/embed/unix/touch.c b/core/embed/unix/touch.c index 5c81cebda..b040aba76 100644 --- a/core/embed/unix/touch.c +++ b/core/embed/unix/touch.c @@ -17,10 +17,8 @@ * along with this program. If not, see . */ -#include -#ifndef TREZOR_EMULATOR_NOUI #include -#endif +#include #include "touch.h" @@ -31,7 +29,6 @@ extern void __shutdown(void); extern const char *display_save(const char *prefix); uint32_t touch_read(void) { -#ifndef TREZOR_EMULATOR_NOUI SDL_Event event; SDL_PumpEvents(); if (SDL_PollEvent(&event) > 0) { @@ -113,6 +110,5 @@ uint32_t touch_read(void) { break; } } -#endif return 0; } diff --git a/legacy/Makefile.include b/legacy/Makefile.include index c2a96e254..1ddc13f47 100644 --- a/legacy/Makefile.include +++ b/legacy/Makefile.include @@ -91,14 +91,8 @@ LDFLAGS += -L$(TOP_DIR)emulator LDLIBS += -ltrezor -lemulator LIBDEPS += $(TOP_DIR)/libtrezor.a $(TOP_DIR)emulator/libemulator.a -ifeq ($(HEADLESS),1) -CFLAGS += -DHEADLESS=1 -else -CFLAGS += -DHEADLESS=0 - CFLAGS += $(shell pkg-config --cflags sdl2) LDLIBS += $(shell pkg-config --libs sdl2) -endif ifdef RANDOM_DEV_FILE CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\" diff --git a/legacy/emulator/buttons.c b/legacy/emulator/buttons.c index 2d456aafb..77b097794 100644 --- a/legacy/emulator/buttons.c +++ b/legacy/emulator/buttons.c @@ -19,14 +19,11 @@ #include "buttons.h" -#if !HEADLESS #include -#endif uint16_t buttonRead(void) { uint16_t state = 0; -#if !HEADLESS const uint8_t *scancodes = SDL_GetKeyboardState(NULL); if (scancodes[SDL_SCANCODE_LEFT]) { state |= BTN_PIN_NO; @@ -34,7 +31,6 @@ uint16_t buttonRead(void) { if (scancodes[SDL_SCANCODE_RIGHT]) { state |= BTN_PIN_YES; } -#endif return ~state; } diff --git a/legacy/emulator/oled.c b/legacy/emulator/oled.c index a4466e993..353d4dbd0 100644 --- a/legacy/emulator/oled.c +++ b/legacy/emulator/oled.c @@ -19,14 +19,6 @@ #include "oled.h" -#if HEADLESS - -void oledInit(void) {} -void oledRefresh(void) {} -void emulatorPoll(void) {} - -#else - #include static SDL_Renderer *renderer = NULL; @@ -146,5 +138,3 @@ void emulatorPoll(void) { } } } - -#endif