11cmake_minimum_required (VERSION 3.19.0 )
22set (CMAKE_MESSAGE_LOG_LEVEL debug)
33
4- if ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Device" )
5- message ("Device platform selected" )
6- set (CMAKE_TOOLCHAIN_FILE utilities/cmake/arm-none-eabi-gcc.cmake)
7- set (PROJECT Cypherock-${FIRMWARE_TYPE} )
8- elseif ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Simulator" )
9- message ("Simulator platform selected" )
10- set (PROJECT Cypherock_Simulator)
11- else ()
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- endif ()
15-
16- # Replace this with actual vendors
4+ # Add vendor specific compile definitions
175if ("${VENDOR} " STREQUAL "Odix" )
6+ message ("Vendor Odix" )
187 add_compile_definitions (VENDOR_NAME= "Odix Wallet" )
198 add_compile_definitions (VENDOR_COMPANION_APP= "Odix" )
209 add_compile_definitions (VENDOR_DEVICE_NAME= "Odix Wallet" )
2110 add_compile_definitions (VENDOR_COMPANY_NAME "Odix" )
22- set (PROJECT ${PROJECT} - Odix)
11+ set (PROJECT Odix)
2312 add_compile_definitions (VENDOR_ID=1 )
2413else ()
14+ message ("Vendor Cypherock" )
2515 add_compile_definitions (VENDOR_NAME= "Cypherock X1 Wallet" )
2616 add_compile_definitions (VENDOR_COMPANION_APP= "cySync" )
2717 add_compile_definitions (VENDOR_DEVICE_NAME= "Cypherock X1" )
2818 add_compile_definitions (VENDOR_COMPANY_NAME "Cypherock" )
2919 add_compile_definitions (VENDOR_ID=0 )
20+ set (PROJECT Cypherock)
21+ endif ()
22+
23+ if ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Device" )
24+ message ("Device platform selected" )
25+ set (CMAKE_TOOLCHAIN_FILE utilities/cmake/arm-none-eabi-gcc.cmake)
26+ set (PROJECT ${PROJECT} -${FIRMWARE_TYPE} )
27+ elseif ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Simulator" )
28+ message ("Simulator platform selected" )
29+ set (PROJECT ${PROJECT} _Simulator)
30+ else ()
31+ message (WARNING "No platform specified defaulting to Simulator. Specify using -DCMAKE_BUILD_PLATFORM=<Type> Type can be Device or Simulator" )
32+ set (PROJECT ${PROJECT} _Simulator)
3033endif ()
3134
35+ # Define all options upfront, including BTC_ONLY
36+ OPTION (DEV_SWITCH "Additional features/logs to aid developers" OFF )
37+ OPTION (UNIT_TESTS_SWITCH "Compile build for main firmware or unit tests" OFF )
38+ OPTION (BTC_ONLY "Build firmware for Bitcoin only" OFF )
39+
40+ # Append -BTC to project name if BTC_ONLY is enabled
41+ if (BTC_ONLY)
42+ set (PROJECT ${PROJECT} -BTC)
43+ endif ()
44+
45+ # Make static functions testable via unit-tests
46+ IF (UNIT_TESTS_SWITCH)
47+ add_compile_definitions ( STATIC = )
48+ ELSE ()
49+ add_compile_definitions ( STATIC =static )
50+ ENDIF (UNIT_TESTS_SWITCH )
51+
52+ # Now define the project with its final name, after all modifications
3253project (${PROJECT} )
3354
3455# python is needed for compiling proto files using nanopb
3556# also for generating & appending firmware signature headers
3657find_package ( Python3 REQUIRED COMPONENTS Interpreter )
37- execute_process (COMMAND sh utilities/proto/generate-protob.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY )
58+
59+ # Conditionally generate protobuf files based on the BTC_ONLY option
60+ IF (BTC_ONLY)
61+ message (STATUS "Generating protobufs for BTC-only build" )
62+ execute_process (COMMAND bash utilities/proto/generate-protob.sh --btc-only
63+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
64+ COMMAND_ERROR_IS_FATAL ANY )
65+ ELSE ()
66+ message (STATUS "Generating protobufs for full build" )
67+ execute_process (COMMAND bash utilities/proto/generate-protob.sh
68+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
69+ COMMAND_ERROR_IS_FATAL ANY )
70+ ENDIF ()
3871
3972# Populate version.c
4073include (utilities/cmake/version.cmake )
4174
4275file (GLOB_RECURSE PROTO_SRCS "generated/proto/*.*" )
43- list (APPEND PROTO_SRCS "vendor/nanopb/pb_common.c" "vendor/nanopb/pb_decode.c" "vendor/nanopb/pb_encode.c" "vendor/nanopb/pb_common.h" "vendor/nanopb/pb_decode.h" "vendor/nanopb/pb_encode.h" "vendor/nanopb/pb.h" )
76+ list (APPEND PROTO_SRCS
77+ "vendor/nanopb/pb_common.c"
78+ "vendor/nanopb/pb_decode.c"
79+ "vendor/nanopb/pb_encode.c"
80+ "vendor/nanopb/pb_common.h"
81+ "vendor/nanopb/pb_decode.h"
82+ "vendor/nanopb/pb_encode.h"
83+ "vendor/nanopb/pb.h"
84+ )
4485
45- list (APPEND MINI_GMP_SRCS "vendor/mini-gmp/mini-gmp-helpers.c" "vendor/mini-gmp/mini-gmp.c" )
46- list (APPEND POSEIDON_SRCS "vendor/poseidon/sources/f251.c" "vendor/poseidon/sources/poseidon.c" "vendor/poseidon/sources/poseidon_rc.c" )
47-
48- OPTION (DEV_SWITCH "Additional features/logs to aid developers" OFF )
49- OPTION (UNIT_TESTS_SWITCH "Compile build for main firmware or unit tests" OFF )
50-
51- # Make static functions testable via unit-tests
52- IF (UNIT_TESTS_SWITCH)
53- add_compile_definitions ( STATIC = )
54- ELSE ()
55- add_compile_definitions ( STATIC =static )
56- ENDIF (UNIT_TESTS_SWITCH )
86+ list (APPEND MINI_GMP_SRCS
87+ "vendor/mini-gmp/mini-gmp-helpers.c"
88+ "vendor/mini-gmp/mini-gmp.c"
89+ )
90+ list (APPEND POSEIDON_SRCS
91+ "vendor/poseidon/sources/f251.c"
92+ "vendor/poseidon/sources/poseidon.c"
93+ "vendor/poseidon/sources/poseidon_rc.c"
94+ )
5795
5896if ("${CMAKE_BUILD_TYPE} " STREQUAL "Release" )
5997 add_compile_definitions (FIRMWARE_HASH_CALC=1 )
@@ -63,12 +101,17 @@ endif()
63101
64102if ("${CMAKE_BUILD_PLATFORM} " STREQUAL "Device" )
65103 include (utilities/cmake/firmware/firmware.cmake )
66- else ()
104+ else () # Simulator or default
67105 include (utilities/cmake/simulator/simulator.cmake )
68106endif ()
69107
70108# Include nanopb source headers
71- target_include_directories ( ${EXECUTABLE} PRIVATE vendor/nanopb generated /proto vendor/mini-gmp vendor/poseidon/sources )
109+ target_include_directories ( ${EXECUTABLE} PRIVATE
110+ vendor/nanopb
111+ generated /proto
112+ vendor/mini-gmp
113+ vendor/poseidon/sources
114+ )
72115
73116# Enable support for dynamically allocated fields in nanopb
74117# Ref: vendor/nanopb/pb.h
0 commit comments