Skip to content

Commit d1a47eb

Browse files
committed
fix configure
1 parent 29ef557 commit d1a47eb

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

configure

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ path_basename() {
273273
# we avoid use `dirname -- ${1}`, because it's too slow
274274
path_directory() {
275275
local path="${1}"
276+
if test_z "${path}"; then
277+
raise "invalid empty path in path_directory()."
278+
fi
276279
local oldifs="${IFS}"
277280
IFS='/'
278281
set -- ${path}
@@ -317,42 +320,59 @@ path_is_absolute() {
317320

318321
# get relative path, e.g $(path_relative ${rootdir} ${absolute_path}`
319322
path_relative() {
320-
local source=$1
321-
local target=$2
323+
local source="${1}"
324+
local target="${2}"
325+
if test_z "${source}" || test_z "${target}"; then
326+
raise "invalid empty path in path_relative()"
327+
fi
328+
329+
# patch missing "./"
330+
source=${source#./}
331+
source=${source#.}
332+
target=${target#./}
333+
target=${target#.}
334+
if test_z "${source}"; then
335+
_ret="${target}"
336+
return
337+
fi
322338

323-
local common_part=$source
339+
# find common path
324340
local result=""
325-
341+
local common_part=$source
326342
while test_eq "${target#$common_part}" "${target}"; do
327343
# no match, means that candidate common part is not correct
328344
# go up one level (reduce common part)
329345
path_directory "${common_part}"; common_part="${_ret}"
330346
# and record that we went back, with correct / handling
331-
if test_z $result; then
347+
if test_z "${result}"; then
332348
result=".."
333349
else
334-
result="../$result"
350+
result="../${result}"
335351
fi
336352
done
337353

338-
if test_eq $common_part "/"; then
354+
if test_eq "${common_part}" "/"; then
339355
# special case for root (no common path)
340-
result="$result/"
356+
result="${result}/"
341357
fi
342358

343359
# since we now have identified the common part,
344360
# compute the non-common part
345361
local forward_part="${target#$common_part}"
346362

347363
# and now stick all parts together
348-
if test_nz $result && test_nz $forward_part; then
349-
result="$result$forward_part"
350-
elif test_nz $forward_part; then
351-
# remote extra '/', e.g. "/xxx" => "xxx"
364+
if test_nz "${result}" && test_nz "${forward_part}"; then
365+
result="${result}${forward_part}"
366+
elif test_nz "${forward_part}"; then
352367
result="${forward_part#*/}"
353368
fi
354369

355-
_ret="$result"
370+
# same directory?
371+
if test_z "${result}" && test_eq "${source}" "${target}"; then
372+
result="."
373+
fi
374+
375+
_ret="${result}"
356376
}
357377

358378
path_sourcekind() {
@@ -911,7 +931,9 @@ option() {
911931
fi
912932
return
913933
fi
914-
_xmake_sh_options="${_xmake_sh_options} ${name}"
934+
if ! _map_has "options" "${name}_name"; then
935+
_xmake_sh_options="${_xmake_sh_options} ${name}"
936+
fi
915937
_map_set "options" "${name}_name" "${name}"
916938
_map_set "options" "${name}_description" "${description}"
917939
_map_set "options" "${name}_default" "${default}"
@@ -1187,7 +1209,9 @@ target() {
11871209
if ! ${_loading_targets}; then
11881210
return
11891211
fi
1190-
_xmake_sh_targets="${_xmake_sh_targets} ${name}"
1212+
if ! _map_has "targets" "${name}_name"; then
1213+
_xmake_sh_targets="${_xmake_sh_targets} ${name}"
1214+
fi
11911215
_map_set "targets" "${name}_name" "${name}"
11921216
return 0
11931217
}

src/res/png/subdir/test2.png

Loading

src/xmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ target "demo"
3838
add_headerfiles "${buildir}/include/config.h" "hello"
3939
add_headerfiles "(bar/*.h)" "hello"
4040
add_headerfiles "foo/(*.h)" "hello"
41-
add_installfiles "res/(png/*.png)" "share"
41+
add_installfiles "res/(png/**.png)" "share"
4242
if has_config "debug"; then
4343
add_defines "DEBUG" "TEST"
4444
fi

0 commit comments

Comments
 (0)