meson.build 2.71 KB
Newer Older
Rahix's avatar
Rahix committed
1
2
name = 'epicardium'

Rahix's avatar
Rahix committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##########################################################################
#
# API
#
##########################################################################

api = custom_target(
  'api_*.c',
  input: 'epicardium.h',
  output: ['api_caller.c', 'api_dispatcher.c'],
  command: [
    python3,
    meson.current_source_dir() + '/api/genapi.py',
    '-H', '@INPUT0@',
    '-c', '@OUTPUT0@', '-s', '@OUTPUT1@',
  ],
  depend_files: 'api/genapi.py',
)

api_caller_lib = static_library(
  'api-caller',
  'api/caller.c',
25
  'api/interrupt-receiver.c',
Rahix's avatar
Rahix committed
26
27
28
29
30
31
32
33
34
35
36
37
38
  api[0], # Caller
  dependencies: periphdriver,
)

api_caller = declare_dependency(
  include_directories: include_directories('.'),
  link_with: api_caller_lib,
  dependencies: periphdriver,
)

api_dispatcher_lib = static_library(
  'api-dispatcher',
  'api/dispatcher.c',
39
  'api/interrupt-sender.c',
40
  'api/control.c',
Rahix's avatar
Rahix committed
41
  api[1], # Dispatcher
42
  dependencies: [libcard10, periphdriver],
Rahix's avatar
Rahix committed
43
44
)

Rahix's avatar
Rahix committed
45
46
47
48
49
50
51
52
53
##########################################################################
#
# FreeRTOS
#
##########################################################################

freertos = static_library(
  'freertos',
  freertos_sources,
54
  freertos_heap3,
Rahix's avatar
Rahix committed
55
56
57
58
59
60
61
  dependencies: periphdriver,
  include_directories: [
    freertos_includes,
    include_directories('./'),
  ],
)

Rahix's avatar
Rahix committed
62
63
64
65
66
67
##########################################################################
#
# Epicardium executable
#
##########################################################################

68
subdir('modules/')
69
subdir('ble/')
70

q3k's avatar
q3k committed
71
72
subdir('l0der/')

swym's avatar
swym committed
73
epicardium_cargs = ['-D_POSIX_C_SOURCE=200809']
swym's avatar
swym committed
74
75
76
77
78
79
if get_option('jailbreak_card10')
  epicardium_cargs += [
    '-DJAILBREAK_CARD10=1',
  ]
endif

80
81
82
83
84
85
86
87
88
89
90
version_screen = custom_target(
  'version-splash.h',
  input: 'version-splash.png',
  output: 'version-splash.h',
  command: [
    python3,
    meson.current_source_dir() + '../tools/version-image.py',
    '@INPUT@',
    '@OUTPUT@',
  ],
)
swym's avatar
swym committed
91

Rahix's avatar
Rahix committed
92
93
elf = executable(
  name + '.elf',
swym's avatar
swym committed
94
95
96
  'usb/epc_usb.c',
  'usb/cdcacm.c',
  'usb/mass_storage.c',
97
98
  'main.c',
  'support.c',
99
  'fs/filesystem_fat.c',
100
  'fs/fs_util.c',
101
  module_sources,
q3k's avatar
q3k committed
102
  l0der_sources,
103
  ble_sources,
Rahix's avatar
Rahix committed
104
  version_hdr,
105
  version_screen,
106
  dependencies: [libcard10, max32665_startup_core0, maxusb, libff13, ble, bhy1, libcrypto],
Rahix's avatar
Rahix committed
107
  link_with: [api_dispatcher_lib, freertos],
108
  link_whole: [max32665_startup_core0_lib, board_card10_lib, newlib_heap_lib],
Rahix's avatar
Rahix committed
109
  include_directories: [freertos_includes],
Rahix's avatar
Rahix committed
110
111
  link_args: [
    '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
112
    '-Wl,--defsym=_write=_write_epicardium',
Rahix's avatar
Rahix committed
113
  ],
swym's avatar
swym committed
114
  c_args: epicardium_cargs,
Rahix's avatar
Rahix committed
115
116
)

117
epicardium_bin = custom_target(
Rahix's avatar
Rahix committed
118
119
120
121
122
123
  name + '.bin',
  build_by_default: true,
  output: name + '.bin',
  input: elf,
  command: [build_image, '@INPUT@', '@OUTPUT0@'],
)