From 748dd61615d2329efaf01f95a02ab0219314c4f6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 12:55:34 +0100 Subject: [PATCH] makepanda: Require flex 2.5.9 for building egg lexer Otherwise, fall back to prebuilt file instead --- makepanda/makepanda.py | 15 ++++++++++++++- makepanda/makepandacore.py | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a80e85ad04..a07ad63ba9 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1663,6 +1663,19 @@ def CompileFlex(wobj,wsrc,opts): pre = GetValueOption(opts, "BISONPREFIX_") dashi = opts.count("FLEXDASHI") flex = GetFlex() + want_version = GetValueOption(opts, "FLEXVERSION:") + if want_version: + # Is flex at the required version for this file? + want_version = tuple(map(int, want_version.split('.'))) + have_version = GetFlexVersion() + if want_version > have_version: + Warn("Skipping flex %s for file %s, need at least %s" % ( + '.'.join(map(str, have_version)), + ifile, + '.'.join(map(str, want_version)), + )) + flex = None + if flex is None: # We don't have flex. See if there is a prebuilt file. base, ext = os.path.splitext(wsrc) @@ -4932,7 +4945,7 @@ if GetTarget() == 'windows' and PkgSkip("DX9")==0 and not RUNTIME: # if not RUNTIME and not PkgSkip("EGG"): - OPTS=['DIR:panda/src/egg', 'BUILDING:PANDAEGG', 'ZLIB', 'BISONPREFIX_eggyy', 'FLEXDASHI'] + OPTS=['DIR:panda/src/egg', 'BUILDING:PANDAEGG', 'ZLIB', 'BISONPREFIX_eggyy', 'FLEXDASHI', 'FLEXVERSION:2.5.9'] CreateFile(GetOutputDir()+"/include/parser.h") TargetAdd('p3egg_parser.obj', opts=OPTS, input='parser.yxx') TargetAdd('parser.h', input='p3egg_parser.obj', opts=['DEPENDENCYONLY']) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 61a1bdf9bc..04712b9f85 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -553,6 +553,16 @@ def GetFlex(): return FLEX +def GetFlexVersion(): + flex = GetFlex() + if not flex: + return None + + handle = subprocess.Popen(["flex", "--version"], executable=flex, stdout=subprocess.PIPE) + version = handle.communicate()[0].strip().splitlines()[0].split(b' ')[-1] + version = tuple(map(int, version.split(b'.'))) + return version + ######################################################################## ## ## LocateBinary