Makefile Tools activation in projects where makefile is not in root - visual-studio-code

I have a project where there is a Makefile in a sub-directory and I would like to use the VS Code Makefile Tools extension to configure builds. This works fine when I open VS Code in the sub-directory where the Makefile resides. However when I open VS Code in the parent directory I cannot activate the Makefile Tools extension. I have tried following the instructions in the user documentation (https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) but this does not seem to have any effect for me. My settings are shown in the attached screenshot.

A workaround for this issue is to put a makefile in the root VS Code directory. E.g., something like,
SUBDIRS := path/to/project1 project2
all: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $#
.PHONY: all $(SUBDIRS)
Credit to this post for explaining how to nest Makefiles across sub-directories.

Related

Ocaml compile on eclipse using Makefile occurs no file error even if there is

When I try to compile my project with Makefile, it keeps show error that there is no file lang.ml even if there is in same path. It seems that make.exe can't totally recognize the file contents in projects.
Maybe there is problem with entering directory /home/mario/eclipse/assignment/miniML_skel folder, but I can't find the way how to check or manange the path where make.exe actually gone through.
However, the absolute path of project is C:/OCaml64/home/mario/eclipse/assignment/miniML_skel and workspace is set as C:/OCaml64/home/mario/eclipse/assignment.
I create this project as an Ocaml Empty Makefile Project and import contents file from some other folder.
Here is paths of preference and project.
Note that if I compile lang.ml separately and create lang.cmo file, then make process normally detect it and continue.

Supporting multiple version of ESLint in VS Code

I am using the ESLint plugin by Dirk Baeumer in Visual Studio Code.
My project is large and complex and divided into several primary directories. Each directory has its own package.json file, its own node_modules directory and its own version of eslint. This is causing havoc after upgrading to ESLint 6 because my ESLint plugins won't resolve.
How do I configure the ESLint plugin to respect the eslint version used in each directory? I think it has something to do with the eslint.workingDirectories setting, but I don't understand how to use it properly.
Further information:
My project workspace has two root directories, "folder1" and "folder2". The directory structure looks something like this:
folder1
.eslintrc.json -- rules for the entire "folder1" project to follow
build
platform
core
Makefile
core-v1
.eslintrc.json
Makefile
package.json -- eslint v4
node_modules
core-v2
.eslintrc.json
Makefile
package.json -- eslint v6
node_modules
folder2
My workspace configuration file includes:
"eslint.workingDirectories": [
"./folder1/core/core-v1",
"./folder1/core/core-v2"
]
This seems to produce the following error, and no linting errors are detected or highlighted:
Uncaught exception received.
Error: spawn /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper (Renderer).app/Contents/MacOS/Code - Insiders Helper (Renderer) ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
How do I configure the ESLint plugin to use eslint v4 for files in "folder1/core/core-v1" and v6 for files in "folder1/core/core-v2"? My build process runs separate scripts for these directories, but my editor (VS Code) is trying to use a either v4 or v6 to lint all of the files in my project.
First off, the working directories cannot include root folder names:
"eslint.workingDirectories": [
"./core/core-v1",
"./core/core-v2"
]
This seems to correctly identify the working directories and allows version 6 of ESLint to correctly resolve plugins, etc. It also applies v6 rules to core-v2 but still seems to be using the v4 rules for core-v1, so I think this is correct.
One issue that is still not resolve completely is how this works with multi-root workspaces. This works fine for folder1. folder2 just seems to be working, though I can't explain why since it's not identified as a working directory. Thankfully there are no conflicting paths, but what would I do if there were? That may be worth a separate question, but I seem to be up and running now.

CMake Eclipse project, make targets not available

I use CMake as a build manager for a C++ project. All my sources are in a src subdirectory, and I created a sibling build directory. Following the directions from https://cmake.org/Wiki/Eclipse_CDT4_Generator, the build commands I use are:
cd build
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ../src
This creates the .project and .cproject files used to import an existing project in Eclipse. In the IDE, everything seems to work perfectly, except that the make target does not work.
When I click on a build target, the CDT build console opens, but nothing occurs. Also when I click on Project / Clean in the Eclipse dropdown menus, nothing occurs. I checked the commands invoked by the targets, and they are of the form /usr/bin/make -j8, which should work.
Can anyone help me get the make target work ?
An automatic update to CDT just occurred and everything works now. So check for updates I guess.
Hope this is followed to create target....
The docs for eclipse says:
Your project name should be different from your executable name and different from your build folder name. Otherwise, Eclipse will NOT pick up your executable as you build them. Since my build folder name is certi_build, a CMakeLists.txt file like below should work (notice the difference in project name and executable name)
PROJECT(AwesomeProject)
ADD_EXECUTABLE(AwesomeProjectMain
main.cpp
util.h
util.cpp
)

PhpStorm PhpUnit via phar autocomplete not working

I have PHPStorm 8.0.1.
PHPUnit is installed via PHAR archive like:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/bin/phpunit
PHPUnit works via cli:
user#pc:/usr/bin$ cd ~
user#pc:~$ phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.
I followed the instructions from JetBrains website https://www.jetbrains.com/phpstorm/webhelp/enabling-phpunit-support.html#d298258e897
In PHPStorm File->Settings tab PHP/PHPUnit
the radio button Path to phpunit.phar is checked
and value is set to /usr/bin/phpunit
I have a file with a test defined like:
class MyTest extends PHPUnit_Framework_TestCase {
...
At this point PHPStorm marks Undefined class PHPUnit_Framework_TestCase
I've restarted PHPStorm and Computer, but still have the same problem.
I've also tried adding /usr/bin to include path (right click on external libraries in project view, and choose option Configure PHP include paths) without success.
Here's the config for PHPStorm Settings, tab PHP (if it matters):
PHP Language level: 5.5 (finally, generators, etc.)
Interpreter: PHP 5.5 (5.5.9-1ubuntu4.5)
Include path is empty
In order to have a PHAR archive indexed by the IDE it has to have a .phar extension (that's a requirement).
The easiest solution is to place phpunit.phar somewhere in your project (usually it would be PROJECT_ROOT/vendor/ folder).
If having local copy inside the project folder is not desired (for whatever reason; although Composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links:
either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar --> /usr/bin/phpunit)
or place a full copy (or such symbolic link) in a separate folder outside of the project and then reference it via PhpStorm's Settings | PHP | Include Paths functionality.
The above fix by Calin worked for me too on PhpStorm 2019.1.1, so I'll post it as an answer for easier visibility:
Try right clicking on the .phar and clicking "Exclude phar from project", then clicking "Include phar into project" to refresh it.
In my case, both the .phar file and my .idea folder were pulled from a git commit. I guess PhpStorm didnt realise that the file needed reimporting.
I noticed even though PHP itself can find and run phar that is in its include path, PHPStorm having trouble finding and parsing them.
LazyOne's explanation is correct, however, I didn't need to put it in project folder to be recognized, you can put them in any path as long as its path is introduced to IDE. In my case, I put all phar files in PHP folder, so I just needed to add PHP folder to Include Path list in IDE
Include Path for PHP is under Settings -> Language & Frameworks -> PHP screen (that tiny + at the bottom of screen).

Custom Makefile With Eclipse CDT

I have a C++ project with 3 .hpp files and 1 .cpp file, and a custom Makefile. The code and the Makefile for this project already existed, so I right clicked in the Project Explorer, and did Import->Existing Code as Makefile Project I named my project and pointed the location to the root dir of the project which contains all of my files. And I selected MinGW GCC as my toolchain because that is the compiler that I have. Then I went to Project->Properties->C/C++ Build and unchecked Generate Makefiles automatically
Then I changed my Build directory by choosing File system and navigating to the root directory of my project which contains all of my files. The Build directory is C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges
Then I changed the Build command to make -f C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges\Makefile bst where bst is a target in my Makefile and my Makefile is at that location. When I click the hammer on the toolbar to build my project, nothing happens. When I try to run my project, I get Launch failed: Binary not found.
I just want my project to use my Makefile and build properly.
I have searched Google and stack overflow for hours trying to figure out how to get this to work and have had no luck. Any help is appreciated.
The solution to these sorts of problems usually begins with breaking them down.
First try and build build from the command line. Does the "make -f ..." work from the command line?
It could be an issue with MinGW not working properly.
It sounds like you have done everything correctly as far as eclipse goes. You may find a clue in the eclipse console window.
Too late for giving an answer. But this is for the other people who end up here.
You need to create a new run configuration in Run->Run Configuration... for your project, and then type a name for the output binary file like Debug\name.exe in 'C/C++ Application' box. The name must be the same as the project name.