package/pkg-cargo: allow building in a sub-directory
Some packages have their rust sources as a sub-directory, rather than at the root of the source tree. Do like we do for autotools-package, and use the package's _SRCDIR rather than the top-level directory $(@D). Additionally, in such a situation, it is more than probable that the Cargo.toml is also present in that sub-directory, so use that when vendoring the package. Signed-off-by: Yann E. MORIN <yann.morin@orange.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
parent
6d508d8e45
commit
6b59ed35a2
@ -73,6 +73,11 @@ A few additional variables, specific to the Cargo infrastructure, can
|
||||
also be defined. Many of them are only useful in very specific cases,
|
||||
typical packages will therefore only use a few of them.
|
||||
|
||||
* +FOO_SUBDIR+ may contain the name of a subdirectory inside the package
|
||||
that contains the Cargo.toml file. This is useful, if for example, it
|
||||
is not at the root of the tree extracted by the tarball. If
|
||||
+HOST_FOO_SUBDIR+ is not specified, it defaults to +FOO_SUBDIR+.
|
||||
|
||||
* +FOO_CARGO_ENV+ can be used to pass additional variables in the
|
||||
environment of +cargo+ invocations. It used at both build and
|
||||
installation time
|
||||
|
@ -71,6 +71,11 @@ $(2)_DOWNLOAD_DEPENDENCIES += host-rustc
|
||||
$(2)_DOWNLOAD_POST_PROCESS = cargo
|
||||
$(2)_DL_ENV += CARGO_HOME=$$(HOST_DIR)/share/cargo
|
||||
|
||||
# If building in a sub directory, use that to find the Cargo.toml
|
||||
ifneq ($$($(2)_SUBDIR),)
|
||||
$(2)_DL_ENV += BR_CARGO_MANIFEST_PATH=$$($(2)_SUBDIR)/Cargo.toml
|
||||
endif
|
||||
|
||||
# Due to vendoring, it is pretty likely that not all licenses are
|
||||
# listed in <pkg>_LICENSE.
|
||||
$(2)_LICENSE += , vendored dependencies licenses probably not listed
|
||||
@ -97,7 +102,7 @@ $(2)_LICENSE += , vendored dependencies licenses probably not listed
|
||||
ifndef $(2)_BUILD_CMDS
|
||||
ifeq ($(4),target)
|
||||
define $(2)_BUILD_CMDS
|
||||
cd $$(@D) && \
|
||||
cd $$($$(PKG)_SRCDIR) && \
|
||||
$$(TARGET_MAKE_ENV) \
|
||||
$$(TARGET_CONFIGURE_OPTS) \
|
||||
$$(PKG_CARGO_ENV) \
|
||||
@ -111,7 +116,7 @@ define $(2)_BUILD_CMDS
|
||||
endef
|
||||
else # ifeq ($(4),target)
|
||||
define $(2)_BUILD_CMDS
|
||||
cd $$(@D) && \
|
||||
cd $$($$(PKG)_SRCDIR) && \
|
||||
$$(HOST_MAKE_ENV) \
|
||||
RUSTFLAGS="$$(addprefix -C link-args=,$$(HOST_LDFLAGS))" \
|
||||
$$(HOST_CONFIGURE_OPTS) \
|
||||
@ -133,7 +138,7 @@ endif # ifndef $(2)_BUILD_CMDS
|
||||
#
|
||||
ifndef $(2)_INSTALL_TARGET_CMDS
|
||||
define $(2)_INSTALL_TARGET_CMDS
|
||||
cd $$(@D) && \
|
||||
cd $$($$(PKG)_SRCDIR) && \
|
||||
$$(TARGET_MAKE_ENV) \
|
||||
$$(TARGET_CONFIGURE_OPTS) \
|
||||
$$(PKG_CARGO_ENV) \
|
||||
@ -152,7 +157,7 @@ endif
|
||||
|
||||
ifndef $(2)_INSTALL_CMDS
|
||||
define $(2)_INSTALL_CMDS
|
||||
cd $$(@D) && \
|
||||
cd $$($$(PKG)_SRCDIR) && \
|
||||
$$(HOST_MAKE_ENV) \
|
||||
RUSTFLAGS="$$(addprefix -C link-args=,$$(HOST_LDFLAGS))" \
|
||||
$$(HOST_CONFIGURE_OPTS) \
|
||||
|
Loading…
Reference in New Issue
Block a user