Skip to content

Commit 7025b62

Browse files
committed
Handle processing toc files better
Fixes #116
1 parent 3ba5b53 commit 7025b62

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

release.sh

+45-30
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ declare -A si_game_type_interface_all=() # type -> toc (last file)
7676
declare -A si_game_type_interface=() # type -> game type toc (last file)
7777
declare -A toc_interfaces=() # path -> all toc interface values (: delim)
7878
declare -A toc_root_interface=() # path -> base interface value
79+
declare -A root_paths=() # path -> directory name
7980

8081
# Script return code
8182
exit_code=0
@@ -935,6 +936,12 @@ if [ -f "$pkgmeta_file" ]; then
935936
;;
936937
esac
937938
;;
939+
move-folders)
940+
# Save project root directories
941+
if [[ $yaml_value != *"/"* ]]; then
942+
root_paths["$topdir/$yaml_value"]="$yaml_value"
943+
fi
944+
;;
938945
esac
939946
;;
940947
esac
@@ -1151,11 +1158,16 @@ if [[ -z "$package" ]]; then
11511158
fi
11521159
fi
11531160

1161+
# Add the project root
1162+
root_paths["$topdir"]="$package"
1163+
11541164
# Parse the main addon's TOC file(s)
1155-
for toc in "$topdir"{,/"$package"}/"$package"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC}.toc; do
1156-
if [[ -f "$toc" ]]; then
1157-
do_toc "$toc" "$package"
1158-
fi
1165+
for path in "${!root_paths[@]}"; do
1166+
for toc in "$path/${root_paths[$path]}"{,-Mainline,_Mainline,-Classic,_Classic,-Vanilla,_Vanilla,-BCC,_BCC,-TBC,_TBC}.toc; do
1167+
if [[ -f "$toc" ]]; then
1168+
do_toc "$toc" "${root_paths[$path]}"
1169+
fi
1170+
done
11591171
done
11601172

11611173
if [[ ${#toc_interfaces[@]} -eq 0 ]]; then
@@ -1170,13 +1182,13 @@ if [[ -n "$slug" && "$slug" -gt 0 && ! -f "$topdir/$package.toc" && ! -f "$topdi
11701182
fi
11711183

11721184
if [[ -n "$split" ]]; then
1173-
if [[ ${#toc_interfaces[@]} -gt 1 ]]; then
1174-
echo "Creating TOC files is enabled but there are already multiple TOC files:" >&2
1175-
for path in "${!toc_interfaces[@]}"; do
1176-
echo " ${path##$topdir/}" >&2
1177-
done
1178-
exit 1
1179-
fi
1185+
# if [[ ${#toc_interfaces[@]} -gt 1 ]]; then
1186+
# echo "Creating TOC files is enabled but there are already multiple TOC files:" >&2
1187+
# for path in "${!toc_interfaces[@]}"; do
1188+
# echo " ${path##$topdir/}" >&2
1189+
# done
1190+
# exit 1
1191+
# fi
11801192
if [[ "${toc_interfaces[*]}" != *":"* ]]; then
11811193
echo "Creating TOC files is enabled but there is only one TOC interface version: ${toc_interfaces[*]}" >&2
11821194
exit 1
@@ -1593,7 +1605,7 @@ copy_directory_tree() {
15931605
mkdir -p "$_cdt_destdir/$dir"
15941606
fi
15951607
# Check if the file matches a pattern for keyword replacement.
1596-
if [ -n "$unchanged" ] || ! match_pattern "$file" "*.lua:*.md:*.toc:*.txt:*.xml" || [[ "$file" == *".toc" && -z "$package" ]]; then
1608+
if [ -n "$unchanged" ] || ! match_pattern "$file" "*.lua:*.md:*.toc:*.txt:*.xml"; then
15971609
echo " Copying: $file (unchanged)"
15981610
cp "$_cdt_srcdir/$file" "$_cdt_destdir/$dir"
15991611
else
@@ -1619,25 +1631,28 @@ copy_directory_tree() {
16191631
[ "$_cdt_gametype" != "bcc" ] && _cdt_filters+="|xml_filter version-bcc"
16201632
;;
16211633
*.toc)
1622-
do_toc "$_cdt_srcdir/$file" "$package"
1623-
# Process the fallback TOC file according to it's base interface version
1624-
if [[ -z $_cdt_gametype && -n $_cdt_split ]]; then
1625-
case ${toc_root_interface["$_cdt_srcdir/$file"]} in
1626-
11*) _cdt_gametype="classic" ;;
1627-
20*) _cdt_gametype="bcc" ;;
1628-
*) _cdt_gametype="retail"
1629-
esac
1634+
# We only care about processing project TOC files
1635+
if [[ -n ${toc_root_interface["$_cdt_srcdir/$file"]} ]]; then
1636+
do_toc "$_cdt_srcdir/$file" "${root_paths["$_cdt_srcdir/$file"]}"
1637+
# Process the fallback TOC file according to it's base interface version
1638+
if [[ -z $_cdt_gametype && -n $_cdt_split ]]; then
1639+
case ${toc_root_interface["$_cdt_srcdir/$file"]} in
1640+
11*) _cdt_gametype="classic" ;;
1641+
20*) _cdt_gametype="bcc" ;;
1642+
*) _cdt_gametype="retail"
1643+
esac
1644+
fi
1645+
_cdt_filters+="|do_not_package_filter toc"
1646+
[ -n "$_cdt_nolib" ] && _cdt_filters+="|toc_filter no-lib-strip true" # leave the tokens in the file normally
1647+
_cdt_filters+="|toc_filter debug ${_cdt_debug}"
1648+
_cdt_filters+="|toc_filter alpha ${_cdt_alpha}"
1649+
_cdt_filters+="|toc_filter retail $([[ "$_cdt_gametype" != "retail" ]] && echo "true")"
1650+
_cdt_filters+="|toc_filter version-retail $([[ "$_cdt_gametype" != "retail" ]] && echo "true")"
1651+
_cdt_filters+="|toc_filter version-classic $([[ "$_cdt_gametype" != "classic" ]] && echo "true")"
1652+
_cdt_filters+="|toc_filter version-bcc $([[ "$_cdt_gametype" != "bcc" ]] && echo "true")"
1653+
_cdt_filters+="|toc_interface_filter '${si_game_type_interface_all[${_cdt_gametype:- }]}' '${toc_root_interface["$_cdt_srcdir/$file"]}'"
1654+
[ -n "$_cdt_localization" ] && _cdt_filters+="|localization_filter"
16301655
fi
1631-
_cdt_filters+="|do_not_package_filter toc"
1632-
[ -n "$_cdt_nolib" ] && _cdt_filters+="|toc_filter no-lib-strip true" # leave the tokens in the file normally
1633-
_cdt_filters+="|toc_filter debug ${_cdt_debug}"
1634-
_cdt_filters+="|toc_filter alpha ${_cdt_alpha}"
1635-
_cdt_filters+="|toc_filter retail $([[ "$_cdt_gametype" != "retail" ]] && echo "true")"
1636-
_cdt_filters+="|toc_filter version-retail $([[ "$_cdt_gametype" != "retail" ]] && echo "true")"
1637-
_cdt_filters+="|toc_filter version-classic $([[ "$_cdt_gametype" != "classic" ]] && echo "true")"
1638-
_cdt_filters+="|toc_filter version-bcc $([[ "$_cdt_gametype" != "bcc" ]] && echo "true")"
1639-
_cdt_filters+="|toc_interface_filter '${si_game_type_interface_all[${_cdt_gametype:- }]}' '${toc_root_interface["$_cdt_srcdir/$file"]}'"
1640-
[ -n "$_cdt_localization" ] && _cdt_filters+="|localization_filter"
16411656
;;
16421657
esac
16431658

0 commit comments

Comments
 (0)