[Libreoffice-commits] core.git: bin/gbuild-to-ide
jan iversen
jani at documentfoundation.org
Tue Dec 1 02:45:49 PST 2015
bin/gbuild-to-ide | 121 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 83 insertions(+), 38 deletions(-)
New commits:
commit 02b411818b79154bd41f1654e23c2422170e3629
Author: jan iversen <jani at documentfoundation.org>
Date: Sat Nov 28 11:08:05 2015 +0100
gbuild-to-ide split state machine
Catching the needed information and the state machine is split.
gbuild-to-ide only finds 27 of 93 exe, due to the state machine
sequence:
CXXOBJECTS for exe1
CXXOBJECTS for exe2
Recipe to execute for exe2
Recipe to execute for exe1
only identifies exe2 and leaves exe1 without a project.
Solution is to have an array of state one for all pending exe.
This patch only contains the split
Change-Id: I2539f10a9850d956a85b6993b26561b1970575df
Reviewed-on: https://gerrit.libreoffice.org/20254
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index 8b08380..1df534f 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -113,7 +113,7 @@ class GbuildParser:
mapping_dict[target] = library
return mapping_dict
- def _parse_hash(self, line, state):
+ def _parse_hash_old(self, line, state):
libmatch = GbuildParser.libpattern.match(line)
if libmatch:
libname = self.libnames.get(state.ilib, None)
@@ -169,55 +169,100 @@ class GbuildParser:
# we could match a lot of other stuff here if needed for integration rpaths etc.
return state
+ def _parse_hash(self, line):
+ libmatch = GbuildParser.libpattern.match(line)
+ if libmatch:
+ return True
+ exematch = GbuildParser.exepattern.match(line)
+ if exematch:
+ return True
+ if line.find('# INCLUDE :=') == 0:
+ return True
+ defsmatch = GbuildParser.defspattern.match(line)
+ if defsmatch:
+ return True
+ cxxmatch = GbuildParser.cxxpattern.match(line)
+ if cxxmatch:
+ return True
+ linkedlibsmatch = GbuildParser.linkedlibspattern.match(line)
+ if linkedlibsmatch:
+ return True
+ ilibmatch = GbuildParser.ilibpattern.match(line)
+ if ilibmatch:
+ return True
+ if line.find('# T_CXXFLAGS :=') == 0:
+ return True
+ # we could match a lot of other stuff here if needed for integration rpaths etc.
+ return False
+
+ def _parse_without_hash(self, line):
+ makecmdmatch = GbuildParser.makecmdpattern.match(line)
+ if makecmdmatch:
+ self.makecmd = makecmdmatch.group(1)
+ # FIXME: Hack
+ if self.makecmd == 'make':
+ self.makecmd = '/usr/bin/make'
+ return False
+ srcdirmatch = GbuildParser.srcdirpattern.match(line)
+ if srcdirmatch:
+ self.srcdir = srcdirmatch.group(1)
+ return False
+ builddirmatch = GbuildParser.builddirpattern.match(line)
+ if builddirmatch:
+ self.builddir = builddirmatch.group(1)
+ return False
+ instdirmatch = GbuildParser.instdirpattern.match(line)
+ if instdirmatch:
+ self.instdir = instdirmatch.group(1)
+ return False
+ binpathmatch = GbuildParser.binpathpattern.match(line)
+ if binpathmatch:
+ self.binpath = binpathmatch.group(1)
+ return False
+ libnamesmatch = GbuildParser.libnamespattern.match(line)
+ if libnamesmatch:
+ self.libnames = self.__mapping_to_dict(libnamesmatch.group(1))
+ return False
+ exenamesmatch = GbuildParser.exenamepattern.match(line)
+ if exenamesmatch:
+ self.exenames = self.__mapping_to_dict(exenamesmatch.group(1))
+ return False
+ rulematch = self.rulepattern.match(line)
+ if rulematch:
+ return True
+
def parse(self, gbuildstate):
- state = GbuildParserState()
+ workLines = []
+ stateActive = False
for line in gbuildstate:
line = line.rstrip('\r\n')
if line.startswith('#'):
- state = self._parse_hash(line, state)
+ if self._parse_hash(line):
+ stateActive = True
+ workLines.append(line)
+ else:
+ if self._parse_without_hash(line):
+ workLines.append(line)
+ elif stateActive:
+ workLines.append('!END OF STATE')
+
+ state = GbuildParserState()
+ for line in workLines:
+ if line.startswith('!END OF STATE'):
+ state = GbuildParserState()
+ continue
+ if line.startswith('#'):
+ state = self._parse_hash_old(line, state)
else:
- makecmdmatch = GbuildParser.makecmdpattern.match(line)
- if makecmdmatch:
- self.makecmd = makecmdmatch.group(1)
- # FIXME: Hack
- if self.makecmd == 'make':
- self.makecmd = '/usr/bin/make'
- continue
- srcdirmatch = GbuildParser.srcdirpattern.match(line)
- if srcdirmatch:
- self.srcdir = srcdirmatch.group(1)
- continue
- builddirmatch = GbuildParser.builddirpattern.match(line)
- if builddirmatch:
- self.builddir = builddirmatch.group(1)
- continue
- instdirmatch = GbuildParser.instdirpattern.match(line)
- if instdirmatch:
- self.instdir = instdirmatch.group(1)
- continue
- binpathmatch = GbuildParser.binpathpattern.match(line)
- if binpathmatch:
- self.binpath = binpathmatch.group(1)
- continue
rulematch = self.rulepattern.match(line)
if rulematch:
if len(rulematch.groups()) == 2 \
and rulematch.group(2) is not None \
and ':=' in rulematch.group(2):
# Hack to make GNU make >= 4.x happy
- state = self._parse_hash('#' + rulematch.group(2), state)
+ state = self._parse_hash_old('#' + rulematch.group(2), state)
else:
- state.target = os.path.basename(rulematch.group(1))
- continue
- libnamesmatch = GbuildParser.libnamespattern.match(line)
- if libnamesmatch:
- self.libnames = self.__mapping_to_dict(libnamesmatch.group(1))
- continue
- exenamesmatch = GbuildParser.exenamepattern.match(line)
- if exenamesmatch:
- self.exenames = self.__mapping_to_dict(exenamesmatch.group(1))
- continue
- state = GbuildParserState()
+ state.target = os.path.basename(rulematch.group(1))
for target in set(self.libs) | set(self.exes):
if target.location not in self.target_by_location:
More information about the Libreoffice-commits
mailing list