| 56 | |
| 57 | |
| 58 | def copy_emscripten(target): |
| 59 | script_dir = os.path.dirname(os.path.abspath(__file__)) |
| 60 | emscripten_root = os.path.dirname(script_dir) |
| 61 | |
| 62 | excludes = EXCLUDES |
| 63 | |
| 64 | os.chdir(emscripten_root) |
| 65 | for root, dirs, files in os.walk('.'): |
| 66 | # Handle the case where the target directory is underneath emscripten_root |
| 67 | if os.path.abspath(root) == os.path.abspath(target): |
| 68 | dirs.clear() |
| 69 | continue |
| 70 | |
| 71 | remove_dirs = [] |
| 72 | for d in dirs: |
| 73 | if d in EXCLUDE_PATTERNS: |
| 74 | remove_dirs.append(d) |
| 75 | continue |
| 76 | fulldir = os.path.normpath(os.path.join(root, d)) |
| 77 | if fulldir in EXCLUDES: |
| 78 | remove_dirs.append(d) |
| 79 | continue |
| 80 | os.makedirs(os.path.join(target, fulldir)) |
| 81 | |
| 82 | for d in remove_dirs: |
| 83 | # Prevent recursion in excluded dirs |
| 84 | logger.debug('skipping dir: ' + os.path.join(root, d)) |
| 85 | dirs.remove(d) |
| 86 | |
| 87 | for f in files: |
| 88 | if any(fnmatch.fnmatch(f, pat) for pat in EXCLUDE_PATTERNS): |
| 89 | logger.debug('skipping file: ' + os.path.join(root, f)) |
| 90 | continue |
| 91 | full = os.path.normpath(os.path.join(root, f)) |
| 92 | if full in excludes: |
| 93 | logger.debug('skipping file: ' + os.path.join(root, f)) |
| 94 | continue |
| 95 | logger.debug('installing file: ' + os.path.join(root, f)) |
| 96 | shutil.copy2(full, os.path.join(target, root, f), follow_symlinks=False) |
| 97 | |
| 98 | |
| 99 | def npm_install(target): |