debugging blockly

453 views
Skip to first unread message

Greg Varga

unread,
Jun 25, 2012, 6:01:28 PM6/25/12
to blo...@googlegroups.com
Hi,

when trying to
a) getting familiar with blockly
b) debugging code added to original source
it's kind of hard to track down problems, especially when using blockly_compressed.js.

I've put together a shell script that parses build.sh and creates a loader .js to use the original source for custom projects. and you just have to exchange blockly_compressed.js to blockly_debug_loader.js in the html.

With this, it's more convenient to debug the app you're developing with blockly. (E.g. when clicking somewhere on the canvas while profiling is running, you can see what functions were called).

--
greg

------------------------------
# relative path to build.sh
BUILD_SH_FILE=../build.sh

# the content of the js src loader file -- optional: change path to original source files in 'src' attribute
inc='function __include(file) {\r\n\tdocument.write("<script type='"'text/javascript' src='"'../"+file+"'"'></script>"'"'');\r\n}\r\n\r\n'

# load original build.sh to know which files were 'compressed' // demos/blockly_compressed.js excluded
buildSH=`cat ${BUILD_SH_FILE} | grep -Po "\S*\.js" | grep -Po "^[^/]*\.js"`

#iterate through 'compressed' .js files
for f in $buildSH
do
inc="$inc __include('$f');\r\n"
done

# save the loader file
echo "$inc" > blockly_debug_loader.js

Neil Fraser

unread,
Jun 25, 2012, 6:59:07 PM6/25/12
to blo...@googlegroups.com
On 25 June 2012 15:01, Greg Varga <sphe...@gmail.com> wrote:
> when trying to
> a) getting familiar with blockly
> b) debugging code added to original source
> it's kind of hard to track down problems, especially when using
> blockly_compressed.js.
>
> I've put together a shell script that parses build.sh and creates a loader
> .js to use the original source for custom projects. and you just have to
> exchange blockly_compressed.js to blockly_debug_loader.js in the html.
>
> With this, it's more convenient to debug the app you're developing with
> blockly. (E.g. when clicking somewhere on the canvas while profiling is
> running, you can see what functions were called).

I hate to do this to you, but I just blew away build.sh and replaced
it with a more advanced build.py. The new build file creates a fully
compressed file, not just a concatenated one.

I'm happy to tweak build.py so that you can call it as a library and
extract the filename list, if that helps...

--
Neil Fraser
http://neil.fraser.name

sph3r

unread,
Jun 25, 2012, 11:45:34 PM6/25/12
to blo...@googlegroups.com
Neil,

it's ok, this is how things work during the development process :)

however, during the development process (both for the framework and the app you're building on top of it), it's good to be able to have all the source files loaded and not just the compressed one (as we don't care about multiple http requests locally:).

i've made some changes to your build.sh, but i didn't want to spam the group, so i've sent it to your email address.

--
greg

Neil Fraser

unread,
Jun 26, 2012, 12:00:02 AM6/26/12
to blo...@googlegroups.com
On 25 June 2012 20:45, sph3r <sphe...@gmail.com> wrote:
> however, during the development process (both for the framework and the app
> you're building on top of it), it's good to be able to have all the source
> files loaded and not just the compressed one (as we don't care about
> multiple http requests locally:).

Note that tests/playground.html uses uncompressed files. When
hacking, that's the one I use.
Reply all
Reply to author
Forward
0 new messages