============== MakeCommands ============== Overview -------- If you have installed this package, there are automatically created sublime-commands from Makefiles' targets. Motivation ~~~~~~~~~~ I mostly work with makefiles and I am used to vim's ``:make`` command, where you can optionally pass a target. So you can run ``:make test`` or ``:make deploy``, or whatever target is there. This package makes targets available as sublime commands, such that you can run them from Command Palette. Default Behaviour ~~~~~~~~~~~~~~~~~ .. highlight:: make If you are editing a file, which has a Makefile on same or higher level in directory structure, targets from it are automatically made available as commands. If there is a target "test", then there will be created command ":make test". How Makefiles are Processed ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Usually all targets containing only characters, numbers, "_" or "-", are made available as targets. There may be produced too many targets from your makefiles and you only use a subset of the targets. Then you can create a special target ``.SUBLIME_TARGETS`` and list targets as prerequisites, which you want to access from sublime text:: .SUBLIME_TARGETS: all deploy test This example would only make targets ``all``, ``deploy`` and ``test`` available as commands regardless, which targets you have in your Makefile. There is a special recipe for writing targets, which may have input and are always displayed as sublime-targets, even if they are not part of ``.SUBLIME_TARGETS``. Initial motivation for this mechanism was the need of an overall commit in the root of nested repositories even if editing a file in a subrepository. First have a look at the targets:: sublime.hg-status: hg status hg commit -m "$(SUBLIME_INPUT_commit_message)" if [ -z $(SUBLIME_INPUT_file)] ; then \ cd $(dirname $(SUBLIME_FILENAME)) ; \ hg add $(SUBLIME_FILENAME) ; \ else \ cd $(dirname $(SUBLIME_INPUT_file)) ; \ hg add $(SUBLIME_INPUT_file) ;\ fi sublime.hg-status This target will be displayed as ``:make hg-status`` in command palette and displays the status of the repository the Makefile is in. This target is represented by ``:make hg-commit`` in command palette and will first open input_panel and ask for a *commit_message* and then runs the target with ``SUBLIME_INPUT_commit_message`` make variable set. This target is represented by ``:make hg-add`` in command palette and will ask for a *file*. If no filepath given, the view's filename represented by make variable ``SUBLIME_FILENAME`` will be taken, else the filepath entered will be taken and interpreted relative to Makefile. Finally file represented by final filepath, will be added to nearest enclosing repository. So it is easy to ask for interactive input, which you can later use in your make recipes. Installation ------------ Download `Package Control`_ and use *Package Control: Install Package* Command from command palette. Command Palette is opened using ``ctrl+shift+p`` on Windows and Linux and ``cmd+shift+p`` on Mac. Once you run *Package Control: Install Package*, there will open up a list of packages. Type ``MakeCommands`` and hit enter. .. _Package Control: Configuration ------------- .. highlight:: json First a quick overview on configuration settings. +-----------------------------------------+----------------+--------------+ | Setting | Type | Default | +=========================================+================+==============+ | make_commands_makefiles_ | String or List | [] | +-----------------------------------------+----------------+--------------+ | make_commands_makefile_pattern_ | String | "/Makefile$" | +-----------------------------------------+----------------+--------------+ | make_commands_stop_at_opened_folders_ | Boolean | true | +-----------------------------------------+----------------+--------------+ | make_commands_find_parent_makefile_ | Boolean | true | +-----------------------------------------+----------------+--------------+ | make_commands_search_in_opened_folders_ | Boolean | true | +-----------------------------------------+----------------+--------------+ | make_commands_command_caption_format_ | Boolean | true | +-----------------------------------------+----------------+--------------+ | make_commands_make_command_ | String | "make" | +-----------------------------------------+----------------+--------------+ | make_commands_debug_ | Boolean | false | +-----------------------------------------+----------------+--------------+ make_commands_makefiles ~~~~~~~~~~~~~~~~~~~~~~~ Either a single makefile or a list of makefiles. You may either use absolute paths, or paths are interpreted relative to to one of the opened folders in your current window (project folders). Example for single makefile:: { make_commands_makefiles: "foo.mak" } Example for list of makefiles:: { make_commands_makefiles: ["foo.mak", "path/to/bar.mak", "/path/to/Makefile"] } make_commands_makefile_pattern ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Filepaths matching this pattern are considered as Makefiles. If you also wanted :file:`*.mak` beeing considered, then you could specify:: { make_commands_makefile_pattern: "/Makefile$|\.mak$" } make_commands_stop_at_opened_folders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If there is turned on make_commands_find_parent_makefile_, this toggle specifies, if it is stopped looking for Makefile at directory level of currently opened folders. make_commands_find_parent_makefile ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If this setting is turned on, there is tried to find a makefile matching make_commands_makefile_pattern_ in parent folders starting in folder of file in current view. Depending on make_commands_stop_at_opened_folders_ it is stopped in folders opened in current window. make_commands_search_in_opened_folders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If this setting is turned on, it is looked for makefiles matching make_commands_makefile_pattern_ in opened folders. make_commands_command_caption_format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This specifies how your commands' caption shall look like. Default is:: ":make %(target)s" make_commands_make_command ~~~~~~~~~~~~~~~~~~~~~~~~~~ This specifies your make command. It defaults to ``make``. make_commands_debug ~~~~~~~~~~~~~~~~~~~ This toggle enables debug output to console panel. License ------- You can use this under Simplified BSD License: Copyright (c) 2013, `Kay-Uwe (Kiwi) Lorenz <>`_ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Donate ------ If you want to honour this work, you can \ `donate some money via paypal`_ or `buy me something from my amazon wishlist`_. .. _donate some money via paypal: .. _buy me something from my amazon wishlist: