Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaRU committed Nov 8, 2020
0 parents commit 42b6561
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.swiftpm
/*.zip
/.build
/build
/Packages
/*.xcodeproj
xcuserdata/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Dmitriy Borovikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions script/cmake/ios.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
unset(CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH)

set(MACOSX_BUNDLE_GUI_IDENTIFIER "in.ioshack")
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")

set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")

set(CMAKE_OSX_SYSROOT "$ENV{PLATFORM_NAME}")
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO")
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "$ENV{PLATFORM_NAME}")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "$ENV{EFFECTIVE_PLATFORM_NAME}")
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "$ENV{IPHONEOS_DEPLOYMENT_TARGET}")

set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "$ENV{ARCHS}")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "$ENV{ARCHS}")

# Set iPhoneSimulator architectures
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "$ENV{ARCHS}")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "$ENV{ARCHS}")

set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE[sdk=iphone*] "YES")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "\$(BITCODE_GENERATION_MODE_\$(CONFIGURATION))")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_Debug "marker")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_Release "bitcode")

set(CMAKE_CXX_FLAGS "-std=c++11 -Wno-shorten-64-to-32")
14 changes: 14 additions & 0 deletions script/cmake/maccatalyst.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
unset(CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH)

set(MACOSX_BUNDLE_GUI_IDENTIFIER "in.ioshack")
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")

set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS macosx)
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES")

set(CMAKE_CXX_FLAGS "-std=c++11 -Wno-shorten-64-to-32")
117 changes: 117 additions & 0 deletions script/fastrtps_build_apple.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash
#
# fastrtps_build_apple.sh
# Copyright © 2020 Dmitriy Borovikov. All rights reserved.
#
set -e
set -x
echo $PLATFORM_NAME$EFFECTIVE_PLATFORM_NAME $ARCHS

if [ -f "$BUILT_PRODUCTS_DIR/lib/libfastrtpsa.a" ]; then
echo Already build "$BUILT_PRODUCTS_DIR/lib/libfastrtpsa.a"
exit 0
fi
#export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl hw.ncpu | awk '{print $2}')

rm -rf "$PROJECT_TEMP_DIR"
if [ "$PLATFORM_NAME" = "macosx" ]; then
if [ "$EFFECTIVE_PLATFORM_NAME" = "-maccatalyst" ]; then
cmake -S$SOURCE_DIR/memory -B"$PROJECT_TEMP_DIR/memory" \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D CMAKE_TOOLCHAIN_FILE=$ROOT_PATH/script/cmake/maccatalyst.toolchain.cmake \
-D FOONATHAN_MEMORY_BUILD_EXAMPLES=OFF \
-D FOONATHAN_MEMORY_BUILD_TESTS=OFF \
-D FOONATHAN_MEMORY_BUILD_TOOLS=OFF \
-D CMAKE_DEBUG_POSTFIX="" \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.15" \
-D CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET="13.1" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-G Xcode

xcodebuild build -scheme install -destination 'generic/platform=macOS,variant=Mac Catalyst' -project "$PROJECT_TEMP_DIR/memory/FOONATHAN_MEMORY.xcodeproj"

cmake -S$SOURCE_DIR/Fast-DDS -B"$PROJECT_TEMP_DIR/Fast-DDS" \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D CMAKE_TOOLCHAIN_FILE="$ROOT_PATH/script/cmake/maccatalyst.toolchain.cmake" \
-D foonathan_memory_DIR="$BUILT_PRODUCTS_DIR/share/foonathan_memory/cmake" \
-D SQLITE3_SUPPORT=OFF \
-D THIRDPARTY=ON \
-D COMPILE_EXAMPLES=OFF \
-D BUILD_DOCUMENTATION=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.15" \
-D CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET="13.1" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-G Xcode

xcodebuild build -scheme install -destination 'generic/platform=macOS,variant=Mac Catalyst' -project "$PROJECT_TEMP_DIR/Fast-DDS/fastrtps.xcodeproj"

else
cmake -S$SOURCE_DIR/memory -B"$PROJECT_TEMP_DIR/memory" \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D FOONATHAN_MEMORY_BUILD_EXAMPLES=OFF \
-D FOONATHAN_MEMORY_BUILD_TESTS=OFF \
-D FOONATHAN_MEMORY_BUILD_TOOLS=ON \
-D CMAKE_DEBUG_POSTFIX="" \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.10" \
-D CMAKE_OSX_ARCHITECTURES="$ARCHS" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-G Xcode
cmake --build "$PROJECT_TEMP_DIR/memory" --config Release --target install

cmake -S$SOURCE_DIR/Fast-DDS -B"$PROJECT_TEMP_DIR/Fast-DDS" \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D foonathan_memory_DIR="$BUILT_PRODUCTS_DIR/share/foonathan_memory/cmake" \
-D SQLITE3_SUPPORT=OFF \
-D THIRDPARTY=ON \
-D COMPILE_EXAMPLES=OFF \
-D BUILD_DOCUMENTATION=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.10" \
-D CMAKE_OSX_ARCHITECTURES="$ARCHS" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-G Xcode

cmake --build "$PROJECT_TEMP_DIR/Fast-DDS" --config Release --target install

fi
fi

if [ "$PLATFORM_NAME" = "iphoneos" ] || [ "$PLATFORM_NAME" = "iphonesimulator" ]; then
export IPHONEOS_DEPLOYMENT_TARGET="9.0"
cmake -S$SOURCE_DIR/memory -B"$PROJECT_TEMP_DIR/memory" \
-D CMAKE_TOOLCHAIN_FILE="$ROOT_PATH/script/cmake/ios.toolchain.cmake" \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-D CMAKE_C_COMPILER=clang \
-D CMAKE_CXX_COMPILER=clang++ \
-D CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-D CMAKE_DEBUG_POSTFIX="" \
-D FOONATHAN_MEMORY_BUILD_EXAMPLES=OFF \
-D FOONATHAN_MEMORY_BUILD_TESTS=OFF \
-D FOONATHAN_MEMORY_BUILD_TOOLS=OFF \
-G Xcode

cmake --build "$PROJECT_TEMP_DIR/memory" --config Release --target install --

cmake -S$SOURCE_DIR/Fast-DDS -B"$PROJECT_TEMP_DIR/Fast-DDS" \
-D CMAKE_TOOLCHAIN_FILE="$ROOT_PATH/script/cmake/ios.toolchain.cmake" \
-D CMAKE_CONFIGURATION_TYPES=Release \
-D CMAKE_C_COMPILER=clang \
-D CMAKE_CXX_COMPILER=clang++ \
-D CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-D BUILD_SHARED_LIBS=NO \
-D CMAKE_INSTALL_PREFIX="$BUILT_PRODUCTS_DIR" \
-D foonathan_memory_DIR="$BUILT_PRODUCTS_DIR/foonathan_memory/cmake" \
-D SQLITE3_SUPPORT=OFF \
-D THIRDPARTY=ON \
-D COMPILE_EXAMPLES=OFF \
-D BUILD_DOCUMENTATION=OFF \
-G Xcode

cmake --build "$PROJECT_TEMP_DIR/Fast-DDS" --config Release --target install --
fi
rm -rf "$PROJECT_TEMP_DIR"

cd "$BUILT_PRODUCTS_DIR/lib"
libtool -static -o libfastrtpsa.a libfastrtps.a libfastcdr.a libfoonathan_memory-0.6.2.a
102 changes: 102 additions & 0 deletions script/fastrtps_build_xctframework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
#
# fastrtps_build_xctframework.sh
# Copyright © 2020 Dmitriy Borovikov. All rights reserved.
#
set -e
set -x

TAG="2.0.1"
BRANCH=$(git branch --show-current)
if [ "$BRANCH" == "master" ]
then
Foonathan_memory_repo="-b crosscompile https://github.com/DimaRU/memory.git"
FastRTPS_repo="-b v2.0.1 https://github.com/eProsima/Fast-DDS.git"

elif [ "$BRANCH" == "whitelist" ]
then
TAG="$BRANCH-$TAG"
Foonathan_memory_repo="-b crosscompile https://github.com/DimaRU/memory.git"
FastRTPS_repo="-b feature/remote-whitelist-2.0.1 https://github.com/DimaRU/Fast-DDS.git"
else
echo "Wrong branch $BRANCH"
exit -1
fi
echo $TAG

ZIPNAME=fastrtps-$TAG.xcframework.zip
GIT_REMOTE_URL_UNFINISHED=`git config --get remote.origin.url|sed "s=^ssh://==; s=^https://==; s=:=/=; s/git@//; s/.git$//;"`
DOWNLOAD_URL=https://$GIT_REMOTE_URL_UNFINISHED/releases/download/$TAG/$ZIPNAME

export ROOT_PATH=$(cd "$(dirname "$0")/.."; pwd -P)
pushd $ROOT_PATH > /dev/null

BUILD=$ROOT_PATH/build
export PROJECT_TEMP_DIR=$BUILD/temp
export SOURCE_DIR=$BUILD/src

if [ ! -d $SOURCE_DIR/memory ]; then
git clone --quiet --recurse-submodules --depth 1 $Foonathan_memory_repo $SOURCE_DIR/memory
fi
if [ ! -d $SOURCE_DIR/Fast-DDS ]; then
git clone --quiet --recurse-submodules --depth 1 $FastRTPS_repo $SOURCE_DIR/Fast-DDS
fi

export BUILT_PRODUCTS_DIR=$BUILD/macosx
export PLATFORM_NAME=macosx
export EFFECTIVE_PLATFORM_NAME=""
export ARCHS="x86_64 arm64"
script/fastrtps_build_apple.sh

export BUILT_PRODUCTS_DIR=$BUILD/maccatalyst
export PLATFORM_NAME=macosx
export EFFECTIVE_PLATFORM_NAME="-maccatalyst"
export ARCHS="x86_64 arm64"
script/fastrtps_build_apple.sh

export BUILT_PRODUCTS_DIR=$BUILD/iphoneos
export PLATFORM_NAME=iphoneos
export EFFECTIVE_PLATFORM_NAME="-iphoneos"
export ARCHS="armv7 armv7s arm64"
script/fastrtps_build_apple.sh

export BUILT_PRODUCTS_DIR=$BUILD/iphonesimulator
export PLATFORM_NAME=iphonesimulator
export EFFECTIVE_PLATFORM_NAME="-iphonesimulator"
export ARCHS="x86_64 arm64"
script/fastrtps_build_apple.sh

xcodebuild -create-xcframework \
-library $BUILD/macosx/lib/libfastrtpsa.a \
-headers $BUILD/macosx/include \
-library $BUILD/iphoneos/lib/libfastrtpsa.a \
-headers $BUILD/iphoneos/include \
-library $BUILD/iphonesimulator/lib/libfastrtpsa.a \
-headers $BUILD/iphonesimulator/include \
-library $BUILD/maccatalyst/lib/libfastrtpsa.a \
-headers $BUILD/maccatalyst/include \
-output FastDDS.xcframework
zip --recurse-paths --quiet $ZIPNAME FastDDS.xcframework
rm -rf FastDDS.xcframework

CHECKSUM=`shasum -a 256 -b $ZIPNAME | awk '{print $1}'`

cat >Package.swift << EOL
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "FastDDS",
products: [
.library(name: "FastDDS", targets: ["FastDDS"])
],
targets: [
.binaryTarget(name: "FastDDS",
url: "$DOWNLOAD_URL",
checksum: "$CHECKSUM")
]
)
EOL

popd > /dev/null

0 comments on commit 42b6561

Please sign in to comment.