sidhant-guliani / script-cover

Automatically exported from code.google.com/p/script-cover
Apache License 2.0
0 stars 0 forks source link

./build.py fails with a ClosureError build (with python2.7) #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. python2.7 ./build.py

What is the expected output? 
that ./build.py compiles without error

What do you see instead?
$ python2.7 ./build.py 
Running command: java -jar SoyToJsSrcCompiler.jar 
--shouldProvideRequireSoyNamespaces --outputPathFormat 
build_gen/src/coverage_report.soy.js src/coverage_report.soy
Running command: java -jar SoyToJsSrcCompiler.jar 
--shouldProvideRequireSoyNamespaces --outputPathFormat 
build_gen/src/popup.soy.js src/popup.soy
<generator object <genexpr> at 0x94c50a4>
Running command: closure-library/closure/bin/build/closurebuilder.py --root=src 
--root=closure-library --root=build_gen --output_mode=compiled 
--output_file=build/content_compiled.js --compiler_jar=compiler.jar 
--input=src/scriptLoader.js --input=src/instrumentation.js 
--input=src/startTool.js
ERROR:root:closure-library/closure/bin/build/closurebuilder.py: Scanning 
paths...
closure-library/closure/bin/build/closurebuilder.py: 791 sources scanned.
closure-library/closure/bin/build/closurebuilder.py: Building dependency tree..
closure-library/closure/bin/build/closurebuilder.py: Closure Compiler requires 
Java 1.6 or higher. Please visit http://www.java.com/getjava
closure-library/closure/bin/build/closurebuilder.py: JavaScript compilation 
failed.

Traceback (most recent call last):
  File "./build.py", line 223, in <module>
    main()
  File "./build.py", line 203, in main
    os.path.join('build', dest))
  File "./build.py", line 72, in BuildClosureScript
    raise ClosureError('Failed while compiling to %s.' % output_filename)
__main__.ClosureError: Failed while compiling to build/content_compiled.js.

Original issue reported on code.google.com by solstice.dhiver@gmail.com on 29 Oct 2011 at 7:53

GoogleCodeExporter commented 8 years ago
Hello, 

Thanks for your report. Could you, please, mention your OS and version of Java?
Do you still observe the same issue (if you download the latest version of 
ScriptCover code)?

Note: Today the build.py has been fixed to run on Windows. You need to have 
python in your PATH variable, and also Java 1.6 or higher though.

Original comment by ekamensk...@google.com on 17 Nov 2011 at 12:35

GoogleCodeExporter commented 8 years ago
With latest git (at cee1fc96c5c2a26fa3e7bde15abc5f229978fc80 commit), I got:
$ python2.7 ./build.py 
  File "./build.py", line 37
    os.path.join('closure-library', 'closure', 'bin',
     ^
SyntaxError: invalid syntax

so I have to fix the build.py file with
diff --git a/build.py b/build.py
index 613f72b..7d76ee8 100755
--- a/build.py
+++ b/build.py
@@ -33,9 +33,9 @@ CLOSURE_COMPILER_URL = 
('http://closure-compiler.googlecode.com/files/'
                         'compiler-latest.zip')
 SOY_COMPILER_URL = ('http://closure-templates.googlecode.com/files/'
                     'closure-templates-for-javascript-latest.zip')
-COMPILE_CLOSURE_COMMAND = ('python '
+COMPILE_CLOSURE_COMMAND = ('python ' + 
                            os.path.join('closure-library', 'closure', 'bin',
-                                        'build', 'closurebuilder.py')
+                                        'build', 'closurebuilder.py') +
                            ' --root=src'
                            ' --root=closure-library'
                            ' --root=build_gen'

then
$ python2.7 ./build.py 
Running command: java -jar SoyToJsSrcCompiler.jar 
--shouldProvideRequireSoyNamespaces --outputPathFormat 
build_gen/src/coverage_report.soy.js src/coverage_report.soy
Running command: java -jar SoyToJsSrcCompiler.jar 
--shouldProvideRequireSoyNamespaces --outputPathFormat 
build_gen/src/popup.soy.js src/popup.soy
Running command: python closure-library/closure/bin/build/closurebuilder.py 
--root=src --root=closure-library --root=build_gen --output_mode=compiled 
--output_file=build/content_compiled.js --compiler_jar=compiler.jar 
--input=src/scriptLoader.js --input=src/instrumentation.js 
--input=src/startTool.js
ERROR:root:closure-library/closure/bin/build/closurebuilder.py: Scanning 
paths...
closure-library/closure/bin/build/closurebuilder.py: 792 sources scanned.
closure-library/closure/bin/build/closurebuilder.py: Building dependency tree..
closure-library/closure/bin/build/closurebuilder.py: Closure Compiler requires 
Java 1.6 or higher. Please visit http://www.java.com/getjava
closure-library/closure/bin/build/closurebuilder.py: JavaScript compilation 
failed.

Traceback (most recent call last):
  File "./build.py", line 213, in <module>
    main()
  File "./build.py", line 193, in main
    os.path.join('build', dest))
  File "./build.py", line 71, in BuildClosureScript
    raise ClosureError('Failed while compiling to %s.' % output_filename)
__main__.ClosureError: Failed while compiling to build/content_compiled.js.

I am using archlinux (latest) and jdk 7-3
$ java -version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)

Original comment by solstice.dhiver@gmail.com on 17 Nov 2011 at 1:03

GoogleCodeExporter commented 8 years ago
Hi, thanks for your update!

Closure compiler gets your java version from the first line of "java -version" 
output. It should work fine, if you have:
$ java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)

Think about getting rid of "Picked up _JAVA_OPTIONS: 
-Dawt.useSystemAAFontSettings=on" from 'java -version' output.

Original comment by ekamensk...@google.com on 17 Nov 2011 at 1:37

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
it's not the closure compiler that is at fault but the GetJavaVersion function 
in ./closure-library/closure/bin/calcdeps.py

I don't know: use something like that:
version_line = [line for line in proc.stderr.read().splitlines() if 'version' 
in line][0]

Original comment by solstice.dhiver@gmail.com on 17 Nov 2011 at 3:27

GoogleCodeExporter commented 8 years ago
yes, this is the function which I was looking at (from 
http://code.google.com/p/closure-library/source/browse/trunk/closure/bin/calcdep
s.py?r=134):

def GetJavaVersion():
  """Returns the string for the current version of Java installed."""
  proc = subprocess.Popen(['java', '-version'], stderr=subprocess.PIPE)
  proc.wait()
  version_line = proc.stderr.read().splitlines()[0]
  return version_regex.search(version_line).group()

This is a know bug in Closure:
http://code.google.com/p/closure-library/issues/detail?id=287&q=Java%20version

Original comment by ekamensk...@google.com on 17 Nov 2011 at 3:36

GoogleCodeExporter commented 8 years ago
I fixed syntax error (from comment #2) in build.py in the latest code revision. 
Probably should work fine now.

As of issue in Closure (getting java version), I suppose it's better to send a 
patch to that project 
(http://code.google.com/p/closure-library/issues/detail?id=287).

Original comment by ekamensk...@google.com on 17 Nov 2011 at 3:46