mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
meson: use "cpp -E -dM" to process header file
This was requested in review: https://github.com/systemd/systemd/pull/27846#discussion_r1210383265 I kept this as separate commit because the change would impact both of the previous commits and splitting it up seems like unnecessary work. The result is unchanged. v2: - use universal_newlines=True to keep compat with Python 3.6 on C8S.
This commit is contained in:
@@ -2,21 +2,27 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
OVERRIDES = {
|
||||
'autoneg' : 'autonegotiation',
|
||||
}
|
||||
|
||||
xml = sys.argv[1] == '--xml'
|
||||
mode, cpp, header = sys.argv[1:]
|
||||
xml = mode == '--xml'
|
||||
|
||||
f = open(sys.argv[-1])
|
||||
for line in f:
|
||||
command = [*shlex.split(cpp), '-include', header, '-']
|
||||
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, universal_newlines=True)
|
||||
|
||||
lines = iter(out.splitlines())
|
||||
for line in lines:
|
||||
if line.startswith('enum ethtool_link_mode_bit_indices {'):
|
||||
break
|
||||
|
||||
entries = []
|
||||
for line in f:
|
||||
for line in lines:
|
||||
if line.startswith('}'):
|
||||
break
|
||||
# ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0,
|
||||
|
||||
@@ -275,7 +275,7 @@ ethtool_link_mode_h = custom_target(
|
||||
fname,
|
||||
input : ['ethtool-link-mode.py', 'linux/ethtool.h'],
|
||||
output : fname,
|
||||
command : [python, '@INPUT0@', '@INPUT1@'],
|
||||
command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'],
|
||||
capture : true)
|
||||
shared_sources += ethtool_link_mode_h
|
||||
|
||||
@@ -284,7 +284,7 @@ ethtool_link_mode_xml = custom_target(
|
||||
fname,
|
||||
input : ['ethtool-link-mode.py', 'linux/ethtool.h'],
|
||||
output : fname,
|
||||
command : [python, '@INPUT0@', '--xml', '@INPUT1@'],
|
||||
command : [python, '@INPUT0@', '--xml', cpp, '@INPUT1@'],
|
||||
capture : true)
|
||||
man_page_depends += ethtool_link_mode_xml
|
||||
|
||||
|
||||
Reference in New Issue
Block a user