avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From th...@apache.org
Subject svn commit: r1065352 - in /avro/trunk: BUILD.txt CHANGES.txt lang/c++/ lang/c++/CMakeLists.txt lang/c++/Makefile.am lang/c++/README lang/c++/build.sh lang/c++/configure.in lang/c++/parser/AvroLex.ll lang/c++/test/precompile.cc
Date Sun, 30 Jan 2011 19:10:52 GMT
Author: thiru
Date: Sun Jan 30 19:10:51 2011
New Revision: 1065352

URL: http://svn.apache.org/viewvc?rev=1065352&view=rev
Log:
AVRO-700. Change C++ build system to CMake

Added:
    avro/trunk/lang/c++/CMakeLists.txt
Removed:
    avro/trunk/lang/c++/configure.in
Modified:
    avro/trunk/BUILD.txt
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c++/   (props changed)
    avro/trunk/lang/c++/Makefile.am
    avro/trunk/lang/c++/README
    avro/trunk/lang/c++/build.sh
    avro/trunk/lang/c++/parser/AvroLex.ll
    avro/trunk/lang/c++/test/precompile.cc

Modified: avro/trunk/BUILD.txt
URL: http://svn.apache.org/viewvc/avro/trunk/BUILD.txt?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/BUILD.txt (original)
+++ avro/trunk/BUILD.txt Sun Jan 30 19:10:51 2011
@@ -8,7 +8,7 @@ The following packages must be installed
  - PHP: php5, phpunit, php5-gmp
  - Python: 2.5 or greater, python-setuptools for dist target
  - C: gcc, autoconf, automake, libtool, asciidoc, source-highlight
- - C++: g++, flex, bison, libboost-dev
+ - C++: cmake,g++, flex, bison, libboost-dev
  - Ruby: ruby 1.86 or greater, ruby-dev, gem, rake, echoe, yajl-ruby
  - Apache Ant 1.7
  - Apache Forrest 0.8 (for documentation)

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Sun Jan 30 19:10:51 2011
@@ -137,6 +137,7 @@ Avro 1.5.0 (unreleased)
     AVRO-734. Java: Update maven build plugin versions. (Holger Hoffstätte
     via scottcarey)
 
+    AVRO-700. Change C++ build system to CMake (thiru)
   BUG FIXES
 
     AVRO-675. C: Bytes and fixed setters don't update datum size.

Propchange: avro/trunk/lang/c++/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Jan 30 19:10:51 2011
@@ -1,6 +1,11 @@
-autom4te.cache
-configure
-Makefile.in
-INSTALL
-aclocal.m4
-config.log
+CMakeFiles
+CMakeCache.txt
+CPackSourceConfig.cmake
+CPackConfig.cmake
+Makefile
+cmake_install.cmake
+build
+test.avro
+doc
+
+

Added: avro/trunk/lang/c++/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/CMakeLists.txt?rev=1065352&view=auto
==============================================================================
--- avro/trunk/lang/c++/CMakeLists.txt (added)
+++ avro/trunk/lang/c++/CMakeLists.txt Sun Jan 30 19:10:51 2011
@@ -0,0 +1,101 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+cmake_minimum_required (VERSION 2.8)
+
+if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
+    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" AVRO_VERSION)
+else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
+    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../share/VERSION.txt"
+        AVRO_VERSION)
+endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
+
+set (AVRO_VERSION_MAJOR ${AVRO_VERSION})
+set (AVRO_VERSION_MINOR "0")
+set (BUILD_DIRECTORY build)
+set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
+set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
+set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
+
+project (Avro-cpp)
+include_directories (api ${BUILD_DIRECTORY})
+add_library (avrocpp SHARED impl/Compiler.cc
+        impl/Compiler.cc impl/CompilerNode.cc impl/Node.cc
+        impl/NodeImpl.cc impl/Resolver.cc impl/ResolverSchema.cc impl/Schema.cc
+        impl/Types.cc impl/Validator.cc impl/ValidSchema.cc impl/Zigzag.cc
+        ${BUILD_DIRECTORY}/AvroYacc.cc ${BUILD_DIRECTORY}/AvroLex.cc)
+target_link_libraries (avrocpp boost_regex-mt)
+
+add_executable (precompile test/precompile.cc)
+
+add_dependencies(avrocpp parser lexer)
+
+target_link_libraries (precompile avrocpp boost_regex-mt)
+
+find_package(BISON)
+
+find_package(FLEX)
+
+add_custom_command (OUTPUT ${BUILD_DIRECTORY}/bigrecord
+    COMMAND precompile jsonschemas/bigrecord ${BUILD_DIRECTORY}/bigrecord
+    DEPENDS precompile)
+
+add_custom_target (testgen
+    COMMAND python ../scripts/gen-cppcode.py -n testgen
+    -i bigrecord -o testgen.hh
+    WORKING_DIRECTORY ${BUILD_DIRECTORY}
+    DEPENDS ${BUILD_DIRECTORY}/bigrecord)
+
+add_custom_command (OUTPUT ${BUILD_DIRECTORY}/bigrecord2
+    COMMAND precompile jsonschemas/bigrecord2 ${BUILD_DIRECTORY}/bigrecord2
+    DEPENDS precompile)
+
+add_custom_target (testgen2
+    COMMAND python ../scripts/gen-cppcode.py -n testgen2
+    -i bigrecord2 -o testgen2.hh
+    WORKING_DIRECTORY ${BUILD_DIRECTORY}
+    DEPENDS ${BUILD_DIRECTORY}/bigrecord2)
+
+BISON_TARGET (parser parser/AvroYacc.yy ${BUILD_DIRECTORY}/AvroYacc.cc)
+FLEX_TARGET (lexer parser/AvroLex.ll ${BUILD_DIRECTORY}/AvroLex.cc)
+
+macro (test name)
+    add_executable (${name} test/${name}.cc)
+    target_link_libraries (${name} avrocpp boost_regex-mt)
+endmacro (test)
+
+test(buffertest)
+test(unittest)
+
+add_executable (testgentest test/testgen.cc)
+add_dependencies (testgentest testgen testgen2)
+target_link_libraries (testgentest avrocpp boost_regex-mt)
+
+include (InstallRequiredSystemLibraries)
+
+set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}")
+
+include (CPack)
+
+install(TARGETS avrocpp
+    LIBRARY DESTINATION lib
+    ARCHIVE DESTINATION lib
+    RUNTIME DESTINATION lib)
+
+install(DIRECTORY api/ DESTINATION include/avro
+    FILES_MATCHING PATTERN *.hh)

Modified: avro/trunk/lang/c++/Makefile.am
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/Makefile.am?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/lang/c++/Makefile.am (original)
+++ avro/trunk/lang/c++/Makefile.am Sun Jan 30 19:10:51 2011
@@ -1,135 +0,0 @@
-
-BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
-BOOST_LDFLAGS = @BOOST_LDFLAGS@
-BOOST_REGEX_LIB = @BOOST_REGEX_LIB@
-PYTHON = @PYTHON@
-
-AM_CXXFLAGS= -I$(top_srcdir)/api $(BOOST_CPPFLAGS) -Wall -Wno-invalid-offsetof
-# removed -Werror for Cygwin builds, maybe should add a check flag
-
-ACLOCAL_AMFLAGS=-I m4
-
-library_includedir=$(includedir)/avrocpp
-library_include_HEADERS = \
-api/AvroParse.hh \
-api/AvroSerialize.hh \
-api/AvroTraits.hh \
-api/Boost.hh \
-api/Compiler.hh \
-api/CompilerNode.hh \
-api/Exception.hh \
-api/Layout.hh \
-api/Node.hh \
-api/NodeConcepts.hh \
-api/NodeImpl.hh \
-api/Parser.hh \
-api/Reader.hh \
-api/Resolver.hh \
-api/ResolverSchema.hh \
-api/ResolvingReader.hh \
-api/Schema.hh \
-api/SchemaResolution.hh \
-api/Serializer.hh \
-api/SymbolMap.hh \
-api/Types.hh \
-api/ValidSchema.hh \
-api/Validator.hh \
-api/Writer.hh \
-api/Zigzag.hh \
-api/buffer/BufferStreambuf.hh \
-api/buffer/detail/BufferDetailIterator.hh \
-api/buffer/detail/BufferDetail.hh \
-api/buffer/BufferStream.hh \
-api/buffer/BufferPrint.hh \
-api/buffer/Buffer.hh \
-api/buffer/BufferReader.hh
-
-BUILT_SOURCES = AvroYacc.h testgen.hh testgen2.hh
-
-bin_PROGRAMS = precompile testparser 
-bin_SCRIPTS = scripts/gen-cppcode.py
-
-precompile_SOURCES = test/precompile.cc
-
-precompile_LDFLAGS = -static $(BOOST_LDFLAGS)
-precompile_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
-
-testparser_SOURCES = test/testparser.cc
-
-testparser_LDFLAGS = -static -no-install $(BOOST_LDFLAGS)
-testparser_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
-
-lib_LTLIBRARIES = libavrocpp.la
-
-libavrocpp_la_SOURCES = $(library_include_HEADERS) \
-api/Zigzag.hh \
-impl/Compiler.cc \
-impl/CompilerNode.cc \
-impl/Node.cc \
-impl/NodeImpl.cc \
-impl/Resolver.cc \
-impl/ResolverSchema.cc \
-impl/Schema.cc \
-impl/Types.cc \
-impl/ValidSchema.cc \
-impl/Validator.cc \
-impl/Zigzag.cc \
-parser/AvroYacc.yy \
-parser/AvroLex.ll 
-
-# libavrocpp_la_LDFLAGS = -export-dynamic
-
-AM_LFLAGS= -o$(LEX_OUTPUT_ROOT).c
-AM_YFLAGS = -d
-
-check_PROGRAMS = unittest testgen buffertest
-
-TESTS=unittest testgen buffertest
-TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir)
-
-unittest_SOURCES = test/unittest.cc
-unittest_LDFLAGS = -static -no-install $(BOOST_LDFLAGS)
-unittest_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
-
-testgen_SOURCES = test/testgen.cc testgen.hh testgen2.hh
-testgen_LDFLAGS = -static -no-install $(BOOST_LDFLAGS)
-testgen_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
-
-buffertest_SOURCES = test/buffertest.cc 
-buffertest_LDFLAGS = -static -no-install $(BOOST_LDFLAGS)
-buffertest_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) $(BOOST_SYSTEM_LIB)
$(BOOST_FILESYSTEM_LIB)
-
-# Make sure we never package up '.svn' directories
-dist-hook:
-	find $(distdir) -name '.svn' | xargs rm -rf
-
-testgen.hh : bigrecord.precompile $(top_srcdir)/scripts/gen-cppcode.py
-	$(PYTHON) $(top_srcdir)/scripts/gen-cppcode.py -n testgen -i $< -o $@
-
-testgen2.hh : bigrecord2.precompile $(top_srcdir)/scripts/gen-cppcode.py 
-	$(PYTHON) $(top_srcdir)/scripts/gen-cppcode.py -n testgen2 -i $< -o $@
-
-bigrecord.precompile: $(top_srcdir)/jsonschemas/bigrecord precompile$(EXEEXT)
-	$(top_builddir)/precompile$(EXEEXT) < $< > $@
-
-bigrecord2.precompile: $(top_srcdir)/jsonschemas/bigrecord2 precompile$(EXEEXT) 
-	$(top_builddir)/precompile$(EXEEXT) < $< > $@
-
-DOXYGEN_INPUTS= $(top_srcdir)/MainPage.dox $(patsubst %,$(top_srcdir)/%, $(library_include_HEADERS))
-
-CPP_DOC_DIR ?= "$(top_builddir)/doc"
-
-doc: $(CPP_DOC_DIR)/html/index.html
-
-$(CPP_DOC_DIR)/html/index.html: $(DOXYGEN_INPUTS) $(srcdir)/Doxyfile
-	(cat $(srcdir)/Doxyfile; echo "OUTPUT_DIRECTORY=$(CPP_DOC_DIR)";  echo "INPUT=$(DOXYGEN_INPUTS)")
| $(DOXYGEN) - ;
-
-EXTRA_DIST=jsonschemas scripts
-
-CLEANFILES=bigrecord.precompile bigrecord2.precompile testgen.hh testgen2.hh AvroLex.cc AvroYacc.cc
AvroYacc.h test.avro
-
-clean-local: clean-local-check
-.PHONY: clean-local-check
-clean-local-check:
-	-rm -rf $(CPP_DOC_DIR)
-

Modified: avro/trunk/lang/c++/README
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/README?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/lang/c++/README (original)
+++ avro/trunk/lang/c++/README Sun Jan 30 19:10:51 2011
@@ -30,25 +30,25 @@ INSTRUCTIONS
 
 To compile requires boost headers, and the boost regex library.
 Additionally, to generate the avro spec compiler requires flex and bison.
+To build one requires cmake 2.6 or later.
 
-There is a configure file generated by autoconf.  Use:
+To generate a Makefile under Unix or Cygwin use:
 
-    ./configure 
-
-to generate a Makefile.
+cmake -G "Unix Makefiles"
 
 If it doesn't work, either you are missing some packages (boost, flex or bison),
 or you need to help configure locate them.
 
-Type ./configure --help if you need help.
-
 If the Makefile is configured correctly, then you can make and run tests:
 
     make
-    make check
+    ./build/unittest
+    ./build/buffertest
+    ./build/testgentest
+
+To install
 
-Before running tests, you may need to set LD_LIBRARY_PATH to the boost
-libraries if they are staged instead of installed.
+    make package
 
-The install target is not yet set up (coming soon!)
+and then untar the generated .tar.gz file.
 

Modified: avro/trunk/lang/c++/build.sh
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/build.sh?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/lang/c++/build.sh (original)
+++ avro/trunk/lang/c++/build.sh Sun Jan 30 19:10:51 2011
@@ -27,110 +27,68 @@ then
   usage
 fi
 
-cd `dirname "$0"` # connect to root
-
+if [ -f VERSION.txt ]
+then
+VERSION=`cat VERSION.txt`
+else
 VERSION=`cat ../../share/VERSION.txt`
+fi
 
-root_dir=$(pwd)
-build_dir="../../build/avro-cpp-$VERSION"
-dist_dir="../../dist/cpp"
-doc_dir="../../build/avro-doc-$VERSION/api/cpp/html"
-
-tarfile=avro-cpp-$VERSION.tar.gz
-
-set -x # echo commands
+BUILD=../../build
+AVRO_CPP=avro-cpp-$VERSION
+AVRO_DOC=avro-doc-$VERSION
+BUILD_DIR=../../build
+BUILD_CPP=$BUILD/$AVRO_CPP
+DIST_DIR=../../dist/$AVRO_CPP
+DOC_CPP=$BUILD/$AVRO_DOC/api/cpp
+DIST_DIR=../../dist/cpp
+TARFILE=../dist/cpp/$AVRO_CPP.tar.gz 
 
+cmake -G "Unix Makefiles"
 for target in "$@"
 do
 
-function do_autoreconf {
-    if [ ! -f configure ]; then
-        autoreconf -f -i
-    fi
-    if [ ! -f configure ]; then
-        exit 1
-    fi
-}
-
-function check_dir {
-    if [ ! -d $1 ]; then
-        mkdir -p $1
-    fi
-    if [ ! -d $1 ]; then
-        exit 1
-    fi
-}
-
-function do_configure {
-
-    do_autoreconf
-
-    check_dir $build_dir
-
-    if [ ! -f $build_dir/Makefile ]; then
-        (cd $build_dir && ../../lang/c++/configure)
-    fi
-
-    if [ ! -f $build_dir/Makefile ]; then
+function do_doc() {
+    doxygen
+    if [ -d doc ]
+    then
+        mkdir -p $DOC_CPP
+        cp -R doc/* $DOC_CPP
+    else
         exit 1
     fi
 }
-
-function do_build {
-    (cd $build_dir && make check)
-}
-
-function do_docs {
-    check_dir $doc_dir
-    (cd $build_dir && make doc)
-    if [ ! -f $build_dir/doc/html/index.html ]; then
+function do_dist() {
+    rm -rf $BUILD_CPP/
+    mkdir -p $BUILD_CPP
+    cp -r api AUTHORS build.sh CMakeLists.txt ChangeLog \
+        COPYING impl jsonschemas NEWS parser README scripts test \
+        $BUILD_CPP
+    find $BUILD_CPP -name '.svn' | xargs rm -rf
+    cp ../../share/VERSION.txt $BUILD_CPP
+    mkdir -p $DIST_DIR
+    (cd $BUILD_DIR; tar cvzf $TARFILE $AVRO_CPP && cp $TARFILE $AVRO_CPP )
+    if [ ! -f $DIST_FILE ]
+    then
         exit 1
     fi
-    cp -rf $build_dir/doc/html/* $doc_dir/
-}
-
-function do_tar_file {
-    check_dir $dist_dir
-    (cd $build_dir && make dist)
-    if [ ! -f $build_dir/$tarfile ]; then
-        exit 1
-    fi
-    cp -f $build_dir/$tarfile $dist_dir/$tarfile
-}
-
-function do_dist {
-    do_tar_file
-    do_docs
-}
-
-function do_clean {
-
-    if [ -d $build_dir ]; then
-        rm -rf $build_dir
-    fi
-    if [ -d $doc_dir ]; then
-        rm -rf $doc_dir
-    fi
-    rm -rf $dist_dir/$tarfile
-    rm -rf $dist_dir/$tarfile.md5
-
 }
 
 case "$target" in
-
-
     test)
-    do_configure
-    do_build
+    make
+    ./build/buffertest
+    ./build/unittest
+    ./build/testgentest
 	;;
 
     dist)
-    do_configure
-    do_dist
+        do_dist
+        do_doc
     ;;
 
     clean)
-    do_clean 
+    make clean
 	;;
 
     *)

Modified: avro/trunk/lang/c++/parser/AvroLex.ll
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/parser/AvroLex.ll?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/lang/c++/parser/AvroLex.ll (original)
+++ avro/trunk/lang/c++/parser/AvroLex.ll Sun Jan 30 19:10:51 2011
@@ -22,7 +22,7 @@
 #define EOF (-1)
 #endif
 
-#include "AvroYacc.h"
+#include "AvroYacc.hh"
 
 // this undef is a hack for my mac implementation
 #undef yyFlexLexer

Modified: avro/trunk/lang/c++/test/precompile.cc
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/test/precompile.cc?rev=1065352&r1=1065351&r2=1065352&view=diff
==============================================================================
--- avro/trunk/lang/c++/test/precompile.cc (original)
+++ avro/trunk/lang/c++/test/precompile.cc Sun Jan 30 19:10:51 2011
@@ -16,20 +16,30 @@
  * limitations under the License.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <iostream>
+#include <fstream>
 
 #include "Compiler.hh"
 #include "ValidSchema.hh"
 
-int main()
+int main(int argc, char** argv)
 {
     int ret = 0;
     try {
         avro::ValidSchema schema;
-        avro::compileJsonSchema(std::cin, schema);
+        if (argc > 1) {
+            std::ifstream in(argv[1]);
+            avro::compileJsonSchema(in, schema);
+        } else {
+            avro::compileJsonSchema(std::cin, schema);
+        }
 
-        schema.toFlatList(std::cout);
+        if (argc > 2) {
+            std::ofstream out(argv[2]);
+            schema.toFlatList(out);
+        } else {
+            schema.toFlatList(std::cout);
+        }
     }
     catch (std::exception &e) {
         std::cerr << "Failed to parse or compile schema: " << e.what() <<
std::endl;



Mime
View raw message