Skip to content

Commit

Permalink
Build for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
paddybyers committed Nov 18, 2011
1 parent 4a80bd3 commit 326ccbd
Show file tree
Hide file tree
Showing 10 changed files with 1,610 additions and 0 deletions.
110 changes: 110 additions & 0 deletions Android.common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ifndef NODE_PREFIX
NODE_PREFIX := $(LOCAL_PATH)
endif

include $(CLEAR_VARS)

intermediates := $(LOCAL_PATH)/out/$(APP_OPTIM)

include $(LOCAL_PATH)/Android.jsnatives.mk
src/node_javascript.cc : $(jsnatives)

LOCAL_MODULE := node

LOCAL_CPP_EXTENSION := .cc

LOCAL_C_INCLUDES += \
$(intermediates)/src \
$(LOCAL_PATH)/src

LOCAL_SRC_FILES := \
src/node.cc \
src/node_buffer.cc \
src/node_constants.cc \
src/node_crypto.cc \
src/node_dtrace.cc \
src/node_extensions.cc \
src/node_file.cc \
src/node_http_parser.cc \
src/node_io_watcher.cc \
src/node_javascript.cc \
src/node_main.cc \
src/node_os.cc \
src/node_script.cc \
src/node_signal_watcher.cc \
src/node_stat_watcher.cc \
src/node_string.cc \
src/node_zlib.cc \
src/cares_wrap.cc \
src/fs_event_wrap.cc \
src/handle_wrap.cc \
src/pipe_wrap.cc \
src/process_wrap.cc \
src/stream_wrap.cc \
src/tcp_wrap.cc \
src/timer_wrap.cc \
src/tty_wrap.cc \
src/udp_wrap.cc \
src/v8_typed_array.cc \
src/platform_android.cc

LOCAL_SHARED_LIBRARIES += \
crypto \
ssl

LOCAL_STATIC_LIBRARIES := \
http_parser \
uv \
v8 \
pty

# debug
ifeq ($(debug),true)
LOCAL_CFLAGS += \
-DDEBUG \
-g \
-O0 \
-Wall \
-Wextra
endif

# common flags
LOCAL_CFLAGS += \
-D__POSIX__ \
-DX_STACKSIZE=65536 \
-D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64 \
-DHAVE_FDATASYNC=1 \
-DHAVE_MONOTONIC_CLOCK \
-D_FORTIFY_SOURCE=2 \
-DPLATFORM=\"android\" \
-DARCH=\"arch-arm\" \
-Wno-unused-parameter

# node
LOCAL_CFLAGS += \
-DHAVE_OPENSSL \
-DNODE_CFLAGS=\"\" \
-DNODE_PREFIX=\"$(NODE_PREFIX)\" \
-include sys/select.h

# ev
LOCAL_CFLAGS += \
-DEV_FORK_ENABLE=0 \
-DEV_EMBED_ENABLE=0 \
-DEV_MULTIPLICITY=0
34 changes: 34 additions & 0 deletions Android.exe.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/Android.common.mk

LOCAL_SHARED_LIBRARIES += \
crypto \
ssl

LOCAL_STATIC_LIBRARIES := \
uv \
http_parser \
v8 \
pty

include $(BUILD_EXECUTABLE)

$(call import-module,deps/http_parser)
$(call import-module,deps/uv)
$(call import-module,deps/v8)
$(call import-module,pty)
$(call import-module,openssl-android)
55 changes: 55 additions & 0 deletions Android.jsnatives.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
NODE_LOCAL_JS_LIBRARY_FILES := \
src/node.js \
lib/_debugger.js \
lib/_linklist.js \
lib/assert.js \
lib/buffer.js \
lib/buffer_ieee754.js \
lib/child_process.js \
lib/cluster.js \
lib/console.js \
lib/constants.js \
lib/crypto.js \
lib/dgram.js \
lib/dns.js \
lib/events.js \
lib/freelist.js \
lib/fs.js \
lib/http.js \
lib/https.js \
lib/module.js \
lib/net.js \
lib/os.js \
lib/path.js \
lib/punycode.js \
lib/querystring.js \
lib/readline.js \
lib/repl.js \
lib/stream.js \
lib/string_decoder.js \
lib/sys.js \
lib/timers.js \
lib/tls.js \
lib/tty.js \
lib/url.js \
lib/util.js \
lib/vm.js \
lib/zlib.js \
macros.py

PATH_LOCAL_JS_LIBRARY_FILES := $(addprefix $(LOCAL_PATH)/, $(NODE_LOCAL_JS_LIBRARY_FILES))

# FIXME: Copy js2c.py to intermediates directory and invoke there to avoid generating
# jsmin.pyc in the source directory
#JS2C_PY := $(intermediates)/js2c.py $(intermediates)/jsmin.py
#$(JS2C_PY): $(intermediates)/%.py : $(LOCAL_PATH)/tools/%.py | $(ACP)
# @echo "Copying $@"
# $(copy-file-to-target)

# Generate node_natives.h
jsnatives := $(intermediates)/src/node_natives.h
$(jsnatives): SCRIPT := tools/js2c.py
$(jsnatives): $(PATH_LOCAL_JS_LIBRARY_FILES) $(JS2C_PY)
@echo "Building node_natives.h"
@mkdir -p $(dir $@)
python $(SCRIPT) $(jsnatives) $(PATH_LOCAL_JS_LIBRARY_FILES)
32 changes: 32 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file builds a static library suitable for inclusion in a
# shared library (eg for JNI).

LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/Android.common.mk

LOCAL_SRC_FILES += src/lib_wrapper.cc

# to override exit handling in node.cc
LOCAL_CFLAGS += -D__LIBNODE__

include $(BUILD_STATIC_LIBRARY)

$(call import-module,deps/http_parser)
$(call import-module,deps/uv)
$(call import-module,deps/v8)
$(call import-module,pty)
$(call import-module,openssl-android)
48 changes: 48 additions & 0 deletions deps/http_parser/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := http_parser

LOCAL_SRC_FILES := http_parser.c

# debug
ifeq ($(debug),true)
LOCAL_CFLAGS += \
-DHTTP_PARSER_STRICT=1 \
-DDEBUG \
-g \
-O0 \
-Wall \
-Wextra
endif

# common flags
LOCAL_CFLAGS += \
-D__POSIX__ \
-DX_STACKSIZE=65536 \
-D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64 \
-DHAVE_FDATASYNC=1 \
-D_FORTIFY_SOURCE=2 \
-DPLATFORM=\"android\" \
-Wno-unused-parameter

LOCAL_EXPORT_C_INCLUDES := \
$(LOCAL_PATH)

include $(BUILD_STATIC_LIBRARY)
Loading

0 comments on commit 326ccbd

Please sign in to comment.