build 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  4. distdir=/var/tmp/dist/nss
  5. builddir=/var/tmp/build/[% project %]
  6. mkdir /var/tmp/build
  7. tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %]
  8. export PATH=/var/tmp/dist/ninja:$PATH
  9. nspr_64=""
  10. [% IF c("var/cross_prefix") == "armv7a-linux-androideabi" -%]
  11. gyp_arch="arm"
  12. [% ELSIF c("var/cross_prefix") == "i686-linux-android" -%]
  13. gyp_arch="ia32"
  14. [% ELSIF c("var/cross_prefix") == "x86_64-linux-android" -%]
  15. gyp_arch="x64"
  16. nspr_64="--enable-64bit"
  17. [% ELSIF c("var/cross_prefix") == "aarch64-linux-android" -%]
  18. gyp_arch="arm64"
  19. nspr_64="--enable-64bit"
  20. [% END -%]
  21. export AR="[% c('var/cross_prefix') %]-ar"
  22. # XXX: Mozilla really uses the NDK_API_VERSION here, which is weird.
  23. export CC="[% c('var/cross_prefix') %][% pc('android-toolchain', 'var/android_ndk_version') %]-clang"
  24. export CXX="[% c('var/cross_prefix') %][% pc('android-toolchain', 'var/android_ndk_version') %]-clang++"
  25. export LD="[% c('var/cross_prefix') %]-ld"
  26. export NM="[% c('var/cross_prefix') %]-nm"
  27. export RANLIB="[% c('var/cross_prefix') %]-ranlib"
  28. export READELF="[% c('var/cross_prefix') %]-readelf"
  29. tar -C /var/tmp/build -xf [% c('input_files_by_name/nss') %]
  30. mv /var/tmp/build/[% project %]-[% c('version') %] $builddir
  31. cd $builddir
  32. # Early return hack to prevent NSPR Android setup
  33. # which does not work with ndk unified headers and clang. See:
  34. # application-services/libs/build-all.sh
  35. cat $rootdir/configure.patch | patch nspr/configure
  36. # Some NSS symbols clash with OpenSSL symbols, rename them using
  37. # C preprocessor define macros. See:
  38. # application-services/libs/build-all.sh
  39. patch -p2 < $rootdir/config.patch
  40. # Let's apply our proxy bypass defense-in-depth here as well to be on the safe
  41. # side.
  42. patch -p2 < $rootdir/bug_13028.patch
  43. # Building NSPR
  44. mkdir $builddir/nspr_build
  45. cd $builddir/nspr_build
  46. ../nspr/configure \
  47. $nspr_64 \
  48. --target=[% IF c("arch") == "armv7" %]arm-linux-androideabi[% ELSE %][% c("var/cross_prefix") %][% END %] \
  49. --disable-debug \
  50. --enable-optimize
  51. make
  52. cd ..
  53. # Building NSS
  54. mkdir $builddir/nss_build
  55. gyp -f ninja-android "$builddir/nss/nss.gyp" \
  56. --depth "$builddir/nss/" \
  57. --generator-output=. \
  58. -DOS=android \
  59. -Dnspr_lib_dir="$builddir/nspr_build/dist/lib" \
  60. -Dnspr_include_dir="$builddir/nspr_build/dist/include/nspr" \
  61. -Dnss_dist_dir="$builddir/nss_build" \
  62. -Dnss_dist_obj_dir="$builddir/nss_build" \
  63. -Dhost_arch="$gyp_arch" \
  64. -Dtarget_arch="$gyp_arch" \
  65. -Dstatic_libs=1 \
  66. -Ddisable_dbm=1 \
  67. -Dsign_libs=0 \
  68. -Denable_sslkeylogfile=0 \
  69. -Ddisable_tests=1 \
  70. -Ddisable_libpkix=1
  71. gendir="$builddir/nss/out/Release"
  72. ninja -C "$gendir"
  73. mkdir -p $distdir/include/nss
  74. mkdir -p $distdir/lib
  75. cp -p -L "$builddir/nss_build/lib/libcertdb.a" "$distdir/lib"
  76. cp -p -L "$builddir/nss_build/lib/libcerthi.a" "$distdir/lib"
  77. cp -p -L "$builddir/nss_build/lib/libcryptohi.a" "$distdir/lib"
  78. cp -p -L "$builddir/nss_build/lib/libfreebl_static.a" "$distdir/lib"
  79. cp -p -L "$builddir/nss_build/lib/libnss_static.a" "$distdir/lib"
  80. cp -p -L "$builddir/nss_build/lib/libnssb.a" "$distdir/lib"
  81. cp -p -L "$builddir/nss_build/lib/libnssdev.a" "$distdir/lib"
  82. cp -p -L "$builddir/nss_build/lib/libnsspki.a" "$distdir/lib"
  83. cp -p -L "$builddir/nss_build/lib/libnssutil.a" "$distdir/lib"
  84. cp -p -L "$builddir/nss_build/lib/libpk11wrap_static.a" "$distdir/lib"
  85. cp -p -L "$builddir/nss_build/lib/libpkcs12.a" "$distdir/lib"
  86. cp -p -L "$builddir/nss_build/lib/libpkcs7.a" "$distdir/lib"
  87. cp -p -L "$builddir/nss_build/lib/libsmime.a" "$distdir/lib"
  88. cp -p -L "$builddir/nss_build/lib/libsoftokn_static.a" "$distdir/lib"
  89. cp -p -L "$builddir/nss_build/lib/libssl.a" "$distdir/lib"
  90. # HW specific.
  91. # https://searchfox.org/nss/rev/08c4d05078d00089f8d7540651b0717a9d66f87e/lib/freebl/freebl.gyp#278-296
  92. [% IF c("var/cross_prefix") == "i686-linux-android" || c("var/cross_prefix") == "x86_64-linux-android"-%]
  93. cp -p -L "$builddir/nss_build/lib/libgcm-aes-x86_c_lib.a" "$distdir/lib"
  94. [% END %]
  95. [% IF c("var/cross_prefix") == "armv7a-linux-androideabi" || c("var/cross_prefix") == "aarch64-linux-android"-%]
  96. cp -p -L "$builddir/nss_build/lib/libarmv8_c_lib.a" "$distdir/lib"
  97. [% END %]
  98. [% IF c("var/cross_prefix") == "aarch64-linux-android" -%]
  99. cp -p -L "$builddir/nss_build/lib/libgcm-aes-aarch64_c_lib.a" "$distdir/lib"
  100. [% END %]
  101. [% IF c("var/cross_prefix") == "armv7a-linux-androideabi" -%]
  102. cp -p -L "$builddir/nss_build/lib/libgcm-aes-arm32-neon_c_lib.a" "$distdir/lib"
  103. [% END %]
  104. # https://searchfox.org/nss/rev/08c4d05078d00089f8d7540651b0717a9d66f87e/lib/freebl/freebl.gyp#315-324
  105. # https://searchfox.org/nss/rev/08c4d05078d00089f8d7540651b0717a9d66f87e/lib/freebl/freebl.gyp#43-47
  106. [% IF c("var/cross_prefix") == "x86_64-linux-android"-%]
  107. cp -p -L "$builddir/nss_build/lib/libintel-gcm-wrap_c_lib.a" "$distdir/lib"
  108. cp -p -L "$builddir/nss_build/lib/libintel-gcm-s_lib.a" "$distdir/lib"
  109. cp -p -L "$builddir/nss_build/lib/libhw-acc-crypto-avx.a" "$distdir/lib"
  110. cp -p -L "$builddir/nss_build/lib/libhw-acc-crypto-avx2.a" "$distdir/lib"
  111. [% END %]
  112. cp -p -L "$builddir/nspr_build/dist/lib/libplc4.a" "$distdir/lib"
  113. cp -p -L "$builddir/nspr_build/dist/lib/libplds4.a" "$distdir/lib"
  114. cp -p -L "$builddir/nspr_build/dist/lib/libnspr4.a" "$distdir/lib"
  115. cp -p -L -R "$builddir/nss_build/public/nss/"* "$distdir/include/nss"
  116. cp -p -L -R "$builddir/nspr_build/dist/include/nspr/"* "$distdir/include/nss"
  117. cd /var/tmp/dist
  118. [% c('tar', {
  119. tar_src => [ project ],
  120. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  121. }) %]