brick-module 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,6 +217,81 @@ ext.applyBrickModules = { settings, args ->
217
217
  gradle.rootProject.ext.brickProjectRoot = projectRoot
218
218
  gradle.rootProject.ext.brickAppProjectName = appProjectName
219
219
  configureAppProject(gradle)
220
+ // Inline: ensure RN autolinking doesn't fail due to missing codegen/jni for brick-module
221
+ gradle.rootProject.subprojects { subproj ->
222
+ if (subproj.name == 'brick-module') {
223
+ subproj.afterEvaluate {
224
+ try {
225
+ def dummyCMake = '''# Dummy CMakeLists.txt for React Native autolinking
226
+ # This file is required by React Native's autolinking system
227
+ # The actual TurboModule implementation is handled by brick-codegen in user projects
228
+ cmake_minimum_required(VERSION 3.13)
229
+ set(CMAKE_VERBOSE_MAKEFILE on)
230
+
231
+ # Header for BrickModuleSpec. When included by RN autolinking (no BRICKMODULESPEC_DUMMY_IMPL),
232
+ # include RN headers and provide an inline nullptr-returning implementation. When building the
233
+ # dummy static library (with BRICKMODULESPEC_DUMMY_IMPL), avoid depending on RN headers.
234
+ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/BrickModuleSpec.h [[
235
+ /** Auto-generated dummy header for BrickModuleSpec */
236
+ #pragma once
237
+ #include <memory>
238
+ #include <string>
239
+ namespace facebook { namespace react {
240
+
241
+ #ifndef BRICKMODULESPEC_DUMMY_IMPL
242
+ #include <ReactCommon/JavaTurboModule.h>
243
+ inline std::shared_ptr<TurboModule> BrickModuleSpec_ModuleProvider(
244
+ const std::string & /*moduleName*/, const JavaTurboModule::InitParams & /*params*/) {
245
+ return nullptr;
246
+ }
247
+ #else
248
+ class TurboModule; // forward declaration
249
+ class JavaTurboModule; // forward declaration
250
+ #endif
251
+
252
+ }} // namespace facebook::react
253
+ ]])
254
+
255
+ # Create a trivial compilation unit for the static library
256
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp [[
257
+ // Dummy TU for react_codegen_BrickModuleSpec
258
+ int brick_codegen_BrickModuleSpec_dummy = 0;
259
+ ]])
260
+
261
+ # Create an empty static library to satisfy React Native's build system
262
+ add_library(react_codegen_BrickModuleSpec STATIC ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
263
+
264
+ # Set necessary properties
265
+ target_include_directories(react_codegen_BrickModuleSpec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
266
+ target_compile_definitions(react_codegen_BrickModuleSpec PRIVATE BRICKMODULESPEC_DUMMY_IMPL=1)
267
+ '''
268
+
269
+ def prepareTask = subproj.tasks.findByName('prepareBrickModuleAutolinkCMake') ?: subproj.tasks.create('prepareBrickModuleAutolinkCMake') {
270
+ group = 'brick-module'
271
+ description = 'Creates a dummy CMakeLists.txt so RN autolinking can add_subdirectory for brick-module without error.'
272
+ doLast {
273
+ def jniDir = new File(subproj.buildDir, 'generated/source/codegen/jni')
274
+ if (!jniDir.exists()) {
275
+ jniDir.mkdirs()
276
+ }
277
+ def cmakeFile = new File(jniDir, 'CMakeLists.txt')
278
+ cmakeFile.text = dummyCMake
279
+ println("🧱 BrickModules: Prepared stub CMake at ${cmakeFile}")
280
+ }
281
+ }
282
+
283
+ if (subproj.tasks.findByName('preBuild')) {
284
+ subproj.preBuild.dependsOn(prepareTask)
285
+ }
286
+ } catch (Exception e) {
287
+ println("🧱 BrickModules: Failed to configure CMake stub for brick-module: ${e.message}")
288
+ }
289
+ }
290
+ }
291
+ }
292
+
293
+ // Note: We only wire the dependency for the app project below to avoid
294
+ // introducing cycles across all subprojects.
220
295
  }
221
296
  }
222
297
 
@@ -227,6 +302,24 @@ def configureAppProject(gradle) {
227
302
  if (project.name == appProjectName) {
228
303
  project.afterEvaluate {
229
304
  configureBrickModules(project)
305
+
306
+ // If brick-module exists, make sure native-related tasks run after stub CMake is prepared
307
+ def hasBrickModule = gradle.rootProject.subprojects.find { it.name == 'brick-module' } != null
308
+ if (hasBrickModule) {
309
+ try {
310
+ // Run early in the build
311
+ project.preBuild.dependsOn(":brick-module:prepareBrickModuleAutolinkCMake")
312
+ // Also guard native/CMake tasks
313
+ project.tasks.matching { t ->
314
+ def n = t.name.toLowerCase()
315
+ return n.contains('extern') || n.contains('cmake')
316
+ }.all { t ->
317
+ t.dependsOn(":brick-module:prepareBrickModuleAutolinkCMake")
318
+ }
319
+ } catch (Exception e) {
320
+ println("🧱 BrickModules: Failed to wire CMake stub dependency: ${e.message}")
321
+ }
322
+ }
230
323
  }
231
324
  }
232
325
  }
@@ -396,4 +489,3 @@ ${moduleNames}
396
489
  }
397
490
  """
398
491
  }
399
-
@@ -28,9 +28,9 @@ apply plugin: "com.android.library"
28
28
  apply plugin: "kotlin-android"
29
29
  apply from: "$projectDir/react-native-helpers.gradle"
30
30
 
31
- if (isNewArchitectureEnabled()) {
32
- apply plugin: "com.facebook.react"
33
- }
31
+
32
+ apply plugin: "com.facebook.react"
33
+
34
34
 
35
35
  def getExtOrDefault(name) {
36
36
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["BrickModule_" + name]
@@ -84,8 +84,8 @@ android {
84
84
  }
85
85
 
86
86
  compileOptions {
87
- sourceCompatibility JavaVersion.VERSION_1_8
88
- targetCompatibility JavaVersion.VERSION_1_8
87
+ sourceCompatibility JavaVersion.VERSION_17
88
+ targetCompatibility JavaVersion.VERSION_17
89
89
  }
90
90
  }
91
91
 
@@ -105,7 +105,7 @@ dependencies {
105
105
  api 'com.facebook.react:react-android:+'
106
106
  } else {
107
107
  // noinspection GradleDynamicVersion
108
- api 'com.facebook.react:react-native:+'
108
+ api 'com.facebook.react:react-android:0.81.1'
109
109
  }
110
110
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
111
111
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
@@ -117,12 +117,12 @@ task cleanButPreserveCMakeLists {
117
117
  doFirst {
118
118
  def cmakeFile = file("$buildDir/generated/source/codegen/jni/CMakeLists.txt")
119
119
  def cmakeContent = ""
120
-
120
+
121
121
  // Save CMakeLists.txt content if it exists
122
122
  if (cmakeFile.exists()) {
123
123
  cmakeContent = cmakeFile.text
124
124
  }
125
-
125
+
126
126
  // Store in project property for restoration
127
127
  project.ext.savedCMakeContent = cmakeContent
128
128
  }
@@ -131,7 +131,7 @@ task cleanButPreserveCMakeLists {
131
131
  // Override the clean task to preserve CMakeLists.txt
132
132
  clean {
133
133
  dependsOn cleanButPreserveCMakeLists
134
-
134
+
135
135
  doLast {
136
136
  // Restore CMakeLists.txt after clean
137
137
  if (project.hasProperty('savedCMakeContent') && project.savedCMakeContent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brick-module",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Better React Native native module development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "brick-codegen": "./bin/brick-codegen.js"
63
63
  },
64
64
  "dependencies": {
65
- "brick-codegen": "0.1.12"
65
+ "brick-codegen": "0.1.13"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": ">=18.2.0",