Skip to content

Commit

Permalink
Fix build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jan 4, 2024
1 parent 78177be commit ae3b9ec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ python_compressed.js
/*compiler*.jar
/local_blockly_compressed_vertical.js
/chromedriver
# --flagfiles used on Windows
/*.config
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

## Local development

Requires Node.js (`node`), Python (`python3`), and Java (`java`). It is known to work in these environments but should work in others:

- Windows 10, Python 3.11.7 (Microsoft Store), Node.js 20.10.0 (nodejs.org installer), Java 11 (Temurin-11.0.21+9)

Python 3.12 currently does not work.

Install dependencies:

```sh
Expand All @@ -20,7 +26,7 @@ To build, run:
npm run prepublish
```

requires Python (2 or 3). scratch-gui development server must be restarted to update linked scratch-blocks.
scratch-gui development server must be restarted to update linked scratch-blocks.

<!--
#### Scratch Blocks is a library for building creative computing interfaces.
Expand Down
14 changes: 13 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

import sys

import errno, glob, json, os, re, subprocess, threading, codecs, functools
import errno, glob, json, os, re, subprocess, threading, codecs, functools, platform

if sys.version_info[0] == 2:
import httplib
Expand Down Expand Up @@ -333,9 +333,21 @@ def do_compile_local(self, params, target_filename):
for group in [[CLOSURE_COMPILER_NPM], dash_args]:
args.extend(filter(lambda item: item, group))

# On Windows, the command line is too long, so we save the arguments to a file instead
use_flagfile = platform.system() == "Windows"
if platform.system() == "Windows":
flagfile_name = target_filename + ".config"
with open(flagfile_name, "w") as f:
# \ needs to be escaped still
f.write(" ".join(args[1:]).replace("\\", "\\\\"))
args = [CLOSURE_COMPILER_NPM, "--flagfile", flagfile_name]

proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout, stderr) = proc.communicate()

if use_flagfile:
os.remove(flagfile_name)

# Build the JSON response.
filesizes = [os.path.getsize(value) for (arg, value) in params if arg == "js_file"]
return dict(
Expand Down

0 comments on commit ae3b9ec

Please sign in to comment.