Skip to content

Commit

Permalink
feat: export symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Oct 19, 2022
1 parent 1da24c2 commit 65a7945
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/
.idea/
iris_event.iml
macos/iris_event_handler.framework
macos/iris_event_handler.framework.dSYM
iris_event_handler.podspec
windows/third_party/
.vscode/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

iris_event is a bridge of iris event handling between C/C++ and dart, which is only used internally, **NOTE** that you should not use it.

## Build
```
bash cxx/build-<platform>.sh $(pwd)/cxx <output-path> <build-type>
```

## License

The project is under the MIT license.
68 changes: 67 additions & 1 deletion cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,47 @@ set(LIBRARY_NAME iris_event_handler)

set(IRIS_EVENT_VERSION "1.4.2")

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(IRIS_EVENT_DEBUG 1)
else ()
set(IRIS_EVENT_DEBUG 0)
endif ()
message(STATUS "IRIS_EVENT_DEBUG ${IRIS_EVENT_DEBUG}")

set(MACOSX_DEPLOYMENT_TARGET "10.11")

if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG")
else ()
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g")
endif ()

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${MACOSX_DEPLOYMENT_TARGET})
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")

if (MSVC)
if (NOT IRIS_EVENT_DEBUG)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
)
else()
add_compile_options(
$<$<CONFIG:>:/MD> #---------|
$<$<CONFIG:Debug>:/MDd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MD> #--|
)
endif ()
endif ()
endif ()

set(SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/iris_event.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/iris_event.cc"
Expand All @@ -37,12 +78,35 @@ add_library(${LIBRARY_NAME} SHARED
${SOURCES}
)

set_target_properties(${LIBRARY_NAME} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

target_include_directories(${LIBRARY_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/dart-sdk/include"
)

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
if (NOT IRIS_EVENT_DEBUG)
add_custom_command(
TARGET ${LIBRARY_NAME}
POST_BUILD
COMMAND cp -RP
"${CMAKE_BINARY_DIR}/lib${LIBRARY_NAME}.so"
"${CMAKE_BINARY_DIR}/lib${LIBRARY_NAME}Symbol.so"
)
add_custom_command(
TARGET ${LIBRARY_NAME}
POST_BUILD
COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" -g -S -d --strip-debug --verbose
"${CMAKE_BINARY_DIR}/lib${LIBRARY_NAME}.so"
COMMENT "Strip debug symbols done on final binary."
)
endif ()
elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
set_target_properties(${LIBRARY_NAME} PROPERTIES
FRAMEWORK TRUE
Expand All @@ -51,6 +115,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${IRIS_EVENT_VERSION}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${IRIS_EVENT_VERSION}"
CXX_VISIBILITY_PRESET hidden
COMPILE_OPTIONS "-g"
)
set(FRAMEWORKS
"-framework Foundation"
Expand All @@ -62,14 +127,15 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
)

elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.11")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${MACOSX_DEPLOYMENT_TARGET})
set_target_properties(${LIBRARY_NAME} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_FRAMEWORK_IDENTIFIER io.agora.iris.event
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${IRIS_EVENT_VERSION}"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${IRIS_EVENT_VERSION}"
CXX_VISIBILITY_PRESET hidden
COMPILE_OPTIONS "-g"
)
set(FRAMEWORKS
"-framework Foundation"
Expand Down
7 changes: 7 additions & 0 deletions cxx/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ do
mkdir -p $OUT_DIR/$ABI
fi

if [ ! -d "$OUT_DIR/symbols/$ABI" ]; then
mkdir -p $OUT_DIR/symbols/$ABI
fi

# rm -rf ${OUT_DIR}/iris_event_handler.framework
cp -RP "$IRIS_EVENT_DIR/build/android/$ABI/libiris_event_handler.so" "$OUT_DIR/$ABI/libiris_event_handler.so"
if [[ -f "$IRIS_EVENT_DIR/build/android/$ABI/libiris_event_handlerSymbol.so" ]]; then
cp -RP "$IRIS_EVENT_DIR/build/android/$ABI/libiris_event_handlerSymbol.so" "$OUT_DIR/symbols/$ABI/libiris_event_handlerSymbol.so"
fi
done;

# rm -rf iris_android.zip
Expand Down
38 changes: 20 additions & 18 deletions cxx/build-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ done;
rm -rf "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE"
mkdir -p "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE"

# /Users/fenglang/codes/aw/ng/agora_rtc_ng/iris_event/cxx/build/ios/SIMULATOR64/Debug-iphonesimulator/iris_event_handler.framework

# /Users/fenglang/codes/aw/ng/agora_rtc_ng/iris_event/cxx/build/ios/OS64COMBINED/Debug-iphoneos/iris_event_handler.framework

xcodebuild -create-xcframework \
-framework "${IRIS_EVENT_DIR}/build/ios/OS64COMBINED/$BUILD_TYPE-iphoneos/iris_event_handler.framework" \
-framework "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/$BUILD_TYPE-iphonesimulator/iris_event_handler.framework" \
-output "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework"

echo "start create .framework ----------"
cp -RP "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework" "${OUT_DIR}"
# # lipo -remove arm64 \
# # "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/output/dcg/$buildType/AgoraRtcWrapper.framework/AgoraRtcWrapper" \
# # -output "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/output/dcg/$buildType/AgoraRtcWrapper.framework/AgoraRtcWrapper"
# lipo -create \
# "${IRIS_EVENT_DIR}/build/ios/OS64COMBINED/output/dcg/$buildType/AgoraRtcWrapper.framework/AgoraRtcWrapper" \
# "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/output/dcg/$buildType/AgoraRtcWrapper.framework/AgoraRtcWrapper" \
# -output "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/output/dcg/$buildType/AgoraRtcWrapper.framework/AgoraRtcWrapper"
echo "start create .framework ----------"
xcodebuild -create-xcframework \
-framework "${IRIS_EVENT_DIR}/build/ios/OS64COMBINED/$BUILD_TYPE/iris_event_handler.framework" \
-debug-symbols "${IRIS_EVENT_DIR}/build/ios/OS64COMBINED/$BUILD_TYPE/iris_event_handler.framework.dSYM" \
-framework "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/$BUILD_TYPE/iris_event_handler.framework" \
-debug-symbols "${IRIS_EVENT_DIR}/build/ios/SIMULATOR64/$BUILD_TYPE/iris_event_handler.framework.dSYM" \
-output "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework"

mkdir -p ${OUT_DIR}/dSYMs
mkdir -p ${OUT_DIR}/dSYMs/ios-arm64_armv7
mkdir -p ${OUT_DIR}/dSYMs/ios-arm64_x86_64-simulator

cp -RP "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework/ios-arm64_armv7/dSYMs" "${OUT_DIR}/dSYMs/ios-arm64_armv7"
rm -rf "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework/ios-arm64_armv7/dSYMs"
cp -RP "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework/ios-arm64_x86_64-simulator/dSYMs" "${OUT_DIR}/dSYMs/ios-arm64_x86_64-simulator"
rm -rf "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework/ios-arm64_x86_64-simulator/dSYMs"

cp -RP "${IRIS_EVENT_DIR}/build/ios/ALL_ARCHITECTURE/$BUILD_TYPE/iris_event_handler.xcframework" "${OUT_DIR}"


4 changes: 4 additions & 0 deletions cxx/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ cmake --build . --config "$BUILD_TYPE"
popd

rm -rf ${OUT_DIR}/iris_event_handler.framework
rm -rf ${OUT_DIR}/iris_event_handler.framework.dSYM
cp -RP "${IRIS_EVENT_DIR}/build/macos/MAC/$BUILD_TYPE/iris_event_handler.framework" "${OUT_DIR}/iris_event_handler.framework"
if [[ -d "${IRIS_EVENT_DIR}/build/macos/MAC/$BUILD_TYPE/iris_event_handler.framework.dSYM" ]]; then
cp -RP "${IRIS_EVENT_DIR}/build/macos/MAC/$BUILD_TYPE/iris_event_handler.framework.dSYM" "${OUT_DIR}/iris_event_handler.framework.dSYM"
fi

# echo "Generating framework"
# lipo -create "$IRIS_EVENT_DIR/build/ios/OS64COMBINED/Debug-iphoneos/iris_event_handler.framework/iris_event_handler" "$IRIS_EVENT_DIR/build/ios/SIMULATOR64/Debug-iphonesimulator/iris_event_handler.framework/iris_event_handler" -output "$OUT_DIR/ios/iris_event_handler.framework/iris_event_handler"
5 changes: 5 additions & 0 deletions cxx/build-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ cmake \
cmake --build . --config "$BUILD_TYPE"
popd

ls ${IRIS_EVENT_DIR}/build/windows/x64/$BUILD_TYPE
cp -RP "${IRIS_EVENT_DIR}/build/windows/x64/$BUILD_TYPE/iris_event_handler.dll" "${OUT_DIR}/iris_event_handler.dll"
cp -RP "${IRIS_EVENT_DIR}/build/windows/x64/$BUILD_TYPE/iris_event_handler.lib" "${OUT_DIR}/iris_event_handler.lib"
if [[ -f "${IRIS_EVENT_DIR}/build/windows/x64/$BUILD_TYPE/iris_event_handler.pdb" ]]; then
cp -RP "${IRIS_EVENT_DIR}/build/windows/x64/$BUILD_TYPE/iris_event_handler.pdb" "${OUT_DIR}/iris_event_handler.pdb"
fi

# echo "Generating framework"
# lipo -create "$IRIS_EVENT_DIR/build/ios/OS64COMBINED/Debug-iphoneos/iris_event_handler.framework/iris_event_handler" "$IRIS_EVENT_DIR/build/ios/SIMULATOR64/Debug-iphonesimulator/iris_event_handler.framework/iris_event_handler" -output "$OUT_DIR/ios/iris_event_handler.framework/iris_event_handler"

0 comments on commit 65a7945

Please sign in to comment.