Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test-ios-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ jobs:
curl -fsSL "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Restore cached bridge files
run: cp -r ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/ci/.cppjs ./cppjs-samples/cppjs-sample-mobile-reactnative-cli
run: |
mkdir -p ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs
cp -r ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/ci/cppjs-snapshot/. ./cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/
- name: Build cppjs-sample-lib-prebuilt-matrix
run: pnpm --filter=@cpp.js/sample-lib-prebuilt-matrix run build:ios
- name: Pod install
Expand Down
12 changes: 7 additions & 5 deletions cppjs-core/cpp.js/src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,13 @@ function buildLib(targetParams) {
}
}

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

async function createWasmJs(targetParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Pod::Spec.new do |s|
s.source = { :http => "https://cpp.js.org" }

s.vendored_frameworks = 'cppjs-sample-lib-prebuilt-matrix.xcframework'
# arm64-only iOS simulator slice; drop x86_64 to avoid linker errors on consumer apps.
# arm64-only iOS simulator slice; drop x86_64 on both pod and consumer targets.
# pod_target_xcconfig is required so CocoaPods' [CP] Copy XCFrameworks slice selector
# (which reads $ARCHS in the pod target's context) matches ios-arm64-simulator instead
# of silently warning and skipping the copy, which would leave the .a missing at link time.
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
end
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,3 @@ yarn-error.log
!.yarn/releases
!.yarn/sdks
!.yarn/versions

!ci/.cppjs
!ci/.cppjs/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.4.0
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* This section contains generic SWIG labels for method/variable
* declarations/attributes, and other compiler dependent labels.
* ----------------------------------------------------------------------------- */

/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
# define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
# define SWIGTEMPLATEDISAMBIGUATOR template
# else
# define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif

/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
# define SWIGINLINE inline
# else
# define SWIGINLINE
# endif
#endif

/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
# elif defined(__ICC)
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
#endif

#ifndef SWIG_MSC_UNSUPPRESS_4505
# if defined(_MSC_VER)
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
# endif
#endif

#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
# else
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif

/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif

/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif

/* exporting methods */
#if defined(__GNUC__)
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif
# endif
#endif

#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(STATIC_LINKED)
# define SWIGEXPORT
# else
# define SWIGEXPORT __declspec(dllexport)
# endif
# else
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
# define SWIGEXPORT __attribute__ ((visibility("default")))
# else
# define SWIGEXPORT
# endif
# endif
#endif

/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
# endif
#endif

/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif

/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif

/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#endif

/* Intel's compiler complains if a variable which was never initialised is
* cast to void, which is a common idiom which we use to indicate that we
* are aware a variable isn't used. So we just silence that warning.
* See: https://github.com/swig/swig/issues/192 for more discussion.
*/
#ifdef __INTEL_COMPILER
# pragma warning disable 592
#endif

#if defined(__cplusplus) && __cplusplus >=201103L
# define SWIG_NOEXCEPT noexcept
#else
# define SWIG_NOEXCEPT throw()
#endif

/* -----------------------------------------------------------------------------
* swigcompat.swg
*
* Macros to provide support compatibility with older C and C++ standards.
*
* Note that SWIG expects __cplusplus to be defined to the appropriate C++ standard.
* MSVC users are urged to check and examine the /Zc:__cplusplus compiler option.
* See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus.
* ----------------------------------------------------------------------------- */

/* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
* if you're missing it.
*/
#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
(defined __cplusplus && __cplusplus >= 201103L) || \
defined SWIG_HAVE_SNPRINTF) && \
!defined SWIG_NO_SNPRINTF
# define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
# define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
#else
/* Fallback versions ignore the buffer size, but most of our uses either have a
* fixed maximum possible size or dynamically allocate a buffer that's large
* enough.
*/
# define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
# define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
#endif

#include <emscripten/bind.h>

#ifdef __cplusplus
#include <utility>
/* SwigValueWrapper is described in swig.swg */
template<typename T> class SwigValueWrapper {
struct SwigSmartPointer {
T *ptr;
SwigSmartPointer(T *p) : ptr(p) { }
~SwigSmartPointer() { delete ptr; }
SwigSmartPointer& operator=(SwigSmartPointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
void reset(T *p) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = p; }
} pointer;
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
SwigValueWrapper(const SwigValueWrapper<T>& rhs);
public:
SwigValueWrapper() : pointer(0) { }
SwigValueWrapper& operator=(const T& t) { SwigSmartPointer tmp(new T(t)); pointer = tmp; return *this; }
#if __cplusplus >=201103L
SwigValueWrapper& operator=(T&& t) { SwigSmartPointer tmp(new T(std::move(t))); pointer = tmp; return *this; }
operator T&&() const { return std::move(*pointer.ptr); }
#else
operator T&() const { return *pointer.ptr; }
#endif
T *operator&() const { return pointer.ptr; }
static void reset(SwigValueWrapper& t, T *p) { t.pointer.reset(p); }
};

/*
* SwigValueInit() is a generic initialisation solution as the following approach:
*
* T c_result = T();
*
* doesn't compile for all types for example:
*
* unsigned int c_result = unsigned int();
*/
template <typename T> T SwigValueInit() {
return T();
}

#if __cplusplus >=201103L
# define SWIG_STD_MOVE(OBJ) std::move(OBJ)
#else
# define SWIG_STD_MOVE(OBJ) OBJ
#endif

#endif


#include "native.h"

EMSCRIPTEN_BINDINGS(Native) {
emscripten::class_<Native>("Native")
.smart_ptr<std::shared_ptr<Native>>("Native")
.class_function("sample", &Native::sample)
.smart_ptr_constructor("Native", &std::make_shared<Native>)
;
}

EMSCRIPTEN_BINDINGS(Functions_NATIVE) {
emscripten::register_vector<std::shared_ptr<Native>>("VectorNative");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["VectorNative", "Native"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _NATIVE_I
#define _NATIVE_I

%module NATIVE

%{
#include "native.h"
%}

%feature("shared_ptr");
%feature("polymorphic_shared_ptr");

%include "native.h"

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"hashes": {
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/src/native/native.h": "d105082c6e8c8652ea461e161c501e824b6b625f7b819490102c5c0699744249",
"/Users/runner/work/cpp.js/cpp.js/cppjs-samples/cppjs-sample-mobile-reactnative-cli/.cppjs/build/interface/native.i": "eab7d231467438ee3e5f5af1c3ae64919c0514393461653981fb40f26b5edad3"
},
"interfaces": {
"/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"
},
"bridges": {
"/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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
cppjs-sample-lib-prebuilt-matrix: c8a7788fe42f5086e3b0b48b9756edde0a63c429
cppjs-sample-lib-prebuilt-matrix: e8ab1fffacc624daad0a64fe33273cfe11e38399
FBLazyVector: 26fd21c75314e101f280d401e97f27d54f3f7064
hermes-engine: b6cef8f1f6c726240e275520fd5cfdb6b2ff6826
RCTDeprecation: c7a2768f905d76ca6d2cfefb26e4349eacbdfca3
Expand Down
Loading