2
0
Эх сурвалжийг харах

improve option and target

ruki 2 жил өмнө
parent
commit
77c811380d
1 өөрчлөгдсөн 43 нэмэгдсэн , 102 устгасан
  1. 43 102
      configure

+ 43 - 102
configure

@@ -974,11 +974,12 @@ _get_option_item() {
 _set_option_item() {
     local name=${1}
     local key=${2}
-    local value=${3}
+    shift
+    shift
     if test_nz "${name}"; then
-        _map_set "options" "${name}_${key}" "${value}"
+        _map_set "options" "${name}_${key}" "${@}"
     else
-        raise "please call set_${key}(${value}) in the option scope!"
+        raise "please call set_${key}(${@}) in the option scope!"
     fi
 }
 
@@ -986,13 +987,14 @@ _set_option_item() {
 _add_option_item() {
     local name=${1}
     local key=${2}
-    local value=${3}
+    shift
+    shift
     if test_nz "${name}"; then
         _map_get "options" "${name}_${key}"; local values="${_ret}"
-        values="${values} ${value}"
+        values="${values} ${@}"
         _map_set "options" "${name}_${key}" "${values}"
     else
-        raise "please call add_${key}(${value}) in the option scope!"
+        raise "please call add_${key}(${@}) in the option scope!"
     fi
 }
 
@@ -1155,10 +1157,7 @@ add_cincludes() {
     if ! ${_loading_options}; then
         return
     fi
-    local cinclude=""
-    for cinclude in $@; do
-        _add_option_item "${_xmake_sh_option_current}" "cincludes" "${cinclude}"
-    done
+    _add_option_item "${_xmake_sh_option_current}" "cincludes" "${@}"
 }
 
 # add cxxincludes in option
@@ -1166,10 +1165,7 @@ add_cxxincludes() {
     if ! ${_loading_options}; then
         return
     fi
-    local cxxinclude=""
-    for cxxinclude in $@; do
-        _add_option_item "${_xmake_sh_option_current}" "cxxincludes" "${cxxinclude}"
-    done
+    _add_option_item "${_xmake_sh_option_current}" "cxxincludes" "${@}"
 }
 
 # add ctypes in option
@@ -1177,10 +1173,7 @@ add_ctypes() {
     if ! ${_loading_options}; then
         return
     fi
-    local ctype=""
-    for ctype in $@; do
-        _add_option_item "${_xmake_sh_option_current}" "ctypes" "${ctype}"
-    done
+    _add_option_item "${_xmake_sh_option_current}" "ctypes" "${@}"
 }
 
 # add cxxtypes in option
@@ -1188,10 +1181,7 @@ add_cxxtypes() {
     if ! ${_loading_options}; then
         return
     fi
-    local cxxtype=""
-    for cxxtype in $@; do
-        _add_option_item "${_xmake_sh_option_current}" "cxxtypes" "${cxxtype}"
-    done
+    _add_option_item "${_xmake_sh_option_current}" "cxxtypes" "${@}"
 }
 
 # add csnippets in option
@@ -1285,11 +1275,12 @@ _get_target_item() {
 _set_target_item() {
     local name=${1}
     local key=${2}
-    local value=${3}
+    shift
+    shift
     if test_nz "${name}"; then
-        _map_set "targets" "${name}_${key}" "${value}"
+        _map_set "targets" "${name}_${key}" "${@}"
     else
-        _map_set "targets" "__root_${key}" "${value}"
+        _map_set "targets" "__root_${key}" "${@}"
     fi
 }
 
@@ -1297,14 +1288,15 @@ _set_target_item() {
 _add_target_item() {
     local name=${1}
     local key=${2}
-    local value=${3}
+    shift
+    shift
     if test_nz "${name}"; then
         _map_get "targets" "${name}_${key}"; local values="${_ret}"
-        values="${values} ${value}"
+        values="${values} ${@}"
         _map_set "targets" "${name}_${key}" "${values}"
     else
         _map_get "targets" "__root_${key}"; local values="${_ret}"
-        values="${values} ${value}"
+        values="${values} ${@}"
         _map_set "targets" "__root_${key}" "${values}"
     fi
 }
@@ -1929,10 +1921,7 @@ add_deps() {
     if ! ${_loading_targets}; then
         return
     fi
-    local dep=""
-    for dep in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "deps" "${dep}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "deps" "${@}"
 }
 
 # add files in target
@@ -1987,9 +1976,7 @@ add_defines() {
             done
         fi
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for define in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "defines" "${define}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "defines" "${@}"
     fi
 }
 
@@ -2013,9 +2000,7 @@ add_udefines() {
             done
         fi
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for udefine in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "udefines" "${udefine}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "udefines" "${@}"
     fi
 }
 
@@ -2077,9 +2062,7 @@ add_links() {
             done
         fi
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for link in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "links" "${link}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "links" "${@}"
     fi
 }
 
@@ -2103,9 +2086,7 @@ add_syslinks() {
             done
         fi
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for syslink in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "syslinks" "${syslink}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "syslinks" "${@}"
     fi
 }
 
@@ -2182,9 +2163,7 @@ add_frameworks() {
             done
         fi
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for framework in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "frameworks" "${framework}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "frameworks" "${@}"
     fi
 }
 
@@ -2234,63 +2213,46 @@ set_languages() {
 
 # set warnings in target
 set_warnings() {
-    local warnings="${@}"
     if ${_loading_targets} && test_z "${_xmake_sh_option_current}"; then
-        _set_target_item "${_xmake_sh_target_current}" "warnings" "${warnings}"
+        _set_target_item "${_xmake_sh_target_current}" "warnings" "${@}"
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        _set_option_item "${_xmake_sh_option_current}" "warnings" "${warnings}"
+        _set_option_item "${_xmake_sh_option_current}" "warnings" "${@}"
     fi
 }
 
 # set optimizes in target
 set_optimizes() {
-    local optimizes="${@}"
     if ${_loading_targets} && test_z "${_xmake_sh_option_current}"; then
-        _set_target_item "${_xmake_sh_target_current}" "optimizes" "${optimizes}"
+        _set_target_item "${_xmake_sh_target_current}" "optimizes" "${@}"
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        _set_option_item "${_xmake_sh_option_current}" "optimizes" "${optimizes}"
+        _set_option_item "${_xmake_sh_option_current}" "optimizes" "${@}"
     fi
 }
 
 # add cflags in target
 add_cflags() {
-    local flag=""
     if ${_loading_targets} && test_z "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_target_item "${_xmake_sh_target_current}" "cflags" "${flag}"
-        done
+        _add_target_item "${_xmake_sh_target_current}" "cflags" "${@}"
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "cflags" "${flag}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "cflags" "${@}"
     fi
 }
 
 # add cxflags in target
 add_cxflags() {
-    local flag=""
     if ${_loading_targets} && test_z "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_target_item "${_xmake_sh_target_current}" "cxflags" "${flag}"
-        done
+        _add_target_item "${_xmake_sh_target_current}" "cxflags" "${@}"
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "cxflags" "${flag}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "cxflags" "${@}"
     fi
 }
 
 # add cxxflags in target
 add_cxxflags() {
-    local flag=""
     if ${_loading_targets} && test_z "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_target_item "${_xmake_sh_target_current}" "cxxflags" "${flag}"
-        done
+        _add_target_item "${_xmake_sh_target_current}" "cxxflags" "${@}"
     elif ${_loading_options} && test_nz "${_xmake_sh_option_current}"; then
-        for flag in $@; do
-            _add_option_item "${_xmake_sh_option_current}" "cxxflags" "${flag}"
-        done
+        _add_option_item "${_xmake_sh_option_current}" "cxxflags" "${@}"
     fi
 }
 
@@ -2299,10 +2261,7 @@ add_asflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "asflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "asflags" "${@}"
 }
 
 # add mflags in target
@@ -2310,10 +2269,7 @@ add_mflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "mflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "mflags" "${@}"
 }
 
 # add mxflags in target
@@ -2321,10 +2277,7 @@ add_mxflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "mxflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "mxflags" "${@}"
 }
 
 # add mxxflags in target
@@ -2332,10 +2285,7 @@ add_mxxflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "mxxflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "mxxflags" "${@}"
 }
 
 # add ldflags in target
@@ -2343,10 +2293,7 @@ add_ldflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "ldflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "ldflags" "${@}"
 }
 
 # add shflags in target
@@ -2354,10 +2301,7 @@ add_shflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "shflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "shflags" "${@}"
 }
 
 # add arflags in target
@@ -2365,10 +2309,7 @@ add_arflags() {
     if ! ${_loading_targets}; then
         return
     fi
-    local flag=""
-    for flag in $@; do
-        _add_target_item "${_xmake_sh_target_current}" "arflags" "${flag}"
-    done
+    _add_target_item "${_xmake_sh_target_current}" "arflags" "${@}"
 }
 
 # add options in target