KomodoOcean
KomodoOcean copied to clipboard
build system: unexpected behavior with build cmds path (native vs. system)
Let's imagine that we have following dependency declared in depends/packages
:
# dummy package to learn how recipes work
package=dummy
$(package)_version=1.0.0
$(package)_download_path=https://github.com/DeckerSU/dummy-package/archive/refs/tags/
$(package)_download_file=v$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=b56360df29a29205f36dfe888d320369b7c859ca205376a9ca25180a7c931796
$(package)_dependencies=rust
green:=$(shell tput setaf 10)
red:=$(shell tput setaf 9)
yellow:=$(shell tput setaf 11)
grey:=$(shell tput setaf 8)
reset:=$(shell tput sgr0)
$(info $(green)[ Dummy ]$(reset) Let's build the package ...)
# Example of making tool(s) variables
clang_prog=$(build_prefix)/bin/clang
clangxx_prog=$(clang_prog)++
cctools_TOOLS=AR RANLIB STRIP NM LIBTOOL OTOOL INSTALL_NAME_TOOL
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
$(foreach TOOL,$(cctools_TOOLS),$(eval special_$(TOOL) = $$(build_prefix)/bin/$$(host)-$(call lc,$(TOOL))))
$(foreach TOOL,$(cctools_TOOLS),$(info $(green)[ Dummy ]$(reset) $$(special_$(TOOL))=$(special_$(TOOL))))
define $(package)_set_vars
$(package)_conf_tool=./configure
$(package)_config_opts=--common-conf-option
$(package)_config_opts_linux=--just-a-linux-conf-option
$(package)_config_opts_mingw32=--special-windows-conf-option
endef
define $(package)_preprocess_cmds
echo "$(grey)--------------------------------------------$(reset)" && \
echo "Current directory: $(PWD)" && \
echo "Global variables: " && \
echo "$(grey)build_prefix:${reset} $(build_prefix)" && \
echo "Path variables: " && \
echo "$(grey)$(package)_staging_dir:${reset} $($(package)_staging_dir)" && \
echo "$(grey)$(package)_staging_prefix_dir:${reset} $($(package)_staging_prefix_dir)" && \
echo "$(grey)$(package)_extract_dir:${reset} $($(package)_extract_dir)" && \
echo "$(grey)$(package)_build_dir:${reset} $($(package)_build_dir)" && \
echo "$(grey)$(package)_build_subdir:${reset} $($(package)_build_subdir)" && \
echo "$(grey)$(package)_patch_dir:${reset} $($(package)_patch_dir)" && \
echo "Build variables: " && \
echo "$(grey)$(package)_cc :${reset} $($(package)_cc)" && \
echo "$(grey)$(package)_cxx :${reset} $($(package)_cxx)" && \
echo "$(grey)$(package)_objc :${reset} $($(package)_objc)" && \
echo "$(grey)$(package)_objcxx :${reset} $($(package)_objcxx)" && \
echo "$(grey)$(package)_ar :${reset} $($(package)_ar)" && \
echo "$(grey)$(package)_ranlib :${reset} $($(package)_ranlib)" && \
echo "$(grey)$(package)_libtool :${reset} $($(package)_libtool)" && \
echo "$(grey)$(package)_nm :${reset} $($(package)_nm)" && \
echo "$(grey)$(package)_cflags :${reset} $($(package)_cflags)" && \
echo "$(grey)$(package)_cxxflags :${reset} $($(package)_cxxflags)" && \
echo "$(grey)$(package)_ldflags :${reset} $($(package)_ldflags)" && \
echo "$(grey)$(package)_cppflags :${reset} $($(package)_cppflags)" && \
echo "$(grey)$(package)_config_env :${reset} $($(package)_config_env)" && \
echo "$(grey)$(package)_build_env :${reset} $($(package)_build_env)" && \
echo "$(grey)$(package)_stage_env :${reset} $($(package)_stage_env)" && \
echo "$(grey)$(package)_build_opts :${reset} $($(package)_build_opts)" && \
echo "$(grey)$(package)_config_opts:${reset} $($(package)_config_opts)" && \
echo "$(grey)--------------------------------------------$(reset)"
endef
#
define $(package)_config_cmds
echo "$(yellow)$($(package)_conf_tool) $($(package)_config_opts)$(reset)"
endef
define $(package)_build_cmds
echo "Let's build it ... " && cargo --version
endef
define $(package)_stage_cmds
cp LICENSE $($(package)_staging_prefix_dir) && \
cp README.md $($(package)_staging_prefix_dir)
endef
As we are see it depends on rust package:
$(package)_dependencies=rust
which version is declared here:
https://github.com/DeckerSU/KomodoOcean/blob/static/depends/packages/rust.mk#L2
and have build commands like this:
define $(package)_build_cmds
echo "Let's build it ... " && cargo --version
endef
Also we have system-wide installed cargo version cargo 1.65.0 (4bc8f24d3 2022-10-20)
. Expected behavior of executing:
make -C ${PWD}/depends HOST=$(depends/config.guess) -j$(nproc --all) dummy
Should be output of native (!) cargo version built from rust.mk
, i.e. 1.36
in this case (!), but instead of this we see:
Building dummy...
Let's build it ...
cargo 1.65.0 (4bc8f24d3 2022-10-20)
So the recipe used system wide cargo (!). But if we will change build commands on:
define $(package)_build_cmds
cargo --version
endef
The output will be:
Building dummy...
cargo 1.36.0 (c4fcfb725 2019-05-15)
as expected.
Don't get trapped with this.
Once again, in case of:
define $(package)_build_cmds
echo "Let's build it ... " && command -v cargo
endef
It will use system-wide cargo:
Building dummy...
Let's build it ...
/home/decker/.cargo/bin/cargo
and in case of:
define $(package)_build_cmds
command -v cargo
endef
it will use built package from rust.mk
as expected:
Building dummy...
/home/decker/depends/x86_64-unknown-linux-gnu/native/bin/cargo
Don't be confused by this.