Skip to content

Commit

Permalink
Andrei feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchi committed Sep 9, 2024
1 parent 85a8095 commit 3edd529
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
20 changes: 20 additions & 0 deletions README_poolside.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# how to sync with upstream

```
git remote add upstream [email protected]:smacker/go-tree-sitter.git
git fetch upstream
git merge upstream/master # or some other branch that you want to merge with
```

There will be lots of conflicts. Unless we have changes we specifically made for poolside's use case and have not pushed to upstream, you probably will want to prefer upstream's version in any conflict.

Then you need to fix up some C header #include directives, mostly because upstream is OK with having Unix shortcuts in them but Forge cannot build with such. There is a python script in this repo to help you with that:

```
# in the root of go-tree-sitter repo:
./header_fix.py
```

If the script fails on some files, debug and fix the script and go again. Thank you very much. Make sure your merge commit and your script change commits are sepearate commits (OK to be in the same PR) so that it's easier to review the script changes.

*TODO: The script can generate new files. We do not have a good procedure to automatically clean them up during a merge with upstream.*
7 changes: 4 additions & 3 deletions header_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'python',
'ruby',
'rust',
#'typescript', Oh you are so special. You make me feel dumb
# typescript has a slightly different directory structure. Right now it works without fixing up headers.
#'typescript',
'kotlin',
'scala',
'zig'
Expand All @@ -46,7 +47,7 @@ def ls_exts(directory, extensions):


# fix_headers assumes some pre-processing is already done. Then it changes:
# #include "../foo/bar.h"
# #include "../bar.h"
# #include "./bar.h"
# #include "foo/bar.h"
# all into #include "bar.h"
Expand Down Expand Up @@ -121,7 +122,7 @@ def op_recur(src, dst_dir, operation):
headers.append(lines.split('"')[1])
for h in headers:
op_recur(h, dst_dir, operation)
operation(src, os.path.join(dst_dir, os.path.basename(src)))
operation(src, os.path.join(dst_dir))


def copy_with_extra_commends(src, dst):
Expand Down

0 comments on commit 3edd529

Please sign in to comment.