Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: cmake cleanup #241

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 191 additions & 83 deletions src/CMakeLists.txt

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions src/apps/btc/btc_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void _sha256(const uint8_t* bytes, size_t bytes_len, uint8_t* out)
sha256_finish(&ctx, out);
}

static void _reset(void)
void btc_sign_reset(void)
{
_state = STATE_INIT;
_coin_params = NULL;
Expand All @@ -103,7 +103,7 @@ static void _reset(void)

static app_btc_sign_error_t _error(app_btc_sign_error_t err)
{
_reset();
btc_sign_reset();
return err;
}

Expand Down Expand Up @@ -134,7 +134,7 @@ app_btc_sign_error_t app_btc_sign_init(
// legacy not supported
return _error(APP_BTC_SIGN_ERR_INVALID_INPUT);
}
_reset();
btc_sign_reset();
_coin_params = coin_params;
_script_type = request->script_type;
_bip44_account = request->bip44_account;
Expand Down Expand Up @@ -292,7 +292,7 @@ static app_btc_sign_error_t _sign_input_pass2(
next_out->index = _index;
} else {
// Done with inputs pass2 -> done completely.
_reset();
btc_sign_reset();
next_out->type = BTCSignNextResponse_Type_DONE;
}
return APP_BTC_SIGN_OK;
Expand Down Expand Up @@ -472,10 +472,3 @@ app_btc_sign_error_t app_btc_sign_output(
}
return APP_BTC_SIGN_OK;
}

#ifdef TESTING
void tst_app_btc_reset(void)
{
_reset();
}
#endif
4 changes: 1 addition & 3 deletions src/apps/btc/btc_sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ app_btc_sign_input(const BTCSignInputRequest* request, BTCSignNextResponse* next
USE_RESULT app_btc_sign_error_t
app_btc_sign_output(const BTCSignOutputRequest* request, BTCSignNextResponse* next_out);

#ifdef TESTING
void tst_app_btc_reset(void);
#endif
void btc_sign_reset(void);

#endif
1 change: 1 addition & 0 deletions src/bitboxbase/bitboxbase_background.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ui/components/image.h>
#include <ui/components/label.h>
#include <ui/components/ui_images.h>
#include <ui/components/ui_logos.h>
#include <ui/event.h>
#include <ui/oled/oled.h>
#include <ui/screen_stack.h>
Expand Down
1 change: 1 addition & 0 deletions src/bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <pukcc/curve_p256.h>
#include <screen.h>
#include <ui/components/ui_images.h>
#include <ui/components/ui_logos.h>
#include <ui/oled/oled.h>
#include <ui/ugui/ugui.h>
#if PLATFORM_BITBOXBASE == 1
Expand Down
1 change: 1 addition & 0 deletions src/commander/commander.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <flags.h>
#include <hardfault.h>
#include <memory/memory.h>
#include <platform_config.h>
#include <random.h>
#include <screen.h>
#include <sd.h>
Expand Down
1 change: 1 addition & 0 deletions src/hww.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <usb/noise.h>
#include <usb/usb_packet.h>
#include <usb/usb_processing.h>
#include <version.h>
#include <workflow/status.h>
#include <workflow/unlock.h>

Expand Down
75 changes: 58 additions & 17 deletions src/platform/platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,108 @@
#ifndef _PLATFORM_CONFIG_H
#define _PLATFORM_CONFIG_H

// Force the PRODUCT_ defines to be 0 or 1, so they can be used safely without risk of typos.
#if !defined(PLATFORM_BITBOX02)
#define PLATFORM_BITBOX02 0
#elif PLATFORM_BITBOX02 != 0 && PLATFORM_BITBOX02 != 1
#error "Invalid value for PLATFORM_BITBOX02."
#endif

#if !defined(PLATFORM_BITBOXBASE)
#define PLATFORM_BITBOXBASE 0
#elif PLATFORM_BITBOXBASE != 0 && PLATFORM_BITBOXBASE != 1
#error "Invalid value for PLATFORM_BITBOXBASE."
#endif

#if !defined(EDITION_STANDARD)
#define EDITION_STANDARD 0
#elif EDITION_STANDARD != 0 && EDITION_STANDARD != 1
#error "Invalid value for EDITION_STANDARD."
#endif
#if !defined(EDITION_BTCONLY)
#define EDITION_BTCONLY 0
#elif EDITION_BTCONLY != 0 && EDITION_BTCONLY != 1
#error "Invalid value for EDITION_BTCONLY."
#endif
#if !defined(EDITION_FACTORYSETUP)
#define EDITION_FACTORYSETUP 0
#elif EDITION_FACTORYSETUP != 0 && EDITION_FACTORYSETUP != 1
#error "Invalid value for EDITION_FACTORYSETUP."
#endif

#if PLATFORM_BITBOX02 == 1

#if EDITION_STANDARD == 1
#define PRODUCT_BITBOX_MULTI 1
#elif EDITION_BTCONLY == 1
#define PRODUCT_BITBOX_BTCONLY 1
#elif EDITION_FACTORYSETUP == 1
#define PRODUCT_BITBOX02_FACTORYSETUP 1
#else
#error "Invalid EDITION value."
#endif

#elif PLATFORM_BITBOXBASE == 1

#if EDITION_STANDARD == 1
#define PRODUCT_BITBOX_BASE 1
#elif EDITION_FACTORYSETUP == 1
#define PRODUCT_BITBOXBASE_FACTORYSETUP 1
#else
#error "Invalid EDITION value."
#endif

#else
#error "Invalid PRODUCT value."
#endif

#if !defined(PRODUCT_BITBOX_MULTI)
#define PRODUCT_BITBOX_MULTI 0
#elif PRODUCT_BITBOX_MULTI != 1
#error "invalid product value"
#error "invalid PRODUCT_BITBOX_MULTI value"
#endif

#if !defined(PRODUCT_BITBOX_BTCONLY)
#define PRODUCT_BITBOX_BTCONLY 0
#elif PRODUCT_BITBOX_BTCONLY != 1
#error "invalid product value"
#error "invalid PRODUCT_BITBOX_BTCONLY value"
#endif

#if !defined(PRODUCT_BITBOX_BASE)
#define PRODUCT_BITBOX_BASE 0
#elif PRODUCT_BITBOX_BASE != 1
#error "invalid product value"
#error "invalid PRODUCT_BITBOX_BASE value"
#endif

#if !defined(PRODUCT_BITBOX02_FACTORYSETUP)
#define PRODUCT_BITBOX02_FACTORYSETUP 0
#elif PRODUCT_BITBOX02_FACTORYSETUP != 1
#error "invald product value"
#error "invald PRODUCT_BITBOX02_FACTORYSETUP value"
#endif

#if !defined(PRODUCT_BITBOXBASE_FACTORYSETUP)
#define PRODUCT_BITBOXBASE_FACTORYSETUP 0
#elif PRODUCT_BITBOXBASE_FACTORYSETUP != 1
#error "invald product value"
#error "invald PRODUCT_BITBOXBASE_FACTORYSETUP value"
#endif

// Derive other useful definitions from the product.

#if PRODUCT_BITBOX_MULTI == 1
#define PLATFORM_BITBOX02 1
#define PLATFORM_BITBOXBASE 0
#define FACTORYSETUP 0
#endif

#if PRODUCT_BITBOX_BTCONLY == 1
#define PLATFORM_BITBOX02 1
#define PLATFORM_BITBOXBASE 0
#define FACTORYSETUP 0
#endif

#if PRODUCT_BITBOX_BASE == 1
#define PLATFORM_BITBOX02 0
#define PLATFORM_BITBOXBASE 1
#define FACTORYSETUP 0
#endif

#if PRODUCT_BITBOX02_FACTORYSETUP == 1
#define PLATFORM_BITBOX02 1
#define PLATFORM_BITBOXBASE 0
#define FACTORYSETUP 1
#endif

#if PRODUCT_BITBOXBASE_FACTORYSETUP == 1
#define PLATFORM_BITBOX02 0
#define PLATFORM_BITBOXBASE 1
#define FACTORYSETUP 1
#endif

Expand Down
6 changes: 6 additions & 0 deletions src/qtouch/qtouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Copyright (c) 2017 Microchip. All rights reserved.
#include <driver_init.h>
#include <platform_config.h>

#if PLATFORM_BITBOXBASE == 1
#include "qtouch_bitboxbase.h"
#else
#include "qtouch_bitbox02.h"
#endif

/*----------------------------------------------------------------------------
* prototypes
*----------------------------------------------------------------------------*/
Expand Down
Loading