N
nick
Has anyone here used preprocessing instructions in their js source,
for example to import other files, conditionally include bits of code
based on compile time options, etc?
If so, how did you do it?
I've discovered that using gcc with the -E option seems to work pretty
well. It feels hackish though, I don't totally trust it. Lines
beginning with # and : have to be removed from the output. The benefit
is that pretty much any C(++) preprocessor stuff can be used with
javascript... Is there a cleaner way to do this though?
# preprocess as chromium extension
cp src.js temp.c
echo '/** my chromium extension */' > out.js
gcc -DMY_VERSION=1.23 -DEXT_CHROMIUM=1 -E temp.c \
| sed s/^[#:].*// | jsmin >> out.js
rm temp.c
for example to import other files, conditionally include bits of code
based on compile time options, etc?
If so, how did you do it?
I've discovered that using gcc with the -E option seems to work pretty
well. It feels hackish though, I don't totally trust it. Lines
beginning with # and : have to be removed from the output. The benefit
is that pretty much any C(++) preprocessor stuff can be used with
javascript... Is there a cleaner way to do this though?
# preprocess as chromium extension
cp src.js temp.c
echo '/** my chromium extension */' > out.js
gcc -DMY_VERSION=1.23 -DEXT_CHROMIUM=1 -E temp.c \
| sed s/^[#:].*// | jsmin >> out.js
rm temp.c