Google closure compiler application using multiple files and how not to print standard output - google-closure-compiler

I'm using Google closure compiler application and can't figure out which of the following commands from the help menu would turn off the printing of standard output.
I'm combining multiple js files:
compiler-latest TimPeterson$ java -jar compiler.jar --js assets/js/file1.js
assets/js/file2.js --js_output_file assets/js/file.min.js
note: here's the command to access the help menu
compiler-latest TimPeterson$ java -jar compiler.jar --help

When using the --js_output_file option, the compiler prints warnings and errors to the terminal (to standard error). The compiler should not write anything to standard output in this case.
Note that the standard error can include significant portions of the code you'd like to have compiled in its compiled form. This is not standard output though.

You can use https://github.com/knyga/kjscompiler
It compiles js files in project. And watch the dependencies

Related

Karate Runner -> karate jar : Command line args settings issue

I am using Visual Studio code and Karate Runner plugin is installed. Using karate-config.js with standalone jar (karate.jar). I have tried to configure in karate runner settings in VS code for Karate Runner -> karate jar : Command line args as "java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main" but it throws an exception like
Executing task: java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9" <
Error: Could not find or load main class .config.dir=test.resources.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9"" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Also, I have tried full path for -Dkarate.config.dir=D:/GitHub/KarateTestFramework/test/resources but didn't work either.
Please guide me to resolve this issue.
#ChandramohanRamabadran, I tried to replicate the issue on my system. I believe it's not a bug!
It's happening because your VisualStudio is using PowerShell instead of CMD. I believe you might have missed the step to change the default shell of VisualStudio after installing Karate. Try updating the default shell from PowerShell to CMD; then you should be good.
However, if you still want to use PowerShell, then update the command
java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main
to
java `-Dkarate.config.dir`=test/resources/ -cp karate.jar com.intuit.karate.Main
More context over the issue:
PowerShell has a more standard rule to parse system-properties parameters which are different from CMD. In a PowerShell command, the parameter names always begin with a hyphen. The hyphen tells PowerShell that the item in the command is a parameter name.
Here, we are passing the parameter as -Dkarate.config.dir, PowerShell sights the parameter name-tag as -Dkarate and not -Dkarate.config.dir; hence the error.
This is a bug. Thanks for reporting it: https://github.com/intuit/karate/issues/1330
For now please find a workaround. Karate will look for karate-config.js in the current directory or the classpath. So if you change the command to something like this (please try variations) it should work
-cp 'karate.jar;test/resources/'
I have changed preferred terminal shell from Powershell to command as default for VS code and followed the below listed steps
Press Ctrl + Shift + P to show all commands.
Type shell in the displayed text box to filter the list.
Select Terminal: Select Default Shell .
You will be prompted to Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now.
I have changed the karate runner->karate jar:Command Line Args settings as java -Dkarate.config.dir=resources/ -cp karate.jar com.intuit.karate.Main
Now its working fine.

Compiling C++ code for R (CRAN) packages on Solaris

I am a little bit confused on how to efficiently prepare the R package, so that it will be compatible across all needed system platforms. This is needed so that the new version of package will be accepted by CRAN. The main difficulty comes from compiling external C++ shared library, and optionally CUDA version if the compiler is available. To support this flow I've created specific Makefile, unfortunately using GNU-extensions. It works fine on Linux, OSX and when executed manually via gmake on Solaris. Relevant part is here:
# Checking whether nvcc compiler is available
NVCC_TEST = $(shell basename $(shell which nvcc 2> /dev/null)"")
ifeq ($(NVCC_TEST),nvcc)
ALL_LIBS += libcucubes_gpu.so
ALL_OBJS += $(GPU_OBJS)
ALL_FLAGS += $(GPU_FLAGS)
else
ALL_OBJS += gpu_fallback.o
endif
Turns out that, when running R CMD INSTALL (...) on Solaris, the installation fails on something like this:
make: Fatal error in reader: Makefile, line 39: Unexpected end of line seen
ERROR: compilation failed for package 'libcucubes'
As it turns out, it is caused by the fact that Solaris' version of make is executed instead of GNU-compatible gmake (I've tested it works fine), even though it is available. My question is whether there is any simple way to force usage of gmake here, for the R package build. In general I know I could use autotools to solve compatibility issues during installation, but it seems to bring too much complexity for that simple case. Any advices will be really appreciated, thanks!
If you can't get your build process to use gmake instead of Solaris's pure POSIX make, you can use this hack:
Make a dedicated directory for this hack: mkdir $HOME/make_hack
Softlink gmake asmakein that directory: ln -s /path/to/gmake $HOME/make_hack/make
Set your PATH: PATH=$HOME/make_hack:$PATH
Now, run your build process using that PATH, and it should use gmake. Hopefully it just uses make from its PATH envval and not some hardcoded full path.
Yeah, it's a hack. But it's probably a lot easier than modifying the build process to use gmake instead of make.
From Writing R Extensions:
If you really must require GNU make, declare it in the DESCRIPTION
file by
SystemRequirements: GNU make
and ensure that you use the value of environment variable MAKE (and
not just make) in your scripts.
configure scripts are the preferred solution though. BTW, in general a Makevars file is also preferred over a full Makefile.

google closure compiler - not inlining goog lib function calls?

I wrote a JavaScrip application a few years back using the closure framework and compiler. It uses goog.require, goog.provides and goog.inherits a lot, and was working fine using the old python script to build it.
I wanted it working again so I updated the library and compiler and used my old make script. But get this.
Closure Compiler now natively understands and orders Closure
dependencies and is prefererred over using this script for performing
JavaScript compilation. Please migrate your codebase. See:
https://github.com/google/closure-compiler/wiki/Managing-Dependencies
I read the link provided and did not see anything wrong. So I replaced the script with this.
java -jar C:/closure/closure-compiler-v20160713.jar --output_manifest _manifest.txt
--compilation_level ADVANCED_OPTIMIZATIONS --js M*.js
--js_output_file _M_min.js
It compiles fine, however when running I get errors such as...
_M_min.js?v=4:23 Uncaught ReferenceError: goog is not defined
_M_min.js?v=4:54 Uncaught TypeError: Cannot read property 'extend' of undefined
I thought the compiler unrolled all of this and did not require including the goog library at run time?
If I do include the library with "js/goog/base.js" I get goog.yb is not a function and so on. But I really did not think I needed to do this.
What am I doing wrong.
I think there are multiple problems:
You have to include closure library in your compilation as source. Adding --js path/to/closure/**.js will do it.
You need to use the dependency management flags. If you use goog.require and goog.provide in ALL of your files, you'll want strict mode.

Leiningen: Create executable jar to run without java -jar

I'm trying to understand how to package a command line application written in Clojure for distribution. I don't want users to have to use java -jar myproject.jar arg1 arg2 to run the program. PHP has something called "Phar" files, which are basically executable zip files, so they include a shebang that tells POSIX systems how to unpack and run them.
I've seen other Clojure apps that allow the jar file to be set chmod +x and then executed directly. How do they achieve this? Uberjar just seems to make a jar that requires the java -jar prefix.
You can do this using lein-bin.
Ah, I just found the answer to my own question. It's not standard functionality and you basically have to roll your own: https://github.com/tailrecursion/boot/blob/master/Makefile#L21

how to create a "makefile" for c++?

I usually work on visual c++ 2010 for creating console applications as programming problems. There is this submission which requires me to give the source for the file "Makefile" by some command in unix environment
all:
g++ program.cc -o program
since i don't use unix and have never created a "makefile". I don't know how to make this submission. I have read about a makefile which is supposed to give the directions dependencies etc for compiling the program. I am using the header files iostream string and iterator in the program. i have tried the "all:" command . The bash returns command not found.
Can someone help me with this submission? The code is ready but the only thing stopping for submitting is this "makefile". please include the shell commands as well.
You're missing newline and two tabs (yes, you read right, not spaces) after the all: line, something like this:
all:
g++ helloworld.cc -o helloworld
To invoke make, type make in the directory with the Makefile. Dependencies on system headers are usually not considered, if your code has just one file, you can safely ignore that.

Resources