Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for WebAssembly #63

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Patch for WebAssembly #63

wants to merge 1 commit into from

Conversation

mglaman
Copy link
Owner

@mglaman mglaman commented Jul 23, 2024

Build a version of patch for WebAssembly to allow patching files inside of the WebAssembly runtime instead of in the archive (and not in composer.json)

Copy link
Owner Author

@mglaman mglaman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    <script src="patch.js"></script>
    <script>
        function applyPatch() {
            // Load files into Emscripten FS
            FS.writeFile('/file_to_patch', 'Original file content');
            FS.writeFile('/patch_file', 'Patch content');

            // Perform patching
            Module.ccall('apply_patch', 'number', ['string', 'string'], ['/file_to_patch', '/patch_file']);

            // Get the result
            const patchedFile = FS.readFile('/file_to_patch', { encoding: 'utf8' });
            console.log('Patched File:', patchedFile);
        }

        Module.onRuntimeInitialized = applyPatch;
    </script>

roughly

Comment on lines +31 to +32
RUN emconfigure ./configure
RUN emmake make
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emcc -o patch.js patch.c -s EXPORTED_FUNCTIONS="['_main', '_apply_patch']" -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant