Skip to content

Commit

Permalink
failing init
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakan committed Feb 5, 2023
1 parent 90eab11 commit 879e80e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions emscriptenbuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ elif [ "$1" == "Debug-async" ]; then
POST_JS="--post-js $(pwd)/post-async.js"
fi

# Before building, remove any ../libgit2/src/transports/emscriptenhttp.c left from running setup.sh
# Before building, remove any ../libgit2/src/transports/emscriptenhttp.c left from running setup.sh
[ -f "../libgit2/src/libgit2/transports/emscriptenhttp-async.c" ] && rm ../libgit2/src/libgit2/transports/emscriptenhttp-async.c

emcmake cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="$EXTRA_CMAKE_C_FLAGS --pre-js $(pwd)/pre.js $POST_JS -s \"EXTRA_EXPORTED_RUNTIME_METHODS=['FS','callMain']\" -lnodefs.js -lidbfs.js -s INVOKE_RUN=0 -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=131072" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON ../libgit2
emcmake cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="$EXTRA_CMAKE_C_FLAGS \
--pre-js $(pwd)/pre.js $POST_JS -sEXPORTED_FUNCTIONS=['_my_sqrt','_main','_malloc','_git_repository_open_ext','_git_repository_init'] -s \"EXTRA_EXPORTED_RUNTIME_METHODS=['FS','callMain','ccall','cwrap']\" -lnodefs.js -lidbfs.js -s INVOKE_RUN=0 -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=131072" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON ../libgit2
emmake make lg2
21 changes: 21 additions & 0 deletions examples/example_webworker_init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
importScripts('lg2.js');

Module.onRuntimeInitialized = () => {

FS.mkdir('/working');
FS.mount(MEMFS, { }, '/working');

FS.writeFile('/home/web_user/.gitconfig', '[user]\n' +
'name = Test User\n' +
'email = [email protected]');

// Allocate memory of 8 bytes for pointer (probably 4 would be enough)
let repoPointer = Module._malloc(8);

// int git_repository_init(git_repository **out, const char *path, unsigned int is_bare);
let git_repository_init = Module.cwrap('git_repository_init', 'number', ['number','string','number'])

let r1 = git_repository_init(repoPointer, "/working", 0)
console.log(`r1 ${r1}`);

};

0 comments on commit 879e80e

Please sign in to comment.