rokucommunity / roku-debug

A compatibility wrapper around the BrightScript debug protocol https://developer.roku.com/en-ca/docs/developer-program/debugging/socket-based-debugger.md
MIT License
13 stars 8 forks source link

Source dirs priority issue when setting breakpoints #9

Closed elsassph closed 4 years ago

elsassph commented 4 years ago

Our project is organised (for some reason):

project/src/components/...
project/src/source/main.brs

So bsconfig.json has: rootDir: "." and sourceRoot: "src/"

And VSCode launch.json for debugging has: "sourceDirs": [ "${workspaceFolder}/src" ]

Now the problem is that BreakpointManager calls LocationManager.getStagingLocations with source roots in this order:

which crashes during breakpoint insertion because it tries to create a breakpoint in project/out/.staging/src/source/main.brs

TwitchBronBron commented 4 years ago

sourceRoot is only used to adjust source map paths when using BrighterScript to transpile your project from a staging directory. The extension does not use BrighterScript at all when packaging the project for debug. From what I can tell, you should delete sourceRoot and sourceDirs, and set rootDir to "./src".

I think your only issue is that you need to tell the debugger where the root of your Roku project resides...and that's exactly what rootDir is for.

TwitchBronBron commented 4 years ago

So just to be clear, if this is your project structure:

And you aren't doing any type of pre-build, then your launch config (and bsconfig) should look like this:

{
    "rootDir": "./src",
}

That tells the language server (and roku-deploy) to treat project/src as the root of your project.

elsassph commented 4 years ago

I'll try again by changing rootDir, but we have resources and manifest outside of src.

elsassph commented 4 years ago

So you're right I can make it work with rootDir: "src" and in the files moving ../manifest into place.

I had issues because { src: "../manifest", dest: "." } causes unintuitive "can not unlink 'out/.roku-deploy-staging'" errors, but it works with { src: "../manifest", dest: "manifest" }.

I know I should change our project structure but we have half a dozen of projects with this odd organisation.

TwitchBronBron commented 4 years ago

{ src: "../manifest", dest: "." } is invalid, and { src: "../manifest", dest: "manifest" } is correct. Here's the rule from roku-deploy: image

As far as the cryptic error message, it's pretty hard in roku-deploy to know what you intended to do until runtime, since we support globs. But for single file paths, I think we might be able to better detect that. I'll open an issue on roku-deploy and see what we can do.

So, is this issue resolved for you?

elsassph commented 4 years ago

Yes I'm good now.