Skip to content

Commit

Permalink
Move encoding_util to gui/base.
Browse files Browse the repository at this point in the history
encoding_util is used only by mozc_tool.  Moving it to src/gui/base
consolidates build dependencies and improves code portability.

This is just a refactoring.  No behavior change is intended.

BUG=#252
TEST=unittest
REF_BUG=19010851
REF_CL=87592180
  • Loading branch information
Noriyuki Takahashi authored and yukawa committed Nov 14, 2015
1 parent 2379560 commit 03a4b5e
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 32 deletions.
6 changes: 0 additions & 6 deletions src/base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
'toolsets': ['host', 'target'],
'sources': [
'cpu_stats.cc',
'encoding_util.cc',
'process.cc',
'process_mutex.cc',
'run_level.cc',
Expand All @@ -58,11 +57,6 @@
'mac_process.mm',
'mac_util.mm',
],
'link_settings': {
'libraries': [
'/usr/lib/libiconv.dylib', # used in iconv.cc
],
},
}],
['OS=="win"', {
'sources': [
Expand Down
15 changes: 0 additions & 15 deletions src/base/base_test.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,6 @@
'test_size': 'small',
},
},
{
'target_name': 'encoding_util_test',
'type': 'executable',
'sources': [
'encoding_util_test.cc',
],
'dependencies': [
'../testing/testing.gyp:gtest_main',
'base.gyp:base',
],
'variables': {
'test_size': 'small',
},
},
{
'target_name': 'number_util_test',
'type': 'executable',
Expand Down Expand Up @@ -416,7 +402,6 @@
'clock_mock_test',
'clock_test',
'config_file_stream_test',
'encoding_util_test',
'encryptor_test',
'file_util_test',
'hash_test',
Expand Down
4 changes: 2 additions & 2 deletions src/base/encoding_util.cc → src/gui/base/encoding_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "base/encoding_util.h"
#include "gui/base/encoding_util.h"

// No implementation for Android.
#ifndef OS_ANDROID
Expand Down Expand Up @@ -94,7 +94,7 @@ inline bool Convert(const char *from, const char *to,
// 1. Read the list of code-page identifiers supported by Windows (*1), and;
// 2. Find a code-page identifier matching to the encoding name:
// (*1) "http://msdn.microsoft.com/en-us/library/ms776446(VS.85).aspx".
static int GetCodepage(const char* name) {
int GetCodepage(const char* name) {
static const struct {
const char* name;
int codepage;
Expand Down
6 changes: 3 additions & 3 deletions src/base/encoding_util.h → src/gui/base/encoding_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef MOZC_BASE_ENCODING_UTIL_H_
#define MOZC_BASE_ENCODING_UTIL_H_
#ifndef MOZC_GUI_BASE_ENCODING_UTIL_H_
#define MOZC_GUI_BASE_ENCODING_UTIL_H_

// Currently EncodingUtil is not available on Android.
#ifndef OS_ANDROID
Expand All @@ -51,4 +51,4 @@ class EncodingUtil {

#endif // OS_ANDROID

#endif // MOZC_BASE_ENCODING_UTIL_H_
#endif // MOZC_GUI_BASE_ENCODING_UTIL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "base/encoding_util.h"
#include "gui/base/encoding_util.h"

#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/gui/base/msime_user_dictionary_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <vector>

#include "base/compiler_specific.h"
#include "base/encoding_util.h"
#include "base/hash.h"
#include "base/logging.h"
#include "base/mmap.h"
Expand All @@ -54,6 +53,7 @@
#include "base/util.h"
#include "base/win_util.h"
#include "dictionary/user_dictionary_util.h"
#include "gui/base/encoding_util.h"

namespace mozc {

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dictionary_tool/dictionary_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <string>
#include <vector>

#include "base/encoding_util.h"
#include "base/file_stream.h"
#include "base/logging.h"
#include "base/run_level.h"
Expand All @@ -55,6 +54,7 @@
#include "dictionary/user_dictionary_storage.h"
#include "dictionary/user_dictionary_util.h"
#include "dictionary/user_pos.h"
#include "gui/base/encoding_util.h"
#include "gui/base/msime_user_dictionary_importer.h"
#include "gui/base/win_util.h"
#include "gui/config_dialog/combobox_delegate.h"
Expand Down
42 changes: 42 additions & 0 deletions src/gui/gui.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
'../ipc/ipc.gyp:window_info_protocol',
'../protocol/protocol.gyp:commands_proto',
'../protocol/protocol.gyp:user_dictionary_storage_proto',
'encoding_util',
'gen_base_files',
],
'includes': [
Expand Down Expand Up @@ -595,6 +596,7 @@
'../protocol/protocol.gyp:commands_proto',
'../protocol/protocol.gyp:config_proto',
'../protocol/protocol.gyp:user_dictionary_storage_proto',
'encoding_util',
'gen_config_dialog_files',
'gen_dictionary_tool_files',
],
Expand Down Expand Up @@ -1016,6 +1018,46 @@
}],
],
},
{
'target_name': 'encoding_util',
'type': 'static_library',
'sources': [
'base/encoding_util.cc',
],
'dependencies': [
'../base/base.gyp:base_core',
],
'conditions': [
['OS=="mac"', {
'link_settings': {
'libraries': [
'/usr/lib/libiconv.dylib',
],
},
}],
],
},
{
'target_name': 'encoding_util_test',
'type': 'executable',
'sources': [
'base/encoding_util_test.cc',
],
'dependencies': [
'../testing/testing.gyp:gtest_main',
'encoding_util',
],
'variables': {
'test_size': 'small',
},
},
{
'target_name': 'gui_all_test',
'type': 'none',
'dependencies': [
'encoding_util_test',
],
},
],
'conditions': [
['OS=="win"', {
Expand Down
3 changes: 1 addition & 2 deletions src/gyp/tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
'../dictionary/file/dictionary_file_test.gyp:dictionary_file_all_test',
'../dictionary/system/system_dictionary_test.gyp:system_dictionary_all_test',
'../handwriting/handwriting_test.gyp:handwriting_all_test',
# Currently 'gui_all_test' does not exist.
# '../gui/gui.gyp:gui_all_test',
'../gui/gui.gyp:gui_all_test',
'../ipc/ipc.gyp:ipc_all_test',
'../net/net_test.gyp:net_all_test',
'../prediction/prediction_test.gyp:prediction_all_test',
Expand Down
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2230
BUILD=2231
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
Expand Down

0 comments on commit 03a4b5e

Please sign in to comment.