Skip to content

Commit

Permalink
use msys2/setup-msys2@v2 (#50)
Browse files Browse the repository at this point in the history
* use msys2/setup-msys2@v2

* use LTLIBICONV instead of LIBICONV

* fix: undefined reference to `wWinMain'

* fix WPATH

* fix CreateFile redefined

* use file command

* revert changes of Makefile

* fix

* Revert "fix"

This reverts commit 33d889a.

* Revert "revert changes of Makefile"

This reverts commit 55e891f.
  • Loading branch information
shogo82148 committed Oct 6, 2020
1 parent acf40c1 commit 2f98047
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/setup-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -eux
brew install automake autoconf libtool gettext
echo ::set-env name=ACLOCAL_PATH::/usr/local/opt/gettext/share/aclocal/
echo ACLOCAL_PATH=/usr/local/opt/gettext/share/aclocal/ >> "$GITHUB_ENV"
40 changes: 15 additions & 25 deletions .github/workflows/test-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,28 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set ENV
run: |
# MSYS2 is pre-installed from https://github.com/actions/virtual-environments/releases/tag/win19%2F20200608.1
# but not added to PATH.
# so, we need to add it to PATH here.
echo 'C:\msys64;' >> "$GITHUB_PATH"
echo 'C:\msys64\bin' >> "$GITHUB_PATH"
echo 'C:\msys64\usr\bin' >> "$GITHUB_PATH"
echo 'C:\msys64\mingw64\bin' >> "$GITHUB_PATH"
shell: bash
- name: setup MSYS2
run: |
msys2_shell.cmd -c "pacman-key --init"
msys2_shell.cmd -c "pacman-key --populate msys2"
msys2_shell.cmd -c "pacman.exe -Sy"
msys2_shell.cmd -c "pacman.exe -S --verbose --noconfirm --noprogressbar --needed autoconf bison make automake1.16 automake-wrapper mingw-w64-x86_64-gcc mingw-w64-x86_64-libtool"
- uses: msys2/setup-msys2@v2
with:
install: autoconf bison make automake1.16 automake-wrapper mingw-w64-x86_64-gcc mingw-w64-x86_64-libtool mingw-w64-x86_64-libiconv
- name: configure
run: |
msys2_shell.cmd -c "./autogen.sh"
msys2_shell.cmd -c "./configure --host=x86_64-w64-mingw32"
./autogen.sh
./configure --host=x86_64-w64-mingw32
shell: msys2 {0}
working-directory: mecab
- name: make
run: |
msys2_shell.cmd -c "make all"
msys2_shell.cmd -c "make check"
msys2_shell.cmd -c "make install"
make all
make check
make install
shell: msys2 {0}
working-directory: mecab

- name: build ipadic
run: |
msys2_shell.cmd -c "./autogen.sh"
msys2_shell.cmd -c "./configure --with-charset=utf8"
msys2_shell.cmd -c "make all"
msys2_shell.cmd -c "make install"
./autogen.sh
./configure --with-charset=utf8
make all
make install
shell: msys2 {0}
working-directory: mecab-ipadic
4 changes: 0 additions & 4 deletions mecab/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
MECAB_PKGCONFIG_DIR=${pkgconfigdir}
AC_SUBST(MECAB_PKGCONFIG_DIR)

LIBS="$LIBS $MECAB_LIBS $LIBICONV"
AC_SUBST(MECAB_LIBS)
AC_SUBST(MECAB_USE_UTF8_ONLY)

Expand Down Expand Up @@ -333,9 +332,6 @@ AC_MSG_RESULT([yes])
case "$host_os" in
mingw32* | msys* | os2*)
MECAB_DEFAULT_RC='c:\\\\Program Files\\\\mecab\\\\etc\\\\mecabrc'
CFLAGS="$CFLAGS -municode -DUNICODE -D_UNICODE -DDLL_EXPORT"
CXXFLAGS="$CXXFLAGS -municode -DUNICODE -D_UNICODE -DDLL_EXPORT"
LDFLAGS="$LDFLAGS -municode"
;;
*)
MECAB_DEFAULT_RC="$sysconfdir/mecabrc"
Expand Down
13 changes: 7 additions & 6 deletions mecab/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ libmecab_la_SOURCES = viterbi.cpp tagger.cpp utils.cpp utils.h eval.cpp iconv_u
feature_index.cpp feature_index.h lbfgs.cpp \
lbfgs.h learner_tagger.cpp learner_tagger.h learner.cpp \
learner_node.h libmecab.cpp
libmecab_la_LIBADD = $(MECAB_LIBS) $(LTLIBICONV)

include_HEADERS = mecab.h
bin_PROGRAMS = mecab
pkglibexec_PROGRAMS = mecab-dict-index mecab-dict-gen mecab-cost-train mecab-system-eval mecab-test-gen

mecab_dict_index_SOURCES = mecab-dict-index.cpp
mecab_dict_index_LDADD = libmecab.la
mecab_dict_index_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

mecab_dict_gen_SOURCES = mecab-dict-gen.cpp
mecab_dict_gen_LDADD = libmecab.la
mecab_dict_gen_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

mecab_system_eval_SOURCES = mecab-system-eval.cpp
mecab_system_eval_LDADD = libmecab.la
mecab_system_eval_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

mecab_cost_train_SOURCES = mecab-cost-train.cpp
mecab_cost_train_LDADD = libmecab.la
mecab_cost_train_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

mecab_test_gen_SOURCES = mecab-test-gen.cpp
mecab_test_gen_LDADD = libmecab.la
mecab_test_gen_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

mecab_SOURCES = mecab.cpp
mecab_LDADD = libmecab.la
mecab_LDADD = libmecab.la $(MECAB_LIBS) $(LTLIBICONV)

pkgincludedir = $(includedir)
pkginclude_HEADERS = mecab.h
Expand Down
10 changes: 2 additions & 8 deletions mecab/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,9 @@
#define EXIT_SUCCESS 0
#endif

#ifdef _WIN32
#define WPATH_FORCE(path) (MeCab::Utf8ToWide(path).c_str())
#ifdef __GNUC__
#define WPATH(path) (path)
#else
#define WPATH(path) WPATH_FORCE(path)
#endif
#ifdef UNICODE
#define WPATH(path) (MeCab::Utf8ToWide(path).c_str())
#else
#define WPATH_FORCE(path) (path)
#define WPATH(path) (path)
#endif

Expand Down
2 changes: 1 addition & 1 deletion mecab/src/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ template <class T> class Mmap {
CHECK_FALSE(false) << "unknown open mode:" << filename;
}

hFile = ::CreateFileW(WPATH_FORCE(filename), mode1, FILE_SHARE_READ, 0,
hFile = CreateFile(WPATH(filename), mode1, FILE_SHARE_READ, 0,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
CHECK_FALSE(hFile != INVALID_HANDLE_VALUE)
<< "CreateFile() failed: " << filename;
Expand Down
2 changes: 1 addition & 1 deletion mecab/src/winmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Copyright(C) 2001-2011 Taku Kudo <taku@chasen.org>
// Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
#if defined(_WIN32)
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(__GNUC__)

#ifndef NOMINMAX
#define NOMINMAX 1
Expand Down

0 comments on commit 2f98047

Please sign in to comment.