markw65 / prettier-extension-monkeyc

A VSCode extension for Garmin MonkeyC
MIT License
12 stars 1 forks source link

When I complie a release version, it report an Error #12

Closed nnkn closed 1 year ago

nnkn commented 1 year ago

hi markw65: I tried to complie a release version by adding the option "-r" (change nothing but here) image

and then I choose "build and run optiomized project" ,an Error appeared:

ERROR: fr245: E:\watchface1\ManOfSteel\bin\optimized\group013-debug\source\source\ManOfSteelApp.mc:2: Cannot find module '$.Log' in using statement.
ERROR: fr245: E:\watchface1\ManOfSteel\bin\optimized\group013-debug\source\source\ManOfSteelView.mc:6: Cannot find module '$.Log' in using statement.
ERROR: fr245: E:\watchface1\ManOfSteel\bin\optimized\group013-debug\source\source\utils\WeatherConditionUtils.mc:1: Cannot find module '$.Log' in using statement.
ERROR: fr245: E:\watchface1\ManOfSteel\bin\optimized\group013-debug\source\source\utils\getDFInfo.mc:5: Cannot find module '$.Log' in using statement.
ERROR: fr245: E:\watchface1\ManOfSteel\bin\optimized\group013-debug\source\source\utils\getDatas.mc:1: Cannot find module '$.Log' in using statement.

image the code of Log module is :

(:debug)
module Log {
    function debug(string) {
        System.println(timeNow() + " debug :: " + string);
    }
    // function debugII(string) {
    //   System.println(" debug :: " + string);
    // }

    function timeNow() {
        var today = Gregorian.info(Time.now(), Time.FORMAT_MEDIUM);
        var dateString = today.hour.format("%02d") + ":" + today.min.format("%02d") + ":" + today.sec.format("%02d");
        return dateString;
    }
}

(:release)
module Log {
    function debug(string) {}
    // function debugII(string) {}
}

what I can do to get it through? thank you ! :)

markw65 commented 1 year ago

Well, I guess I need to fix the extension to notice that you added a "-r" option. I'll try to fix that in the next release.

But meanwhile, the way I expected this to work is that you would put something like this in your .vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "monkeyc",
      "request": "launch",
      "name": "Run Unoptimized",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
    },
    {
      "type": "omonkeyc",
      "request": "launch",
      "name": "Run Optimized Release",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
      "releaseBuild": true
    },
    {
      "type": "omonkeyc",
      "request": "launch",
      "name": "Run Optimized Debug",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
      "releaseBuild": false
    }
  ]
}

Then, from the "Run and Debug" menu, you can select the one you want to run, and launch it. No need to change the settings. Note that you can put an actual device, rather than ${command:GetTargetDevice}, if you don't want to have to choose the device every time you launch.

Note that the "monkeyc" config is handled by Garmin's extension, and doesn't support the "releaseBuild" flag, while the "omonkeyc" configs are handled by my extension.

In the same way, you can create build tasks, by putting something like this in .vscode/tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "omonkeyc",
      "device": "choose",
      "simulatorBuild": true,
      "label": "Optimized Debug Build",
    },
    {
      "type": "omonkeyc",
      "device": "choose",
      "simulatorBuild": true,
      "label": "Optimized Release Build",
      "releaseBuild": true
    },
    {
      "type": "omonkeyc",
      "device": "fenix5xplus",
      "simulatorBuild": true,
      "label": "Optimized Debug Fenix 5x Plus Build",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Note that vscode doesn't allow "commands" in tasks, so you use choose here, rather than ${command:GetTargetDevice}. Also, if you mark one task as the default build task, you can run it via Cmd-Shift-B.

nnkn commented 1 year ago

Well, I guess I need to fix the extension to notice that you added a "-r" option. I'll try to fix that in the next release.

But meanwhile, the way I expected this to work is that you would put something like this in your .vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "monkeyc",
      "request": "launch",
      "name": "Run Unoptimized",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
    },
    {
      "type": "omonkeyc",
      "request": "launch",
      "name": "Run Optimized Release",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
      "releaseBuild": true
    },
    {
      "type": "omonkeyc",
      "request": "launch",
      "name": "Run Optimized Debug",
      "stopAtLaunch": false,
      "device": "${command:GetTargetDevice}",
      "releaseBuild": false
    }
  ]
}

Then, from the "Run and Debug" menu, you can select the one you want to run, and launch it. No need to change the settings. Note that you can put an actual device, rather than ${command:GetTargetDevice}, if you don't want to have to choose the device every time you launch.

Note that the "monkeyc" config is handled by Garmin's extension, and doesn't support the "releaseBuild" flag, while the "omonkeyc" configs are handled by my extension.

In the same way, you can create build tasks, by putting something like this in .vscode/tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "omonkeyc",
      "device": "choose",
      "simulatorBuild": true,
      "label": "Optimized Debug Build",
    },
    {
      "type": "omonkeyc",
      "device": "choose",
      "simulatorBuild": true,
      "label": "Optimized Release Build",
      "releaseBuild": true
    },
    {
      "type": "omonkeyc",
      "device": "fenix5xplus",
      "simulatorBuild": true,
      "label": "Optimized Debug Fenix 5x Plus Build",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Note that vscode doesn't allow "commands" in tasks, so you use choose here, rather than ${command:GetTargetDevice}. Also, if you mark one task as the default build task, you can run it via Cmd-Shift-B.

thank you very much for your help! I did it by your code , and I'm totally a newbie using vscode =(