Skip to content

Commit 74c28a6

Browse files
android: update native-gradle to mobile v0.1.3
1 parent 113959e commit 74c28a6

File tree

139 files changed

+66404
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+66404
-25
lines changed

android/native-gradle/README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The sample app runs the node.js engine in a background thread to start an HTTP s
66

77
## How to run
88
- Clone this project.
9-
- Download the Node.js on Mobile shared library from [here](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.2/nodejs-mobile-v0.1.2-android.zip).
9+
- Download the Node.js on Mobile shared library from [here](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.3/nodejs-mobile-v0.1.3-android.zip).
1010
- Copy the `bin/` folder from inside the downloaded zip file to `app/libnode/bin` (There are `copy-libnode.so-here` files in each architecture's path for convenience). If it's been done correctly you'll end with the following paths for the binaries:
1111
- `app/libnode/bin/arm64-v8a/libnode.so`
1212
- `app/libnode/bin/armeabi-v7a/libnode.so`
@@ -34,20 +34,17 @@ Using the Android Studio's New Project wizard, create a new Project with the fol
3434
- `Runtime TYpe Information Support (-frtti)` checked off
3535
1. Finish
3636

37-
### Create node.h
37+
### Copy libnode's header files
3838

39-
To access libnode's `Start()` entrypoint, a header file is required.
40-
Create a `node.h` file in the `cpp` folder (`app/src/main/cpp/`) with the following content:
39+
To access libnode's `Start()` entrypoint, the libnode's header files are required.
4140

42-
```h
43-
#ifndef SRC_NODE_H_
44-
#define SRC_NODE_H_
41+
Create the `libnode/` folder inside the project's `app/` folder. Copy the `include/` folder from inside the [downloaded zip file](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.3/nodejs-mobile-v0.1.3-android.zip) to `app/libnode/include`. If it's been done correctly you'll end with the following path for the `node.h` header file:
42+
- `app/libnode/include/node/node.h`
4543

46-
namespace node {
47-
int Start(int argc, char *argv[]);
48-
}
49-
#endif // SRC_NODE_H_
50-
```
44+
In `app/CMakeLists.txt` add the following line to add libnode's header files to the CMake include paths:
45+
```CMake
46+
include_directories(libnode/include/node/)
47+
```
5148

5249
### Add native JNI function to start node.js
5350

@@ -240,7 +237,7 @@ Since the app runs an HTTP server, it requires the right permissions in `app/src
240237

241238
#### Copy the `libnode.so` binaries to the project structure:
242239

243-
Create the `libnode/` folder inside the project's `app/` folder. Copy the `bin/` folder from inside the [downloaded zip file](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.2/nodejs-mobile-v0.1.2-android.zip) to `app/libnode/bin`. If it's been done correctly you'll end with the following paths for the binaries:
240+
Copy the `bin/` folder from inside the [downloaded zip file](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.3/nodejs-mobile-v0.1.3-android.zip) to `app/libnode/bin`. If it's been done correctly you'll end with the following paths for the binaries:
244241
- `app/libnode/bin/arm64-v8a/libnode.so`
245242
- `app/libnode/bin/armeabi-v7a/libnode.so`
246243
- `app/libnode/bin/x86/libnode.so`

android/native-gradle/app/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ add_library( # Sets the name of the library.
1919
# Provides a relative path to your source file(s).
2020
src/main/cpp/native-lib.cpp )
2121

22-
22+
#Includes node's header files.
23+
include_directories(libnode/include/node/)
24+
2325
add_library( libnode
2426
SHARED
2527
IMPORTED )
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 1995, 1999
3+
* Berkeley Software Design, Inc. All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
12+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14+
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
15+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
16+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
17+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
19+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
20+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21+
* SUCH DAMAGE.
22+
*
23+
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
24+
*/
25+
26+
#ifndef _IFADDRS_H_
27+
#define _IFADDRS_H_
28+
29+
struct ifaddrs {
30+
struct ifaddrs *ifa_next;
31+
char *ifa_name;
32+
unsigned int ifa_flags;
33+
struct sockaddr *ifa_addr;
34+
struct sockaddr *ifa_netmask;
35+
struct sockaddr *ifa_dstaddr;
36+
void *ifa_data;
37+
};
38+
39+
/*
40+
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
41+
* to be included it must be included before this header file.
42+
*/
43+
#ifndef ifa_broadaddr
44+
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
45+
#endif
46+
47+
#include <sys/cdefs.h>
48+
49+
__BEGIN_DECLS
50+
extern int getifaddrs(struct ifaddrs **ifap);
51+
extern void freeifaddrs(struct ifaddrs *ifa);
52+
__END_DECLS
53+
54+
#endif

0 commit comments

Comments
 (0)