You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by gr...@apache.org on 2010/09/23 14:28:16 UTC

svn commit: r1000427 - in /incubator/etch/trunk: binding-c/runtime/c/README.txt examples/helloworld/CMakeLists.txt examples/helloworld/README.txt examples/helloworld/build.xml examples/helloworld/dist-build.xml

Author: grandyho
Date: Thu Sep 23 12:28:15 2010
New Revision: 1000427

URL: http://svn.apache.org/viewvc?rev=1000427&view=rev
Log:
ETCH-101 
Helloworld Example integrated into trunk build (incl. code generation and compile for c)
when on release dist, only code is generated, no cmake call is made (don't want cmake-ant dependency in release package)

Modified:
    incubator/etch/trunk/binding-c/runtime/c/README.txt
    incubator/etch/trunk/examples/helloworld/CMakeLists.txt
    incubator/etch/trunk/examples/helloworld/README.txt
    incubator/etch/trunk/examples/helloworld/build.xml
    incubator/etch/trunk/examples/helloworld/dist-build.xml

Modified: incubator/etch/trunk/binding-c/runtime/c/README.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/README.txt?rev=1000427&r1=1000426&r2=1000427&view=diff
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/README.txt (original)
+++ incubator/etch/trunk/binding-c/runtime/c/README.txt Thu Sep 23 12:28:15 2010
@@ -89,6 +89,8 @@ and ../trunk/binding-c/runtime/c/target/
 
 Please note that tests need libapr-1.dll and libapriconv-1.dll either in your path environment
 variable or in case of MS Visual Studio under the ..\binding-c\runtime\c\target\src\test\ folder.
+Additionally, you have to set APR_ICONV_PATH to <ETCH_EXTERNAL_DEPENDS>\apr\1.3.12\iconv\ to make
+character conversion run. 
 
 ==================================================
 Build for linux

Modified: incubator/etch/trunk/examples/helloworld/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/CMakeLists.txt?rev=1000427&r1=1000426&r2=1000427&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/CMakeLists.txt (original)
+++ incubator/etch/trunk/examples/helloworld/CMakeLists.txt Thu Sep 23 12:28:15 2010
@@ -17,7 +17,6 @@
 cmake_minimum_required (VERSION 2.6) 
 project (etch-c-helloworld)
 
-message(STATUS "using external libraries ${ETCH_EXTERNAL_DEPENDS}")
 message(STATUS "using etch home ${ETCH_HOME}")
 
 #Etch Home
@@ -25,11 +24,6 @@ IF (NOT ETCH_HOME)
     MESSAGE(FATAL_ERROR "ETCH_HOME not set")
 ENDIF (NOT ETCH_HOME)
 
-# Etch external
-IF (NOT ETCH_EXTERNAL_DEPENDS)
-    MESSAGE(FATAL_ERROR "ETCH_EXTERNAL_DEPENDS not set")
-ENDIF (NOT ETCH_EXTERNAL_DEPENDS)
-
 # Set definitions
 IF (UNIX)
     add_definitions(-D_GNU_SOURCE -D_REENTRANT -DLINUX=2 -D__LINUX__)
@@ -48,7 +42,7 @@ IF (NOT ETCH_FOUND)
 ENDIF (NOT ETCH_FOUND)
 
 # APR library
-SET(APR ${ETCH_EXTERNAL_DEPENDS}/apr/1.3.12)
+SET(APR ${ETCH_HOME}/binding-c/extern/apr)
 FIND_PATH(APR_INCLUDE_DIR apr.h ${APR}/include ${APR}/include/apr-1)
 FIND_LIBRARY(APR_LIBRARY NAMES libapr-1.lib libapr-1.so PATHS ${APR}/lib)
 IF (APR_INCLUDE_DIR AND APR_LIBRARY)
@@ -59,7 +53,7 @@ IF (NOT APR_FOUND)
 ENDIF (NOT APR_FOUND)
 
 # APR-ICONV library
-SET(APR ${ETCH_EXTERNAL_DEPENDS}/apr/1.3.12)
+SET(APR ${ETCH_HOME}/binding-c/extern/apr)
 FIND_PATH(APR-ICONV_INCLUDE_DIR apr_iconv.h ${APR}/include ${APR}/include/apr-1)
 FIND_LIBRARY(APR-ICONV_LIBRARY NAMES libapriconv-1.lib libapriconv-1.so PATHS ${APR}/lib)
 IF (APR-ICONV_INCLUDE_DIR AND APR-ICONV_LIBRARY)
@@ -69,21 +63,10 @@ IF (NOT APR-ICONV_FOUND)
     MESSAGE(FATAL_ERROR "Could not find libapriconv")
 ENDIF (NOT APR-ICONV_FOUND)
 
-# APR-ICONV library
-SET(CUNIT ${ETCH_EXTERNAL_DEPENDS}/cunit/2.1)
-FIND_PATH(CUNIT_INCLUDE_DIR CUnit.h ${CUNIT}/include /usr/include/CUnit)
-FIND_LIBRARY(CUNIT_LIBRARY NAMES libcunit.lib libcunit.a PATHS ${CUNIT}/lib /usr/lib)
-IF (CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
-    SET(CUNIT_FOUND TRUE)
-ENDIF (CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
-IF (NOT CUNIT_FOUND)
-    MESSAGE(FATAL_ERROR "Could not find libcunit")
-ENDIF (NOT CUNIT_FOUND)
-
 # set include dirs
 include_directories (${APR_INCLUDE_DIR})
-include_directories (${ETCH_INCLUDE_DIR})
 include_directories (${APR-ICONV_INCLUDE_DIR})
+include_directories (${ETCH_INCLUDE_DIR})
 include_directories (${PROJECT_SOURCE_DIR}/src/main/c)
 include_directories (${PROJECT_SOURCE_DIR}/target/generated-sources/main/etch/c)
 

Modified: incubator/etch/trunk/examples/helloworld/README.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/README.txt?rev=1000427&r1=1000426&r2=1000427&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/README.txt (original)
+++ incubator/etch/trunk/examples/helloworld/README.txt Thu Sep 23 12:28:15 2010
@@ -8,29 +8,52 @@ cd examples
 cd helloworld
 ant Debug
 
-This will generate sources for all csharp, java and c. It will also build the csharp and java sources.
-To build the C sources, use cmake. Start cmake-gui, set source to this folder, build to a subfolder (e.g. "ctarget").
-You have to set to string variables in CMake:
-- ETCH_EXTERNAL_DEPENDS must point to your dependency directory (see binding-c/runtime/c/README.txt for details)
-- ETCH_HOME must point to your etch installation directory (if you are doing this on trunk, then use
-  your path to trunk\target\Installers\dist\)
+This will generate sources for all csharp, java and c. It will also build the csharp and java sources. See below
+regarding the build of the C binding sources.
 
+JAVA INSTRUCTIONS:
+******************
 To run java HelloWorld example for java, run these commands:
 
 > cd target\bin
 > start java -cp helloworld.jar org.apache.etch.examples.helloworld.MainHelloWorldListener
 > start java -cp helloworld.jar org.apache.etch.examples.helloworld.MainHelloWorldClient
 
+CSHARP INSTRUCTIONS:
+********************
 To run csharp example:
 
 > cd target\bin
 > start HelloWorldListener.exe
 > start HelloWorldClient.exe
 
+C INSTRUCTIONS:
+***************
 To run the c example:
-> build using cmake (see above)
+> build using cmake (see below)
 > on windows using visual studio: build the generated solution and execute server and client targets
 > on linux: use make to build using generated makefiles, execute etch-c-helloworld-client 
             and etch-c-helloworld-server executables.
 
+To build the C sources, use cmake. Start cmake-gui, set source to example/helloworld folder and "build" to a subfolder (e.g. "ctarget").
+You have to set the following variable in CMake:
+- ETCH_HOME must point to your Etch directory (this is were you installed Etch, or target/Installers/dist if building from trunk)
+
+on the shell, you could do this using
+cd examples/helloworld/target
+cmake .. -DETCH_HOME:string=<YOUR ETCH INSTALLATION DIR>
+make (or open visual studio on win32...)
+
+You also have to set the following environment variable:
+- APR_ICONV_PATH to <YOUR ETCH INSTALLATION DIR>/binding-c/extern/apr/iconv/
+
+To run c example:
+
+> cd target\bin
+> start helloworld-server.exe
+> start helloworld-client.exe
+
+
+
+
 You can mix and match the various clients and listeners.

Modified: incubator/etch/trunk/examples/helloworld/build.xml
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/build.xml?rev=1000427&r1=1000426&r2=1000427&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/build.xml (original)
+++ incubator/etch/trunk/examples/helloworld/build.xml Thu Sep 23 12:28:15 2010
@@ -214,7 +214,28 @@
 
     <target name="build-csharp" depends="build-csharp-with-mono,build-csharp-with-dotnet" />
 
-    <target name="build" depends="build-java,build-csharp" />
+	<target name="build-c" depends="generate-sources" if="USE.cmake">
+		 <cmake srcdir="${basedir}" bindir="${basedir}/target" buildtype="Debug" >
+		           	<variable name="ETCH_HOME" type="PATH" value="${etch.home}" />
+  		 </cmake>
+                 <copy todir="${bin}" flatten="true">
+                    <fileset dir="${basedir}/target/" >
+                         <include name="helloworld-client" />
+                         <include name="helloworld-server" />
+                         <include name="debug/helloworld-client.exe" />
+                         <include name="debug/helloworld-server.exe" />
+                    </fileset>
+                 </copy>
+                 <copy todir="${bin}" flatten="true">
+                    <fileset dir="${etch.home}/binding-c/extern/apr/bin" >
+                         <include name="libapr-1.dll" />
+                         <include name="libapriconv-1.dll" />
+                    </fileset>
+                 </copy>
+                
+	</target>
+	
+    <target name="build" depends="build-java,build-csharp,build-c" />
 
     <!-- run unit tests -->
 
@@ -266,6 +287,14 @@ To run csharp example:
 > start HelloWorldListener.exe
 > start HelloWorldClient.exe
 
+To run the c example:
+
+> build using cmake (see README.txt) (if you are not building from trunk, 
+  e.g. if you have an official release)
+> cd target\debug
+> start helloworld-server.exe
+> start helloworld-client.exe
+
 You can mix and match the various clients and listeners.
 
         </echo>
@@ -284,6 +313,7 @@ You can mix and match the various client
        <copy file="dist-build.xml" tofile="${dist-src}/build.xml" overwrite="true" >
            <filterset refid="Etch.buildTokens" />
        </copy>    
+        <copy file="CMakeLists.txt" tofile="${dist-src}/CMakeLists.txt" overwrite="true" />
         <copy file="README.txt" tofile="${dist-src}/README.txt" overwrite="true" />
         
         <copy todir="${dist-src}/src/main/etch" overwrite="true" >
@@ -306,6 +336,15 @@ You can mix and match the various client
                 <include name="**/*.cs" />
             </fileset>
         </copy>
+
+        <copy todir="${dist-src}/src/main/c" overwrite="true" >
+            <fileset dir="${src}/main/c" >
+                <exclude name="**/.svn/**" />
+                <include name="**/*.c" />
+                <include name="**/*.h" />
+                <include name="**/CMakeLists.txt" />
+            </fileset>
+        </copy>
         
         <copy todir="${dist}/examples/helloworld" overwrite="true" >
             <fileset dir="${dist-src}" />

Modified: incubator/etch/trunk/examples/helloworld/dist-build.xml
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/dist-build.xml?rev=1000427&r1=1000426&r2=1000427&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/dist-build.xml (original)
+++ incubator/etch/trunk/examples/helloworld/dist-build.xml Thu Sep 23 12:28:15 2010
@@ -39,6 +39,7 @@
     <property name="generated-sources" location="${target}/generated-sources"/>
     <property name="gensrc-main-etch-java" location="${generated-sources}/main/etch/java"/>
     <property name="gensrc-main-etch-csharp" location="${generated-sources}/main/etch/csharp"/>
+    <property name="gensrc-main-etch-c" location="${generated-sources}/main/etch/c"/>
     <property name="classes"           location="${target}/classes"/>
     <property name="bin"               location="${target}/bin"/>
     
@@ -48,7 +49,7 @@
 
     <taskdef resource="org/apache/etch/tools/ant/etch.xml" classpath="${etch-ant-plugin.jar}"/>
 
-    <target name="build" depends="build-java, build-csharp, done"/>
+    <target name="build" depends="build-java, build-csharp, build-c, done"/>
 
     <target name="build-java" depends="gensrc-java">
         <javac destdir="${classes}" source="1.5" debug="true">
@@ -85,6 +86,28 @@ To run csharp example:
 > start HelloWorldListener.exe
 > start HelloWorldClient.exe
 
+To run the c example:
+> first build using cmake (see below)
+
+You have to set the following variable in CMake:
+- ETCH_HOME must point to your Etch directory (this is were you installed Etch, or target/Installers/dist if building from trunk)
+
+on the shell, you could do this using:
+
+cd examples/helloworld/target
+cmake .. -DETCH_HOME:string=[YOUR ETCH INSTALLATION DIR]
+make (or open visual studio on win32...)
+
+You also have to set the following environment variable:
+- APR_ICONV_PATH to [YOUR ETCH INSTALLATION DIR]/binding-c/extern/apr/iconv/
+
+To run c example:
+
+> cd target\bin
+> start helloworld-server.exe
+> start helloworld-client.exe
+
+
 You can mix and match the various clients and listeners.
 
         </echo>
@@ -122,7 +145,9 @@ You can mix and match the various client
         <copy todir="${bin}" file="${etch-csharp-runtime.dll}"/>
     </target>
 
-    <target name="gensrc" depends="gensrc-java, gensrc-csharp"/>
+    <target name="build-c" depends="gensrc-c">
+       <echo message="c binding sources can be built with cmake!"/>
+    </target>
 
     <target name="gensrc-java" depends="init">
         <etch
@@ -142,11 +167,21 @@ You can mix and match the various client
             file="${src-main-etch}/HelloWorld.etch"/>
     </target>
 
+    <target name="gensrc-c" depends="init">
+        <etch
+            home="${etch.home}"
+            binding="c"
+            quiet="true"
+            outputDir="${gensrc-main-etch-c}"
+            file="${src-main-etch}/HelloWorld.etch"/>
+    </target>
+
     <target name="init">
         <mkdir dir="${target}"/>
         <mkdir dir="${generated-sources}"/>
         <mkdir dir="${gensrc-main-etch-java}"/>
         <mkdir dir="${gensrc-main-etch-csharp}"/>
+        <mkdir dir="${gensrc-main-etch-c}"/>
         <mkdir dir="${classes}"/>
         <mkdir dir="${bin}"/>
     </target>