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

Copy source files into source map file #22190

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

Conversation

verhovsky
Copy link

@verhovsky verhovsky commented Jul 5, 2024

Closes #22189

@verhovsky verhovsky force-pushed the source-map-sources branch 2 times, most recently from a74fdff to 543f987 Compare July 30, 2024 01:31
@verhovsky
Copy link
Author

verhovsky commented Jul 30, 2024

To test this on M1 macOS, I had to

brew install llvm
git checkout f2568054e3ab2251647e87c8bd651373e1b003b7

make this edit

diff --git a/tools/building.py b/tools/building.py
index 900918b44..d2fc19d60 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -39,7 +39,7 @@ logger = logging.getLogger('building')
 
 #  Building
 binaryen_checked = False
-EXPECTED_BINARYEN_VERSION = 115
+EXPECTED_BINARYEN_VERSION = 117
 
 _is_ar_cache: Dict[str, bool] = {}
 # the exports the user requested

then

./bootstrap
make
./emcc --generate-config

then edit .emscripten and change LLVM_ROOT to this

LLVM_ROOT = '/opt/homebrew/opt/llvm/bin' # directory

then

make
./emcc --check

Then I did

cd ..
git clone https://github.com/tree-sitter/tree-sitter.git
cd tree-sitter
git checkout 3abb1047

made this edit there

 script/build-wasm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/script/build-wasm b/script/build-wasm
index d22b5875..c1a37414 100755
--- a/script/build-wasm
+++ b/script/build-wasm
@@ -117,6 +117,7 @@ exported_functions=$(
 
 # Use emscripten to generate `tree-sitter.js` and `tree-sitter.wasm`
 # in the `target/scratch` directory
+emcc=../emscripten/emcc
 $emcc                                            \
   -s WASM=1                                      \
   -s INITIAL_MEMORY=33554432                     \

then ran

./scripts/build-wasm

and it turns out that sourcesContent is removed by some other step (binaryen?) after if it's written with --sources in wasm-sourcemap.py with the fixes above.

@verhovsky verhovsky marked this pull request as draft July 30, 2024 01:39
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.

Embed source files in source map file
1 participant