init_env.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-3.0-only
  3. #
  4. # Copyright (C) 2021 ImmortalWrt.org
  5. # --------------------------------------------------------
  6. # Init build dependencies for naiveproxy
  7. # Read args from shell
  8. target_arch="$1"
  9. cpu_type="$2"
  10. cpu_subtype="$3"
  11. toolchain_dir="$4"
  12. # Set arch info
  13. case "${target_arch}" in
  14. "aarch64")
  15. naive_arch="arm64"
  16. ;;
  17. "i386")
  18. naive_arch="x86"
  19. ;;
  20. "x86_64")
  21. naive_arch="x64"
  22. ;;
  23. *)
  24. naive_arch="${target_arch}"
  25. ;;
  26. esac
  27. # OS detection
  28. [ "$(uname)" != "Linux" -o "$(uname -m)" != "x86_64" ] && { echo -e "Support Linux AMD64 only."; exit 1; }
  29. # Create TMP dir
  30. mkdir -p "$PWD/tmp"
  31. export TMPDIR="$PWD/tmp"
  32. # Set ENV
  33. export DEPOT_TOOLS_WIN_TOOLCHAIN=0
  34. export naive_flags="
  35. is_official_build=true
  36. exclude_unwind_tables=true
  37. enable_resource_allowlist_generation=false
  38. symbol_level=0
  39. is_clang=true
  40. use_sysroot=false
  41. fatal_linker_warnings=false
  42. treat_warnings_as_errors=false
  43. enable_base_tracing=false
  44. use_udev=false
  45. use_aura=false
  46. use_ozone=false
  47. use_gio=false
  48. use_gtk=false
  49. use_platform_icu_alternatives=true
  50. use_glib=false
  51. disable_file_support=true
  52. enable_websockets=false
  53. use_kerberos=false
  54. enable_mdns=false
  55. enable_reporting=false
  56. include_transport_security_state_preload_list=false
  57. use_nss_certs=false
  58. enable_backup_ref_ptr_support=false
  59. enable_dangling_raw_ptr_checks=false
  60. target_os=\"openwrt\"
  61. target_cpu=\"${naive_arch}\"
  62. target_sysroot=\"${toolchain_dir}\""
  63. case "${target_arch}" in
  64. "arm")
  65. naive_flags+=" arm_version=0 arm_cpu=\"${cpu_type}\""
  66. case "${cpu_type}" in "arm1176jzf-s"|"arm926ej-s"|"mpcore"|"xscale") naive_flags+=" arm_use_thumb=false" ;; esac
  67. if [ -n "${cpu_subtype}" ]; then
  68. if grep -q "neon" <<< "${cpu_subtype}"; then
  69. neon_flag="arm_use_neon=true"
  70. else
  71. neon_flag="arm_use_neon=false"
  72. fi
  73. naive_flags+=" arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"
  74. else
  75. naive_flags+=" arm_float_abi=\"soft\" arm_use_neon=false"
  76. fi
  77. ;;
  78. "arm64")
  79. [ -n "${cpu_type}" ] && naive_flags+=" arm_cpu=\"${cpu_type}\""
  80. ;;
  81. "mipsel"|"mips64el")
  82. naive_flags+=" use_thin_lto=false chrome_pgo_phase=0"
  83. if [ -z "${cpu_type}" ]; then
  84. naive_flags+=" mips_arch_variant=\"r1\""
  85. else
  86. naive_flags+=" mips_arch_variant=\"r2\""
  87. fi
  88. if [ "${target_arch}" == "mipsel" ]; then
  89. if [ "${cpu_subtype}" == "24kf" ]; then
  90. naive_flags+=" mips_float_abi=\"hard\""
  91. else
  92. naive_flags+=" mips_float_abi=\"soft\""
  93. fi
  94. fi
  95. ;;
  96. esac