LoginSignup
0
1

More than 1 year has passed since last update.

mac OS Montereyにアップデートしたらcocos2d-x 3.15.1のAndroidビルドが通らなくなった。

Posted at

これは個人的なメモとして残しておく

起きた現象

mac OSをBig SurからMontereyにアップデートした。
AndroidStudioのビルドとJenkinsを使ったビルドでエラーになる。

エラーの内容

  Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !    
  
  /Applications/android-ndk-r14b/build/core/init.mk:391: *** Android NDK: Aborting.    .  Stop.

試行錯誤

awkが良く無いからGawkかNawkにしてって言ってるのかな?
NDK_HOST_AWKを環境変数を指定してねってことだろうか。

gawkをインストールしてみる。

brew install gawk

ちゃんと反応するかコマンドを叩いてみる

$ awk
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:		GNU long options: (standard)
	-f progfile		--file=progfile
	-F fs			--field-separator=fs
	-v var=val		--assign=var=val
Short options:		GNU long options: (extensions)
	-b			--characters-as-bytes
	-c			--traditional
	-C			--copyright
	-d[file]		--dump-variables[=file]
	-D[file]		--debug[=file]
	-e 'program-text'	--source='program-text'
	-E file			--exec=file
	-g			--gen-pot
	-h			--help
	-i includefile		--include=includefile
	-I			--trace
	-l library		--load=library
	-L[fatal|invalid|no-ext]	--lint[=fatal|invalid|no-ext]
	-M			--bignum
	-N			--use-lc-numeric
	-n			--non-decimal-data
	-o[file]		--pretty-print[=file]
	-O			--optimize
	-p[file]		--profile[=file]
	-P			--posix
	-r			--re-interval
	-s			--no-optimize
	-S			--sandbox
	-t			--lint-old
	-V			--version

To report bugs, see node `Bugs' in `gawk.info'
which is section `Reporting Problems and Bugs' in the
printed version.  This same information may be found at
https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
PLEASE do NOT try to report bugs by posting in comp.lang.awk,
or by using a web forum such as Stack Overflow.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
	awk '{ sum += $1 }; END { print sum }' file
	awk -F: '{ print $1 }' /etc/passwd

よし、これで大丈夫だ。
もう一回ビルドしてみよう。

またエラーになる!!

エラーの内容

  Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !    
  
  /Applications/android-ndk-r14b/build/core/init.mk:391: *** Android NDK: Aborting.    .  Stop.

エラーになる理由は別のところにあるのか?

AndroidStudioのエラーログをみると
./android-ndk-r14b/build/core/init.mkのなかでエラーが起きてるみたいだ。

init.mkファイルの中身をみてみる 374行目あたりにかいてある

init.mk
#
# Verify that the 'awk' tool has the features we need.
# Both Nawk and Gawk do.
#
HOST_AWK := $(strip $(HOST_AWK))
ifndef HOST_AWK
    HOST_AWK := awk
endif
$(call ndk_log,Host 'awk' tool: $(HOST_AWK))

# Location of all awk scripts we use
BUILD_AWK := $(NDK_ROOT)/build/awk

AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
$(call ndk_log,Host 'awk' test returned: $(AWK_TEST))
ifneq ($(AWK_TEST),Pass)
    $(call __ndk_info,Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !)
    $(call __ndk_error,Aborting.)
endif

AWK_TESTを通した時にエラーになるようだ。

HOST_AWKってなんや!
NDK_HOST_AWKじゃないやん!

HOST_AWKで検索したら、init.mkの上のほうで宣言されてた。
HOST_AWKにNDK_HOST_AWKをいれてるようだ。

init.mk
# Check for NDK-specific versions of our host tools
HOST_TOOLS_ROOT := $(NDK_ROOT)/prebuilt/$(HOST_TAG64)
HOST_PREBUILT := $(strip $(wildcard $(HOST_TOOLS_ROOT)/bin))
HOST_AWK := $(strip $(NDK_HOST_AWK))
HOST_MAKE := $(strip $(NDK_HOST_MAKE))
HOST_PYTHON := $(strip $(NDK_HOST_PYTHON))
ifdef HOST_PREBUILT
    $(call ndk_log,Host tools prebuilt directory: $(HOST_PREBUILT))
    # The windows prebuilt binaries are for ndk-build.cmd
    # On cygwin, we must use the Cygwin version of these tools instead.
    ifneq ($(HOST_OS),cygwin)
        ifndef HOST_AWK
            HOST_AWK := $(wildcard $(HOST_PREBUILT)/awk$(HOST_EXEEXT))
        endif
        ifndef HOST_MAKE
            HOST_MAKE := $(wildcard $(HOST_PREBUILT)/make$(HOST_EXEEXT))
        endif
       ifndef HOST_PYTHON
            HOST_PYTHON := $(wildcard $(HOST_PREBUILT)/python$(HOST_EXEEXT))
        endif
    endif
else
    $(call ndk_log,Host tools prebuilt directory not found, using system tools)
endif

どんな設定されてるかわからないからinit.mkを改造してみた。

init.mk
# Check for NDK-specific versions of our host tools
HOST_TOOLS_ROOT := $(NDK_ROOT)/prebuilt/$(HOST_TAG64)
HOST_PREBUILT := $(strip $(wildcard $(HOST_TOOLS_ROOT)/bin))
HOST_AWK := $(strip $(NDK_HOST_AWK))
# -- NDK_HOST_AWK環境パス設定してる?
$(call ndk_log,'NDK_HOST_AWK' : $(NDK_HOST_AWK))
# -- HOST_AWKってどうなるん?
$(call ndk_log,'HOST_AWK' : $(HOST_AWK))
HOST_MAKE := $(strip $(NDK_HOST_MAKE))
HOST_PYTHON := $(strip $(NDK_HOST_PYTHON))
ifdef HOST_PREBUILT

もう一度ビルドを試してログを確認
NDK_HOST_AWKもHOST_AWKも空文字やった。
つまり、NDK_HOST_AWKから何も渡ってない。
環境変数等の設定していないからあたりまえなんだけども。

じゃぁAWK_TESTの直前ではどういうパスになってるかログを仕込んでみる

init.mk
#
# Verify that the 'awk' tool has the features we need.
# Both Nawk and Gawk do.
#
HOST_AWK := $(strip $(HOST_AWK))
ifndef HOST_AWK
    HOST_AWK := awk
endif
# -- この時点でのHOST_AWKはどんな感じ?
$(call ndk_log,Host 'awk' tool: $(HOST_AWK))

# Location of all awk scripts we use
BUILD_AWK := $(NDK_ROOT)/build/awk

AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
$(call ndk_log,Host 'awk' test returned: $(AWK_TEST))
ifneq ($(AWK_TEST),Pass)
    $(call __ndk_info,Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !)
    $(call __ndk_error,Aborting.)
endif

ログを確認したら。
宣言されていない場合は
./android-ndk-r14b/prebuilt/darwin-x86_64/bin/awk
が選ばれるようだ。

じゃぁ、AWK_TESTのコマンドが通るか試してみる(android-ndk-r14bはApplicationsフォルダに個人的にいれてあるよ)

$ /Applications/android-ndk-r14b/prebuilt/darwin-x86_64/bin/awk -f /Applications/android-ndk-r14b/build/awk/check-awk.awk


Segmentation fault: 11

どうやらOSアップデートしてからかこのコマンドが通らなくなったらしい。
MontereyにアップしてからPython2.7が標準で無くなったりとか、色々変わってるから
何かの原因で動かなくなったかな?
誰かが調べてくれるだろう。

仕方ないので、NDK_HOST_AWKに環境変数を設定しよう。
以下内容を追加してみる。

.bash_profile
export NDK_HOST_AWK=awk

またエラーになる!!

エラーの内容

  Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !    
  
  /Applications/android-ndk-r14b/build/core/init.mk:391: *** Android NDK: Aborting.    .  Stop.

Android Studioのビルドをした時にNDK_HOST_AWKが設定されない・・・

build.gradle
ndkBuild {
// ~ 中略 ~
    arguments 'NDK_HOST_AWK=awk'
}

AndroidStudioビルドを通してみる。
通った・・・よかった・・・

よし、ついでにJenkinsでもビルドしてみよう。

またエラーになる!!

エラーの内容

  Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !    
  
  /Applications/android-ndk-r14b/build/core/init.mk:391: *** Android NDK: Aborting.    .  Stop.

一緒のエラーやんか!!なぜに!!
しかたない・・・

jenkinsfileに定義しよう!

jenkinsfile
pipeline {
    //中略

    environment {
	  NDK_HOST_AWK="awk"
    }    

    //中略

よし、ビルド通った!

なぜ環境変数が反映されないかまた時間ができた時に調べよう。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1