Skip to content

Commit

Permalink
fix: Adressed linker errors due to duplicated symbols in draco and …
Browse files Browse the repository at this point in the history
…`dracodec_unity`.

- Consolidated dracodec_unity and dracoenc_unity into a single target named draco_unity
  • Loading branch information
atteneder committed Oct 24, 2023
1 parent ed48ab9 commit 643d2c4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 87 deletions.
83 changes: 32 additions & 51 deletions .github/workflows/unity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_mac
run: cmake --build build_mac --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_mac --config MinSizeRel --target draco_unity

- name: configure_ios
run: >
Expand All @@ -67,20 +67,17 @@ jobs:
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_ios
run: |
cmake --build build_ios --config MinSizeRel --target dracodec_unity dracoenc_unity
cmake --build build_ios --config MinSizeRel --target dracodec_unity dracoenc_unity -- -sdk iphonesimulator
cmake --build build_ios --config MinSizeRel --target draco_unity
cmake --build build_ios --config MinSizeRel --target draco_unity -- -sdk iphonesimulator
- name: package Apple
run: |
mkdir draco_apple
mkdir draco_apple/x86_64
mv build_mac/dracodec_unity.bundle draco_apple/x86_64
mv build_mac/dracoenc_unity.bundle draco_apple/x86_64
mv build_mac/draco_unity.bundle draco_apple/x86_64
mkdir -p draco_apple/iOS/simulator
mv build_ios/MinSizeRel-iphoneos/libdracodec_unity.a draco_apple/iOS
mv build_ios/MinSizeRel-iphoneos/libdracoenc_unity.a draco_apple/iOS
mv build_ios/MinSizeRel-iphonesimulator/libdracodec_unity.a draco_apple/iOS/simulator
mv build_ios/MinSizeRel-iphonesimulator/libdracoenc_unity.a draco_apple/iOS/simulator
mv build_ios/MinSizeRel-iphoneos/libdraco_unity.a draco_apple/iOS
mv build_ios/MinSizeRel-iphonesimulator/libdraco_unity.a draco_apple/iOS/simulator
- name: upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -102,7 +99,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_win64
run: cmake --build build_win_64 --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_win_64 --config MinSizeRel --target draco_unity

- name: configure_win32
run: >
Expand All @@ -111,7 +108,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_win32
run: cmake --build build_win_32 --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_win_32 --config MinSizeRel --target draco_unity

# Universal Windows Platform
- name: configure_uwp_arm
Expand All @@ -123,7 +120,7 @@ jobs:
-DCMAKE_SYSTEM_NAME:String=WindowsStore
-DCMAKE_SYSTEM_VERSION:String="10.0"
- name: build_uwp_arm
run: cmake --build build_uwp_arm --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_uwp_arm --config MinSizeRel --target draco_unity

- name: configure_uwp_arm64
run: >
Expand All @@ -134,7 +131,7 @@ jobs:
-DCMAKE_SYSTEM_NAME:String=WindowsStore
-DCMAKE_SYSTEM_VERSION:String="10.0"
- name: build_uwp_arm64
run: cmake --build build_uwp_arm64 --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_uwp_arm64 --config MinSizeRel --target draco_unity

- name: configure_uwp_x86
run: >
Expand All @@ -145,7 +142,7 @@ jobs:
-DCMAKE_SYSTEM_NAME:String=WindowsStore
-DCMAKE_SYSTEM_VERSION:String="10.0"
- name: build_uwp_x86
run: cmake --build build_uwp_x86 --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_uwp_x86 --config MinSizeRel --target draco_unity

- name: configure_uwp_x64
run: >
Expand All @@ -156,7 +153,7 @@ jobs:
-DCMAKE_SYSTEM_NAME:String=WindowsStore
-DCMAKE_SYSTEM_VERSION:String="10.0"
- name: build_uwp_x64
run: cmake --build build_uwp_x64 --config MinSizeRel --target dracodec_unity dracoenc_unity
run: cmake --build build_uwp_x64 --config MinSizeRel --target draco_unity

- name: package Windows
run: |
Expand All @@ -166,18 +163,12 @@ jobs:
mkdir draco_win/WSA/ARM64
mkdir draco_win/WSA/x86
mkdir draco_win/WSA/x64
mv build_win_32\MinSizeRel\dracodec_unity.dll draco_win/x86
mv build_win_32\MinSizeRel\dracoenc_unity.dll draco_win/x86
mv build_win_64\MinSizeRel\dracodec_unity.dll draco_win/x86_64
mv build_win_64\MinSizeRel\dracoenc_unity.dll draco_win/x86_64
mv build_uwp_arm\MinSizeRel\dracodec_unity.dll draco_win/WSA/ARM
mv build_uwp_arm\MinSizeRel\dracoenc_unity.dll draco_win/WSA/ARM
mv build_uwp_arm64\MinSizeRel\dracodec_unity.dll draco_win/WSA/ARM64
mv build_uwp_arm64\MinSizeRel\dracoenc_unity.dll draco_win/WSA/ARM64
mv build_uwp_x86\MinSizeRel\dracodec_unity.dll draco_win/WSA/x86
mv build_uwp_x86\MinSizeRel\dracoenc_unity.dll draco_win/WSA/x86
mv build_uwp_x64\MinSizeRel\dracodec_unity.dll draco_win/WSA/x64
mv build_uwp_x64\MinSizeRel\dracoenc_unity.dll draco_win/WSA/x64
mv build_win_32\MinSizeRel\draco_unity.dll draco_win/x86
mv build_win_64\MinSizeRel\draco_unity.dll draco_win/x86_64
mv build_uwp_arm\MinSizeRel\draco_unity.dll draco_win/WSA/ARM
mv build_uwp_arm64\MinSizeRel\draco_unity.dll draco_win/WSA/ARM64
mv build_uwp_x86\MinSizeRel\draco_unity.dll draco_win/WSA/x86
mv build_uwp_x64\MinSizeRel\draco_unity.dll draco_win/WSA/x64
- name: upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -220,7 +211,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_android_arm64-v8a
run: cmake --build build_android_arm64-v8a --target dracodec_unity dracoenc_unity -j
run: cmake --build build_android_arm64-v8a --target draco_unity -j

- name: configure_android_armeabi-v7a
run: >
Expand All @@ -233,7 +224,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_android_armeabi-v7a
run: cmake --build build_android_armeabi-v7a --target dracodec_unity dracoenc_unity -j
run: cmake --build build_android_armeabi-v7a --target draco_unity -j

- name: configure_android_x86
run: >
Expand All @@ -246,7 +237,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_android_x86_dracodec_unity
run: cmake --build build_android_x86 --target dracodec_unity dracoenc_unity -j
run: cmake --build build_android_x86 --target draco_unity -j

# # Emscripten
# - name: setup Emscripten
Expand All @@ -263,28 +254,21 @@ jobs:
# -DDRACO_GLTF_BITSTREAM=ON
# -DDRACO_BACKWARDS_COMPATIBILITY=OFF
# - name: build_webassembly_dracodec_unity
# run: cmake --build build_web --target dracodec_unity dracoenc_unity -j
# run: cmake --build build_web --target draco_unity -j

# Linux artifacts
- name: package Linux
run: |
# mkdir -p draco_linux/WebGL/2021
# mv build_web/libdracodec_unity.a draco_linux/WebGL/2021
# mv build_web/libdracoenc_unity.a draco_linux/WebGL/2021
# mv build_web/libdraco_unity.a draco_linux/WebGL/2021
mkdir -p draco_linux/Android/libs/arm64-v8a
mkdir -p draco_linux/Android/libs/armeabi-v7a
mkdir -p draco_linux/Android/libs/x86
mv build_android_arm64-v8a/libdracodec_unity.so \
mv build_android_arm64-v8a/libdraco_unity.so \
draco_linux/Android/libs/arm64-v8a
mv build_android_arm64-v8a/libdracoenc_unity.so \
draco_linux/Android/libs/arm64-v8a
mv build_android_armeabi-v7a/libdracodec_unity.so \
draco_linux/Android/libs/armeabi-v7a
mv build_android_armeabi-v7a/libdracoenc_unity.so \
mv build_android_armeabi-v7a/libdraco_unity.so \
draco_linux/Android/libs/armeabi-v7a
mv build_android_x86/libdracodec_unity.so \
draco_linux/Android/libs/x86
mv build_android_x86/libdracoenc_unity.so \
mv build_android_x86/libdraco_unity.so \
draco_linux/Android/libs/x86
- name: upload artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -321,14 +305,13 @@ jobs:
# -DDRACO_GLTF_BITSTREAM=ON \
# -DDRACO_BACKWARDS_COMPATIBILITY=OFF
# - name: build_webassembly_dracodec_unity
# run: cmake --build build_web --target dracodec_unity dracoenc_unity -j
# run: cmake --build build_web --target draco_unity -j

# # Artifacts
# - name: package
# run: |
# mkdir -p draco_emscripten_3/WebGL/2022
# mv build_web/libdracodec_unity.a draco_emscripten_3/WebGL/2022
# mv build_web/libdracoenc_unity.a draco_emscripten_3/WebGL/2022
# mv build_web/libdraco_unity.a draco_emscripten_3/WebGL/2022
# - name: upload artifact
# uses: actions/upload-artifact@v3
# with:
Expand Down Expand Up @@ -361,7 +344,7 @@ jobs:
-DDRACO_GLTF_BITSTREAM=ON
-DDRACO_BACKWARDS_COMPATIBILITY=OFF
- name: build_linux64_dracodec_unity
run: cmake --build build_linux_64 --target dracodec_unity dracoenc_unity -j
run: cmake --build build_linux_64 --target draco_unity -j

# # Emscripten 1
# - name: setup Emscripten 1
Expand All @@ -378,17 +361,15 @@ jobs:
# -DDRACO_GLTF_BITSTREAM=ON
# -DDRACO_BACKWARDS_COMPATIBILITY=OFF
# - name: build_webassembly_1_dracodec_unity
# run: cmake --build build_web --target dracodec_unity dracoenc_unity -j
# run: cmake --build build_web --target draco_unity -j

# Linux legacy artifacts
- name: package Linux legacy
run: |
mkdir -p draco_linux_legacy/x86_64
mv build_linux_64/libdracodec_unity.so draco_linux_legacy/x86_64
mv build_linux_64/libdracoenc_unity.so draco_linux_legacy/x86_64
mv build_linux_64/libdraco_unity.so draco_linux_legacy/x86_64
# mkdir -p draco_linux_legacy/WebGL/2020
# mv build_web/libdracodec_unity.bc draco_linux_legacy/WebGL/2020
# mv build_web/libdracoenc_unity.bc draco_linux_legacy/WebGL/2020
# mv build_web/libdraco_unity.bc draco_linux_legacy/WebGL/2020
- name: upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down
66 changes: 31 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1059,29 +1059,34 @@ else()
set(unity_decoder_lib_type MODULE)
endif()

set(unity_lib_dependency ${draco_plugin_dependency})
set(unity_objlib_dependency draco_unity_plugin)
if(EMSCRIPTEN OR IOS)
unset(unity_lib_dependency)
list(APPEND unity_objlib_dependency
# Link selected object libs directly instead of ${draco_plugin_dependency}
# minimizes build size
# results in a single static lib file
draco_attributes
draco_compression_attributes_dec
draco_compression_bit_coders
draco_compression_decode
draco_compression_entropy
draco_compression_mesh_dec
draco_compression_point_cloud_dec
draco_core
draco_mesh
draco_metadata
draco_metadata_dec
draco_point_cloud
draco_points_dec
)
endif()

list(APPEND unity_objlib_dependency
# Link selected object libs directly instead of ${draco_plugin_dependency}
# minimizes build size by omitting animation/IO/transcoder related symbols
# results in a single static lib file (no dependency on target `draco`)
draco_attributes
draco_compression_attributes_dec
draco_compression_attributes_enc
draco_compression_attributes_pred_schemes_dec
draco_compression_attributes_pred_schemes_enc
draco_compression_bit_coders
draco_compression_decode
draco_compression_encode
draco_compression_entropy
draco_compression_mesh_dec
draco_compression_mesh_enc
draco_compression_point_cloud_dec
draco_compression_point_cloud_enc
draco_core
draco_mesh
draco_metadata
draco_metadata_dec
draco_metadata_enc
draco_point_cloud
draco_points_dec
draco_points_enc
)

draco_add_library(
NAME draco_unity_plugin
Expand All @@ -1090,14 +1095,6 @@ else()
DEFINES ${draco_defines}
INCLUDES ${draco_include_paths})

draco_add_library(
NAME dracodec_unity
TYPE ${unity_decoder_lib_type}
DEFINES ${draco_defines}
INCLUDES ${draco_include_paths}
OBJLIB_DEPS ${unity_objlib_dependency}
LIB_DEPS ${unity_lib_dependency})

draco_add_library(
NAME draco_unity_enc_plugin
TYPE OBJECT
Expand All @@ -1106,17 +1103,16 @@ else()
INCLUDES ${draco_include_paths})

draco_add_library(
NAME dracoenc_unity
NAME draco_unity
TYPE ${unity_decoder_lib_type}
DEFINES ${draco_defines}
INCLUDES ${draco_include_paths}
OBJLIB_DEPS draco_unity_enc_plugin
LIB_DEPS ${draco_plugin_dependency})
OBJLIB_DEPS ${unity_objlib_dependency} draco_unity_enc_plugin
)

# For Mac, we need to build a .bundle for the unity plugin.
if(APPLE)
set_target_properties(dracodec_unity PROPERTIES BUNDLE true)
set_target_properties(dracoenc_unity PROPERTIES BUNDLE true)
set_target_properties(draco_unity PROPERTIES BUNDLE true)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/draco_install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ macro(draco_setup_install_target)
endif()

if(DRACO_UNITY_PLUGIN)
install(TARGETS dracodec_unity DESTINATION "${libs_path}")
install(TARGETS draco_unity DESTINATION "${libs_path}")
endif()

if(DRACO_MAYA_PLUGIN)
Expand Down

0 comments on commit 643d2c4

Please sign in to comment.