From 31d7978354ec520644fa8efa07b16d1fe56c21de Mon Sep 17 00:00:00 2001
From: Danmei Chen <danmei.chen@belledonne-communications.com>
Date: Tue, 31 Aug 2021 16:55:50 +0200
Subject: [PATCH] update welcome page for swift and add cmake for jazzy doc

---
 wrappers/swift/CMakeLists.txt |  8 +++++++-
 wrappers/swift/JazzyDoc.cmake | 24 ++++++++++++++++++++++++
 wrappers/swift/README         | 21 ---------------------
 wrappers/swift/README.cmake   | 23 +++++++++++++++++++++++
 4 files changed, 54 insertions(+), 22 deletions(-)
 create mode 100644 wrappers/swift/JazzyDoc.cmake
 delete mode 100644 wrappers/swift/README
 create mode 100644 wrappers/swift/README.cmake

diff --git a/wrappers/swift/CMakeLists.txt b/wrappers/swift/CMakeLists.txt
index cc7c59c7cc..00b612ec57 100644
--- a/wrappers/swift/CMakeLists.txt
+++ b/wrappers/swift/CMakeLists.txt
@@ -23,7 +23,7 @@
 # Cmake 3.15 is required for swift wrapper compilation, otherwise you have immediate build time errors.
 # However, cmake-1.15 swift support is not mature yet.
 # For example, creating a swift framework doesn't work with Ninja backend (only Xcode).
-# Fortunately, creating a swift shared library works. 
+# Fortunately, creating a swift shared library works.
 # As a result, I had to create my own script to create a framework from a shared library, called make-framework.sh.
 # For xcode, create a swift framework directly.
 
@@ -54,6 +54,12 @@ if (NOT ENABLE_SWIFT_WRAPPER_COMPILATION)
 		DESTINATION "${CMAKE_INSTALL_DATADIR}/linphonesw/")
 endif()
 
+if (ENABLE_JAZZY_DOC)
+	# Remove everything after the last point in LINPHONE_VERSION (4.5.0 --> 4.5) to create STRIPPED_LINPHONE_VERSION
+	string(REGEX REPLACE "\\.[^.]*$" "" STRIPPED_LINPHONE_VERSION ${LINPHONE_VERSION})
+	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README.cmake ${CMAKE_CURRENT_BINARY_DIR}/README)
+endif()
+
 if (ENABLE_JAZZY_DOC OR ENABLE_SWIFT_WRAPPER_COMPILATION)
 	cmake_minimum_required(VERSION 3.15)
 	set(CMAKE_Swift_LANGUAGE_VERSION 4.0)
diff --git a/wrappers/swift/JazzyDoc.cmake b/wrappers/swift/JazzyDoc.cmake
new file mode 100644
index 0000000000..ac11edf067
--- /dev/null
+++ b/wrappers/swift/JazzyDoc.cmake
@@ -0,0 +1,24 @@
+############################################################################
+# JazzyDoc.cmake
+# Copyright (C) 2010-2021 Belledonne Communications, Grenoble France
+#
+############################################################################
+
+if(ENABLE_SWIFT_WRAPPER AND ENABLE_JAZZY_DOC)
+  message("Generating jazzy doc for swift module, we need archs x86_64 to generate jazzy doc!")
+  execute_process(
+    COMMAND "jazzy" "-x" "-project,linphone.xcodeproj,-scheme,linphonesw" "--readme" "README"
+    WORKING_DIRECTORY "${LINPHONESDK_BUILD_DIR}/WORK/ios-x86_64/Build/linphone/"
+  )
+  execute_process(
+    COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "WORK/ios-x86_64/Build/linphone/docs" "docs"
+    WORKING_DIRECTORY "${LINPHONESDK_BUILD_DIR}"
+  )
+
+  if(NOT ENABLE_SWIFT_WRAPPER_COMPILATION)
+		message("Not ENABLE_SWIFT_WRAPPER_COMPILATION, remove linphonesw.frameworks......")
+		foreach(_arch ${LINPHONESDK_IOS_ARCHS})
+			file(REMOVE_RECURSE "linphone-sdk/${_arch}-apple-darwin.ios/Frameworks/linphonesw.framework")
+		endforeach()
+	endif()
+endif()
diff --git a/wrappers/swift/README b/wrappers/swift/README
deleted file mode 100644
index f08f578517..0000000000
--- a/wrappers/swift/README
+++ /dev/null
@@ -1,21 +0,0 @@
-Welcome to Linphone API's documentation!
-========================================
-What is liblinphone
--------------------
-
-Liblinphone is a high level library for bringing SIP video call functionnality
-into an application. It aims at making easy the integration of the SIP
-video calls into any applications. All variants of linphone are directly based
-on it:
-
-* linphone (gtk interface)
-* linphonec (console interface)
-* linphone for iOS
-* linphone for Android
-
-Liblinphone is GPL (see COPYING file). Please understand the licencing details
-before using it!
-
-For any use of this library beyond the rights granted to you by the
-GPL license, please contact Belledonne Communications
-(contact@belledonne-communications.com).
diff --git a/wrappers/swift/README.cmake b/wrappers/swift/README.cmake
new file mode 100644
index 0000000000..7e41e2ede3
--- /dev/null
+++ b/wrappers/swift/README.cmake
@@ -0,0 +1,23 @@
+Liblinphone Documentation
+========================================
+
+See also
+      http://www.linphone.org
+
+What is liblinphone
+-------------------
+
+Liblinphone is a high-level open source library that integrates all the SIP voice/video and instant messaging features into a single easy-to-use API. This is the VoIP SDK engine on which Linphone applications are based.
+
+Liblinphone combines our media processing and streaming toolkit (Mediastreamer2) with our user-agent library for SIP signaling (belle-sip). Liblinphone has support for a variety of languages, each one has its own reference documentation:
+
+* C (https://linphone.org/@LINPHONESDK_STATE@/docs/liblinphone/@STRIPPED_LINPHONE_VERSION@/c)
+* C++ (https://linphone.org/@LINPHONESDK_STATE@/docs/liblinphone/@STRIPPED_LINPHONE_VERSION@/c++)
+* Swift (https://linphone.org/@LINPHONESDK_STATE@/docs/liblinphone/@STRIPPED_LINPHONE_VERSION@/swift)
+* Java (https://linphone.org/@LINPHONESDK_STATE@/docs/liblinphone/@STRIPPED_LINPHONE_VERSION@/java)
+* C# (https://linphone.org/@LINPHONESDK_STATE@/docs/liblinphone/@STRIPPED_LINPHONE_VERSION@/cs)
+* Python (coming soon)
+
+Liblinphone is distributed under GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html). Please understand the licencing details before using it!
+
+For any use of this library beyond the rights granted to you by the GPLv3 license, please contact Belledonne Communications (https://www.linphone.org/contact).
-- 
GitLab