diff options
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/meson.build b/meson.build index f657f874..eb5039ee 100644 --- a/meson.build +++ b/meson.build | |||
@@ -13,8 +13,6 @@ project( | |||
13 | 13 | ||
14 | add_project_arguments( | 14 | add_project_arguments( |
15 | [ | 15 | [ |
16 | '-DSWAY_SRC_DIR="@0@"'.format(meson.current_source_dir()), | ||
17 | |||
18 | '-DWL_HIDE_DEPRECATED', | 16 | '-DWL_HIDE_DEPRECATED', |
19 | '-DWLR_USE_UNSTABLE', | 17 | '-DWLR_USE_UNSTABLE', |
20 | 18 | ||
@@ -142,6 +140,44 @@ if git.found() | |||
142 | endif | 140 | endif |
143 | add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') | 141 | add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') |
144 | 142 | ||
143 | # Compute the relative path used by compiler invocations. | ||
144 | source_root = meson.current_source_dir().split('/') | ||
145 | build_root = meson.build_root().split('/') | ||
146 | relative_dir_parts = [] | ||
147 | i = 0 | ||
148 | in_prefix = true | ||
149 | foreach p : build_root | ||
150 | if i >= source_root.length() or not in_prefix or p != source_root[i] | ||
151 | in_prefix = false | ||
152 | relative_dir_parts += '..' | ||
153 | endif | ||
154 | i += 1 | ||
155 | endforeach | ||
156 | i = 0 | ||
157 | in_prefix = true | ||
158 | foreach p : source_root | ||
159 | if i >= build_root.length() or not in_prefix or build_root[i] != p | ||
160 | in_prefix = false | ||
161 | relative_dir_parts += p | ||
162 | endif | ||
163 | i += 1 | ||
164 | endforeach | ||
165 | relative_dir = join_paths(relative_dir_parts) + '/' | ||
166 | |||
167 | # Strip relative path prefixes from the code if possible, otherwise hide them. | ||
168 | if cc.has_argument('-fmacro-prefix-map=/prefix/to/hide=') | ||
169 | add_project_arguments( | ||
170 | '-fmacro-prefix-map=@0@='.format(relative_dir), | ||
171 | language: 'c', | ||
172 | ) | ||
173 | else | ||
174 | add_project_arguments( | ||
175 | '-DSWAY_REL_SRC_DIR="@0@"'.format(relative_dir), | ||
176 | language: 'c', | ||
177 | ) | ||
178 | endif | ||
179 | |||
180 | |||
145 | sway_inc = include_directories('include') | 181 | sway_inc = include_directories('include') |
146 | 182 | ||
147 | subdir('include') | 183 | subdir('include') |