moved cog to compile time, now aware of its own version
This commit is contained in:
		
							
								
								
									
										15
									
								
								bootstrap
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								bootstrap
									
									
									
									
									
								
							@@ -4,19 +4,4 @@ if [ ! -d "m4" ]; then
 | 
				
			|||||||
	mkdir m4
 | 
						mkdir m4
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export COG=$(command -v cog)
 | 
					 | 
				
			||||||
[ -z "$COG"] && export COG=$(command -v cog.py)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -z "$COG" ]; then
 | 
					 | 
				
			||||||
    echo "Please install the Cog code generator, probably with pip install cogapp"
 | 
					 | 
				
			||||||
    return 1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "cog found at $COG"
 | 
					 | 
				
			||||||
for cogfile in $(find src -name "*.cog"); do
 | 
					 | 
				
			||||||
    decogged=${cogfile%.cog}
 | 
					 | 
				
			||||||
    echo "greasing cog for ${decogged}..."
 | 
					 | 
				
			||||||
    $COG -d -o ${decogged} ${cogfile}
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
autoreconf --install
 | 
					autoreconf --install
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								configure.ac
									
									
									
									
									
								
							@@ -6,6 +6,16 @@ AC_CONFIG_MACRO_DIR([m4])
 | 
				
			|||||||
AC_PROG_CXX
 | 
					AC_PROG_CXX
 | 
				
			||||||
AX_CXX_COMPILE_STDCXX_11
 | 
					AX_CXX_COMPILE_STDCXX_11
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AC_PATH_PROG([COG], [cog], [not found])
 | 
				
			||||||
 | 
					if test "$COG" == "not found" ; then
 | 
				
			||||||
 | 
					    AC_PATH_PROG([COGPY], [cog.py], [not found])
 | 
				
			||||||
 | 
					    if test "$COGPY" == "not found" ; then
 | 
				
			||||||
 | 
					        AC_MSG_ERROR(["Please install the Cog code generator, probably via "pip install cogapp"])
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    COG="$COGPY"
 | 
				
			||||||
 | 
					    AC_SUBST(COG)
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AX_BOOST_BASE([1.63], , [AC_MSG_ERROR([boost 1.63 required])])
 | 
					AX_BOOST_BASE([1.63], , [AC_MSG_ERROR([boost 1.63 required])])
 | 
				
			||||||
AX_BOOST_SYSTEM
 | 
					AX_BOOST_SYSTEM
 | 
				
			||||||
AX_BOOST_FILESYSTEM
 | 
					AX_BOOST_FILESYSTEM
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,12 @@
 | 
				
			|||||||
bin_PROGRAMS = cellar
 | 
					bin_PROGRAMS = cellar
 | 
				
			||||||
cellar_CPPFLAGS = $(BOOST_CPPFLAGS)
 | 
					cellar_CPPFLAGS = $(BOOST_CPPFLAGS)
 | 
				
			||||||
cellar_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB)
 | 
					cellar_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB)
 | 
				
			||||||
cellar_SOURCES = cellar.cpp fs.cpp bottles.cpp commands.cpp version.cpp
 | 
					cellar_SOURCES = cellar.cpp fs.cpp bottles.cpp commands.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Generated files
 | 
				
			||||||
 | 
					nodist_cellar_SOURCES = version.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLEANFILES = version.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					version.cpp: 
 | 
				
			||||||
 | 
						$(COG) -d -o version.cpp version.cpp.cog
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,44 @@
 | 
				
			|||||||
// vim: filetype=cpp :
 | 
					// vim: filetype=cpp :
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "commands.hpp"
 | 
				
			||||||
#include "version.hpp"
 | 
					#include "version.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					using namespace cellar::version;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
string cellar::version::short_version() {
 | 
					string cellar::version::short_version() {
 | 
				
			||||||
    /*[[[cog
 | 
					    /*[[[cog
 | 
				
			||||||
         import cog
 | 
					         import cog
 | 
				
			||||||
         import os
 | 
					         import configparser
 | 
				
			||||||
 | 
					         import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         print(os.getcwd())
 | 
					         today = datetime.datetime.today()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         cog.outl("return \"dummy cog file!\";")
 | 
					         cparse = configparser.ConfigParser()
 | 
				
			||||||
 | 
					         cparse.read("../cogrc")
 | 
				
			||||||
 | 
					         config = cparse["version"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         if config.getboolean("release"):
 | 
				
			||||||
 | 
					            outstring = "version {0}, built {1}".format(config["release_version"], str(today))
 | 
				
			||||||
 | 
					         else:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                import subprocess
 | 
				
			||||||
 | 
					                cmdoutput = subprocess.check_output(["git", "symbolic-ref", "HEAD"]).decode().strip()
 | 
				
			||||||
 | 
					                gitbranch = cmdoutput.split("/")[2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                githash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
 | 
				
			||||||
 | 
					                outstring = "{0} {1}, built {2}".format(gitbranch, githash, str(today))
 | 
				
			||||||
 | 
					            except:
 | 
				
			||||||
 | 
					                outstring = "exception raised when trying to read git data at precompile time"
 | 
				
			||||||
 | 
					                raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         cog.outl("return \"{0}\";".format(outstring))
 | 
				
			||||||
    ]]]*/
 | 
					    ]]]*/
 | 
				
			||||||
    //[[[end]]]
 | 
					    //[[[end]]]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void print_version(int argc, char** argv) {
 | 
				
			||||||
 | 
					    cout << short_version() << endl;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					bool _ = cellar::commands::add_command("version", &print_version);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user