Skip to content

Commit ce6cd19

Browse files
committed
Merge branch 'dev-0.17'
2 parents 762eb1b + de7fe61 commit ce6cd19

File tree

15 files changed

+1476
-352
lines changed

15 files changed

+1476
-352
lines changed

CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android")
100100
)
101101
endif()
102102

103+
# Builds & places for packing the glob library, for Android-targeted builds.
104+
if(CMAKE_SYSTEM_NAME MATCHES "Android")
105+
execute_process(
106+
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/glob
107+
-B ${CMAKE_BINARY_DIR}/glob
108+
-DCMAKE_BUILD_TYPE=Release
109+
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/sysroot
110+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
111+
${EXTRA_BUILD_ARGS}
112+
COMMAND_ECHO STDOUT
113+
COMMAND_ERROR_IS_FATAL ANY
114+
)
115+
execute_process(
116+
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/glob
117+
--config Release ${EXTRA_INSTALL_ARGS}
118+
)
119+
execute_process(COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR}/glob)
120+
file(
121+
COPY ${CMAKE_BINARY_DIR}/sysroot/lib/libglob.so
122+
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/android/src/main/jniLibs/${ANDROID_ABI}
123+
)
124+
endif()
125+
103126
if(CMAKE_SYSTEM_NAME MATCHES "Android|Windows")
104127
set(BUILD_SHARED_LIBS 1)
105128
endif()

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,6 @@ and [old][Old Architecture] RN architectures.
180180
from NPM._
181181
182182
- For **Android**:
183-
- In the `build.gradle` file set `minSdkVersion` equal `28`
184-
([SDK 28 — Android 9](https://developer.android.com/studio/releases/platforms#9.0),
185-
released in August 2018), or larger. \
186-
**Note:** _Support of older SDKs is technically possible, but it is not
187-
a priority now._
188-
189183
- Android SDK 28 and above
190184
[forbids Cleartext / Plaintext HTTP](https://developer.android.com/privacy-and-security/risks/cleartext)
191185
by default. Thus, to access locally running server over HTTP from within

android/src/main/java/com/lighttpd/Server.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.lighttpd
22

33
import android.util.Log
44
import com.drpogodin.reactnativestaticserver.Errors
5-
import java.util.function.BiConsumer
65

76
/**
87
* Java interface for native Lighttpd server running in a dedicated Thread.
@@ -25,7 +24,7 @@ class Server(
2524
val id: Double,
2625
var configPath: String,
2726
var errlogPath: String,
28-
private val signalConsumer: BiConsumer<String, String?>
27+
private val signalConsumer: (signal: String, message: String?) -> Unit
2928
) : Thread() {
3029
override fun interrupt() {
3130
Log.i(LOGTAG, "Server.interrupt() triggered")
@@ -42,7 +41,7 @@ class Server(
4241
if (activeServer != null) {
4342
val msg = "Another Server instance is active"
4443
Log.e(LOGTAG, msg)
45-
signalConsumer.accept(CRASHED, msg)
44+
signalConsumer(CRASHED, msg)
4645
return
4746
}
4847
try {
@@ -56,11 +55,11 @@ class Server(
5655
// signals.
5756
activeServer = null
5857
Log.i(LOGTAG, "Server terminated gracefully")
59-
signalConsumer.accept(TERMINATED, null)
58+
signalConsumer(TERMINATED, null)
6059
} catch (error: Exception) {
6160
activeServer = null
6261
Log.e(LOGTAG, "Server crashed", error)
63-
signalConsumer.accept(CRASHED, error.message)
62+
signalConsumer(CRASHED, error.message)
6463
}
6564
}
6665

@@ -79,7 +78,7 @@ class Server(
7978
// NOTE: @JvmStatic annotation is needed to make this function
8079
// visible via JNI in C code.
8180
@JvmStatic fun onLaunchedCallback() {
82-
activeServer!!.signalConsumer.accept(LAUNCHED, null)
81+
activeServer!!.signalConsumer(LAUNCHED, null)
8382
}
8483
}
8584
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript {
22
ext {
33
buildToolsVersion = "34.0.0"
4-
minSdkVersion = 28
4+
minSdkVersion = 23
55
compileSdkVersion = 34
66
targetSdkVersion = 34
77
ndkVersion = "26.1.10909125"

example/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PODS:
2222
- ReactCommon/turbomodule/bridging
2323
- ReactCommon/turbomodule/core
2424
- Yoga
25-
- dr-pogodin-react-native-static-server (0.16.0):
25+
- dr-pogodin-react-native-static-server (0.17.0):
2626
- DoubleConversion
2727
- glog
2828
- hermes-engine
@@ -1279,7 +1279,7 @@ PODS:
12791279
- ReactCommon/turbomodule/bridging
12801280
- ReactCommon/turbomodule/core
12811281
- Yoga
1282-
- react-native-webview (13.11.1):
1282+
- react-native-webview (13.12.1):
12831283
- DoubleConversion
12841284
- glog
12851285
- hermes-engine
@@ -1773,7 +1773,7 @@ SPEC CHECKSUMS:
17731773
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
17741774
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
17751775
dr-pogodin-react-native-fs: d4852b7b2d5f6a9d40627dce4a8a30f865634eef
1776-
dr-pogodin-react-native-static-server: f4c365cf9e5ba07fd0d10504572f661039562ba3
1776+
dr-pogodin-react-native-static-server: fbba57f5167d431e10644029cb8efd45a45a06f2
17771777
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
17781778
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
17791779
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
@@ -1807,7 +1807,7 @@ SPEC CHECKSUMS:
18071807
React-logger: 8db32983d75dc2ad54f278f344ccb9b256e694fc
18081808
React-Mapbuffer: 1c08607305558666fd16678b85ef135e455d5c96
18091809
React-microtasksnativemodule: f13f03163b6a5ec66665dfe80a0df4468bb766a6
1810-
react-native-webview: 8e4d4384fe7c702804d6b3d3d21b1fa98077cd7e
1810+
react-native-webview: 987318278133db89939305abefc47ebb28ed4af8
18111811
React-nativeconfig: 57781b79e11d5af7573e6f77cbf1143b71802a6d
18121812
React-NativeModulesApple: 7ff2e2cfb2e5fa5bdedcecf28ce37e696c6ef1e1
18131813
React-perflogger: 8a360ccf603de6ddbe9ff8f54383146d26e6c936

example/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
},
1414
"dependencies": {
1515
"@dr.pogodin/react-native-fs": "^2.28.0",
16-
"@dr.pogodin/react-native-webview": "^13.11.1",
16+
"@dr.pogodin/react-native-webview": "^13.12.1",
1717
"react": "18.3.1",
1818
"react-native": "0.75.2",
19-
"react-native-windows": "0.75.0"
19+
"react-native-windows": "0.75.1"
2020
},
2121
"devDependencies": {
2222
"@babel/core": "^7.25.2",
2323
"@babel/preset-env": "^7.25.4",
24-
"@babel/runtime": "^7.25.4",
24+
"@babel/runtime": "^7.25.6",
2525
"@react-native/babel-preset": "0.75.2",
2626
"@react-native/metro-config": "0.75.2",
2727
"@react-native/typescript-config": "0.75.2",
28-
"metro-config": "^0.80.10",
28+
"metro-config": "^0.80.12",
2929
"react-native-builder-bob": "^0.30.0"
3030
},
3131
"engines": {

glob/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
2+
project(GLOB C)
3+
4+
set(CMAKE_C_STANDARD 99)
5+
set(CMAKE_C_STANDARD_REQUIRED TRUE)
6+
7+
set(HEADERS collate.h freebsd-compat.h glob.h)
8+
set(SOURCES glob.c)
9+
10+
add_compile_definitions(__USE_BSD)
11+
add_library(glob ${HEADERS} ${SOURCES})
12+
13+
install(TARGETS glob)
14+
install(FILES ${HEADERS} DESTINATION include)

glob/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The Glob library is a part of Android SDK starting from SDK 28; thus, to support
2+
older SDKs we compile it from sources. These source files are taken from
3+
the https://android.googlesource.com/platform/bionic repository
4+
([bionic](https://en.wikipedia.org/wiki/Bionic_%28software%29)
5+
is Android's C library, math library, and dynamic linker).

glob/collate.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "freebsd-compat.h"
2+
3+
/**
4+
* [reallocarray(3)](https://man7.org/linux/man-pages/man3/realloc.3.html) resizes
5+
* allocated memory on the heap.
6+
*
7+
* Equivalent to `realloc(__ptr, __item_count * __item_size)` but fails if the
8+
* multiplication overflows.
9+
*
10+
* Returns a pointer (which may be different from `__ptr`) to the resized
11+
* memory on success and returns a null pointer and sets `errno` on failure
12+
* (but see the notes for malloc()).
13+
*/
14+
#if __ANDROID_API__ >= 29
15+
void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __INTRODUCED_IN(29);
16+
#else
17+
#include <errno.h>
18+
static __inline void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) {
19+
size_t __new_size;
20+
if (__builtin_mul_overflow(__item_count, __item_size, &__new_size)) {
21+
errno = ENOMEM;
22+
return NULL;
23+
}
24+
return realloc(__ptr, __new_size);
25+
}
26+
#endif

glob/freebsd-compat.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2013 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#define _BSD_SOURCE
20+
21+
#define REPLACE_GETOPT
22+
23+
/* FreeBSD has this, but we can't really implement it correctly on Linux. */
24+
#define issetugid() 0
25+
26+
#define __compiler_membar() __asm __volatile(" " : : : "memory")

0 commit comments

Comments
 (0)