build: pass directory instead of list of files to js2c.py

On Windows there is a limit to the length of commands, so there
will be an error once the lengths of the JS file names combined
exceed that limit. This patch modifies js2c.py so that
it now takes a --directory argument to glob for .js and
.mjs files in addition to the list of files passed directly.
We still pass the additional files we include from deps/
directly through the command line, as we only includes some of
them so we cannot simply glob, but those are limited so listing
them out should be fine.

Refs: https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation

PR-URL: https://github.com/nodejs/node/pull/39069
Refs: https://github.com/nodejs/node/pull/38971
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Joyee Cheung 2021-06-18 05:01:41 +08:00 committed by James M Snell
parent 11430a6de3
commit 44ecd41892
No known key found for this signature in database
GPG key ID: 7341B15C070877AC
4 changed files with 63 additions and 247 deletions

View file

@ -26,8 +26,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import glob
import platform
import re
import sys
# Reads a .list file into an array of strings
@ -106,3 +108,10 @@ def GuessArchitecture():
def IsWindows():
return GuessOS() == 'win32'
def SearchFiles(dir, ext):
list = glob.glob(dir+ '/**/*.' + ext, recursive=True)
if sys.platform == 'win32':
list = [ x.replace('\\', '/')for x in list]
return list