Skip to content

Commit 515f043

Browse files
committed
fix(ci): unbreak linux package build and stabilize ios bridge snapshot
- bin.js: guard the dist.cmake write with `existsSync(prebuilt)`. On non-darwin runners createLib + createXCFramework early-return for ios targets, so `<output>/prebuilt/` never exists; the template write was crashing with ENOENT and failing `cppjs build -p ios` on linux CI. When prebuilt artifacts are absent the template is meaningless, so silently skip. - ci snapshot: rename cppjs-sample-mobile-reactnative-cli/ci/.cppjs/... -> cppjs-sample-mobile-reactnative-cli/ci/cppjs-snapshot/... so that pnpm clear:cache:samples (and any future variant matching `**/.cppjs`) cannot accidentally wipe the bridge fixtures used by the iOS test workflow. Restore the four files that were lost in the previous deletion. - test-ios-sample.yml: copy snapshot contents into the sample's `.cppjs/` using `mkdir -p` + trailing `/.` so the restore never nests `cppjs-snapshot/` inside `.cppjs/` regardless of pre-existing state.
1 parent 8a0b918 commit 515f043

9 files changed

Lines changed: 272 additions & 11 deletions

File tree

.github/workflows/test-ios-sample.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ jobs:
7474
curl -fsSL "https://get.maestro.mobile.dev" | bash
7575
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
7676
- name: Restore cached bridge files
77-
run: cp -r ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/ci/.cppjs ./cppjs-samples/cppjs-sample-mobile-reactnative-cli
77+
run: |
78+
mkdir -p ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs
79+
cp -r ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/ci/cppjs-snapshot/. ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/
7880
- name: Build cppjs-sample-lib-prebuilt-matrix
7981
run: pnpm --filter=@cpp.js/sample-lib-prebuilt-matrix run build:ios
8082
- name: Pod install

cppjs-core/cpp.js/src/bin.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,13 @@ function buildLib(targetParams) {
315315
}
316316
}
317317

318-
const distCmakeContent = fs.readFileSync(`${state.config.paths.cli}/assets/cmake/dist.cmake`, { encoding: 'utf8', flag: 'r' })
319-
.replace('___PROJECT_NAME___', state.config.general.name)
320-
.replace('___PROJECT_HOST___', targets.map((t) => t.path).join(';'))
321-
.replace('___PROJECT_LIBS___', state.config.export.libName.join(';'));
322-
fs.writeFileSync(`${state.config.paths.output}/prebuilt/CMakeLists.txt`, distCmakeContent);
318+
if (fs.existsSync(`${state.config.paths.output}/prebuilt`)) {
319+
const distCmakeContent = fs.readFileSync(`${state.config.paths.cli}/assets/cmake/dist.cmake`, { encoding: 'utf8', flag: 'r' })
320+
.replace('___PROJECT_NAME___', state.config.general.name)
321+
.replace('___PROJECT_HOST___', targets.map((t) => t.path).join(';'))
322+
.replace('___PROJECT_LIBS___', state.config.export.libName.join(';'));
323+
fs.writeFileSync(`${state.config.paths.output}/prebuilt/CMakeLists.txt`, distCmakeContent);
324+
}
323325
}
324326

325327
async function createWasmJs(targetParams) {

cppjs-samples/cppjs-sample-lib-prebuilt-matrix/cppjs-sample-lib-prebuilt-matrix.podspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Pod::Spec.new do |s|
1212
s.source = { :http => "https://cpp.js.org" }
1313

1414
s.vendored_frameworks = 'cppjs-sample-lib-prebuilt-matrix.xcframework'
15-
# arm64-only iOS simulator slice; drop x86_64 to avoid linker errors on consumer apps.
15+
# arm64-only iOS simulator slice; drop x86_64 on both pod and consumer targets.
16+
# pod_target_xcconfig is required so CocoaPods' [CP] Copy XCFrameworks slice selector
17+
# (which reads $ARCHS in the pod target's context) matches ios-arm64-simulator instead
18+
# of silently warning and skipping the copy, which would leave the .a missing at link time.
19+
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
1620
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
1721
end

cppjs-samples/cppjs-sample-mobile-reactnative-cli/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,3 @@ yarn-error.log
8080
!.yarn/releases
8181
!.yarn/sdks
8282
!.yarn/versions
83-
84-
!ci/.cppjs
85-
!ci/.cppjs/build
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (https://www.swig.org).
3+
* Version 4.4.0
4+
*
5+
* Do not make changes to this file unless you know what you are doing - modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
/* -----------------------------------------------------------------------------
9+
* This section contains generic SWIG labels for method/variable
10+
* declarations/attributes, and other compiler dependent labels.
11+
* ----------------------------------------------------------------------------- */
12+
13+
/* template workaround for compilers that cannot correctly implement the C++ standard */
14+
#ifndef SWIGTEMPLATEDISAMBIGUATOR
15+
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
16+
# define SWIGTEMPLATEDISAMBIGUATOR template
17+
# elif defined(__HP_aCC)
18+
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
19+
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
20+
# define SWIGTEMPLATEDISAMBIGUATOR template
21+
# else
22+
# define SWIGTEMPLATEDISAMBIGUATOR
23+
# endif
24+
#endif
25+
26+
/* inline attribute */
27+
#ifndef SWIGINLINE
28+
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
29+
# define SWIGINLINE inline
30+
# else
31+
# define SWIGINLINE
32+
# endif
33+
#endif
34+
35+
/* attribute recognised by some compilers to avoid 'unused' warnings */
36+
#ifndef SWIGUNUSED
37+
# if defined(__GNUC__)
38+
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
39+
# define SWIGUNUSED __attribute__ ((__unused__))
40+
# else
41+
# define SWIGUNUSED
42+
# endif
43+
# elif defined(__ICC)
44+
# define SWIGUNUSED __attribute__ ((__unused__))
45+
# else
46+
# define SWIGUNUSED
47+
# endif
48+
#endif
49+
50+
#ifndef SWIG_MSC_UNSUPPRESS_4505
51+
# if defined(_MSC_VER)
52+
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
53+
# endif
54+
#endif
55+
56+
#ifndef SWIGUNUSEDPARM
57+
# ifdef __cplusplus
58+
# define SWIGUNUSEDPARM(p)
59+
# else
60+
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
61+
# endif
62+
#endif
63+
64+
/* internal SWIG method */
65+
#ifndef SWIGINTERN
66+
# define SWIGINTERN static SWIGUNUSED
67+
#endif
68+
69+
/* internal inline SWIG method */
70+
#ifndef SWIGINTERNINLINE
71+
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
72+
#endif
73+
74+
/* exporting methods */
75+
#if defined(__GNUC__)
76+
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
77+
# ifndef GCC_HASCLASSVISIBILITY
78+
# define GCC_HASCLASSVISIBILITY
79+
# endif
80+
# endif
81+
#endif
82+
83+
#ifndef SWIGEXPORT
84+
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
85+
# if defined(STATIC_LINKED)
86+
# define SWIGEXPORT
87+
# else
88+
# define SWIGEXPORT __declspec(dllexport)
89+
# endif
90+
# else
91+
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
92+
# define SWIGEXPORT __attribute__ ((visibility("default")))
93+
# else
94+
# define SWIGEXPORT
95+
# endif
96+
# endif
97+
#endif
98+
99+
/* calling conventions for Windows */
100+
#ifndef SWIGSTDCALL
101+
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
102+
# define SWIGSTDCALL __stdcall
103+
# else
104+
# define SWIGSTDCALL
105+
# endif
106+
#endif
107+
108+
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
109+
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
110+
# define _CRT_SECURE_NO_DEPRECATE
111+
#endif
112+
113+
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
114+
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
115+
# define _SCL_SECURE_NO_DEPRECATE
116+
#endif
117+
118+
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
119+
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
120+
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
121+
#endif
122+
123+
/* Intel's compiler complains if a variable which was never initialised is
124+
* cast to void, which is a common idiom which we use to indicate that we
125+
* are aware a variable isn't used. So we just silence that warning.
126+
* See: https://github.com/swig/swig/issues/192 for more discussion.
127+
*/
128+
#ifdef __INTEL_COMPILER
129+
# pragma warning disable 592
130+
#endif
131+
132+
#if defined(__cplusplus) && __cplusplus >=201103L
133+
# define SWIG_NOEXCEPT noexcept
134+
#else
135+
# define SWIG_NOEXCEPT throw()
136+
#endif
137+
138+
/* -----------------------------------------------------------------------------
139+
* swigcompat.swg
140+
*
141+
* Macros to provide support compatibility with older C and C++ standards.
142+
*
143+
* Note that SWIG expects __cplusplus to be defined to the appropriate C++ standard.
144+
* MSVC users are urged to check and examine the /Zc:__cplusplus compiler option.
145+
* See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus.
146+
* ----------------------------------------------------------------------------- */
147+
148+
/* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
149+
* if you're missing it.
150+
*/
151+
#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
152+
(defined __cplusplus && __cplusplus >= 201103L) || \
153+
defined SWIG_HAVE_SNPRINTF) && \
154+
!defined SWIG_NO_SNPRINTF
155+
# define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
156+
# define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
157+
#else
158+
/* Fallback versions ignore the buffer size, but most of our uses either have a
159+
* fixed maximum possible size or dynamically allocate a buffer that's large
160+
* enough.
161+
*/
162+
# define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
163+
# define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
164+
#endif
165+
166+
#include <emscripten/bind.h>
167+
168+
#ifdef __cplusplus
169+
#include <utility>
170+
/* SwigValueWrapper is described in swig.swg */
171+
template<typename T> class SwigValueWrapper {
172+
struct SwigSmartPointer {
173+
T *ptr;
174+
SwigSmartPointer(T *p) : ptr(p) { }
175+
~SwigSmartPointer() { delete ptr; }
176+
SwigSmartPointer& operator=(SwigSmartPointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
177+
void reset(T *p) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = p; }
178+
} pointer;
179+
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
180+
SwigValueWrapper(const SwigValueWrapper<T>& rhs);
181+
public:
182+
SwigValueWrapper() : pointer(0) { }
183+
SwigValueWrapper& operator=(const T& t) { SwigSmartPointer tmp(new T(t)); pointer = tmp; return *this; }
184+
#if __cplusplus >=201103L
185+
SwigValueWrapper& operator=(T&& t) { SwigSmartPointer tmp(new T(std::move(t))); pointer = tmp; return *this; }
186+
operator T&&() const { return std::move(*pointer.ptr); }
187+
#else
188+
operator T&() const { return *pointer.ptr; }
189+
#endif
190+
T *operator&() const { return pointer.ptr; }
191+
static void reset(SwigValueWrapper& t, T *p) { t.pointer.reset(p); }
192+
};
193+
194+
/*
195+
* SwigValueInit() is a generic initialisation solution as the following approach:
196+
*
197+
* T c_result = T();
198+
*
199+
* doesn't compile for all types for example:
200+
*
201+
* unsigned int c_result = unsigned int();
202+
*/
203+
template <typename T> T SwigValueInit() {
204+
return T();
205+
}
206+
207+
#if __cplusplus >=201103L
208+
# define SWIG_STD_MOVE(OBJ) std::move(OBJ)
209+
#else
210+
# define SWIG_STD_MOVE(OBJ) OBJ
211+
#endif
212+
213+
#endif
214+
215+
216+
#include "native.h"
217+
218+
EMSCRIPTEN_BINDINGS(Native) {
219+
emscripten::class_<Native>("Native")
220+
.smart_ptr<std::shared_ptr<Native>>("Native")
221+
.class_function("sample", &Native::sample)
222+
.smart_ptr_constructor("Native", &std::make_shared<Native>)
223+
;
224+
}
225+
226+
EMSCRIPTEN_BINDINGS(Functions_NATIVE) {
227+
emscripten::register_vector<std::shared_ptr<Native>>("VectorNative");
228+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["VectorNative", "Native"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef _NATIVE_I
2+
#define _NATIVE_I
3+
4+
%module NATIVE
5+
6+
%{
7+
#include "native.h"
8+
%}
9+
10+
%feature("shared_ptr");
11+
%feature("polymorphic_shared_ptr");
12+
13+
%include "native.h"
14+
15+
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"hashes": {
3+
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/src/native/native.h": "d105082c6e8c8652ea461e161c501e824b6b625f7b819490102c5c0699744249",
4+
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/build/interface/native.i": "eab7d231467438ee3e5f5af1c3ae64919c0514393461653981fb40f26b5edad3"
5+
},
6+
"interfaces": {
7+
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/src/native/native.h": "/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/build/interface/native.i"
8+
},
9+
"bridges": {
10+
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/build/interface/native.i": "/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/build/bridge/native.i.cpp"
11+
}
12+
}

cppjs-samples/cppjs-sample-mobile-reactnative-cli/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ EXTERNAL SOURCES:
20802080
:path: "../node_modules/react-native/ReactCommon/yoga"
20812081

20822082
SPEC CHECKSUMS:
2083-
cppjs-sample-lib-prebuilt-matrix: c8a7788fe42f5086e3b0b48b9756edde0a63c429
2083+
cppjs-sample-lib-prebuilt-matrix: e8ab1fffacc624daad0a64fe33273cfe11e38399
20842084
FBLazyVector: 26fd21c75314e101f280d401e97f27d54f3f7064
20852085
hermes-engine: b6cef8f1f6c726240e275520fd5cfdb6b2ff6826
20862086
RCTDeprecation: c7a2768f905d76ca6d2cfefb26e4349eacbdfca3

0 commit comments

Comments
 (0)