Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson: Don't use libstdc++ headers if cxxshim is available #968

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -96,55 +96,57 @@ if not headers_only
rtdl_include_dirs += include_directories(ccdir / 'include')
libc_include_dirs += include_directories(ccdir / 'include')

cplusplus_include_path = []

c_output = run_command(c_compiler.cmd_array(), '-E', '-v', '-x', 'c',
'/dev/null', '-o', '-',
capture: true,
check: true).stderr().split('\n')

cpp_output = run_command(cpp_compiler.cmd_array(), '-E', '-v', '-x',
'c++', '/dev/null', '-o', '-',
capture: true,
check: true).stderr().split('\n')

c_relevant_lines = []

relevantmarker = '#include <...>'
relevant_started = false

foreach line : c_output
if relevant_started
if not line.startswith(' ')
break
if not cxxshim_dep.found()
cplusplus_include_path = []

c_output = run_command(c_compiler.cmd_array(), '-E', '-v', '-x', 'c',
'/dev/null', '-o', '-',
capture: true,
check: true).stderr().split('\n')

cpp_output = run_command(cpp_compiler.cmd_array(), '-E', '-v', '-x',
'c++', '/dev/null', '-o', '-',
capture: true,
check: true).stderr().split('\n')

c_relevant_lines = []

relevantmarker = '#include <...>'
relevant_started = false

foreach line : c_output
if relevant_started
if not line.startswith(' ')
break
endif
c_relevant_lines += line.strip()
elif line.startswith(relevantmarker)
relevant_started = true
endif
c_relevant_lines += line.strip()
elif line.startswith(relevantmarker)
relevant_started = true
endif
endforeach

relevant_started = false

foreach line : cpp_output
if relevant_started
if not line.startswith(' ')
break
endif
debug('maybe relevant', line)
stripped = line.strip()
if stripped in c_relevant_lines
debug('not relevant (is C)', line)
continue
endforeach

relevant_started = false

foreach line : cpp_output
if relevant_started
if not line.startswith(' ')
break
endif
debug('maybe relevant', line)
stripped = line.strip()
if stripped in c_relevant_lines
debug('not relevant (is C)', line)
continue
endif
cplusplus_include_path += include_directories(stripped)
elif line.startswith(relevantmarker)
relevant_started = true
endif
cplusplus_include_path += include_directories(stripped)
elif line.startswith(relevantmarker)
relevant_started = true
endif
endforeach
endforeach

rtdl_include_dirs += cplusplus_include_path
libc_include_dirs += cplusplus_include_path
rtdl_include_dirs += cplusplus_include_path
libc_include_dirs += cplusplus_include_path
endif
endif

internal_conf.set_quoted('MLIBC_SYSTEM_NAME', host_machine.system())
Expand Down
Loading