diff --git a/README_poolside.md b/README_poolside.md new file mode 100644 index 00000000..4c3ce338 --- /dev/null +++ b/README_poolside.md @@ -0,0 +1,20 @@ +# how to sync with upstream + +``` +git remote add upstream git@github.com: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.* \ No newline at end of file diff --git a/header_fix.py b/header_fix.py index c542a048..c5edd20e 100755 --- a/header_fix.py +++ b/header_fix.py @@ -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' @@ -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" @@ -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):