Skip to content

Commit

Permalink
nacl/libchewing: Sync to upstream, and remove the libsqlite hacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
hungte committed Jan 7, 2014
1 parent 8c718e5 commit e1a4442
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 227 deletions.
23 changes: 3 additions & 20 deletions src/nacl/libchewing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ LIBCHEWING_HOME ?= libchewing
LIBCHEWING_URL ?= https://github.com/chewing/libchewing.git
LIBCHEWING_BRANCH ?=

# The user data (via sqlite) is currently broken due to nacl_io html5fs issue.
# Before that is fixed, we want to fake the library.
LIBCHEWING_USERDATA ?= 0
LIBCHEWING_SQLITE ?= 0

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../../../nacl_sdk)
include $(NACL_SDK_ROOT)/tools/common.mk
CFLAGS += -DHAVE_CONFIG_H -I. -I$(LIBCHEWING_HOME)/src
Expand All @@ -45,22 +40,10 @@ SOURCES = \
$(LIBCHEWING_HOME)/src/porting_layer/src/plat_path.c \
nacl.cc

ifeq ($(LIBCHEWING_USERDATA), 1)

SOURCES += $(LIBCHEWING_HOME)/src/chewing-sql.c
# User data (hash)
SOURCES += $(LIBCHEWING_HOME)/src/userphrase.c

ifeq ($(LIBCHEWING_SQLITE), 1)
SOURCES += $(LIBCHEWING_HOME)/thirdparty/sqlite-amalgamation/sqlite3.c
CFLAGS += -I$(LIBCHEWING_HOME)/thirdparty/sqlite-amalgamation
CFLAGS += -D_HAVE_SQLITE_CONFIG_H
else # LIBCHEWING_SQLITE
LIBS += sqlite3
endif # LIBCHEWING_SQLITE

else # LIBCHEWING_USERDATA
SOURCES += fake-chewing-sql.c fake-userphrase.c
endif # LIBCHEWING_USERDATA
SOURCES += $(LIBCHEWING_HOME)/src/hash.c
SOURCES += $(LIBCHEWING_HOME)/src/userphrase-hash.c

ifneq ($(CONFIG),Release)
CFLAGS+=-DDEBUG
Expand Down
6 changes: 2 additions & 4 deletions src/nacl/libchewing/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ A sample NaCl based input module for jscin - using libchewing.
To build this:

1. Create a "libchewing" subfolder and fetch libchewing source code in it.
Currently verified version: cbf479a01392cdc3febb53439dddbef57d1010c6
Currently verified version: abda34fd542ddbb0f264fdc9d9f3ac3e696e4304
2. Enter libchewing, ./configure && make
3. Get your Native Client SDK ready, and set NACL_SDK_ROOT properly.
Currently verified SDK version is pepper_31.
4. (optional) Install Nacl Ports https://code.google.com/p/naclports/
and run "./make_all.sh sqlite" inside Nacl Ports folder.
5. make
4. make

To test:
1. $NACL_SDK_ROOT/tools/httpd.py --no_dir_check &
Expand Down
15 changes: 2 additions & 13 deletions src/nacl/libchewing/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@
#define CONFIG_H

#define UNDER_POSIX
#define HAVE_INTTYPES_H
#define HAVE_STRTOK_R
#define LIBDIR "/data"

// Hacks for sqlite3.
#define SQLITE_OMIT_LOAD_EXTENSION
#if !defined __GLIBC__
#include <stdio.h>
struct flock {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
#endif
#define LIBDIR "/data"

#endif /* CONFIG_H */
122 changes: 0 additions & 122 deletions src/nacl/libchewing/fake-chewing-sql.c

This file was deleted.

60 changes: 0 additions & 60 deletions src/nacl/libchewing/fake-userphrase.c

This file was deleted.

9 changes: 1 addition & 8 deletions src/nacl/libchewing/nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,12 @@ class ChewingInstance: public pp::Instance {
return;
}

// TODO(hungte) Change memfs to html5fs once we've figured out why it does
// not work.
if (mount("", USER_DATA_DIR, "memfs", 0,
if (mount("", USER_DATA_DIR, "html5fs", 0,
"type=PERSISTENT,expected_size=1048576") != 0) {
PostMessage(pp::Var("can't mount user data"));
return;
}

// Blank out USER, LOGNAME and set HOME so sqlite won't go crazy.
setenv("HOME", USER_DATA_DIR, 1);
setenv("USER", "", 1);
setenv("LOGNAME", "", 1);

// Note currently chewing_Init does not do anything. DATA_DIR and
// USER_DATA_DIR must be specified again in chewing_new2.
chewing_Init(DATA_DIR, USER_DATA_DIR);
Expand Down

0 comments on commit e1a4442

Please sign in to comment.