diff options
| author | ruki <[email protected]> | 2023-11-22 17:12:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-22 17:12:12 +0800 |
| commit | 3333fb757efc9e1f521cb25d6bab47e05c83ffcc (patch) | |
| tree | 51795059c7018b1edf52a6824993157e8b81c203 | |
| parent | 0415ab4d9b7ba347aed638422a7b40885da2943e (diff) | |
| parent | fa2a32eb23112df93d2357679a5de486a7481ce0 (diff) | |
Merge pull request #4411 from xmake-io/msys
improve to install xmake for msys/mingw
| -rwxr-xr-x | configure | 50 | ||||
| -rwxr-xr-x | core/src/demo/xmake.sh | 13 | ||||
| -rw-r--r-- | xmake/modules/core/tools/armcc.lua | 4 |
3 files changed, 53 insertions, 14 deletions
@@ -686,15 +686,15 @@ _target_kind_default="static" # set the default project generator and build program if is_host "freebsd" "bsd"; then - _project_generator="gmake" + project_generator="gmake" _make_program_default="gmake" _ninja_program_default="ninja" elif is_host "msys" "cygwin"; then - _project_generator="gmake" + project_generator="gmake" _make_program_default="make.exe" _ninja_program_default="ninja.exe" else - _project_generator="gmake" + project_generator="gmake" _make_program_default="make" _ninja_program_default="ninja" fi @@ -2531,6 +2531,24 @@ add_options() { done } +# before_install in target +before_install() { + if ! ${_loading_targets}; then + return + fi + local funcname="${1}" + _add_target_item "${_xmake_sh_target_current}" "before_install" "${funcname}" +} + +# after_install in target +after_install() { + if ! ${_loading_targets}; then + return + fi + local funcname="${1}" + _add_target_item "${_xmake_sh_target_current}" "after_install" "${funcname}" +} + #----------------------------------------------------------------------------- # toolchain configuration apis # @@ -2686,7 +2704,7 @@ Common options: --verbose Display more information. --diagnosis Display lots of diagnosis information. - --generator=GENERATOR Set the project generator. (default: '"${_project_generator}"') + --generator=GENERATOR Set the project generator. (default: '"${project_generator}"') - gmake - ninja --make=MAKE Set the make program. (default: '"${_make_program_default}"') @@ -2791,7 +2809,7 @@ _handle_option() { _target_toolchain=${value} return 0 elif test_eq "${name}" "generator"; then - _project_generator=${value} + project_generator=${value} return 0 elif test_eq "${name}" "make"; then _make_program=${value} @@ -3310,9 +3328,9 @@ _toolchain_detect_ninja() { # detect build backend _toolchain_detect_backend() { - if test "x${_project_generator}" = "xgmake"; then + if test "x${project_generator}" = "xgmake"; then _toolchain_detect_make - elif test "x${_project_generator}" = "xninja"; then + elif test "x${project_generator}" = "xninja"; then _toolchain_detect_ninja fi } @@ -4190,6 +4208,12 @@ _gmake_add_install_target() { installdir="\$(INSTALLDIR)" fi + # before install + _get_target_item "${target}" "before_install"; local before_install="${_ret}" + if test_nz "${before_install}"; then + eval ${before_install} "\${target}" "\${installdir}" + fi + # @see https://github.com/tboox/tbox/issues/214 install_for_soname=false if test_eq "${targetkind}" "shared"; then @@ -4287,6 +4311,12 @@ _gmake_add_install_target() { print "\t@cp -p ${srcinstallfile} ${dstinstallfile}" >> "${xmake_sh_makefile}" done fi + + # after install + _get_target_item "${target}" "after_install"; local after_install="${_ret}" + if test_nz "${after_install}"; then + eval ${after_install} "\${target}" "\${installdir}" + fi } _gmake_add_install_targets() { @@ -4343,12 +4373,12 @@ _generate_for_ninja() { # _generate_build_file() { - if test_eq "${_project_generator}" "gmake"; then + if test_eq "${project_generator}" "gmake"; then _generate_for_gmake - elif test_eq "${_project_generator}" "ninja"; then + elif test_eq "${project_generator}" "ninja"; then _generate_for_ninja else - raise "unknown generator: ${_project_generator}" + raise "unknown generator: ${project_generator}" fi } _generate_build_file diff --git a/core/src/demo/xmake.sh b/core/src/demo/xmake.sh index d91b50d99..2969eb13c 100755 --- a/core/src/demo/xmake.sh +++ b/core/src/demo/xmake.sh @@ -39,8 +39,7 @@ target "demo" # # @see https://github.com/xmake-io/xmake/issues/3628 if is_host "msys"; then - add_installfiles "${projectdir}/scripts/msys/xmake.sh" "bin" "xmake" - add_installfiles "${buildir}/xmake.exe" "share/xmake" + after_install "xmake_after_install" fi # add syslinks @@ -56,3 +55,13 @@ target "demo" else add_syslinks "pthread" "dl" "m" "c" fi + +xmake_after_install() { + local target=${1} + local installdir=${2} + if test_eq "${project_generator}" "gmake"; then + print "\t@if test -f ${installdir}/bin/xmake.exe; then rm ${installdir}/bin/xmake.exe; fi" >> "${xmake_sh_makefile}" + print "\t@cp ${projectdir}/scripts/msys/xmake.sh ${installdir}/bin/xmake" >> "${xmake_sh_makefile}" + print "\t@cp ${buildir}/xmake.exe ${installdir}/share/xmake" >> "${xmake_sh_makefile}" + fi +} diff --git a/xmake/modules/core/tools/armcc.lua b/xmake/modules/core/tools/armcc.lua index 9121e3a04..b4c349873 100644 --- a/xmake/modules/core/tools/armcc.lua +++ b/xmake/modules/core/tools/armcc.lua @@ -135,7 +135,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) try { function () - + local compflags = flags if depfile then compflags = table.join(compflags, "--depend", depfile) @@ -181,7 +181,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) end cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n')) end - + -- generate the dependent includes if depfile and os.isfile(depfile) then if dependinfo then |
