-
Notifications
You must be signed in to change notification settings - Fork 3
/
meson.build
174 lines (152 loc) · 4.29 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
project('libhfx', 'c')
fs = import('fs')
# Need to get exe extension to properly run on windows
exe_extension = ''
if build_machine.system().contains('mingw')
exe_extension = '.exe'
endif
mips_compiler = find_program('mips64-elf-gcc' + exe_extension)
mips_linker = find_program('mips64-elf-ld' + exe_extension)
mips_ar = find_program('mips64-elf-ar' + exe_extension)
mips_objcopy = find_program('mips64-elf-objcopy' + exe_extension)
n64tool = find_program('n64tool' + exe_extension)
chksum64 = find_program('chksum64' + exe_extension)
bash = find_program('bash' + exe_extension)
#####################################
# Add new files here
src_dir = './libhfx_src/'
src_files = [
'src/hfx.c',
'src/hfx_rb.c',
'src/hfx_cmd_dma.c',
'src/hfx_cmd.c',
'src/hfx_display.c',
'src/hfx_math.c',
'src/hfx_render.c',
'src/hfx_render_gl.c',
'src/hfx_matrix.c',
'src/hfx_state.c',
'src/hfx_texture.c',
'src/hfx_dispatch.c',
]
ucode_src_dir = './ucode_src/src/'
ucode_files = [
'crt.S',
'hfx_ucode.c',
]
ucode_loader = 'libhfx_src/src/linker.S'
ucode_linker_script = 'ucode.ld'
# Change compiler flags here
cflags = [
'-I'+meson.source_root()+'/include',
'-I'+meson.source_root()+'/libhfx_src/include',
'-std=gnu99',
'-march=vr4300',
'-mtune=vr4300',
'-O0',
'-Wall',
'-Wpedantic',
'-MMD',
'-g',
]
ucode_cflags = [
'-I'+meson.source_root()+'/include',
'-std=gnu99',
'-Wall',
'-march=vr4300',
'-mtune=vr4300',
'-Os',
'-mno-branch-likely',
'-mno-llsc',
'-Wall',
'-mabi=eabi',
'-mgp32',
'-flto',
'-MMD',
'-EB',
]
ucode_ldflags = [
'-Wall',
'-march=vr4300',
'-mtune=vr4300',
'-mabi=eabi',
'-mgp32',
'-ffreestanding',
'-nostdlib',
'-Os',
'-mno-branch-likely',
'-mno-llsc',
'-flto',
'-EB',
]
#####################################
src = []
foreach source : src_files
src += [src_dir + source]
endforeach
ucode_src_files = []
foreach source : ucode_files
src_file = ucode_src_dir + source
ucode_src_files += [src_file]
endforeach
ucode_define_string = '-DTEXT_SECTION_BIN="@0@" -DDATA_SECTION_BIN="@1@"'
# Build all ucode object files
ucode_obj_files = []
foreach source : ucode_src_files
obj = custom_target(fs.name(source),
output : '@[email protected]',
input : source,
command : [mips_compiler] + ucode_cflags + ['-c', '@INPUT@', '-o', '@OUTPUT@'],
depfile : '@[email protected]')
ucode_obj_files += [obj]
endforeach
# Build ucode into elf file
ucode_elf_file = custom_target('ucode_elf',
output : 'ucode.elf',
input : ucode_obj_files,
depend_files : ucode_linker_script,
command : [mips_compiler] + ucode_ldflags + ['@INPUT@', '-o', '@OUTPUT@', '-T', '../'+ucode_linker_script])
# convert ucode elf into bin files
ucode_bin = custom_target('ucode_bin',
output : ['ucode_text.bin', 'ucode_data.bin'],
input : ucode_elf_file,
command : [mips_objcopy, '--dump-section', '.text=ucode_text.bin',
'--dump-section', '.data=ucode_data.bin', '@INPUT@'])
# Build linker object file
ucode_link = custom_target('ucode_link',
output : '@[email protected]',
input : ucode_loader,
depfile : '@[email protected]',
depends: ucode_bin,
command : [mips_compiler] + cflags +
ucode_define_string.format(ucode_bin[0].full_path(), ucode_bin[1].full_path()).split() +
['-c', '@INPUT@', '-o', '@OUTPUT@'])
# Build all c source files
object_generator = generator(mips_compiler,
output : '@[email protected]',
arguments : cflags + ['-c', '@INPUT@', '-o', '@OUTPUT@'],
depfile : '@[email protected]')
object_files = object_generator.process(src)
# Build library file
libhfx = custom_target('libhfx',
output : 'libhfx.a',
input : [object_files] + [ucode_link],
command : [mips_ar, 'rcs', '@OUTPUT@', '@INPUT@'],
build_by_default:true)
#############################################################
opengl_src = [
'./libhfx_gl/src/hfx.c',
'./libhfx_src/src/hfx_matrix.c',
'./gl_test/cube/main.c'
]
opengl_c_args = [
'-I'+meson.source_root()+'/libhfx_gl/include',
'-I'+meson.source_root()+'/include'
]
# Build OpenGL example platform
# current disable OpenGL example platform
'''
executable('cube', opengl_src,
c_args : opengl_c_args,
link_args : ['-lSDL2', '-lGL', '-lGLEW', '-lm'])
'''