sqlite3.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright (c) 2020, Michael Buesch
  2. # Copyright (c) 2019, Riverbank Computing Limited
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of source code must retain the above copyright notice,
  9. # this list of conditions and the following disclaimer.
  10. #
  11. # 2. Redistributions in binary form must reproduce the above copyright notice,
  12. # this list of conditions and the following disclaimer in the documentation
  13. # and/or other materials provided with the distribution.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. # POSSIBILITY OF SUCH DAMAGE.
  26. import os
  27. from pyqtdeploy.sysroot import ComponentBase, ComponentOption
  28. class sqlite3Component(ComponentBase):
  29. """ The sqlite3 component. """
  30. # The component options.
  31. options = [
  32. ComponentOption('source', required=True,
  33. help="The archive containing the source code."),
  34. ]
  35. def build(self, sysroot):
  36. """ Build zlib for the target. """
  37. archive = sysroot.find_file(self.source)
  38. sysroot.unpack_archive(archive)
  39. if sysroot.target_platform_name == 'android':
  40. # Configure the environment.
  41. original_path = sysroot.add_to_path(sysroot.android_toolchain_bin)
  42. os.environ['CROSS_PREFIX'] = sysroot.android_toolchain_prefix
  43. os.environ['CC'] = sysroot.android_toolchain_cc
  44. cflags = sysroot.android_toolchain_cflags
  45. # It isn't clear why this is needed, possibly a clang bug.
  46. if sysroot.target_arch_name == 'android-32' and sysroot.android_ndk_version >= (16, 0, 0):
  47. cflags.append('-fPIC')
  48. os.environ['CFLAGS'] = ' '.join(cflags)
  49. sysroot.run('./configure',
  50. "--host=arm-linux",
  51. '--prefix=' + sysroot.sysroot_dir)
  52. sysroot.run(sysroot.host_make,
  53. 'AR=' + sysroot.android_toolchain_prefix + 'ar cqs',
  54. 'install')
  55. del os.environ['CROSS_PREFIX']
  56. del os.environ['CC']
  57. del os.environ['CFLAGS']
  58. os.environ['PATH'] = original_path
  59. else:
  60. if sysroot.target_platform_name == 'ios':
  61. # Note that this doesn't create a library that can be used with
  62. # an x86-based simulator.
  63. os.environ['CFLAGS'] = '-fembed-bitcode -O3 -arch arm64 -isysroot ' + sysroot.apple_sdk
  64. sysroot.run('./configure',
  65. "--host=arm-linux",
  66. '--prefix=' + sysroot.sysroot_dir)
  67. sysroot.run(sysroot.host_make)
  68. sysroot.run(sysroot.host_make, 'install')
  69. if sysroot.target_platform_name == 'ios':
  70. del os.environ['CFLAGS']
  71. def configure(self, sysroot):
  72. """ Complete the configuration of the component. """
  73. sysroot.verify_source(self.source)