Sublime Forum

Help with Build System for MonkeyC (garmin language)

#1

Hi there, I’m looking for some help setting up a build-system for MonkeyC development. I’m working from Linux Mint. Sublime Build 4169.

Garmin officially recommends VSCode but I’m not a huge fan. I have Terminus systems in place for C++ and Java development (thanks to Odatnurd’s very helpful youtube videos). However I’m having trouble getting the system to launch the garmin watch simulator. Here’s how my build-system is currently set-up:

{
  "target": "terminus_open",
  "cancel": "terminus_cancel_build",
  "post_window_hooks": [["carry_file_to_pane", {"direction": "right"}]],
  "focus": true,
  "title": "MonkeyC Build Results",
  "auto_close": false,
  "timeit": true,
  "shell_cmd": "env > /tmp/sublime_env.log && export PATH=$PATH:/home/username/.Garmin/ConnectIQ/Sdks/connectiq-sdk-lin-7.2.0-2024-06-06-6c7d3f915/bin && monkeyc -o bin/output_program.prg -m manifest.xml -z resources -f monkey.jungle -d simulator && connectiq --launch bin/output_program.prg",
  "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  "working_dir": "${project_path}",
  "selector": "source.monkeyc",
  "variants": [
    {
      "name": "Run",
      "shell_cmd": "connectiq --launch bin/output_program.prg"
    }
  ]
}

I have the MonkeyC package installed via Package Control (https://github.com/pzl/Sublime-MonkeyC)

Launching the Garmin ConnectIQ application does work from the terminal as well as from VSCode. (this is why I am trying to explicitly define the path to the garmin SDK in the shell_cmd field, but it’s not working. It generates a bash error:

bash: connectiq: command not found

Any help would be very much appreciated!

Thanks

0 Likes

#2

Off the top of my head from looking at that, did you use /home/username as a placeholder in your post so as to not leak your actual username? If not, unless you literally log into Linux with the username username, that may well be the source of your issue. (Though I am confused about you want the build to capture the environment to a file).

Failing that, If you were using a non-terminus build system, you could do this by using an env key in your build to adjust the PATH on the fly:

"env": {
    "PATH": "$PATH:/home/username/.Garmin/ConnectIQ/Sdks/connectiq-sdk-lin-7.2.0-2024-06-06-6c7d3f915/bin
}

However, that does not work in a Terminus build because it doesn’t interpret $PATH from within the env key, which means you would need to explicitly set the entire environment yourself.

The easiest solution I can see to your problem would be to add something like this to your .bashrc or similar (depending on what shell you use):

GARMIN_CONNECTIQ_HOME=$HOME/.Garmin/ConnectIQ/Sdks/connectiq-sdk-lin-7.2.0-2024-06-06-6c7d3f915

# Add Garmin ConnectIQ to the path
export PATH=$PATH:$GARMIN_CONNECTIQ_HOME/bin

Then, quit and relaunch Sublime to pick up the environment change. That will put the tooling directly into the PATH, so your build doesn’t need to try to do it.

If you’re using Linux, you probably need to log out and in again so that the launcher will inherit the new envionment, or in the short term you can just open a fresh terminal and launch subl from there.

0 Likes

#3

Thanks for the reply, your videos have been a big help to me!

Yes, you are correct about my username. I did replace my actual username with “username” so as not to show it publicly.

Also, sorry for not mentioning in my post, but I have already added the “export PATH=” line to my .bashrc file. Its inclusion in my build-system “shell_cmd” line was an attempt to force sublime to recognize the path. The full line is:
export PATH=$PATH:/home/username/.Garmin/ConnectIQ/Sdks/connectiq-sdk-lin-7.2.0-2024-06-06-6c7d3f915/bin

Do you think I should start over with a non-Terminus build system?
I believe that shell is correctly recognizing the “export PATH” line in .bashrc because running “connectiq” from the shell works as expected.

0 Likes

#4

You shouldn’t have to swap away just for this.

As a test, quit Sublime and then start it via subl from a Terminal (one where running that command works); does your build work in that case?

0 Likes

#5

Well, what do you know, running subl from terminal worked! Ctrl-B launched the simulator.

However it doesn’t seem to be running the application as expected. The simulator never populates with the expected watch face.

I will create a new default app in VSCode and ensure it is working, and then try the same app in Sublime and report back.

0 Likes

#6

Confirmed, I ran the same program in VSCode and in Sublime (via the terminal).

VSCode is passing the compiled app to the Garmin simulator.

Sublime is opening the simulator but the watch app never loads. Not sure what’s going on, seems like the build-system isn’t properly passing the app to connectiq.

Here is my build-system currently:

{
  "target": "terminus_open",
  "cancel": "terminus_cancel_build",
  "post_window_hooks": [["carry_file_to_pane", {"direction": "right"}]],
  "focus": true,
  "title": "MonkeyC Build Results",
  "auto_close": false,
  "timeit": true,

  "shell_cmd": "monkeyc -o bin/output_program.prg -m manifest.xml -z resources -f monkey.jungle -d simulator && connectiq --launch bin/output_program.prg",
  "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  "working_dir": "${project_path}",
  "selector": "source.monkeyc",
  "variants": [
    {
      "name": "Run",
      "shell_cmd": "connectiq --launch bin/output_program.prg"
    }
  ]
}
0 Likes

#7

What I would test is, if you run the build command from the shell_cmd in the terminal, does it do what you expect?

In a nutshell, all Sublime is doing is entering commands that you would enter yourself, but saving you from having to do it. So in the general case, what works in the terminal should work in Sublime as well.

1 Like

#8

Okay, thanks for your help. I think I have the Sublime side of things working as expected, and just need help from the Garmin crowd now to get the command line arguments working. Documentation is not great, lots of 404 pages. Hopefully their forum can help!

0 Likes