Sublime Text 2 OS specific Run configuration? - build-process

I would like to create 4 build options for building Actionscript files. One for Building and one for Running in Linux, and the same for Windows.
Is it possible to do this?
Currently it seems 'windows' and 'linux' sections can only overwrite the default build option?
My current broken .sublime-build file is:
{
"selector": "source.actionscript",
"windows":
{
"cmd": [
"${packages}\\User\\Flash-build.bat",
"${project_path}",
"${file}"
],
"variants":
[
{
"name": "Run",
"cmd": [
"${packages}\\User\\Flash-run.bat",
"${file_path}",
"${file_base_name}"
]
}
],
},
"linux":
{
"cmd": [
"${packages}/User/Flash-build.sh",
"${packages}",
"${project_path}",
"${file_path}",
"${file_base_name}"
],
"variants":
[
{
"name": "Run",
"cmd": [
"${packages}/User/Flash-run.sh",
"${packages}",
"${project_path}",
"${file_path}",
"${file_base_name}"
]
}
]
}
}

Looking at the documentation, I can't see why your solution wouldn't work, however, I know that the following works for me.
Sublime preference files can be specified on a per-OS basis. You could create three separate files:
User/actionscript (OSX).sublime-build
User/actionscript (Linux).sublime-build
User/actionscript (Windows).sublime-build
Sublime will only pick up the one that is relevant to your OS.

Related

Can't include QTime in vscode

I've set c_cpp_properties.json to be:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/Cellar/qt/5.13.2/include/QtCore"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
it reports: include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/.../.cpp).C/C++(1696)
cannot open source file "QtCore/qstring.h" (dependency of "QTime")```
The compiler is looking for "QtCore/qstring.h". Based on the include path you've already specified I guess that will be under...
"/usr/local/Cellar/qt/5.13.2/include"
So you need to add that to your list of include paths.
add
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
to your config file.
See Visual Studio Code on macOS + Qt + Intellisense

How to make Arduino work and not give "cannot open source file "avr/pgmspace.h"" on vscode?

I'm trying to program arduino in vscode. The problem is that It's giving me weird header errors:
cannot open source file "avr/pgmspace.h" (dependency of "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h")
This is my arduino.json:
"board": "arduino:avr:uno"
}
This is my c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Program Files (x86)\\Arduino\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
It should recursively include all of the required libraries, and even if imanually try to add the path to avr/pgmspace.h or its directory, it keeps giving me the same errors.
How do I solve this error?
Based on the responses to this issue, I added "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**" to my include path in c_cpp_properties.json:
"includePath": [
"c:\\Program Files (x86)\\Arduino\\tools\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**"
],
For anyone who stumbles here on a Mac, here is the config that works for me with the Uno:
{
"env": {
"arduino_path": "/Applications/Arduino.app/Contents/Java",
"arduino_avr_include_path": "${env:arduino_path}/hardware/arduino/avr",
"arduino_avr_include2_path": "${env:arduino_path}/hardware/tools/avr/avr/include",
"arduino_avr_compiler_path": "${env:arduino_path}/hardware/tools/avr/bin/avr-g++"
},
"configurations": [
{
"name": "Mac",
"defines": [
"ARDUINO=10810",
"__AVR_ATmega328P__",
"UBRRH"
],
"includePath": [
"${workspaceRoot}",
"${env:arduino_avr_include_path}/**",
"${env:arduino_avr_include2_path}/**"
],
"forcedInclude": [
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
],
"intelliSenseMode": "gcc-x64",
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "${env:arduino_compiler_path} -std=gnu++11 -mmcu=atmega328p"
}
],
"version": 4
}
The key to finding <avr/pgmspace.h> was the adding the hardware/tools/avr/avr/include path.
Defining ARDUINO=10810 was identified from the output of running Arduino: Verify with the verbose flag.
Defining __AVR_ATmega328P__ was added to allow proper IntelliSense completion of the raw register macros (e.g. _BV(), OCR0A, TIMSK0, etc.); the correct macro to define was identified based on the chip being an ATMEGA328P-PU and by inspection of the file hardware/tools/avr/avr/include/avr/io.h.
The compilerPath value looks wrong, although it is only used by the IDE and not for target compilation. The documentation says :
The absolute path to the compiler you use to build your project. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense.
In any case I recommend to configure it properly, I was able to remove
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include-fixed",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/../../../../avr/include"
when setting
"compilerPath": "${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++ -std=gnu++11 -mmcu=atmega328p",
To figure out the exact compiler that is used turn on verbose logging in the output window:
File -> Preferences -> Settings -> Extensions -> Arduino configuration -> Log level -> verbose
which in this case also should help you figure out why the compiler does not pick up avr/pgmspace.h.
Here are my arduino.json
{
"board": "arduino:avr:uno",
"port": "/dev/ttyUSB0",
"sketch": "src/myproject.ino",
"output": "../build"
}
and c_cpp_properties.json
{
"env": {
"arduino.path": "${HOME}/.arduino15/packages/arduino",
"arduino.avr.include.path": "${env:arduino.path}/hardware/avr/1.6.23",
"arduino.avr.compiler.path": "${env:arduino.path}/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++",
"arduino.libraries.path": "${HOME}/arduino/sketchbook/libraries",
"dummy-last-line": "To allow the second to last line (e.g. the real last line) to always end with a comma"
},
"configurations": [
{
"name": "Linux",
"includePath": [
"./src",
"./test",
"../arduino_ci/cpp/unittest",
"${env:arduino.libraries.path}/SmartLCD",
"${env:arduino.libraries.path}/Chronos/src",
"${env:arduino.libraries.path}/Time",
"${env:arduino.libraries.path}/RTClib",
"${env:arduino.avr.include.path}/libraries/Wire/src",
"${env:arduino.avr.include.path}/cores/arduino",
"${env:arduino.avr.include.path}/variants/standard"
],
"browse": {
"path": [
"${workspaceFolder}/src"
],
"limitSymbolsToIncludedHeaders": true
},
"defines": [
"UBRRH"
],
"intelliSenseMode": "gcc-x64",
"compilerPath": "${env:arduino.avr.compiler.path} -std=gnu++11 -mmcu=atmega328p",
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
(the UBRRH define is for the Serial variable in HardwareSerial.h)

Why Won't Arduino Intellisense Work in VSCode?

I installed the Arduino extension Arduino extension in VSCode which is supposed to include intellisense however it doesn't seem to be working. This is my c_cpp_properties.json:
And here is an example of the intellisense not working:
As you can see, intellisense should be able to predict the keyword Serial however it does not.
I have Command Line Tools installed. Is there a missing directory that I should include in the "includePath" property.
add the missing lines into your c_cpp_properties.json (and change some filename to mac equivalent)
especially with "defines": [ "USBCON" ] to make Serial class to work with intellisense
{
"configurations": [
{
"name": "Win32",
"includePath": [
"<arduino ide installation folder>\\tools\\**",
"<arduino ide installation folder>\\hardware\\arduino\\avr\\**",
"<arduino ide installation folder>\\hardware\\tools\\**",
"<arduino ide installation folder>\\hardware\\arduino\\avr\\cores\\arduino"
],
"forcedInclude": [
"<arduino ide installation folder>\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "<arduino ide installation folder>\\hardware\\tools\\avr\\bin\\avr-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"defines": [
"USBCON"
]
}
],
"version": 4
}
Try addding this paths to "browse" as in "includePath"
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"arduino_install_dir/hardware/tools/avr/avr/include",
"${workspaceRoot}"
]
},

Packr windows exe not working

Downloaded the packr from https://github.com/libgdx/packr &
Packr json is
{
"platform": "windows64",
"jdk": "C:/Program Files/Java/jdk1.8.0_72",
"executable": "myapp",
"classpath": [
"input/test-hello.jar"
],
"mainclass": "Main",
"vmargs": [
"Xmx1G"
],
"minimizejre": "soft",
"output": "out-windows64",
"verbose": true
}
test-hello.jar has Main.class which simply writes "Hello" on System.out.
There is no error reported while packaging the exe. However, when I run the exe, there is no output on the console. Is there anything in the json that I am missing? Does anyone have a simple working example?
You need to include the path to the main class, for example
"mainclass": "com.example.Main",

User keybindings - return 'letter/symbol' combination not command

I want to create a custom keybinding in sublime text 3 that doesn't return a command but returns the key combination used in R to define a variable like below.
variable <- variable_definition //for example
z1 <- seq(1,100)
In R 3.2.2 GUI mac OS X the keybinding:
"alt+-" returns " <- "
I have read the documentation for user keybindings but couldn't find something that I could use.
I have tried "print" and "echo" as below but they don't work.
[
{ "keys": ["alt+-"], "print": " <- "}
]
or
[
{ "keys": ["alt+-"], "echo": " <- "}
]
Some help would be much appreciated
In Sublime Text you run commands with arguments. If you want to insert something the command is insert and the argument is called characters. If you want to limit it to the language R you can add a context. Hence the keybinding:
[
{
"keys": ["alt+-"], "command": "insert", "args": {"characters": " <- "},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.r" }
]
}
]
Aside: it could also be interesting for you to use snippets as keybindings.
[
{
"keys": ["alt+-"], "command": "insert_snippet", "args": {"contents": "${1:variable} <- ${0:definition}"}
}
]

Resources