@@ -4,58 +4,37 @@ set(CMAKE_MESSAGE_LOG_LEVEL debug)
4
4
if ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Device" )
5
5
message ("Device platform selected" )
6
6
set (CMAKE_TOOLCHAIN_FILE utilities/cmake/arm-none-eabi-gcc.cmake)
7
- set (PROJECT_NAME_BASE Cypherock-${FIRMWARE_TYPE} )
7
+ set (PROJECT Cypherock-${FIRMWARE_TYPE} )
8
8
elseif ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Simulator" )
9
9
message ("Simulator platform selected" )
10
- set (PROJECT_NAME_BASE Cypherock_Simulator)
10
+ set (PROJECT Cypherock_Simulator)
11
11
else ()
12
- message (WARNING "No platform specified, defaulting to Simulator. Specify using -DCMAKE_BUILD_PLATFORM=<Type>" )
13
- set (PROJECT_NAME_BASE Cypherock_Simulator)
12
+ message (WARNING "No platform specified defaulting to Simulator. Specify using -DCMAKE_BUILD_PLATFORM=<Type> Type can be Device or Simulator " )
13
+ set (PROJECT Cypherock_Simulator)
14
14
endif ()
15
15
16
- # Define all build options
16
+ # Define all options upfront, including BTC_ONLY
17
17
OPTION (DEV_SWITCH "Additional features/logs to aid developers" OFF )
18
18
OPTION (UNIT_TESTS_SWITCH "Compile build for main firmware or unit tests" OFF )
19
19
OPTION (BTC_ONLY "Build firmware for Bitcoin only" OFF )
20
20
21
- # Append suffix to the project name if BTC_ONLY is enabled
22
- set (PROJECT ${PROJECT_NAME_BASE} )
21
+ # Logic to append -btc to project name if BTC_ONLY is enabled
23
22
if (BTC_ONLY)
24
23
set (PROJECT ${PROJECT} -btc)
25
24
endif ()
26
25
27
- # Define the project with its final calculated name
28
- project (${PROJECT} )
29
-
30
26
# Make static functions testable via unit-tests
31
27
IF (UNIT_TESTS_SWITCH)
32
28
add_compile_definitions ( STATIC = )
33
29
ELSE ()
34
30
add_compile_definitions ( STATIC =static )
35
31
ENDIF (UNIT_TESTS_SWITCH)
36
32
37
- # Set firmware type (Main or Initial)
38
- if ("${FIRMWARE_TYPE} " STREQUAL "Main" )
39
- add_compile_definitions (X1WALLET_INITIAL=0 X1WALLET_MAIN=1)
40
- elseif ("${FIRMWARE_TYPE} " STREQUAL "Initial" )
41
- add_compile_definitions (X1WALLET_INITIAL=1 X1WALLET_MAIN=0)
42
- endif ()
43
-
44
- # Set variant-specific definition (BTC_ONLY_BUILD)
45
- if (BTC_ONLY)
46
- add_compile_definitions (BTC_ONLY_BUILD=1)
47
- endif ()
48
-
49
- # Set hash calculation definition based on build type
50
- if ("${CMAKE_BUILD_TYPE} " STREQUAL "Release" )
51
- add_compile_definitions (FIRMWARE_HASH_CALC=1)
52
- else ()
53
- add_compile_definitions (FIRMWARE_HASH_CALC=0)
54
- endif ()
55
-
56
- # Enable support for dynamically allocated fields in nanopb
57
- add_compile_definitions (PB_ENABLE_MALLOC=1 PB_NO_ERRMSG=1)
33
+ # Now define the project with its final name, after all modifications
34
+ project (${PROJECT} )
58
35
36
+ # python is needed for compiling proto files using nanopb
37
+ # also for generating & appending firmware signature headers
59
38
find_package ( Python3 REQUIRED COMPONENTS Interpreter )
60
39
61
40
# Conditionally generate protobuf files based on the BTC_ONLY option
@@ -95,17 +74,26 @@ list (APPEND POSEIDON_SRCS
95
74
"vendor/poseidon/sources/poseidon_rc.c"
96
75
)
97
76
98
- # This is where add_executable(${PROJECT} ...) is called
77
+ if ("${CMAKE_BUILD_TYPE} " STREQUAL "Release" )
78
+ add_compile_definitions (FIRMWARE_HASH_CALC=1)
79
+ else ()
80
+ add_compile_definitions (FIRMWARE_HASH_CALC=0)
81
+ endif ()
82
+
99
83
if ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Device" )
100
84
include (utilities/cmake/firmware/firmware.cmake)
101
85
else () # Simulator or default
102
86
include (utilities/cmake/simulator/simulator.cmake)
103
87
endif ()
104
88
105
- # This must come AFTER the add_executable call in the included files
106
- target_include_directories ( ${PROJECT } PRIVATE
89
+ # Include nanopb source headers
90
+ target_include_directories ( ${EXECUTABLE } PRIVATE
107
91
vendor/nanopb
108
92
generated /proto
109
93
vendor/mini-gmp
110
94
vendor/poseidon/sources
111
- )
95
+ )
96
+
97
+ # Enable support for dynamically allocated fields in nanopb
98
+ # Ref: vendor/nanopb/pb.h
99
+ add_compile_definitions (PB_ENABLE_MALLOC=1 PB_NO_ERRMSG=1)
0 commit comments