You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
4.8 KiB

  1. function( sign_kicad_bundle target signing_id use_secure_timestamp use_hardened_runtime entitlements_file)
  2. # If the signing ID wasn't passed in, use - which means adhoc signing
  3. if ( NOT signing_id )
  4. set( signing_id "-")
  5. endif()
  6. MESSAGE( STATUS "Signing ${target} with ${signing_id}, hardened runtime: ${use_hardened_runtime}, secure timestamp: ${use_secure_timestamp}, entitlements file: ${entitlements_file}" )
  7. # --deep doesn't really work and is officially deprecated as of macos 13
  8. # https://developer.apple.com/library/archive/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG201
  9. # collect a list of things to sign, in order
  10. set( sign_list "${target}/Contents/Applications/eeschema.app/Contents/MacOS/eeschema"
  11. "${target}/Contents/Applications/eeschema.app"
  12. "${target}/Contents/Applications/gerbview.app/Contents/MacOS/gerbview"
  13. "${target}/Contents/Applications/gerbview.app" "${target}/Contents/Applications/pcbnew.app/Contents/MacOS/pcbnew" "${target}/Contents/Applications/pcbnew.app" "${target}/Contents/Applications/bitmap2component.app/Contents/MacOS/bitmap2component" "${target}/Contents/Applications/bitmap2component.app" "${target}/Contents/Applications/pcb_calculator.app/Contents/MacOS/pcb_calculator" "${target}/Contents/Applications/pcb_calculator.app" "${target}/Contents/Applications/pl_editor.app/Contents/MacOS/pl_editor" "${target}/Contents/Applications/pl_editor.app")
  14. # Python things!
  15. if( EXISTS "${target}/Contents/Frameworks/Python.framework" )
  16. set( sign_list ${sign_list} "${target}/Contents/Frameworks/Python.framework/Versions/Current/share/doc/python3.9/examples/Tools/pynche"
  17. "${target}/Contents/Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python")
  18. file( GLOB python_bins "${target}/Contents/Frameworks/Python.framework/Versions/Current/bin/*" )
  19. # add dylib, .so and .a files from Contents/Frameworks/Python.framework/Versions/Current/lib/ and recursively
  20. file( GLOB_RECURSE python_libs ${sign_list} "${target}/Contents/Frameworks/Python.framework/Versions/Current/lib/*.dylib"
  21. "${target}/Contents/Frameworks/Python.framework/Versions/Current/lib/*.so"
  22. "${target}/Contents/Frameworks/Python.framework/Versions/Current/lib/*.a"
  23. "${target}/Contents/Frameworks/Python.framework/Versions/Current/lib/*.o" )
  24. set( sign_list ${sign_list} ${python_bins} ${python_libs} )
  25. endif( )
  26. set( sign_list ${sign_list} "${target}/Contents/Frameworks/Python.framework/Versions/Current/Resources/Python.app"
  27. "${target}/Contents/Frameworks/Python.framework" )
  28. # add all the dylibs from contents/frameworks
  29. file( GLOB framework_dylibs "${target}/Contents/Frameworks/*.dylib" )
  30. # add all the files in Contents/PlugIns
  31. file( GLOB_RECURSE plugins "${target}/Contents/PlugIns/*" )
  32. file( GLOB_RECURSE translations "${target}/Contents/SharedSupport/internat/*.mo" )
  33. # add all the files in Contents/MacOS/
  34. # But we've gotta sign kicad-cli before signing kicad, at least on x86_64
  35. set( kicad_bins "${target}/Contents/MacOS/dxf2idf"
  36. "${target}/Contents/MacOS/idf2vrml"
  37. "${target}/Contents/MacOS/idfcyl"
  38. "${target}/Contents/MacOS/idfrect"
  39. "${target}/Contents/MacOS/kicad-cli"
  40. "${target}/Contents/MacOS/kicad")
  41. set( sign_list ${sign_list} ${framework_dylibs} ${plugins} ${translations} ${kicad_bins} ) # do i need to quote this differently?
  42. # add kicad.app!
  43. set( sign_list ${sign_list} "${target}" )
  44. # build the command used for signing
  45. set( command codesign --force --sign "${signing_id}" )
  46. if( use_secure_timestamp )
  47. set( command ${command} --timestamp )
  48. endif( )
  49. if( use_hardened_runtime )
  50. if ( signing_id STREQUAL "-" )
  51. message( FATAL_ERROR "Hardened runtime requires a (non-ad-hoc) signing identity." )
  52. endif( )
  53. set( command ${command} --options runtime )
  54. endif( )
  55. if( entitlements_file )
  56. set( command ${command} --entitlements "${entitlements_file}" )
  57. endif( )
  58. foreach( item ${sign_list} )
  59. set( cmd ${command} "${item}" )
  60. # MESSAGE( STATUS "Running ${cmd}")
  61. execute_process( COMMAND ${cmd}
  62. RESULT_VARIABLE codesign_result)
  63. if( NOT codesign_result EQUAL 0 )
  64. message( WARNING "macOS signing failed; ${cmd} returned ${codesign_result}" )
  65. endif( )
  66. endforeach( )
  67. endfunction()
  68. function( verify_signing target )
  69. set( cmd codesign --verify --deep --strict --verbose=3 "${target}" )
  70. execute_process( COMMAND ${cmd} RESULT_VARIABLE verify_result )
  71. if( NOT verify_result EQUAL 0 )
  72. message( FATAL_ERROR "macOS signing verification failed; ran ${cmd}" )
  73. endif( )
  74. endfunction( )