2
1

rust.mk 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ################################################################################
  2. #
  3. # rust
  4. #
  5. ################################################################################
  6. RUST_VERSION = 1.58.1
  7. RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz
  8. RUST_SITE = https://static.rust-lang.org/dist
  9. RUST_LICENSE = Apache-2.0 or MIT
  10. RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
  11. HOST_RUST_PROVIDES = host-rustc
  12. HOST_RUST_DEPENDENCIES = \
  13. toolchain \
  14. host-python3 \
  15. host-rust-bin \
  16. host-openssl \
  17. $(BR2_CMAKE_HOST_DEPENDENCY)
  18. HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0)
  19. # Some vendor crates contain Cargo.toml.orig files. The associated
  20. # .cargo-checksum.json file will contain a checksum for Cargo.toml.orig but
  21. # support/scripts/apply-patches.sh will delete them. This will cause the build
  22. # to fail, as Cargo will not be able to find the file and verify the checksum.
  23. # So, remove all Cargo.toml.orig entries from the affected .cargo-checksum.json
  24. # files
  25. define HOST_RUST_EXCLUDE_ORIG_FILES
  26. for file in $$(find $(@D) -name '*.orig'); do \
  27. crate=$$(dirname $${file}); \
  28. fn=$${crate}/.cargo-checksum.json; \
  29. sed -i -e 's/"Cargo.toml.orig":"[a-z0-9]\+",//g' $${fn}; \
  30. done
  31. endef
  32. HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_EXCLUDE_ORIG_FILES
  33. define HOST_RUST_CONFIGURE_CMDS
  34. ( \
  35. echo '[build]'; \
  36. echo 'target = ["$(RUSTC_TARGET_NAME)"]'; \
  37. echo 'cargo = "$(HOST_RUST_BIN_DIR)/cargo/bin/cargo"'; \
  38. echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \
  39. echo 'python = "$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR)"'; \
  40. echo 'submodules = false'; \
  41. echo 'vendor = true'; \
  42. echo 'extended = true'; \
  43. echo 'tools = ["cargo"]'; \
  44. echo 'compiler-docs = false'; \
  45. echo 'docs = false'; \
  46. echo 'verbose = $(HOST_RUST_VERBOSITY)'; \
  47. echo '[install]'; \
  48. echo 'prefix = "$(HOST_DIR)"'; \
  49. echo 'sysconfdir = "$(HOST_DIR)/etc"'; \
  50. echo '[rust]'; \
  51. echo 'channel = "stable"'; \
  52. echo '[target.$(RUSTC_TARGET_NAME)]'; \
  53. echo 'cc = "$(TARGET_CROSS)gcc"'; \
  54. echo '[llvm]'; \
  55. echo 'ninja = false'; \
  56. ) > $(@D)/config.toml
  57. endef
  58. define HOST_RUST_BUILD_CMDS
  59. cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py build
  60. endef
  61. define HOST_RUST_INSTALL_CMDS
  62. cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py dist
  63. cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py install
  64. endef
  65. $(eval $(host-generic-package))