mirror of
https://github.com/zeldaret/oot.git
synced 2025-05-10 02:54:24 +00:00
Use iconv from Homebrew on macOS (#2374)
* Use iconv from Homebrew on macOS * Use `brew --prefix`
This commit is contained in:
parent
4873788e2d
commit
bdb3656af9
3 changed files with 19 additions and 5 deletions
9
Makefile
9
Makefile
|
@ -266,6 +266,13 @@ OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy
|
||||||
OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump
|
OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump
|
||||||
NM := $(MIPS_BINUTILS_PREFIX)nm
|
NM := $(MIPS_BINUTILS_PREFIX)nm
|
||||||
|
|
||||||
|
# The default iconv on macOS has some differences from GNU iconv, so we use the Homebrew version instead
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
ICONV := $(shell brew --prefix)/opt/libiconv/bin/iconv
|
||||||
|
else
|
||||||
|
ICONV := iconv
|
||||||
|
endif
|
||||||
|
|
||||||
INC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. -I$(EXTRACTED_DIR)
|
INC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. -I$(EXTRACTED_DIR)
|
||||||
|
|
||||||
# Check code syntax with host compiler
|
# Check code syntax with host compiler
|
||||||
|
@ -598,7 +605,7 @@ $(BUILD_DIR)/assets/misc/z_select_static/%.o: GBI_DEFINES := -DF3DEX_GBI
|
||||||
|
|
||||||
ifeq ($(PERMUTER),) # permuter + preprocess.py misbehaves, permuter doesn't care about rodata diffs or bss ordering so just don't use it in that case
|
ifeq ($(PERMUTER),) # permuter + preprocess.py misbehaves, permuter doesn't care about rodata diffs or bss ordering so just don't use it in that case
|
||||||
# Handle encoding (UTF-8 -> EUC-JP) and custom pragmas
|
# Handle encoding (UTF-8 -> EUC-JP) and custom pragmas
|
||||||
$(BUILD_DIR)/src/%.o: CC := ./tools/preprocess.sh -v $(VERSION) -- $(CC)
|
$(BUILD_DIR)/src/%.o: CC := ./tools/preprocess.sh -v $(VERSION) -i $(ICONV) -- $(CC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,7 @@ You can install them with the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew update
|
brew update
|
||||||
brew install coreutils make python3 libpng bash clang-format libxml2
|
brew install coreutils make python3 libpng bash clang-format libxml2 libiconv
|
||||||
```
|
```
|
||||||
|
|
||||||
(The repository expects Homebrew-installed programs to be either linked correctly in `$PATH` etc. or in their default locations.)
|
(The repository expects Homebrew-installed programs to be either linked correctly in `$PATH` etc. or in their default locations.)
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
# Usage: preprocess [flags] -- [compile command minus input file...] [single input file]
|
# Usage: preprocess [flags] -- [compile command minus input file...] [single input file]
|
||||||
# Flags: -v OOT_VERSION (required)
|
# Flags:
|
||||||
|
# -v OOT_VERSION (required)
|
||||||
|
# -i ICONV_PATH (optional, default: iconv)
|
||||||
# Preprocess a C file to:
|
# Preprocess a C file to:
|
||||||
# * Re-encode from UTF-8 to EUC-JP
|
# * Re-encode from UTF-8 to EUC-JP
|
||||||
# (the repo uses UTF-8 for text encoding, but the strings in the ROM are encoded in EUC-JP)
|
# (the repo uses UTF-8 for text encoding, but the strings in the ROM are encoded in EUC-JP)
|
||||||
|
@ -39,12 +41,17 @@ then
|
||||||
echo srcfile="$srcfile"
|
echo srcfile="$srcfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts "v:" opt "${flags[@]}"
|
ICONV=iconv
|
||||||
|
|
||||||
|
while getopts "v:i:" opt "${flags[@]}"
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
v)
|
v)
|
||||||
OOT_VERSION=$OPTARG
|
OOT_VERSION=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
i)
|
||||||
|
ICONV=$OPTARG
|
||||||
|
;;
|
||||||
?)
|
?)
|
||||||
echo "Error: Bad flags"
|
echo "Error: Bad flags"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -76,7 +83,7 @@ trap "rm -rf $tempdir" EXIT
|
||||||
{
|
{
|
||||||
printf '#line 1 "%s"\n' "$srcfile" # linemarker
|
printf '#line 1 "%s"\n' "$srcfile" # linemarker
|
||||||
./tools/preprocess_pragmas $OOT_VERSION "$srcfile" < "$srcfile"
|
./tools/preprocess_pragmas $OOT_VERSION "$srcfile" < "$srcfile"
|
||||||
} | iconv -f UTF-8 -t EUC-JP > "$tempfile"
|
} | "${ICONV}" -f UTF-8 -t EUC-JP > "$tempfile"
|
||||||
|
|
||||||
# Also include the source file's directory to have the include path as if we compiled the original source.
|
# Also include the source file's directory to have the include path as if we compiled the original source.
|
||||||
# Pass the processed temporary file for compilation.
|
# Pass the processed temporary file for compilation.
|
||||||
|
|
Loading…
Add table
Reference in a new issue