Sublime Forum

OS Independent paths

#1

Hi,

I am using sublime build system with project specific build settings. One variant is “run”. The working_dir is set to my desktop on windows. Which is a windows specific absolute path. Now I’d like to test my project on linux which has a different path. How to I set the working dir in a generic way?

Windows:

"working_dir": "C:/Users/Silberling/Desktop/$project_name/Build"

Linux:

"working_dir": "/home/Silberling/Desktop/$project_name/Build"

What I like to have:

"working_dir": "$userprofile_path/Desktop/$project_name/Build"
0 Likes

#2

If your project file is located in ~/Desktop/$project_name, then you can use $project_path to refer to this directory.

Alternatively, you can use platform specific options: docs.sublimetext.info/en/latest/ … ation.html

0 Likes

#3

Thanks for the reply.

Problem is, This is C++ code. The project is located at ~/Projects. Because I use cmake and like to have a different build location it is mostiyl build at ~/Desktop/$project_name/ or $temp/$project_name.
The main build is to run cmake --build to execute make or MSVC. I use variants to run “cmake -G … $project_path” to create the Makefile, run tests or run the compiled application.

For example:

[code] “build_systems”:

	{
		"name": "MyProject",
		"working_dir": "C:/Users/Silberling/Desktop/$project_name",
		"shell_cmd": "cmake --build .",

		"variants":
		
			{
				"name": "CMake Debug",
				"shell_cmd": "cmake -G \"MinGW Makefiles\" -DCMAKE_BUILD_TYPE=Debug $project_path"
			},
			{
				"name": "CMake Release",
				"shell_cmd": "cmake -G \"MinGW Makefiles\" -DCMAKE_BUILD_TYPE=Release $project_path"
			},
			{
				"name": "Test",
				"shell_cmd": "cmake --test .",
				"shell": true
			},
			{
				"name": "Run",
				"shell_cmd": "MyProjectBinary some arguments",
				"shell": true
			},
			{
				"name": "Clean",
				"shell_cmd": "cmake --clean ."
			}
		]
	}
][/code]

(Incomplete build description)

The platform specific options might suite my needs. They have to work with the variants. I’m going to take a look at them this weekend.

0 Likes