PDA

View Full Version : SenchaSDK jsbuilder does not parse comment <debug> excludes



aenigmatic
6 Jul 2011, 6:13 AM
After poking around for hours trying to use the automated application build tool, I have given up and generated my own jsb2 file with a batch script to use with the sencha SDK jsbuilder.bat (uses jsdb).

Everything works fine, (producing a minfied artifact, copying the resources etc) with the exception of the parser. The code for the parser appears to never be called, and my commented //<debug> tags are just removed as comments. The code they surround ends up in the production build.

Here is a sample of my .jsb2, preced by the command line I am calling it with :


jsbuilder -v -d . -p ps-build.jsb2

--begin ps-build.jsb2 --


{ "projectName" : "Part Source",
"deployDir" : "build",
"pkgs" : [
{
"name" : "Application",
"target" : "pkgs/application.js",
"id" : "app",
"files" : [
{
"path": ".\\",
"name": "app\\Application.js"
}
]
},
{
"name" : "Views",
"target" : "pkgs/Views.js",
"id" : "view",
"files" : [
{
"path":".\\app\\view\\",
"name":"AssociateMedia.js"
}
]
},
{
"name" : "Models",
"target" : "pkgs/Models.js",
"id" : "model",
"files" : [
{
"path":".\\app\\model\\",
"name":"Attribute.js"
}
]
},
{
"name" : "Stores",
"target" : "pkgs/Stores.js",
"id" : "store",
"files" : [
{
"path":".\\app\\store\\",
"name":"Brand.js"
}
]
},
{
"name" : "Controllers",
"target" : "pkgs/Controllers.js",
"id" : "controller",
"files" : [
{
"path":".\\app\\controller\\",
"name":"Application.js"
},
{
"path":".\\app\\controller\\",
"name":"AssociateMedia.js"
}
]
},
{
"name" : "Lib",
"target" : "pkgs/Lib.js",
"id" : "lib",
"files" : [
{
"path":".\\app\\lib\\",
"name":"List.js"
}
]
}
], "builds" : [
{
"name": "All",
"target": "part-source-all.js",
"options" : {
"debugLevel" : 3
},
"compress": true,
"packages": [
"lib",
"model",
"store",
"view",
"controller",
"app"
]
}
], "resources" : [
{
"src" : "./resources/",
"dest" : "resources"
}
]}

aenigmatic
8 Jul 2011, 6:52 AM
So I found the solution and figure I will post it here.

In the code I am trying to parse, the //<debug> statement was appearing after the end of an object definition as below




foo : {
bar : ""
} //<debug>



After reading through the parser source, I realized (seems obvious now) that it parses things line by line.. so all I had to do was put the //<debug> on it's own line and voila, everything works.

DiscoBoy
15 Jul 2011, 12:43 AM
I still have the same problem. My debug comments are each in a newline. What happens is that the debugger only fully removes debug comments and encapsulated code in my app entry (dev.js). In all other files (e.g. the first controller loaded by dev.js), only the debug comments are removed. The encaps. code still remains :(

Example:


//<debug>
/*
* Enable the loader for debugging (Will load only custom classes)!
*/
Ext.Loader.setConfig({
enabled: true
});
//</debug>

gets removed, while the following in my Controller gets not!


init: function() {
// Register listeners
NAMESPACE.Settings.on('settingschanged', function() {
this.setup();
}, this);
//<debug>
console.log('<Controller: ' + this.id + '> started!');
//</debug>
},

DiscoBoy
18 Jul 2011, 6:17 AM
Ping

Noone with the same experience here?

DiscoBoy
19 Jul 2011, 6:16 AM
Damm, this f***** b uild tool! :(
I wasted now more than one day trying to figure out what goes wrong! I wonder what QC Sencha has for releasing their build tool???

If i add now comments like this:


//<debug anyproperty="1">
...code...
//</debug>

my debug comments and the code are removed! Why this odd behaviour?

ext-app-builder.js is configured like this:


"builds": [
{
"name": "All Classes",
"target": "all-classes.js",
"options": {
"debug": true
},
"files": []
},
{
"name": "Application - Production",
"target": "app.js",
"compress": true,
"files": [
{ path: '', name: 'all-classes.js' },
{ path: '', name: 'dev.js' }
]
}
],All debug statements (also from ExtJS files) can still be found in the build files app.js (and all-classes.js), despite the one "top-level" debug-block which is in the dev.js file. This one gets removed with code correctly!

edspencer
19 Jul 2011, 10:52 PM
Just to be clear - you're saying that adding a <debug> tag with no attributes fails, but a <debug attr="something"> works correctly? Which operating system are you running?

DiscoBoy
19 Jul 2011, 11:23 PM
Thanks for the fast answer!
I'm using WinXP, and develop in Eclipse (UTF-8 and Unix line delimiter). I'm using the current sencha-sdk-1.2.2.
The adding of arbitrary attributes (<debug someattr="1">) is a workaround which i discovered yesterday. Sorry for being a bit unfriendly in my last post...it was just very frustrating to waste a whole day on this issue.

I use the SDK in Eclipse and start it with an ANT build task (Which sets all enviroment pathes correctly). The only modifications I had to make were substituting app.js with dev.js in ext-app-builder.js (see below) and the path generation in the same file to correctly work with file based and webserver based loading. These changes should not affect the parsing!

edspencer
19 Jul 2011, 11:34 PM
Oh I see - what command are you running when you call JSBuilder? The sencha command is set up for app.js as it's using the MVC architecture to figure out all of the dependencies automatically...

DiscoBoy
19 Jul 2011, 11:53 PM
This are the ANT tasks which (1) create the JSB-file and (2) build my app.js:


<target name="jsbfile">
<exec executable="${basedir}/build/sencha-sdk-${senchaSDK}/command/sencha.bat">
<arg value="create" />
<arg value="jsb" />
<arg value="-a" />
<arg value="build.html" /> <-- build.html links to dev.js
<arg value="-p" />
<arg value="app.jsb3" />
<env key="PATH" path="${env.PATH}:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;${basedir}/build/sencha-sdk-${senchaSDK};${basedir}/build/sencha-sdk-${senchaSDK}/appbuilder;${basedir}/build/sencha-sdk-${senchaSDK}/jsbuilder;${basedir}/build/sencha-sdk-${senchaSDK}/command;" />
</exec>
</target>



<target name="jsbapp">
<exec executable="${basedir}/build/sencha-sdk-${senchaSDK}/command/sencha.bat">
<arg value="build" />
<arg value="-p" />
<arg value="app.jsb3" />
<arg value="-d" />
<arg value="." />
<arg value="-s" />
<arg value="debug" />
<env key="PATH" path="${env.PATH}:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;${basedir}/build/sencha-sdk-${senchaSDK};${basedir}/build/sencha-sdk-${senchaSDK}/appbuilder;${basedir}/build/sencha-sdk-${senchaSDK}/jsbuilder;${basedir}/build/sencha-sdk-${senchaSDK}/command;" />
</exec>
</target>

This outputs me app.js!

The jsb file created by the previous sdk process looks like this:

{
"projectName": "PROJECTNAME",
"licenseText": "COPYRIGHTTEXT",
"builds": [
{
"name": "All Classes",
"target": "all-classes.js",
"options": {
"debug": true
},
"files": [
{
"path": "lib/ext-4.0.2/src/util/",
"name": "TextMetrics.js"
},
{
"path": "lib/ext-4.0.2/src/util/",
"name": "KeyMap.js"
},
{
"path": "lib/ext-4.0.2/src/util/",
"name": "Observable.js"
},
...
{
"path": "app/controller/app/",
"name": "Application.js"
}
]
},
{
"name": "Application - Production",
"target": "app.js",
"compress": true,
"files": [
{
"path": "",
"name": "all-classes.js"
},
{
"path": "",
"name": "dev.js"
}
]
}
],
"resources": []
}

To sum it up: app.js is build correctly with all dependencies, minimized etc. It's only the debug comments. The only ones removed are the ones in dev.js...nowhere else - if i'm not using my workaround with arbitrary attributes.

edspencer
20 Jul 2011, 12:50 AM
Not sure I understand - isn't it just because:



"options": {
"debug": true
},


is set on the all-classes.js build (it isn't on the dev.js build, so it will strip comments out there)

DiscoBoy
20 Jul 2011, 1:01 AM
Actually this is the sdks default! I tried to remove that/or set to false....but then the build fails...also in the second run all-classes.js & dev.js both are configured as files included for the build. So why debug-blocks should only be removed in dev.js and not in both?

Btw: Thanks for this interactive helping :)

DiscoBoy
20 Jul 2011, 1:21 AM
I now commented out the options and it worked suddenly without the workaround. Strange. I remember that yesterday this produced errors, but i think I replaced true with false instead of disabling fully.

edspencer
20 Jul 2011, 3:56 PM
I had actually just gone to bed at this point :) So at the moment I'm not sure - is this your bug or ours?

DiscoBoy
25 Jul 2011, 12:39 AM
Not sure either...the default setting of



"options": { "debug": true },

seemed to be the reason for me...I have no clue if others experience the same problems or not...but would be nice to hear.