panda-planner-dev / pandaPIparser

The parser of the pandaPI planning system
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

Patch to pandaPIparser makefile for easier compilation on Mac #10

Open rpgoldman opened 1 year ago

rpgoldman commented 1 year ago

As you point out in the readme, the versions of bison and flex on the Mac are unsuitable for building pandaPIparser.

I modified the makefile to make BISON and FLEX variables, so that on the Mac one can build like this (for example):

BISON=/opt/homebrew/opt/bison/bin/bison FLEX=/opt/homebrew/opt/flex/bin/flex make -j

Here's a patch from git format-patch:


These make it easier to override the default versions of these
programs, which is particularly helpful on Mac, because the versions
there are so old.
---
 makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/makefile b/makefile
index fbb2ecd..c159ce8 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,6 @@
 CXX=g++
+BISON ?= bison
+FLEX ?= flex

 CWARN=-Wno-unused-parameter
 CERROR=
@@ -31,11 +33,11 @@ all: src/hddl-token.o src/hddl.o src/main.o src/sortexpansion.o src/parsetree.o
        ${CXX} ${COMPILEFLAGS} -o $@ -c $<

 src/hddl-token.cpp: src/hddl.cpp src/hddl-token.l
-       flex --yylineno -o src/hddl-token.cpp src/hddl-token.l
+       $(FLEX) --yylineno -o src/hddl-token.cpp src/hddl-token.l

 src/hddl.cpp: src/hddl.y
-       bison -v -d -o src/hddl.cpp src/hddl.y
+       $(BISON) -v -d -o src/hddl.cpp src/hddl.y

 src/hddl.hpp: src/hddl.cpp

--
2.40.1
galvusdamor commented 1 year ago

Thanks @rpgoldman !

I've actually gone a step further and made the homebrew paths the default for MacOS now -- the default versions of both flex and bison are too old to compile correctly anyway. This is not integrated into this commit and the master branch.

Can you test it?

rpgoldman commented 1 year ago

I will test it, and also I have asked colleagues if they can tell me where MacPorts puts flex and bison so the build script can support MacPorts users as well as Homebrew users.

rpgoldman commented 1 year ago

flex and bison can be found in /opt/local/bin when they are installed by MacPorts. So maybe the scripts could be modified to look for them from brew or MacPorts and otherwise fail?