Skip to content

Commit 30d8146

Browse files
authored
Merge pull request #3175 from react-native-yeouido/feature/fabric-example
[New Arch] Fabric Example
2 parents 4762f77 + d81d59d commit 30d8146

File tree

78 files changed

+4446
-1
lines changed

Some content is hidden

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

78 files changed

+4446
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ android/keystores/debug.keystore
5353

5454
# windows
5555
Deploy.binlog
56-
msbuild.binlog
56+
msbuild.binlog
57+
android/buildOutput_*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

android/build.gradle

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
buildscript {
6+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNSAC_kotlinVersion']
7+
8+
repositories {
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
14+
}
15+
}
216

317
def safeExtGet(prop, fallback) {
418
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
519
}
620

21+
def getExtOrDefault(name, defaultValue) {
22+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
23+
}
24+
25+
def isNewArchitectureEnabled() {
26+
// To opt-in for the New Architecture, you can either:
27+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
28+
// - Invoke gradle with `-newArchEnabled=true`
29+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
30+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
31+
}
32+
733
def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false)
834

935
println "useExoplayerIMA:" + useExoplayerIMA
@@ -16,6 +42,10 @@ def configStringPath = (
1642
'useExoplayerIMA' + useExoplayerIMA \
1743
).md5()
1844

45+
if (isNewArchitectureEnabled()) {
46+
apply plugin: "com.facebook.react"
47+
}
48+
1949
android {
2050
namespace 'com.brentvatne.react'
2151
compileSdkVersion safeExtGet('compileSdkVersion', 31)
@@ -31,6 +61,15 @@ android {
3161
targetSdkVersion safeExtGet('targetSdkVersion', 28)
3262
versionCode 1
3363
versionName "1.0"
64+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
65+
66+
ndk {
67+
abiFilters(*reactNativeArchitectures())
68+
}
69+
}
70+
71+
packagingOptions {
72+
exclude "**/libreact_render*.so"
3473
}
3574

3675
compileOptions {
@@ -50,12 +89,39 @@ android {
5089
}
5190
}
5291
}
92+
93+
sourceSets.main {
94+
java {
95+
if (isNewArchitectureEnabled()) {
96+
srcDirs += [
97+
"src/fabric/java",
98+
"${project.buildDir}/generated/source/codegen/java"
99+
]
100+
} else {
101+
srcDirs += [
102+
"src/oldarch/java"
103+
]
104+
}
105+
}
106+
}
107+
}
108+
109+
def reactNativeArchitectures() {
110+
def value = project.getProperties().get("reactNativeArchitectures")
111+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
53112
}
54113

55114
repositories {
56115
google()
116+
maven {
117+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
118+
url "$rootDir/../node_modules/react-native/android"
119+
}
120+
mavenCentral()
57121
}
58122

123+
def kotlin_version = getExtOrDefault('kotlinVersion', project.properties['RNSAC_kotlinVersion'])
124+
59125
dependencies {
60126
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
61127
implementation('com.google.android.exoplayer:exoplayer:2.18.1') {
@@ -76,4 +142,5 @@ dependencies {
76142
implementation 'com.google.android.exoplayer:extension-ima:2.18.1'
77143
}
78144
implementation "com.squareup.okhttp3:okhttp:" + '$OKHTTP_VERSION'
145+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
79146
}

examples/FabricExample/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
overrides: [
7+
{
8+
files: ['*.ts', '*.tsx'],
9+
rules: {
10+
'@typescript-eslint/no-shadow': ['error'],
11+
'no-shadow': 'off',
12+
'no-undef': 'off',
13+
},
14+
},
15+
],
16+
};

examples/FabricExample/.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
ios/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
35+
# node.js
36+
#
37+
node_modules/
38+
npm-debug.log
39+
yarn-error.log
40+
41+
# BUCK
42+
buck-out/
43+
\.buckd/
44+
*.keystore
45+
!debug.keystore
46+
47+
# fastlane
48+
#
49+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
50+
# screenshots whenever they are needed.
51+
# For more information about the recommended setup visit:
52+
# https://docs.fastlane.tools/best-practices/source-control/
53+
54+
**/fastlane/report.xml
55+
**/fastlane/Preview.html
56+
**/fastlane/screenshots
57+
**/fastlane/test_output
58+
59+
# Bundle artifact
60+
*.jsbundle
61+
62+
# Ruby / CocoaPods
63+
/ios/Pods/
64+
/vendor/bundle/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)