Skip to content

Commit

Permalink
Test using lipo
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Sep 9, 2023
1 parent 3760e98 commit 6c84d54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
26 changes: 8 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 11 additions & 20 deletions get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...')
Expand All @@ -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()

0 comments on commit 6c84d54

Please sign in to comment.