-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
executable file
·135 lines (101 loc) · 2.96 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
project('jimage', 'c', default_options: ['c_std=c99', 'buildtype=release', 'warning_level=3'], version: run_command('python', join_paths(meson.current_source_dir(), 'tools/version.py'), check: true).stdout().strip())
deps = []
deps += [dependency('', fallback: ['ctoolbox', 'lib'])]
deps += [dependency('', fallback: ['jdeflate', 'lib'])]
cc = meson.get_compiler('c')
if cc.get_id() == 'msvc'
add_project_arguments('-D__MSVC__', language: 'c')
endif
# major, minor and path
versionarray = [0, 0, 0]
mmp = meson.project_version().split('.')
if mmp.length() == 3
versionarray = [
mmp[0].to_int(),
mmp[1].to_int(),
mmp[2].to_int()
]
endif
# Configuration
conf = configuration_data()
# build the version string
v0 = versionarray[0]
v1 = versionarray[1]
v2 = versionarray[2]
version = f'@v0@.@v1@.@v2@'
conf.set('version', version)
conf.set('version_major', v0)
conf.set('version_minor', v1)
conf.set('version_rpath', v2)
projectsources = []
isunix = false
iswindows = false
# System platform
if target_machine.system() == 'windows'
iswindows = true
else
if target_machine.system() == 'haiku'
pass
else
isunix = true
endif
endif
target = target_machine.cpu_family()
if target == 'x86_64'
supported = false
path = 'src/asm/'
if isunix
supported = true
endif
if iswindows
supported = true
endif
if supported
if add_languages('nasm', required: false, native: false)
if isunix
if host_machine.system() in ['darwin', 'ios', 'tvos']
nasmformat = 'macho64'
else
nasmformat = 'elf64'
endif
endif
if iswindows
nasmformat = 'win64'
endif
add_project_arguments('-f', nasmformat, language: 'nasm')
projectsources += [path / 'x64-jpgreader.asm']
projectsources += [path / 'x64-pngreader.asm']
add_project_arguments('-DJPGR_CFG_EXTERNALASM', language: 'c')
add_project_arguments('-DPNGR_CFG_EXTERNALASM', language: 'c')
else
warning('NASM not found, using C fallback code')
endif
endif
endif
python = find_program('python3')
script = join_paths(meson.current_source_dir(), 'tools/listfiles.py')
newline = '''
'''
base = 'src'
r = run_command(python, script, base, '.c', check: true).stdout()
foreach file: r.split(newline)
if not (file == '')
projectsources += [file]
endif
endforeach
headerfiles = []
base = 'jimage'
r = run_command(python, script, base, '.h', check: true).stdout()
foreach file: r.split(newline)
if not (file == '')
headerfiles += [file]
endif
endforeach
configfile = configure_file(input: 'jimageconfig.h.in', output: 'jimageconfig.h', configuration: conf)
headerfiles += [configfile]
largs = []
static_build = static_library('jimage', sources: projectsources, pic: true, install: true, dependencies: deps)
lib = declare_dependency(
link_with: static_build, include_directories: include_directories('.'), dependencies: deps, link_args: largs
)
install_headers(headerfiles, preserve_path: true)