From 6f5362c3fedf09ce93d2cbf9d48f9f142cb45bfb Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 12:53:24 +0100 Subject: [PATCH 1/6] egg: Add missing include --- panda/src/egg/eggNode_ext.h | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/egg/eggNode_ext.h b/panda/src/egg/eggNode_ext.h index aa94aa41cd..41127667a6 100644 --- a/panda/src/egg/eggNode_ext.h +++ b/panda/src/egg/eggNode_ext.h @@ -19,6 +19,7 @@ #ifdef HAVE_PYTHON #include "extension.h" +#include "eggData.h" #include "eggNode.h" #include "py_panda.h" From 748dd61615d2329efaf01f95a02ab0219314c4f6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 12:55:34 +0100 Subject: [PATCH 2/6] 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 From 5d5efb75e8dcded9a4a1fb7b6e1fbed686f4766f Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 18:43:10 +0100 Subject: [PATCH 3/6] egg: Fix egg lexer hanging on unterminated quote or C-style comment --- panda/src/egg/lexer.cxx.prebuilt | 8 ++++---- panda/src/egg/lexer.lxx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index f0b0a2b4ec..06e6dd0123 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1195,12 +1195,12 @@ scan_quoted_string() { int c; c = read_char(line, col); - while (c != '"' && c != EOF) { + while (c != '"' && c != 0 && c != EOF) { result += c; c = read_char(line, col); } - if (c == EOF) { + if (c == 0 || c == EOF) { eggyyerror("This quotation mark is unterminated."); } @@ -1224,7 +1224,7 @@ eat_c_comment() { last_c = '\0'; c = read_char(line, col); - while (c != EOF && !(last_c == '*' && c == '/')) { + while (c != 0 && c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " @@ -1236,7 +1236,7 @@ eat_c_comment() { c = read_char(line, col); } - if (c == EOF) { + if (c == 0 || c == EOF) { eggyyerror("This comment marker is unclosed."); } diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 88aed62e46..c4b6f88028 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -250,12 +250,12 @@ scan_quoted_string() { int c; c = read_char(line, col); - while (c != '"' && c != EOF) { + while (c != '"' && c != 0 && c != EOF) { result += c; c = read_char(line, col); } - if (c == EOF) { + if (c == 0 || c == EOF) { eggyyerror("This quotation mark is unterminated."); } @@ -279,7 +279,7 @@ eat_c_comment() { last_c = '\0'; c = read_char(line, col); - while (c != EOF && !(last_c == '*' && c == '/')) { + while (c != 0 && c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " @@ -291,7 +291,7 @@ eat_c_comment() { c = read_char(line, col); } - if (c == EOF) { + if (c == 0 || c == EOF) { eggyyerror("This comment marker is unclosed."); } From fd2041d209e46a963b6fd572656d3383831ddbd3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 18:50:23 +0100 Subject: [PATCH 4/6] makepanda: Fix detecting flex version on macOS, more robust checking --- makepanda/makepandacore.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 04712b9f85..20f63577c8 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -558,10 +558,17 @@ def GetFlexVersion(): 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 + try: + handle = subprocess.Popen(["flex", "--version"], executable=flex, stdout=subprocess.PIPE) + words = handle.communicate()[0].strip().splitlines()[0].split(b' ') + if words[1] != "version": + version = words[1] + else: + version = words[2] + return tuple(map(int, version.split(b'.'))) + except: + Warn("Unable to detect flex version") + return (0, 0, 0) ######################################################################## ## From 6690b2d86e4be3445decfb33dbafa5951d667b7c Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 19:29:56 +0100 Subject: [PATCH 5/6] makepanda: Fix build error when flex is absent --- makepanda/makepanda.py | 2 +- makepanda/makepandacore.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a07ad63ba9..88735bc34a 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1664,7 +1664,7 @@ def CompileFlex(wobj,wsrc,opts): dashi = opts.count("FLEXDASHI") flex = GetFlex() want_version = GetValueOption(opts, "FLEXVERSION:") - if want_version: + if flex and want_version: # Is flex at the required version for this file? want_version = tuple(map(int, want_version.split('.'))) have_version = GetFlexVersion() diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 20f63577c8..9cac107de1 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -556,7 +556,7 @@ def GetFlex(): def GetFlexVersion(): flex = GetFlex() if not flex: - return None + return (0, 0, 0) try: handle = subprocess.Popen(["flex", "--version"], executable=flex, stdout=subprocess.PIPE) From 2b8711e25e493d39f995f5b3d1f9410dc377b12a Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 19:57:29 +0100 Subject: [PATCH 6/6] readme: Update links to point to 1.10.9 thirdparty tools for Windows They contain an updated version of flex. [skip ci] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eef12fb903..2dd869b468 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ depending on whether you are on a 32-bit or 64-bit system, or you can [click here](https://github.com/rdb/panda3d-thirdparty) for instructions on building them from source. -- https://www.panda3d.org/download/panda3d-1.10.8/panda3d-1.10.8-tools-win64.zip -- https://www.panda3d.org/download/panda3d-1.10.8/panda3d-1.10.8-tools-win32.zip +- https://www.panda3d.org/download/panda3d-1.10.9/panda3d-1.10.9-tools-win64.zip +- https://www.panda3d.org/download/panda3d-1.10.9/panda3d-1.10.9-tools-win32.zip After acquiring these dependencies, you can build Panda3D from the command prompt using the following command. Change the `--msvc-version` option based