[mapguide-commits] r9965 - in sandbox/jng/vanilla_swig/Bindings: . src src/Bindings src/Bindings/Java src/Bindings/Php src/Managed src/Managed/Java src/SwigCommon/Java

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Sep 2 06:26:12 PDT 2022


Author: jng
Date: 2022-09-02 06:26:11 -0700 (Fri, 02 Sep 2022)
New Revision: 9965

Added:
   sandbox/jng/vanilla_swig/Bindings/src/Managed/CMakeLists.txt
   sandbox/jng/vanilla_swig/Bindings/src/Managed/Java/CMakeLists.txt
Modified:
   sandbox/jng/vanilla_swig/Bindings/TODO.txt
   sandbox/jng/vanilla_swig/Bindings/src/Bindings/CMakeLists.txt
   sandbox/jng/vanilla_swig/Bindings/src/Bindings/Java/CMakeLists.txt
   sandbox/jng/vanilla_swig/Bindings/src/Bindings/Php/CMakeLists.txt
   sandbox/jng/vanilla_swig/Bindings/src/CMakeLists.txt
   sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Java/monkey_patch.i
Log:
More binding fixes on Linux:
 - Only build the .net SWIG glub libraries if building for the common libs subset. Don't do this for the regular end-to-end full build.
 - Copy missing .java files to the expected build location for the Java binding
 - Add missing .jar file creation commands
 - Add missing install targets for PHP and Java bindings
 - Remove existing Java cleanup typemaps and replace it with the existing delete method rename for certain classes from the legacy Java binding
 - Update TODO list

Modified: sandbox/jng/vanilla_swig/Bindings/TODO.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/TODO.txt	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/TODO.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -8,7 +8,7 @@
  - [x] Consolidate Tools.sln into Bindings.sln
  - [ ] Relocate/remove existing test code
  - [x] Move packages dir up to to top-level MgDev subdirectory and make sure nuget.config sources from this dir
- - [ ] Update build batch files to build bindings/portable
+ - [x] Update build batch files to build bindings/portable
  - [ ] Fix binding pre-build events to copy ACE/GEOS/lib_json dlls from their respective Oem directories
  - Split .net binding into the Foundation/Geometry/PlatformBase/MapGuideCommon/Web layout (https://github.com/jumpinjackie/mapguide-api-bindings/issues/18)
    - [x] Add .targets files to each C# project so that native dlls are copied properly when consumed by legacy .net framework applications/libraries
@@ -22,7 +22,6 @@
         - Generate and build the .net/Java SWIG glue libraries
         - Copy the compiled libs out of the docker container and into the same native library staging area for Java/.net
       - (x) OR: Update our common libs dockerfile in (https://github.com/jumpinjackie/mapguide-fdo-docker-build) to perform the above tasks
-   - [ ] Remove --common-subset-only flag from cmake_bootstrap.sh. Instead do the full build, but package up a common libs tarball of the needed .so files
    - [x] Refactor current .net test suite to reference these nuget packages
       - [x] Verify test suite still passes (Windows)
       - [x] Verify test suite still passes (Windows, legacy .net Framework)
@@ -65,12 +64,17 @@
    - [x] Review the usage of our monkey-patched PHP traits and see whether they're still necessary
       - [x] Especially the custom dtor for MgException-derived classes since there is now only one MgException class with no subclasses
    - [~] SKIP: Put all the generated code under a OSGeo\MapGuide namespace
-   - [ ] Get it building (Linux)
+   - [x] Get it building (Linux)
    - [~] Verify test suite still passes (Windows)
       - There is 1 failing test that sounds inconsequential, but should still be fixed
    - [ ] Verify test suite still passes (Linux)
    - It should be possible to now get rid of constants.php and define our various constants in the PHP extension itself!
       - [x] Pivot IMake to instead generate a SWIG interface file of constant class defns to be included in the main SWIG interface file
+   - [ ] (Linux) update php.ini.in cmake template to be based on a production PHP 8.1 config (it is still based on a PHP 5.6 one)
+   - (Linux) Build and include mod_fcgid
+      - [ ] Add mod_fcgid sources to Oem/LinuxApt
+      - [ ] Ensure LinuxApt build script also builds mod_fcgid
+      - [ ] Ensure the generated httpd.conf uses the same FastCGI setup for PHP
  - Fix up existing web apps
    - [x] mapviewerjava
    - [x] mapviewerphp
@@ -101,6 +105,21 @@
    - [x] viewer samples (Java)
    - [ ] viewer samples (.net)
      - Give the .net viewer samples the same migration plan as mapviewernet
+   - [ ] Include a web.config for all .net directories with the required settings to avoid needing to set this information with installer or MgInstantSetup:
+     - Add assembly reference to netstandard
+     - Enable legacy request validation mode
+     - Target .net Framework 4.8
+ - [ ] Rename various public C++ APIs to avoid language-specific renaming workarounds
+   - MgCoordinateSystemMeasure
+      - GetDistance -> GetDistanceSimple
+      - GetAzimuth -> GetAzimuthSimple
+      - GetCoordinate -> GetCoordinateSimple
+   - MgMap
+      - Create -> CreateStateless
+   - MgPropertyDefinition/MgClassDefinition/MgFeatureSchema
+      - Delete -> MarkAsDeleted
+   - Mg*Collection
+      - Add -> AddItem
  - Revise API documentation strategy
    - [ ] Don't use doxygen. Instead use the appropriate docgen tool for the languages we support:
      - PHP: phpDocumentor (https://phpdoc.org/)

Modified: sandbox/jng/vanilla_swig/Bindings/src/Bindings/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/Bindings/CMakeLists.txt	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/src/Bindings/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -12,7 +12,11 @@
     ${XERCESC_INCLUDE_DIR}
 )
 
-add_subdirectory(DotNet)
+# We only need to build the .net SWIG glue libs if building for the common subset
+# We don't build this in a regular full end-to-end MG build
+if (MG_COMMON_SUBSET_ONLY)
+    add_subdirectory(DotNet)
+endif (MG_COMMON_SUBSET_ONLY)
 if (WITH_JAVA)
     add_subdirectory(Java)
 endif (WITH_JAVA)

Modified: sandbox/jng/vanilla_swig/Bindings/src/Bindings/Java/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/Bindings/Java/CMakeLists.txt	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/src/Bindings/Java/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -47,6 +47,13 @@
     COMMAND ${MOVE_COMMAND} ${MOVE_ARGS}
             ${CMAKE_CURRENT_BINARY_DIR}/*.java
             ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide
+    COMMAND ${Java_JAVAC_EXECUTABLE} -classpath ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.class
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi-sources.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
     # These commands need to be run in the context of the source directory so that the relative header references
     # in the Constants and ApiGen xml files will resolve propertly (because these headers won't exist in the cmake
     # binary dir)
@@ -66,15 +73,15 @@
 endif (MSVC)
 add_dependencies(MapGuideJavaApi${MG_VERSION_SUFFIX} IMake)
 
-# if (UNIX)
-#     install(TARGETS MapGuideJavaApi${MG_VERSION_SUFFIX} DESTINATION ${LIB_INSTALL_DIR} COMPONENT ${MG_COMPONENT})
-#     install_symlink(${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/libMapGuideJavaApi${MG_VERSION_SUFFIX}.so libMapGuideJavaApi.so ${MG_COMPONENT})
-#     set(MG_JARS
-#         "${MG_JAVA_OUTPUT_DIR}/MapGuideApi.jar"
-#         "${MG_JAVA_OUTPUT_DIR}/MapGuideApi-sources.jar"
-#     )
-#     install(FILES ${MG_JARS} DESTINATION ${MG_WWWROOT}/WEB-INF/lib)
-# endif (UNIX)
+if (UNIX)
+    install(TARGETS MapGuideJavaApi${MG_VERSION_SUFFIX} DESTINATION ${LIB_INSTALL_DIR} COMPONENT ${MG_COMPONENT})
+    install_symlink(libMapGuideJavaApi${MG_VERSION_SUFFIX}.so libMapGuideJavaApi.so ${MG_COMPONENT})
+    set(MG_JARS
+        "${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi.jar"
+        "${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi-sources.jar"
+    )
+    install(FILES ${MG_JARS} DESTINATION ${MG_WWWROOT}/WEB-INF/lib)
+endif (UNIX)
 target_link_libraries(MapGuideJavaApi${MG_VERSION_SUFFIX}
     ${ACE_LIBRARY}
     #${JNI_LIBRARIES}
@@ -96,4 +103,11 @@
     install( TARGETS MapGuideJavaApi${MG_VERSION_SUFFIX} DESTINATION "${MG_JAVA_OUTPUT_DIR}/${MG_DISTRO}" )
 endif (UNIX)
 
-file(COPY "java.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file
+file(COPY "java.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+# Set RPATH to avoid needing to use LD_LIBRARY_PATH in various configs
+if(MG_CPU EQUAL 64)
+    set_target_properties(MapGuideJavaApi${MG_VERSION_SUFFIX} PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/../../lib64")
+else(MG_CPU EQUAL 64)
+    set_target_properties(MapGuideJavaApi${MG_VERSION_SUFFIX} PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/../../lib")
+endif(MG_CPU EQUAL 64)
\ No newline at end of file

Modified: sandbox/jng/vanilla_swig/Bindings/src/Bindings/Php/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/Bindings/Php/CMakeLists.txt	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/src/Bindings/Php/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -15,6 +15,10 @@
     set(SWIG_PHP_DEFS "-DWIN32")
 endif (WIN32)
 
+# Only needed for Linux
+if (UNIX)
+    file(COPY "InitializeWebTier.cpp" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+endif (UNIX)
 # These 2 files will be #included in the MgApi_wrap translation unit so they need
 # to be present on the current binary dir where MgApi_wrap.cpp will be generated in
 file(COPY "PhpClassMap.cpp" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
@@ -72,12 +76,10 @@
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
-# if (UNIX)
-#     install(TARGETS php_MapGuideApi${MG_VERSION_SUFFIX} DESTINATION ${LIB_INSTALL_DIR} COMPONENT ${MG_COMPONENT})
-#     install_symlink(${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/libphp_MapGuideApi${MG_VERSION_SUFFIX}.so libphp_MapGuideApi.so ${MG_COMPONENT})
-#     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/constants.php DESTINATION ${MG_WWWROOT}/mapadmin COMPONENT ${MG_COMPONENT})
-#     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/constants.php DESTINATION ${MG_WWWROOT}/mapviewerphp COMPONENT ${MG_COMPONENT})
-# endif (UNIX)
+if (UNIX)
+    install(TARGETS php_MapGuideApi${MG_VERSION_SUFFIX} DESTINATION ${LIB_INSTALL_DIR} COMPONENT ${MG_COMPONENT})
+    install_symlink(${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/libphp_MapGuideApi${MG_VERSION_SUFFIX}.so libphp_MapGuideApi.so ${MG_COMPONENT})
+endif (UNIX)
 target_link_libraries(php_MapGuideApi${MG_VERSION_SUFFIX}
     ${ACE_LIBRARY}
     ${PHP_LIBRARY}
@@ -93,9 +95,11 @@
     ${XERCESC_LIBRARIES}
 )
 
-# Only needed for Linux
-if (UNIX)
-    file(COPY "InitializeWebTier.cpp" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-endif (UNIX)
+file(COPY "php.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 
-file(COPY "php.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file
+# Set RPATH to avoid needing to use LD_LIBRARY_PATH in various configs
+if(MG_CPU EQUAL 64)
+    set_target_properties(php_MapGuideApi${MG_VERSION_SUFFIX} PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/../../lib64")
+else(MG_CPU EQUAL 64)
+    set_target_properties(php_MapGuideApi${MG_VERSION_SUFFIX} PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/../../lib")
+endif(MG_CPU EQUAL 64)
\ No newline at end of file

Modified: sandbox/jng/vanilla_swig/Bindings/src/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/CMakeLists.txt	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/src/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -16,4 +16,5 @@
 file(COPY "SwigCommon" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 
 add_subdirectory(IMake)
+add_subdirectory(Managed)
 add_subdirectory(Bindings)
\ No newline at end of file

Added: sandbox/jng/vanilla_swig/Bindings/src/Managed/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/Managed/CMakeLists.txt	                        (rev 0)
+++ sandbox/jng/vanilla_swig/Bindings/src/Managed/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -0,0 +1,3 @@
+if (WITH_JAVA)
+    add_subdirectory(Java)
+endif (WITH_JAVA)
\ No newline at end of file

Added: sandbox/jng/vanilla_swig/Bindings/src/Managed/Java/CMakeLists.txt
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/Managed/Java/CMakeLists.txt	                        (rev 0)
+++ sandbox/jng/vanilla_swig/Bindings/src/Managed/Java/CMakeLists.txt	2022-09-02 13:26:11 UTC (rev 9965)
@@ -0,0 +1,4 @@
+file(GLOB MG_JAVA_SOURCES
+    "org/osgeo/mapguide/*.java"
+)
+file(COPY ${MG_JAVA_SOURCES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../Bindings/Java/org/osgeo/mapguide)
\ No newline at end of file

Modified: sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Java/monkey_patch.i
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Java/monkey_patch.i	2022-08-31 16:19:44 UTC (rev 9964)
+++ sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Java/monkey_patch.i	2022-09-02 13:26:11 UTC (rev 9965)
@@ -5,40 +5,19 @@
 
 //---------------------- Renames to avoid Java/C++ API clashes ---------------------------//
 
-/**
- * Rename SWIG's "delete" to "destroy". However the typemaps to do this cannot just rename the thing
- * we have to repeat the expected implementation verbatim with the new name
- */
-%typemap(javafinalize) SWIGTYPE %{
-  protected void finalize() {
-    destroy();  // renamed to prevent conflict with existing delete method
-  }
-%}
-%typemap(javadestruct, methodname="destroy", methodmodifiers="public synchronized") SWIGTYPE
-{
-    if (swigCPtr != 0) {
-      if (swigCMemOwn) {
-        swigCMemOwn = false;
-        $jnicall;
-      }
-      swigCPtr = 0;
-    }
-}
-%typemap(javadestruct_derived, methodname="destroy", methodmodifiers="public synchronized") SWIGTYPE
-{
-    if (swigCPtr != 0) {
-      if (swigCMemOwn) {
-        swigCMemOwn = false;
-        $jnicall;
-      }
-      swigCPtr = 0;
-    }
-    super.destroy();
-}
-
 //Already defined in Java Exception so rename our proxy method
 %rename(getExceptionStackTrace) MgException::GetStackTrace;
 
+//delete() is the name of the standard SWIG release method called on finalize(). Unfortunately this conflicts with
+//MgPropertyDefinition::Delete, MgClassDefinition::Delete and MgFeatureSchema::Delete when java proxy clases for these
+//classes are generated
+//
+//So rename the java proxies to these methods. This is the most minimally destructive change of all the available options
+//available to us
+%rename(markAsDeleted) MgPropertyDefinition::Delete;
+%rename(markAsDeleted) MgClassDefinition::Delete;
+%rename(markAsDeleted) MgFeatureSchema::Delete;
+
 //If we want to implement java.util.Collection, we need to rename this incompatible API (as add() is expected to 
 //return boolean in the java.util.Collection API)
 %rename(addItem) MgBatchPropertyCollection::Add;



More information about the mapguide-commits mailing list