From 6c84d54cc11a127fee0c83e38c61c6c648a93188 Mon Sep 17 00:00:00 2001 From: laggykiller Date: Sun, 10 Sep 2023 02:59:23 +0800 Subject: [PATCH] Test using lipo --- CMakeLists.txt | 26 ++++++++------------------ get_deps.py | 31 +++++++++++-------------------- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0b043a..799f331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,26 +46,16 @@ endif() # Add conan packages if ("${APNGASM_COMPILE_TARGET}" STREQUAL "universal2") - set(CONAN_TOOLCHAIN_1 ${CMAKE_SOURCE_DIR}/conan_output/armv8/conan_toolchain.cmake) - if (EXISTS ${CONAN_TOOLCHAIN_1}) - include(${CONAN_TOOLCHAIN_1}) - else() - message(WARNING "The conan_toolchain file could not be found: ${CONAN_TOOLCHAIN_1}") - endif() - - set(CONAN_TOOLCHAIN_2 ${CMAKE_SOURCE_DIR}/conan_output/x86_64/conan_toolchain.cmake) - if (EXISTS ${CONAN_TOOLCHAIN_2}) - include(${CONAN_TOOLCHAIN_2}) - else() - message(WARNING "The conan_toolchain file could not be found: ${CONAN_TOOLCHAIN_2}") - endif() + # x86_64 Contians static libraries that are universal2 + set(CONAN_TOOLCHAIN ${CMAKE_SOURCE_DIR}/conan_output/x86_64/conan_toolchain.cmake) else() set(CONAN_TOOLCHAIN ${CMAKE_SOURCE_DIR}/conan_output/${APNGASM_COMPILE_TARGET}/conan_toolchain.cmake) - if (EXISTS ${CONAN_TOOLCHAIN}) - include(${CONAN_TOOLCHAIN}) - else() - message(WARNING "The conan_toolchain file could not be found: ${CONAN_TOOLCHAIN}") - endif() +endif() + +if (EXISTS ${CONAN_TOOLCHAIN}) + include(${CONAN_TOOLCHAIN}) +else() + message(WARNING "The conan_toolchain file could not be found: ${CONAN_TOOLCHAIN}") endif() project(apngasm-python VERSION 1.0.6) diff --git a/get_deps.py b/get_deps.py index b38585e..4e46bf1 100755 --- a/get_deps.py +++ b/get_deps.py @@ -52,15 +52,15 @@ def install_deps(arch): 'conan', 'install', *[x for s in settings for x in ('-s', s)], *[x for b in build for x in ('-b', b)], - '-of', conan_output, '--deployer=full_deploy', '.' + '-of', conan_output, '--deployer=direct_deploy', '.' ]) return conan_output def main(): arch = get_arch() - if arch != 'universal2': - conan_output = os.path.join('conan_output', arch) + if arch == 'universal2': + conan_output = os.path.join('conan_output/x86_64') if os.path.isdir(conan_output): print('Dependencies found at:' + conan_output) print('Skip conan install...') @@ -79,24 +79,15 @@ def main(): if os.getenv('APNGASM_COMPILE_TARGET') == 'universal2': # Repeat to install the other architecture version of libwebp conan_output_x64 = install_deps('x86_64') - # conan_output_universal2 = conan_output.replace('armv8', 'universal2') - # shutil.rmtree(conan_output_universal2, ignore_errors=True) - # subprocess.run([ - # 'python3', 'lipo-dir-merge/lipo-dir-merge.py', - # conan_output_x64, conan_output, conan_output_universal2 - # ]) + conan_output_universal2 = conan_output.replace('armv8', 'universal2') + shutil.rmtree(conan_output_universal2, ignore_errors=True) + subprocess.run([ + 'python3', 'lipo-dir-merge/lipo-dir-merge.py', + conan_output_x64, conan_output, conan_output_universal2 + ]) - # with open(os.path.join(conan_output_universal2, 'CMakePresets.json')) as f: - # cmake_presets = f.read() - # cmake_presets = cmake_presets.replace('x86_64', 'universal2') - # with open(os.path.join(conan_output_universal2, 'CMakePresets.json'), 'w+') as f: - # f.write(cmake_presets) - - # with open(os.path.join(conan_output_universal2, 'conan_toolchain.cmake')) as f: - # conan_toolchain = f.read() - # conan_toolchain = conan_toolchain.replace('x86_64', 'universal2') - # with open(os.path.join(conan_output_universal2, 'conan_toolchain.cmake'), 'w+') as f: - # f.write(conan_toolchain) + shutil.rmtree(conan_output_x64) + shutil.move(conan_output_universal2, conan_output_x64) if __name__ == '__main__': main() \ No newline at end of file