|
@@ -27,6 +27,7 @@ xmake_sh_version="1.0.2"
|
|
xmake_sh_verbose=false
|
|
xmake_sh_verbose=false
|
|
xmake_sh_diagnosis=false
|
|
xmake_sh_diagnosis=false
|
|
xmake_sh_copyright="Copyright (C) 2022-present Ruki Wang, tboox.org, xmake.io."
|
|
xmake_sh_copyright="Copyright (C) 2022-present Ruki Wang, tboox.org, xmake.io."
|
|
|
|
+xmake_sh_makefile="${xmake_sh_projectdir}/makefile"
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
#-----------------------------------------------------------------------------
|
|
# some helper functions
|
|
# some helper functions
|
|
@@ -2660,7 +2661,7 @@ _toolchain_linkcmd() {
|
|
case "${toolname}" in
|
|
case "${toolname}" in
|
|
gcc) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
gcc) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
gxx) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
gxx) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
- clang) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; compcmd="${_ret}";;
|
|
|
|
|
|
+ clang) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
clangxx) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
clangxx) _toolchain_linkcmd_for_gcc_clang "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
ar) _toolchain_linkcmd_for_ar "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
ar) _toolchain_linkcmd_for_ar "${toolkind}" "${program}" "${binaryfile}" "${objectfiles}" "${flags}"; linkcmd="${_ret}";;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
@@ -3405,14 +3406,14 @@ _gmake_add_header() {
|
|
echo "# this is the build file for this project
|
|
echo "# this is the build file for this project
|
|
# it is autogenerated by the xmake.sh build system.
|
|
# it is autogenerated by the xmake.sh build system.
|
|
# do not edit by hand.
|
|
# do not edit by hand.
|
|
-" > "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+" > "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_switches() {
|
|
_gmake_add_switches() {
|
|
- echo "ifneq (\$(VERBOSE),1)" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "V=@" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "endif" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "ifneq (\$(VERBOSE),1)" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "V=@" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "endif" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_flags() {
|
|
_gmake_add_flags() {
|
|
@@ -3422,9 +3423,9 @@ _gmake_add_flags() {
|
|
_get_target_flags "${target}" "${kind}"; local flags="${_ret}"
|
|
_get_target_flags "${target}" "${kind}"; local flags="${_ret}"
|
|
_get_flagname "${kind}"; local flagname="${_ret}"
|
|
_get_flagname "${kind}"; local flagname="${_ret}"
|
|
local key="${target}_${flagname}"
|
|
local key="${target}_${flagname}"
|
|
- echo "${key}=${flags}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "${key}=${flags}" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3433,9 +3434,9 @@ _gmake_add_toolchains() {
|
|
for kind in ${kinds}; do
|
|
for kind in ${kinds}; do
|
|
_get_toolchain_toolset "${_target_toolchain}" "${kind}"; local program="${_ret}"
|
|
_get_toolchain_toolset "${_target_toolchain}" "${kind}"; local program="${_ret}"
|
|
local key="${kind}"
|
|
local key="${kind}"
|
|
- echo "${key}=${program}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "${key}=${program}" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_build_object_for_gcc_clang() {
|
|
_gmake_add_build_object_for_gcc_clang() {
|
|
@@ -3444,8 +3445,8 @@ _gmake_add_build_object_for_gcc_clang() {
|
|
local objectfile="${3}"
|
|
local objectfile="${3}"
|
|
local flagname="${4}"
|
|
local flagname="${4}"
|
|
path_directory "${objectfile}"; local objectdir="${_ret}"
|
|
path_directory "${objectfile}"; local objectdir="${_ret}"
|
|
- print "\t@mkdir -p ${objectdir}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t\$(V)\$(${kind}) -c \$(${flagname}) -o ${objectfile} ${sourcefile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${objectdir}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t\$(V)\$(${kind}) -c \$(${flagname}) -o ${objectfile} ${sourcefile}" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_build_object() {
|
|
_gmake_add_build_object() {
|
|
@@ -3457,8 +3458,8 @@ _gmake_add_build_object() {
|
|
path_toolname "${program}"; local toolname="${_ret}"
|
|
path_toolname "${program}"; local toolname="${_ret}"
|
|
_get_flagname "${sourcekind}"; local flagname="${_ret}"
|
|
_get_flagname "${sourcekind}"; local flagname="${_ret}"
|
|
flagname="${target}_${flagname}"
|
|
flagname="${target}_${flagname}"
|
|
- echo "${objectfile}: ${sourcefile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@echo compiling.${_target_mode} ${sourcefile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "${objectfile}: ${sourcefile}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@echo compiling.${_target_mode} ${sourcefile}" >> "${xmake_sh_makefile}"
|
|
case "${toolname}" in
|
|
case "${toolname}" in
|
|
gcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
gcc) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
gxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
gxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
@@ -3466,7 +3467,7 @@ _gmake_add_build_object() {
|
|
clangxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
clangxx) _gmake_add_build_object_for_gcc_clang "${sourcekind}" "${sourcefile}" "${objectfile}" "${flagname}";;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
esac
|
|
esac
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_build_objects() {
|
|
_gmake_add_build_objects() {
|
|
@@ -3484,8 +3485,8 @@ _gmake_add_build_target_for_gcc_clang() {
|
|
local objectfiles="${3}"
|
|
local objectfiles="${3}"
|
|
local flagname="${4}"
|
|
local flagname="${4}"
|
|
path_directory "${targetfile}"; local targetdir="${_ret}"
|
|
path_directory "${targetfile}"; local targetdir="${_ret}"
|
|
- print "\t@mkdir -p ${targetdir}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t\$(V)\$(${kind}) -o ${targetfile} ${objectfiles} \$(${flagname})" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${targetdir}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t\$(V)\$(${kind}) -o ${targetfile} ${objectfiles} \$(${flagname})" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_build_target_for_ar() {
|
|
_gmake_add_build_target_for_ar() {
|
|
@@ -3494,8 +3495,8 @@ _gmake_add_build_target_for_ar() {
|
|
local objectfiles="${3}"
|
|
local objectfiles="${3}"
|
|
local flagname="${4}"
|
|
local flagname="${4}"
|
|
path_directory "${targetfile}"; local targetdir="${_ret}"
|
|
path_directory "${targetfile}"; local targetdir="${_ret}"
|
|
- print "\t@mkdir -p ${targetdir}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t\$(V)\$(${kind}) \$(${flagname}) ${flags} ${targetfile} ${objectfiles}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${targetdir}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t\$(V)\$(${kind}) \$(${flagname}) ${flags} ${targetfile} ${objectfiles}" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_build_target() {
|
|
_gmake_add_build_target() {
|
|
@@ -3522,9 +3523,9 @@ _gmake_add_build_target() {
|
|
flagname="${target}_${flagname}"
|
|
flagname="${target}_${flagname}"
|
|
|
|
|
|
# link target
|
|
# link target
|
|
- echo "${target}: ${targetfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "${targetfile}: ${deps}${objectfiles}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@echo linking.${_target_mode} ${targetfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "${target}: ${targetfile}" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "${targetfile}: ${deps}${objectfiles}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@echo linking.${_target_mode} ${targetfile}" >> "${xmake_sh_makefile}"
|
|
case "${toolname}" in
|
|
case "${toolname}" in
|
|
gcc) _gmake_add_build_target_for_gcc_clang "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
gcc) _gmake_add_build_target_for_gcc_clang "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
gxx) _gmake_add_build_target_for_gcc_clang "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
gxx) _gmake_add_build_target_for_gcc_clang "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
@@ -3533,7 +3534,7 @@ _gmake_add_build_target() {
|
|
ar) _gmake_add_build_target_for_ar "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
ar) _gmake_add_build_target_for_ar "${toolkind}" "${targetfile}" "${objectfiles}" "${flagname}";;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
*) raise "unknown toolname(${toolname})!" ;;
|
|
esac
|
|
esac
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
|
|
|
|
# build objects
|
|
# build objects
|
|
_gmake_add_build_objects "${target}"
|
|
_gmake_add_build_objects "${target}"
|
|
@@ -3546,10 +3547,10 @@ _gmake_add_build_targets() {
|
|
defaults="${defaults} ${target}"
|
|
defaults="${defaults} ${target}"
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
- echo "default:${defaults}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "all:${_xmake_sh_targets}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo ".PHONY: default all" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "default:${defaults}" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "all:${_xmake_sh_targets}" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo ".PHONY: default all" >> "${xmake_sh_makefile}"
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
for target in ${_xmake_sh_targets}; do
|
|
for target in ${_xmake_sh_targets}; do
|
|
_gmake_add_build_target "${target}"
|
|
_gmake_add_build_target "${target}"
|
|
done
|
|
done
|
|
@@ -3562,7 +3563,7 @@ _gmake_add_build() {
|
|
_gmake_add_run_target() {
|
|
_gmake_add_run_target() {
|
|
local target=${1}
|
|
local target=${1}
|
|
_get_target_file "${target}"; local targetfile="${_ret}"
|
|
_get_target_file "${target}"; local targetfile="${_ret}"
|
|
- print "\t@${targetfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@${targetfile}" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_run_targets() {
|
|
_gmake_add_run_targets() {
|
|
@@ -3575,11 +3576,11 @@ _gmake_add_run_targets() {
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
- echo "run:${targets}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "run:${targets}" >> "${xmake_sh_makefile}"
|
|
for target in ${targets}; do
|
|
for target in ${targets}; do
|
|
_gmake_add_run_target "${target}"
|
|
_gmake_add_run_target "${target}"
|
|
done
|
|
done
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_run() {
|
|
_gmake_add_run() {
|
|
@@ -3590,9 +3591,9 @@ _gmake_add_clean_target() {
|
|
local target=${1}
|
|
local target=${1}
|
|
_get_target_file "${target}"; local targetfile="${_ret}"
|
|
_get_target_file "${target}"; local targetfile="${_ret}"
|
|
_get_target_objectfiles "${target}"; local objectfiles="${_ret}"
|
|
_get_target_objectfiles "${target}"; local objectfiles="${_ret}"
|
|
- print "\t@rm ${targetfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@rm ${targetfile}" >> "${xmake_sh_makefile}"
|
|
for objectfile in ${objectfiles}; do
|
|
for objectfile in ${objectfiles}; do
|
|
- print "\t@rm ${objectfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@rm ${objectfile}" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3603,11 +3604,11 @@ _gmake_add_clean_targets() {
|
|
targets="${targets} ${target}"
|
|
targets="${targets} ${target}"
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
- echo "clean:${targets}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "clean:${targets}" >> "${xmake_sh_makefile}"
|
|
for target in ${targets}; do
|
|
for target in ${targets}; do
|
|
_gmake_add_clean_target "${target}"
|
|
_gmake_add_clean_target "${target}"
|
|
done
|
|
done
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_clean() {
|
|
_gmake_add_clean() {
|
|
@@ -3626,11 +3627,11 @@ _gmake_add_install_target() {
|
|
# install target file
|
|
# install target file
|
|
_get_target_item "${target}" "kind"; local targetkind="${_ret}"
|
|
_get_target_item "${target}" "kind"; local targetkind="${_ret}"
|
|
if test_eq "${targetkind}" "binary"; then
|
|
if test_eq "${targetkind}" "binary"; then
|
|
- print "\t@mkdir -p ${installdir}/${_install_bindir_default}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@cp -p ${targetfile} ${installdir}/${_install_bindir_default}/${filename}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${installdir}/${_install_bindir_default}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@cp -p ${targetfile} ${installdir}/${_install_bindir_default}/${filename}" >> "${xmake_sh_makefile}"
|
|
elif test_eq "${targetkind}" "static" || test_eq "${targetkind}" "shared"; then
|
|
elif test_eq "${targetkind}" "static" || test_eq "${targetkind}" "shared"; then
|
|
- print "\t@mkdir -p ${installdir}/${_install_libdir_default}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@cp -p ${targetfile} ${installdir}/${_install_libdir_default}/${filename}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${installdir}/${_install_libdir_default}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@cp -p ${targetfile} ${installdir}/${_install_libdir_default}/${filename}" >> "${xmake_sh_makefile}"
|
|
fi
|
|
fi
|
|
|
|
|
|
# install header files
|
|
# install header files
|
|
@@ -3653,8 +3654,8 @@ _gmake_add_install_target() {
|
|
dstheaderfile="${dstheaderdir}/${subfile}"
|
|
dstheaderfile="${dstheaderdir}/${subfile}"
|
|
fi
|
|
fi
|
|
path_directory "${dstheaderfile}"; dstheaderdir="${_ret}"
|
|
path_directory "${dstheaderfile}"; dstheaderdir="${_ret}"
|
|
- print "\t@mkdir -p ${dstheaderdir}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@cp -p ${srcheaderfile} ${dstheaderfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${dstheaderdir}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@cp -p ${srcheaderfile} ${dstheaderfile}" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
fi
|
|
fi
|
|
|
|
|
|
@@ -3677,8 +3678,8 @@ _gmake_add_install_target() {
|
|
dstinstallfile="${dstinstalldir}/${subfile}"
|
|
dstinstallfile="${dstinstalldir}/${subfile}"
|
|
fi
|
|
fi
|
|
path_directory "${dstinstallfile}"; dstinstalldir="${_ret}"
|
|
path_directory "${dstinstallfile}"; dstinstalldir="${_ret}"
|
|
- print "\t@mkdir -p ${dstinstalldir}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
- print "\t@cp -p ${srcinstallfile} ${dstinstallfile}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ print "\t@mkdir -p ${dstinstalldir}" >> "${xmake_sh_makefile}"
|
|
|
|
+ print "\t@cp -p ${srcinstallfile} ${dstinstallfile}" >> "${xmake_sh_makefile}"
|
|
done
|
|
done
|
|
fi
|
|
fi
|
|
}
|
|
}
|
|
@@ -3690,11 +3691,11 @@ _gmake_add_install_targets() {
|
|
targets="${targets} ${target}"
|
|
targets="${targets} ${target}"
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
- echo "install:${targets}" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "install:${targets}" >> "${xmake_sh_makefile}"
|
|
for target in ${targets}; do
|
|
for target in ${targets}; do
|
|
_gmake_add_install_target "${target}"
|
|
_gmake_add_install_target "${target}"
|
|
done
|
|
done
|
|
- echo "" >> "${xmake_sh_projectdir}/Makefile"
|
|
|
|
|
|
+ echo "" >> "${xmake_sh_makefile}"
|
|
}
|
|
}
|
|
|
|
|
|
_gmake_add_install() {
|
|
_gmake_add_install() {
|