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/22 17:10:44 UTC

svn commit: r1000027 - in /incubator/etch/trunk/examples/helloworld: CMakeLists.txt README.txt src/main/c/helloworld_client_main.c src/main/c/helloworld_listener_main.c src/main/c/helloworld_server_impl.c

Author: grandyho
Date: Wed Sep 22 15:10:44 2010
New Revision: 1000027

URL: http://svn.apache.org/viewvc?rev=1000027&view=rev
Log:
added cmake based build for helloworld example in c binding

Added:
    incubator/etch/trunk/examples/helloworld/CMakeLists.txt
Modified:
    incubator/etch/trunk/examples/helloworld/README.txt
    incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_client_main.c
    incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_listener_main.c
    incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_server_impl.c

Added: incubator/etch/trunk/examples/helloworld/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/CMakeLists.txt?rev=1000027&view=auto
==============================================================================
--- incubator/etch/trunk/examples/helloworld/CMakeLists.txt (added)
+++ incubator/etch/trunk/examples/helloworld/CMakeLists.txt Wed Sep 22 15:10:44 2010
@@ -0,0 +1,130 @@
+#
+# 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.6) 
+project (etch-c-helloworld)
+
+message(STATUS "using external libraries ${ETCH_EXTERNAL_DEPENDS}")
+message(STATUS "using etch home ${ETCH_HOME}")
+
+#Etch Home
+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__)
+ENDIF (UNIX)
+add_definitions(-D_UNICODE -DUNICODE)
+
+# ETCH library
+SET(ETCH ${ETCH_HOME}/binding-c)
+FIND_PATH(ETCH_INCLUDE_DIR etch.h ${ETCH}/include)
+FIND_LIBRARY(ETCH_LIBRARY NAMES etch.lib libetch.a PATHS ${ETCH}/lib)
+IF (ETCH_INCLUDE_DIR AND ETCH_LIBRARY)
+    SET(ETCH_FOUND TRUE)
+ENDIF (ETCH_INCLUDE_DIR AND ETCH_LIBRARY)
+IF (NOT ETCH_FOUND)
+    MESSAGE(FATAL_ERROR "Could not find libetch")
+ENDIF (NOT ETCH_FOUND)
+
+# APR library
+SET(APR ${ETCH_EXTERNAL_DEPENDS}/apr/1.3.12)
+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)
+    SET(APR_FOUND TRUE)
+ENDIF (APR_INCLUDE_DIR AND APR_LIBRARY)
+IF (NOT APR_FOUND)
+    MESSAGE(FATAL_ERROR "Could not find libapr")
+ENDIF (NOT APR_FOUND)
+
+# APR-ICONV library
+SET(APR ${ETCH_EXTERNAL_DEPENDS}/apr/1.3.12)
+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)
+    SET(APR-ICONV_FOUND TRUE)
+ENDIF (APR-ICONV_INCLUDE_DIR AND APR-ICONV_LIBRARY)
+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 (${PROJECT_SOURCE_DIR}/src/main/c)
+include_directories (${PROJECT_SOURCE_DIR}/target/generated-sources/main/etch/c)
+
+add_executable(etch-c-helloworld-server
+ src/main/c/helloworld_server_implx.c
+ src/main/c/helloworld_server_impl.c
+ src/main/c/helloworld_listener_main.c
+ target/generated-sources/main/etch/c/helloworld_interface.c
+ target/generated-sources/main/etch/c/helloworld_client.c
+ target/generated-sources/main/etch/c/helloworld_server_stub.c
+ target/generated-sources/main/etch/c/helloworld_helper.c
+ target/generated-sources/main/etch/c/helloworld_client_stub.c
+ target/generated-sources/main/etch/c/helloworld_remote_client.c
+ target/generated-sources/main/etch/c/helloworld_remote_server.c
+ target/generated-sources/main/etch/c/helloworld_server.c
+ target/generated-sources/main/etch/c/helloworld_valufact.c
+ target/generated-sources/main/etch/c/helloworld_remote.c    
+)
+
+add_executable(etch-c-helloworld-client
+ src/main/c/helloworld_client_impl.c
+ src/main/c/helloworld_client_implx.c
+ src/main/c/helloworld_client_main.c
+ target/generated-sources/main/etch/c/helloworld_interface.c
+ target/generated-sources/main/etch/c/helloworld_client.c
+ target/generated-sources/main/etch/c/helloworld_server_stub.c
+ target/generated-sources/main/etch/c/helloworld_helper.c
+ target/generated-sources/main/etch/c/helloworld_client_stub.c
+ target/generated-sources/main/etch/c/helloworld_remote_client.c
+ target/generated-sources/main/etch/c/helloworld_remote_server.c
+ target/generated-sources/main/etch/c/helloworld_server.c
+ target/generated-sources/main/etch/c/helloworld_valufact.c
+ target/generated-sources/main/etch/c/helloworld_remote.c    
+)
+
+target_link_libraries(etch-c-helloworld-server "${APR_LIBRARY}")
+target_link_libraries(etch-c-helloworld-server "${APR-ICONV_LIBRARY}")
+target_link_libraries(etch-c-helloworld-server "${ETCH_LIBRARY}")
+set_target_properties(etch-c-helloworld-server PROPERTIES OUTPUT_NAME "helloworld-server")
+
+target_link_libraries(etch-c-helloworld-client "${APR_LIBRARY}")
+target_link_libraries(etch-c-helloworld-client "${APR-ICONV_LIBRARY}")
+target_link_libraries(etch-c-helloworld-client "${ETCH_LIBRARY}")
+set_target_properties(etch-c-helloworld-client PROPERTIES OUTPUT_NAME "helloworld-client")

Modified: incubator/etch/trunk/examples/helloworld/README.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/README.txt?rev=1000027&r1=1000026&r2=1000027&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/README.txt (original)
+++ incubator/etch/trunk/examples/helloworld/README.txt Wed Sep 22 15:10:44 2010
@@ -9,7 +9,11 @@ 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, please use the instructions and cmake files provided in the src/main/c folder.
+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\)
 
 To run java HelloWorld example for java, run these commands:
 
@@ -23,5 +27,10 @@ To run csharp example:
 > start HelloWorldListener.exe
 > start HelloWorldClient.exe
 
-You can mix and match the various clients and listeners.
+To run the c example:
+> build using cmake (see above)
+> 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.
 
+You can mix and match the various clients and listeners.

Modified: incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_client_main.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_client_main.c?rev=1000027&r1=1000026&r2=1000027&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_client_main.c (original)
+++ incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_client_main.c Wed Sep 22 15:10:44 2010
@@ -61,10 +61,10 @@ int main(int argc, char* argv[])
     etch_status_t etch_status    = ETCH_SUCCESS;
     helloworld_remote_server* remote = NULL;
     int waitupms = 4000;
-    etch_string result = NULL;
+    etch_string* result = NULL;
     helloworld_user* user = NULL;
 
-    wchar_t* uri = L"tcp://127.0.0.1:4004";	
+    wchar_t* uri = L"tcp://127.0.0.1:4001";	
 	
        etch_config_t* config = NULL;
     etch_config_create(&config);
@@ -90,8 +90,11 @@ int main(int argc, char* argv[])
     user->id = 51;
     user->name = new_stringw(L"Test");
     result = remote->say_hello(remote, user);
-    wprintf("%s\n",result->v.valw);
-
+    wprintf(L"%s\n",result->v.valw);
+    
+    // wait for keypress
+    waitkey();
+    
     etch_status = helloworld_helper_remote_server_stop_wait(remote, waitupms);
     if(etch_status != ETCH_SUCCESS) {
         // error

Modified: incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_listener_main.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_listener_main.c?rev=1000027&r1=1000026&r2=1000027&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_listener_main.c (original)
+++ incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_listener_main.c Wed Sep 22 15:10:44 2010
@@ -93,7 +93,7 @@ int main(int argc, char* argv[])
     i_sessionlistener* listener = NULL;
     int waitupms = 4000;
     
-    wchar_t* uri = L"tcp://0.0.0.0:4001";
+    wchar_t* uri = L"tcp://127.0.0.1:4001";
 
     etch_config_t* config = NULL;
     etch_config_create(&config);
@@ -110,6 +110,7 @@ int main(int argc, char* argv[])
     }
 
     // wait for keypress
+
     waitkey();
 
     etch_status = helloworld_listener_stop(listener, waitupms);
@@ -123,8 +124,6 @@ int main(int argc, char* argv[])
         return 1;
     }
 	etch_config_destroy(config);
-    // wait for keypress
-    waitkey();
 	
     return 0;
 }

Modified: incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_server_impl.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_server_impl.c?rev=1000027&r1=1000026&r2=1000027&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_server_impl.c (original)
+++ incubator/etch/trunk/examples/helloworld/src/main/c/helloworld_server_impl.c Wed Sep 22 15:10:44 2010
@@ -40,6 +40,9 @@ unsigned short CLASSID_HELLOWORLD_SERVER
 	
 char* HELLOWORLD_ETCHSIMP = "SIMP";
 
+
+etch_string* say_hello_impl(void* thisx, helloworld_user* to_whom);
+
 /* generated signatures */
 int destroy_helloworld_server_implx(void*);
 helloworld_server_impl* init_helloworld_server_impl(struct helloworld_remote_client*, etch_object_destructor);
@@ -62,8 +65,9 @@ helloworld_server_impl* new_helloworld_s
     i_helloworld_server* pserver_base = pserver->helloworld_server_base;
     
     ((etch_object*)pserver_base)->class_id = get_dynamic_classid_unique(&CLASSID_HELLOWORLD_SERVER_IMPL);
+    
     /* add virtual method overrides, if any, here */
-    //pserver->xxx = implementation
+    pserver->say_hello = pserver_base->say_hello = say_hello_impl;
 
     return pserver;
 }
@@ -97,3 +101,7 @@ int destroy_helloworld_server_implx(void
  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  */
  
+etch_string* say_hello_impl(void* thisx, helloworld_user* to_whom){
+  etch_string* ret = new_stringw(L"Hello World from C Binding!");
+  return ret;
+}



Mentioning Jira Issue numbers in log messages. (was: RE: svn commit: r1000027 - )

Posted by "Gav..." <ga...@16degrees.com.au>.
Hi Guys,

You have the commit log below :

> 
> Author: grandyho
> Date: Wed Sep 22 15:10:44 2010
> New Revision: 1000027
> 
> URL: http://svn.apache.org/viewvc?rev=1000027&view=rev
> Log:
> added cmake based build for helloworld example in c binding
> 

Then, on the Jira Issue [1] itself you state:


'fixed with rev. 1000027'

Jira has this nice feature which combines log messages with the issue number and 
puts it into the 'subversion' tab of the Jira Issue itself.

To take advantage of this you should specify the jira issue number in the commit log
message itself.

So your above log message should instead read:

> Log:
> added cmake based build for helloworld example in c binding. Fixes ETCH-98

Thats all, then the commit will be linked to issue, and those looking  at the issue
will see the revision number in the issue itself and be able to click on a link to
take them straight to the commit diff.

Most projects do the above and I think you guys should start making a habit of putting the
Issue number in 'every' log message that relates to a commit. (Note that the issue does not
have to be complete, many commits can refer to the same jira issue.)

Here is an example of an Etch commit I found that does mention the jira issue number in the 
log message.

> Author: fitzner
> Date: Wed Sep 22 14:20:33 2010
> New Revision: 999968
> 
> URL: http://svn.apache.org/viewvc?rev=999968&view=rev
> Log:
> [ETCH-65] integrate binding-c into ANT build

On the jira issue itself, you have not made a comment with the svn revision number, but that does
not matter because the log message of the commit mention the jira issue number we now have more
options available to us.

Take a look at ETCH-65 [2] and click on the 'Subversion' tab.

Now you can see:

1. the commit log message.

2. The revision number which links to the viewvc view of it.

3. The list of files changed/added and link to viewvc diffs of each.

Very useful indeed.

So please, try and mention the jira issue number in every commit log that you do and things are
made easier for everyone in the future.

Gav...


[1] - https://issues.apache.org/jira/browse/ETCH-98

[2] - https://issues.apache.org/jira/browse/ETCH-65