Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
KusStar committed Nov 30, 2023
1 parent 6583cb1 commit 3f7f6af
Show file tree
Hide file tree
Showing 9 changed files with 13,413 additions and 25 deletions.
32 changes: 20 additions & 12 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
cmake_minimum_required(VERSION 3.4.1)
project(FastURL)
cmake_minimum_required(VERSION 3.9.0)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 11)

add_library(cpp
SHARED
../cpp/react-native-fast-url.cpp
cpp-adapter.cpp
)
set(PACKAGE_NAME "fast-url")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)

# Specifies a path to native header files.
include_directories(
../cpp
)
include_directories(../cpp)

add_library(${PACKAGE_NAME} SHARED ../cpp/fast-url.cpp cpp-adapter.cpp)

set_target_properties(
${PACKAGE_NAME}
PROPERTIES CXX_STANDARD 17
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)

target_link_libraries(${PACKAGE_NAME} fbjni::fbjni ReactAndroid::jsi android)
32 changes: 31 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ buildscript {
}
}

def resolveBuildType() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()

return tskReqStr.contains('Release') ? 'release' : 'debug'
}

def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}
Expand Down Expand Up @@ -56,9 +68,22 @@ android {

externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all -DONANDROID -std=c++1y"
arguments '-DANDROID_STL=c++_shared'
abiFilters (*reactNativeArchitectures())
}
}

packagingOptions {
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
excludes = [
"META-INF",
"META-INF/**",
"**/libjsi.so",
"**/libc++_shared.so",
"**/libfbjni.so"
]
}
}

externalNativeBuild {
Expand All @@ -67,6 +92,11 @@ android {
}
}

buildFeatures {
buildConfig true
prefab true
}

buildTypes {
release {
minifyEnabled false
Expand Down
2 changes: 1 addition & 1 deletion android/cpp-adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <jni.h>
#include "react-native-fast-url.h"
#include "fast-url.h"

extern "C"
JNIEXPORT jdouble JNICALL
Expand Down
2 changes: 1 addition & 1 deletion cpp/react-native-fast-url.cpp → cpp/fast-url.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "react-native-fast-url.h"
#include "fast-url.h"

namespace fasturl {
double multiply(double a, double b) {
Expand Down
8 changes: 8 additions & 0 deletions cpp/fast-url.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef FASTURLPARSER_H
#define FASTURLPARSER_H

namespace fasturl {
double multiply(double a, double b);
}

#endif /* FASTURLPARSER_H */
8 changes: 0 additions & 8 deletions cpp/react-native-fast-url.h

This file was deleted.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/metro-config": "^0.72.11",
"metro-react-native-babel-preset": "0.76.8",
"babel-plugin-module-resolver": "^5.0.0",
"metro-react-native-babel-preset": "0.76.8",
"pod-install": "^0.1.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion ios/FastUrl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifdef __cplusplus
#import "react-native-fast-url.h"
#import "fast-url.h"
#endif

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down
Loading

0 comments on commit 3f7f6af

Please sign in to comment.