Tim Baumgartner wrote:
Ari Johnson wrote:
On Tue, Aug 26, 2008 at 10:36 AM, Freddie Witherden
<[EMAIL PROTECTED]> wrote:
Hi Ari, Tim,
Good news about the Xcode project!
However, do you know if it is possible to comment out a target for
10.5 (which ships with Bison 2.3)? So far as 10.5 goes, trunk builds
(with a slight modification to multiint.c IIRC).
I don't have 10.5. There would, however, be more than just leaving
out the Bison target required to make it work on both 10.4 and 10.5
with its included copy of Bison. A more likely solution would be for
the Bison target to do the following:
1. If the installed Bison is not 2.3 or better, fetch and build Bison 2.3.
2. No matter what, create a wrapper script that will call Bison 2.3,
whether it was built in step 1 or not.
Then the Xcode project can point to the wrapper script for its build rules.
Ari, thanks for committing the Bison patch.
A quick Google search led me to a page
(http://www.mail-archive.com/[EMAIL PROTECTED]/msg01100.html) that claims the
location of the Bison distribution files can be set with the env var
BISON_PKGDATADIR but a configure flag might be better (I'll look into it).
The Bison wrapper script sounds like a good idea and I don't see any reason why
it shouldn't be implemented as Ari suggested. I'll work on this tomorrow
(Wednesday) and post back to this thread with the details of the final script
and Xcode project setup.
Alright, I have a patch that downloads Bison only if needed and that adds a
Bison wrapper script (located at 'macosx/external/bison.sh'). The patch is
attached and I would appreciate it if someone else could test the patch to make
sure there are no problems on other systems and to give me some feedback before
I commit it.
The script determines the version of Bison by parsing the version value from the
output of the "--version" paramter. If the version of Bison on the system is
older than a minimum version (currently 1.31) or if it is blacklisted (although
none currently are), the build process will attempt to download and build Bison
2.3. To simplify things, if a binary in "macosx/external/bison/" exists, this
version is used regardless.
During the build process, instead of calling Bison directly, bison.sh is called.
If a Bison binary exists in an expected location inside of
"macosx/external/bison/", it is used. Otherwise, the command 'bison' is executed.
Tim
Index: macosx/Warzone.xcodeproj/project.pbxproj
===================================================================
--- macosx/Warzone.xcodeproj/project.pbxproj (revision 5880)
+++ macosx/Warzone.xcodeproj/project.pbxproj (working copy)
@@ -681,7 +681,7 @@
"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.tab.h",
"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.tab.c",
);
- script = "external/bison/src/bison -y -d
-o\"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}\".tab.h \"${INPUT_FILE_PATH}\" ||
exit 1\nexternal/bison/src/bison -y -d
-o\"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}\".tab.c \"${INPUT_FILE_PATH}\" ||
exit 1";
+ script = "external/bison.sh -y -d
-o\"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}\".tab.h \"${INPUT_FILE_PATH}\" ||
exit 1\nexternal/bison.sh -y -d
-o\"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}\".tab.c \"${INPUT_FILE_PATH}\" ||
exit 1";
};
0246AA730BD3E47F004D1C70 /* PBXBuildRule */ = {
isa = PBXBuildRule;
@@ -3793,7 +3793,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript =
"DIRECTORY=\"bison-2.3\"\nOUTDIR=\"bison\"\nEXECUTABLE=\"`pwd`/$OUTDIR/src/bison\"\nFILENAME=\"bison-2.3.tar.bz2\"\nSOURCE=\"http://ftp.gnu.org/gnu/bison/bison-2.3.tar.bz2\"\nMD5=\"c18640c6ec31a169d351e3117ecce3ec\"\n\n##
Fetch source ##\n\ncd external\n\nif [ -d \"$OUTDIR\" ]; then\n echo
\"$OUTDIR exists, skipping\"\n exit 0\nfi\n\nif [ -d \"$DIRECTORY\" ]; then\n
echo \"$DIRECTORY exists, probably from an earlier failed run\" >&2\n exit
1\nfi\n\nif [ ! -r \"$FILENAME\" ]; then\n echo \"Fetching $SOURCE\"\n if !
curl -L -o \"$FILENAME\" \"$SOURCE\"; then\n echo \"Unable to fetch
$SOURCE\" >&2\n exit 1\n fi\nfi\n\nHAVEMD5=`md5 \"$FILENAME\" | sed -n -e
's/^MD5 (\\(.*\\)) = \\(.*\\)$/\\2/p'`\n\nif [ -z \"$HAVEMD5\" ]; then\n echo
\"Unable to compute md5 for $FILENAME\" >&2\n exit 1\nfi\n\nif [ \"$HAVEMD5\"
!= \"$MD5\" ]; then\n echo \"Md5 does not match for $FILENAME\" >&2\n exit
1\nfi\n\nEXTENSION=`echo $FILENAME | sed -e 's/^.*\\.\\([^.]*\\)/\\1/'`\n\nif [
\"$EXTENSION\" = \"gz\" ]; then\n if ! tar -zxf \"$FILENAME\"; then\n echo
\"Unpacking $FILENAME failed\" >&2\n exit 1\n fi\nelif [ \"$EXTENSION\" =
\"bz2\" ]; then\n if ! tar -jxf \"$FILENAME\"; then\n echo \"Unpacking
$FILENAME failed\" >&2\n exit 1\n fi\nelse\n echo \"Unable to unpack
$FILENAME\" >&2\n exit 1\nfi\n\nif [ ! -d \"$DIRECTORY\" ]; then\n echo
\"Can't find $DIRECTORY to rename\" >&2\n exit 1\nfi\n\nmv \"$DIRECTORY\"
\"$OUTDIR\"\n\n## Build source ##\n\ncd \"$OUTDIR\"\n\necho \"Configuring GNU
Bison\"\n./configure\n\nif [ \"$?\" -ne 0 ]; then\n\techo \"GNU Bison configure
operation failed\" >&2\n\texit 1\nfi\n\necho \"Compiling GNU
Bison\"\nmake\n\nif [ \"$?\" -ne 0 ]; then\n\techo \"GNU Bison make operation
failed\" >&2\n\texit 1\nfi\n";
+ shellScript = "#!/bin/bash\n\nOUTDIR=\"bison\" # Dir
in macosx/external to unpack Bison to\nSYS_BISON=\"bison\" # System Bison
executable\nLOCAL_BISON=\"`pwd`/$OUTDIR/src/bison\" # Local Warzone Bison
executable\n\n# getLocalBison\n# \n# Attempts to build and (if needed) download
a version of Bison that is\n# compatible with Warzone. Returns 0 if successful,
else 1.\nfunction getLocalBison\n{\n\tlocal DIRECTORY=\"bison-2.3\"\n\tlocal
EXECUTABLE=$LOCAL_BISON\n\tlocal FILENAME=\"bison-2.3.tar.bz2\"\n\tlocal
SOURCE=\"http://ftp.gnu.org/gnu/bison/bison-2.3.tar.bz2\"\n\tlocal
MD5=\"c18640c6ec31a169d351e3117ecce3ec\"\n\t\n\t## Fetch source ##\n\t\n\tcd
external\n\t\n\tif [ -d \"$OUTDIR\" ]; then\n\t echo \"$OUTDIR exists,
skipping\"\n\t return 0\n\tfi\n\t\n\tif [ -d \"$DIRECTORY\" ]; then\n\t echo
\"$DIRECTORY exists, probably from an earlier failed run\" >&2\n\t return
1\n\tfi\n\t\n\tif [ ! -r \"$FILENAME\" ]; then\n\t echo \"Fetching
$SOURCE\"\n\t if ! curl -L -o \"$FILENAME\" \"$SOURCE\"; then\n\t echo
\"Unable to fetch $SOURCE\" >&2\n\t return 1\n\t fi\n\tfi\n\t\n\tlocal
HAVEMD5=`md5 \"$FILENAME\" | sed -n -e 's/^MD5 (\\(.*\\)) =
\\(.*\\)$/\\2/p'`\n\t\n\tif [ -z \"$HAVEMD5\" ]; then\n\t echo \"Unable to
compute md5 for $FILENAME\" >&2\n\t return 1\n\tfi\n\t\n\tif [ \"$HAVEMD5\" !=
\"$MD5\" ]; then\n\t echo \"Md5 does not match for $FILENAME\" >&2\n\t return
1\n\tfi\n\t\n\tlocal EXTENSION=`echo $FILENAME | sed -e
's/^.*\\.\\([^.]*\\)/\\1/'`\n\t\n\tif [ \"$EXTENSION\" = \"gz\" ]; then\n\t if
! tar -zxf \"$FILENAME\"; then\n\t echo \"Unpacking $FILENAME failed\"
>&2\n\t return 1\n\t fi\n\telif [ \"$EXTENSION\" = \"bz2\" ]; then\n\t if
! tar -jxf \"$FILENAME\"; then\n\t echo \"Unpacking $FILENAME failed\"
>&2\n\t return 1\n\t fi\n\telse\n\t echo \"Unable to unpack $FILENAME\"
>&2\n\t return 1\n\tfi\n\t\n\tif [ ! -d \"$DIRECTORY\" ]; then\n\t echo
\"Can't find $DIRECTORY to rename\" >&2\n\t return 1\n\tfi\n\t\n\tmv
\"$DIRECTORY\" \"$OUTDIR\"\n\t\n\t## Build source ##\n\t\n\tcd
\"$OUTDIR\"\n\t\n\techo \"Configuring GNU Bison\"\n\t./configure\n\t\n\tif [
\"$?\" -ne 0 ]; then\n\t\techo \"GNU Bison configure operation failed\"
>&2\n\t\treturn 1\n\tfi\n\t\n\techo \"Compiling GNU Bison\"\n\tmake\n\t\n\tif [
\"$?\" -ne 0 ]; then\n\t\techo \"GNU Bison make operation failed\"
>&2\n\t\treturn 1\n\tfi\n\t\n\treturn 0\n}\n\n# isValidBison executable\n#\n#
Determines if a version of Bison is compatible with Warzone. The argument\n#
'executable' specifies the location of the Bison executable to test. Returns\n#
1 if the version of Bison is valid, else 0\nfunction isValidBison\n{\n\tlocal
BISON=$1 # Bison command to check version of\n\tlocal
MIN_BISON_MAJOR=1 # Minimum major version of Bison to allow\n\tlocal
MIN_BISON_MINOR=31 # Minimum minor version of Bison to allow\n\tlocal
BISON_BLACKLIST=() # Bison versions to blacklist (e.g. \"2.1\")\n\t\n\t#
Expects the Bison version to be the only token of the form #.# on the
first\n\t# line of the output from ./bison --version, where the first # is the
major\n\t# version and the second # is the minor version\n\tlocal
BISON_VER=`$BISON --version | sed -En '1 s:.*([0-9]+\\.[0-9]+):\\1:
p'`\n\tlocal BISON_MAJOR=`echo $BISON_VER | sed -E
's:([0-9]+)\\.[0-9]+:\\1:'`\n\tlocal BISON_MINOR=`echo $BISON_VER | sed -E
's:[0-9]+\\.([0-9]+):\\1:'`\n\t\n\tlocal VALID_BISON=$(( (BISON_MAJOR >
MIN_BISON_MAJOR)\n\t || ( BISON_MAJOR == MIN_BISON_MAJOR\n\t
&& BISON_MINOR >= MIN_BISON_MINOR) ))\n\t\n\t# If version
is valid so far, check the blacklist\n\tif [ $VALID_BISON -eq 1 ];
then\n\t\tfor (( i = 0; i < [EMAIL PROTECTED]; ++i )); do\n\t\t\tif [
$BISON_VER == ${BISON_BLACKLIST[${i}]} ];
then\n\t\t\t\tVALID_BISON=0\n\t\t\tfi\n\t\tdone\n\tfi\n\t\n\treturn
$VALID_BISON\n}\n\n## Main ##\n#\n# If there is not already a local version of
Bison (one in macosx/external/) and\n# the version of Bison on the system is
incompatible with the build process,\n# attempt to download a compatible
version of Bison.\n\n# Check any local version of Bison\nif [ -e $LOCAL_BISON
]; then\n\tisValidBison $LOCAL_BISON\n\t\n\tif [ $? -eq 1 ]; then\n\t\t# Local
version is valid (nothing further needs to be done)\n\t\texit 0\n\telse\n\t\t#
Local version is invalid\n\t\techo \"The local executable of GNU Bison is of an
incompatible version\" >&2\n\t\texit 1\n\tfi\nfi\n\n# If the system version of
Bison is incompatible, download a compatible version\nisValidBison
$SYS_BISON\nif [ $? -ne 1 ]; then\n\techo \"The version of Bison on your system
is not compatible with Warzone\"\n\techo \"A compatible version will be
attempted to be downloaded and used\"\n\t\n\tgetLocalBison\n\tif [ $? -ne 0 ];
then\n\t\techo \"Retrieval of a compatible version of Bison has failed\"
>&2\n\t\texit 1\n\tfi\nfi\n\nexit 0\n";
};
/* End PBXShellScriptBuildPhase section */
Index: macosx/external/bison.sh
===================================================================
--- macosx/external/bison.sh (revision 0)
+++ macosx/external/bison.sh (revision 0)
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+SYS_BISON="bison" # System Bison executable
+LOCAL_BISON="`pwd`/external/bison/src/bison" # Local Warzone Bison executable
+
+# If a Warzone Bison executable exists, use instead of the system executable
+if [ -e $LOCAL_BISON ]; then
+ $LOCAL_BISON $*
+else
+ $SYS_BISON $*
+fi
Property changes on: macosx/external/bison.sh
___________________________________________________________________
Name: svn:executable
+ *
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev