From 1536e684e4dc41aeddb415dd876ff8f903fff21f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 5 Jun 2015 11:50:13 +0200 Subject: [PATCH 01/17] Add qmake support. Closes #12. --- README.md | 1 + config_gen.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 3567997667..a96fcdee29 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ YCM-Generator can also be used as a Vim plugin. Once installed with Vundle/NeoBu * Supported build systems: + Make + CMake + + qmake + Autotools Your build system should support specifying the compiler through the ```CC```/```CXX``` environment variables, or not use an absolute path to the compiler. diff --git a/config_gen.py b/config_gen.py index da0d3d7203..1cb903533a 100755 --- a/config_gen.py +++ b/config_gen.py @@ -12,6 +12,7 @@ import tempfile import time import subprocess +import glob # Default flags for make @@ -162,6 +163,7 @@ def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_ env_config = env.copy() env_config["YCM_CONFIG_GEN_CC_PASSTHROUGH"] = cc env_config["YCM_CONFIG_GEN_CXX_PASSTHROUGH"] = cxx + env_config["QMAKESPEC"] = "linux-clang" # use -i (ignore errors), since the makefile may include scripts which # depend upon the existence of various output files @@ -216,6 +218,20 @@ def run(cmd, *args, **kwargs): else: run([make_cmd, "maintainer-clean"], env=env, **proc_opts) + elif(glob.glob(os.path.join(project_dir, "*.pro"))): + # qmake + print("Preparing build directory...") + run([make_cmd, "clean"], env=env, **proc_opts) + + print("Running qmake...") + run(["qmake"] + configure_opts, env=env_config, **proc_opts) + + print("\nRunning make...") + run(make_args, env=env, **proc_opts) + + print("\nCleaning up...") + run([make_cmd, "clean"], env=env, **proc_opts) + elif(any([os.path.exists(os.path.join(project_dir, x)) for x in ["GNUmakefile", "makefile", "Makefile"]])): # Make # needs to be handled last, since other build systems can generate Makefiles From 7532703884733d470a8dced9755c2a2a4c3e7ed2 Mon Sep 17 00:00:00 2001 From: iliis Date: Fri, 5 Jun 2015 14:05:31 +0200 Subject: [PATCH 02/17] Escape path to working directory. This prevents issues with special characters (such as spaces) in paths. --- plugin/ycm-generator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/ycm-generator.vim b/plugin/ycm-generator.vim index 9067a1f30e..f91b3ab66a 100644 --- a/plugin/ycm-generator.vim +++ b/plugin/ycm-generator.vim @@ -10,7 +10,7 @@ function! s:GenerateConfig(fmt, flags) " Only append the working directory if the last option is a flag let l:split_flags = split(a:flags) if len(l:split_flags) == 0 || l:split_flags[-1] =~ "^-" - let l:cmd = l:cmd . " " . getcwd() + let l:cmd = l:cmd . " " . fnameescape(getcwd()) endif execute l:cmd From 098b924e751076f63c84b333b184e837f46d6c33 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 5 Jun 2015 14:10:27 +0200 Subject: [PATCH 03/17] Set QMAKESPEC for qmake only. --- config_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_gen.py b/config_gen.py index 1cb903533a..4ca9f274e1 100755 --- a/config_gen.py +++ b/config_gen.py @@ -163,7 +163,6 @@ def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_ env_config = env.copy() env_config["YCM_CONFIG_GEN_CC_PASSTHROUGH"] = cc env_config["YCM_CONFIG_GEN_CXX_PASSTHROUGH"] = cxx - env_config["QMAKESPEC"] = "linux-clang" # use -i (ignore errors), since the makefile may include scripts which # depend upon the existence of various output files @@ -224,6 +223,7 @@ def run(cmd, *args, **kwargs): run([make_cmd, "clean"], env=env, **proc_opts) print("Running qmake...") + env_config["QMAKESPEC"] = "linux-clang" run(["qmake"] + configure_opts, env=env_config, **proc_opts) print("\nRunning make...") From e5327979514c6981d22a7d980d739f36aa6e51d4 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 5 Jun 2015 14:10:55 +0200 Subject: [PATCH 04/17] Change qmake capitalization. --- config_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_gen.py b/config_gen.py index 4ca9f274e1..7774104205 100755 --- a/config_gen.py +++ b/config_gen.py @@ -218,7 +218,7 @@ def run(cmd, *args, **kwargs): run([make_cmd, "maintainer-clean"], env=env, **proc_opts) elif(glob.glob(os.path.join(project_dir, "*.pro"))): - # qmake + # QMake print("Preparing build directory...") run([make_cmd, "clean"], env=env, **proc_opts) From 4bd3e69a7229260442e41f78f77ca51031bdbb3c Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Sat, 6 Jun 2015 00:18:23 +1000 Subject: [PATCH 05/17] Added list of test cases --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 3567997667..4e5fddceca 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ The script is currently supported under Unices (Linux, BSD, OS X) only. Implementing Windows support consists of porting the contents of ```fake-toolchain/Unix```. If you are interested in implementing/testing this, please open a pull request. +### Test Cases +The following projects are used for testing: + +| Project | Build system | Notes | +| ------------------------------------------------------------------------- | ----------------- | ------ | +| [Linux kernel](https://git.kernel.org) | Kbuild (Make) | | +| [Vim-qt](https://rdnetto@bitbucket.org/equalsraf/vim-qt.git) | Autotools | | +| [Clementine](https://github.com/clementine-player/Clementine.git) | Cmake | | + ## License YCM-Generator is published under the GNU GPLv3. From 460b453518bfa499c3cbaa0c5bdc643154dabcd8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 11 Jun 2015 10:58:27 +0200 Subject: [PATCH 06/17] Change build-system names to lowercase. --- README.md | 6 +++--- config_gen.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a96fcdee29..75b2ef77fb 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ YCM-Generator can also be used as a Vim plugin. Once installed with Vundle/NeoBu + Clang * Supported build systems: - + Make - + CMake + + make + + cmake + qmake - + Autotools + + autotools Your build system should support specifying the compiler through the ```CC```/```CXX``` environment variables, or not use an absolute path to the compiler. diff --git a/config_gen.py b/config_gen.py index 7774104205..eb7008ed85 100755 --- a/config_gen.py +++ b/config_gen.py @@ -178,7 +178,7 @@ def run(cmd, *args, **kwargs): # execute the build system if(os.path.exists(os.path.join(project_dir, "CMakeLists.txt"))): - # Cmake + # cmake # run cmake in a temporary directory, then compile the project as usual build_dir = tempfile.mkdtemp() proc_opts["cwd"] = build_dir @@ -194,7 +194,7 @@ def run(cmd, *args, **kwargs): shutil.rmtree(build_dir) elif(os.path.exists(os.path.join(project_dir, "configure"))): - # Autotools + # autotools # perform build in-tree, since not all projects handle out-of-tree builds correctly if(out_of_tree): @@ -218,7 +218,7 @@ def run(cmd, *args, **kwargs): run([make_cmd, "maintainer-clean"], env=env, **proc_opts) elif(glob.glob(os.path.join(project_dir, "*.pro"))): - # QMake + # qmake print("Preparing build directory...") run([make_cmd, "clean"], env=env, **proc_opts) @@ -233,7 +233,7 @@ def run(cmd, *args, **kwargs): run([make_cmd, "clean"], env=env, **proc_opts) elif(any([os.path.exists(os.path.join(project_dir, x)) for x in ["GNUmakefile", "makefile", "Makefile"]])): - # Make + # make # needs to be handled last, since other build systems can generate Makefiles print("Preparing build directory...") run([make_cmd, "clean"], env=env, **proc_opts) From e8b6889b0c121e19ce1c916b545c1c47a3c6c1ee Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 11 Jun 2015 11:10:36 +0200 Subject: [PATCH 07/17] Do an out-of-tree build for qmake. --- config_gen.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/config_gen.py b/config_gen.py index eb7008ed85..6804f3b3e8 100755 --- a/config_gen.py +++ b/config_gen.py @@ -219,18 +219,28 @@ def run(cmd, *args, **kwargs): elif(glob.glob(os.path.join(project_dir, "*.pro"))): # qmake - print("Preparing build directory...") - run([make_cmd, "clean"], env=env, **proc_opts) - - print("Running qmake...") + # find .pro files. + pro_files = glob.glob(os.path.join(project_dir, "*.pro")) + if len(pro_files) != 1: + print("ERROR: Found {} .pro files (expected one): {}.".format( + len(pro_files), ', '.join(pro_files))) + sys.exit(1) + + # run qmake in a temporary directory, then compile the project as usual + build_dir = tempfile.mkdtemp() + proc_opts["cwd"] = build_dir env_config["QMAKESPEC"] = "linux-clang" - run(["qmake"] + configure_opts, env=env_config, **proc_opts) + + print("Running qmake in '{}'...".format(build_dir)) + run(["qmake"] + configure_opts + [pro_files[0]], env=env_config, + **proc_opts) print("\nRunning make...") run(make_args, env=env, **proc_opts) print("\nCleaning up...") - run([make_cmd, "clean"], env=env, **proc_opts) + print("") + shutil.rmtree(build_dir) elif(any([os.path.exists(os.path.join(project_dir, x)) for x in ["GNUmakefile", "makefile", "Makefile"]])): # make From 40acbf59c847f916d6a48a0d50360d94e3b383bd Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Mon, 15 Jun 2015 15:17:52 +1000 Subject: [PATCH 08/17] Readme: added link to AUR package Closes #15 --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e5fddceca..15b11de386 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,15 @@ It works by building the project with a fake toolchain, which simply and filters It is reasonably fast, taking ~10 seconds to generate a configuration file for the Linux kernel. +## Installation +Add ```NeoBundle 'rdnetto/YCM-Generator'``` to your vimrc (or the equivalent for your plugin manager). + +Alternatively, Arch Linux users can install YCM-Generator using the (unofficial) [AUR package](https://aur4.archlinux.org/packages/ycm-generator-git/). + ## Usage Run ```./config_gen.py PROJECT_DIRECTORY```, where ```PROJECT_DIRECTORY``` is the root directory of your project's build system (i.e. the one containing the root Makefile, etc.) -YCM-Generator can also be used as a Vim plugin. Once installed with Vundle/NeoBundle/etc., use the ```:YcmGenerateConfig``` or ```:CCGenerateConfig``` command to generate a config file for the current directory. This command accepts the same arguments as ```./config_gen.py```, but does not require the project directory to be specified (it defaults to the current working directory). +You can also invoke it from within Vim using the ```:YcmGenerateConfig``` or ```:CCGenerateConfig``` commands to generate a config file for the current directory. These commands accept the same arguments as ```./config_gen.py```, but do not require the project directory to be specified (it defaults to the current working directory). ## Requirements and Limitations * Requirements: @@ -27,7 +32,7 @@ Your build system should support specifying the compiler through the ```CC```/`` Some flags present in the resulting configuration file may be mutually exclusive with each other - reading the generated file prior to use is recommended. -# Documentation & Support +## Documentation & Support * run ```./config_gen.py --help``` to see the complete list of supported options. * if you receive the error message ```ERROR: No commands were logged to the build logs```, try using the ```--verbose``` flag to see any error messages + if you open an issue regarding this error message, please include the output when running with ```--verbose``` and a link to the project repo (if possible) From bf24f64a9ab94dbab9dfbc13ef7c4aa5445b1835 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 Jun 2015 10:02:41 +0200 Subject: [PATCH 09/17] Add Qt4 support. --- config_gen.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config_gen.py b/config_gen.py index 6804f3b3e8..aefc689003 100755 --- a/config_gen.py +++ b/config_gen.py @@ -31,6 +31,7 @@ def main(): parser.add_argument("-o", "--output", help="Save the config file as OUTPUT. Default: .ycm_extra_conf.py, or .color_coded if --format=cc.") parser.add_argument("-x", "--language", choices=["c", "c++"], help="Only output flags for the given language. This defaults to whichever language has its compiler invoked the most.") parser.add_argument("--out-of-tree", action="store_true", help="Build autotools projects out-of-tree. This is a no-op for other project types.") + parser.add_argument("--qt-version", choices=["4", "5"], default="5", help="Use the given Qt version.") parser.add_argument("-e", "--preserve-environment", action="store_true", help="Pass environment variables to build processes.") parser.add_argument("PROJECT_DIR", help="The root directory of the project.") args = vars(parser.parse_args()) @@ -123,7 +124,7 @@ def main(): print("Created {} config file with {} {} flags".format(output_format.upper(), len(flags), lang.upper())) -def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_cmd, cc, cxx, out_of_tree, configure_opts, make_flags, preserve_environment): +def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_cmd, cc, cxx, out_of_tree, configure_opts, make_flags, preserve_environment, qt_version): '''Builds the project using the fake toolchain, to collect the compiler flags. project_dir: the directory containing the source files @@ -136,6 +137,7 @@ def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_ configure_opts: additional flags for configure stage make_flags: additional flags for make preserve_environment: pass environment variables to build processes + qt_version: The Qt version to use when building with qmake. ''' # TODO: add Windows support @@ -229,7 +231,12 @@ def run(cmd, *args, **kwargs): # run qmake in a temporary directory, then compile the project as usual build_dir = tempfile.mkdtemp() proc_opts["cwd"] = build_dir - env_config["QMAKESPEC"] = "linux-clang" + if qt_version == "4": + env_config["QMAKESPEC"] = "unsupported/linux-clang" + env_config["QT_SELECT"] = "4" + else: + env_config["QMAKESPEC"] = "linux-clang" + env_config["QT_SELECT"] = "5" print("Running qmake in '{}'...".format(build_dir)) run(["qmake"] + configure_opts + [pro_files[0]], env=env_config, From 1b2f66f5073bb285aa98cc327c22736c571971f6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 Jun 2015 10:04:23 +0200 Subject: [PATCH 10/17] Only call glob.glob once. --- config_gen.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config_gen.py b/config_gen.py index aefc689003..e16be39a2e 100755 --- a/config_gen.py +++ b/config_gen.py @@ -170,6 +170,9 @@ def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_ # depend upon the existence of various output files make_args = [make_cmd] + make_flags + # Used for the qmake build system below + pro_files = glob.glob(os.path.join(project_dir, "*.pro")) + # sanity check - make sure the toolchain is available assert os.path.exists(fake_path), "Could not find toolchain at '{}'".format(fake_path) @@ -219,10 +222,9 @@ def run(cmd, *args, **kwargs): else: run([make_cmd, "maintainer-clean"], env=env, **proc_opts) - elif(glob.glob(os.path.join(project_dir, "*.pro"))): + elif(pro_files): # qmake # find .pro files. - pro_files = glob.glob(os.path.join(project_dir, "*.pro")) if len(pro_files) != 1: print("ERROR: Found {} .pro files (expected one): {}.".format( len(pro_files), ', '.join(pro_files))) From 048ace1852a64e8f8c86da15cd8e1cf2699a4895 Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Mon, 15 Jun 2015 22:31:53 +1000 Subject: [PATCH 11/17] Hide cmake cache during fakebuild, so that the previous in-tree builds do not affect build system generation. See #16 --- config_gen.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config_gen.py b/config_gen.py index da0d3d7203..714604437c 100755 --- a/config_gen.py +++ b/config_gen.py @@ -182,6 +182,17 @@ def run(cmd, *args, **kwargs): build_dir = tempfile.mkdtemp() proc_opts["cwd"] = build_dir + # if the project was built in-tree, we need to hide the cache file so that cmake + # populates the build dir instead of just re-generating the existing files + cache_path = os.path.join(project_dir, "CMakeCache.txt") + + if(os.path.exists(cache_path)): + fd, cache_tmp = tempfile.mkstemp() + os.close(fd) + shutil.move(cache_path, cache_tmp) + else: + cache_tmp = None + print("Running cmake in '{}'...".format(build_dir)) run(["cmake", project_dir] + configure_opts, env=env_config, **proc_opts) @@ -192,6 +203,9 @@ def run(cmd, *args, **kwargs): print("") shutil.rmtree(build_dir) + if(cache_tmp): + shutil.move(cache_tmp, cache_path) + elif(os.path.exists(os.path.join(project_dir, "configure"))): # Autotools # perform build in-tree, since not all projects handle out-of-tree builds correctly From f4105c757109b74145b36cc38e32ed0d346e8581 Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Tue, 16 Jun 2015 18:19:47 +1000 Subject: [PATCH 12/17] Qmake: Remove assumption of there being only two versions --- config_gen.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config_gen.py b/config_gen.py index e16be39a2e..2d7230bbee 100755 --- a/config_gen.py +++ b/config_gen.py @@ -233,12 +233,8 @@ def run(cmd, *args, **kwargs): # run qmake in a temporary directory, then compile the project as usual build_dir = tempfile.mkdtemp() proc_opts["cwd"] = build_dir - if qt_version == "4": - env_config["QMAKESPEC"] = "unsupported/linux-clang" - env_config["QT_SELECT"] = "4" - else: - env_config["QMAKESPEC"] = "linux-clang" - env_config["QT_SELECT"] = "5" + env_config["QT_SELECT"] = qt_version + env_config["QMAKESPEC"] = "unsupported/linux-clang" if qt_version == "4" else "linux-clang" print("Running qmake in '{}'...".format(build_dir)) run(["qmake"] + configure_opts + [pro_files[0]], env=env_config, From 2aa3ba4fee2cff3ea8e557a4610e24c200c6ba2c Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Tue, 16 Jun 2015 18:20:07 +1000 Subject: [PATCH 13/17] Minor formatting fixes --- config_gen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config_gen.py b/config_gen.py index 2d7230bbee..37cdfcc888 100755 --- a/config_gen.py +++ b/config_gen.py @@ -31,7 +31,7 @@ def main(): parser.add_argument("-o", "--output", help="Save the config file as OUTPUT. Default: .ycm_extra_conf.py, or .color_coded if --format=cc.") parser.add_argument("-x", "--language", choices=["c", "c++"], help="Only output flags for the given language. This defaults to whichever language has its compiler invoked the most.") parser.add_argument("--out-of-tree", action="store_true", help="Build autotools projects out-of-tree. This is a no-op for other project types.") - parser.add_argument("--qt-version", choices=["4", "5"], default="5", help="Use the given Qt version.") + parser.add_argument("--qt-version", choices=["4", "5"], default="5", help="Use the given Qt version for qmake. (Default: 5)") parser.add_argument("-e", "--preserve-environment", action="store_true", help="Pass environment variables to build processes.") parser.add_argument("PROJECT_DIR", help="The root directory of the project.") args = vars(parser.parse_args()) @@ -224,7 +224,7 @@ def run(cmd, *args, **kwargs): elif(pro_files): # qmake - # find .pro files. + # make sure there is only one .pro file if len(pro_files) != 1: print("ERROR: Found {} .pro files (expected one): {}.".format( len(pro_files), ', '.join(pro_files))) @@ -236,7 +236,7 @@ def run(cmd, *args, **kwargs): env_config["QT_SELECT"] = qt_version env_config["QMAKESPEC"] = "unsupported/linux-clang" if qt_version == "4" else "linux-clang" - print("Running qmake in '{}'...".format(build_dir)) + print("Running qmake in '{}' with Qt {}...".format(build_dir, qt_version)) run(["qmake"] + configure_opts + [pro_files[0]], env=env_config, **proc_opts) From 355155c7498235b259f86d6829daf020aa374943 Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Tue, 16 Jun 2015 18:30:35 +1000 Subject: [PATCH 14/17] Readme: added test case for qmake This really should have been part of the the previous merge. See #13 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index da005b001d..ad268131f8 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ The following projects are used for testing: | [Linux kernel](https://git.kernel.org) | Kbuild (Make) | | | [Vim-qt](https://rdnetto@bitbucket.org/equalsraf/vim-qt.git) | Autotools | | | [Clementine](https://github.com/clementine-player/Clementine.git) | Cmake | | +| [ExtPlane](https://github.com/vranki/ExtPlane.git) | Qmake | Should be tested with both versions of Qt. | ## License YCM-Generator is published under the GNU GPLv3. From 6ae9ab03717090c123bc17a600569eb1947a5f22 Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Fri, 19 Jun 2015 16:12:39 +1000 Subject: [PATCH 15/17] Made toolchain scripts POSIX-compliant Tested using dash. See #19 --- fake-toolchain/Unix/cc | 4 ++-- fake-toolchain/Unix/cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fake-toolchain/Unix/cc b/fake-toolchain/Unix/cc index 556f226f98..03e796105b 100755 --- a/fake-toolchain/Unix/cc +++ b/fake-toolchain/Unix/cc @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh if [[ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]]; then # Cmake determines compiler properties by compiling a test file, so call clang for this case $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ -elif [[ "$@" == "-v" ]]; then +elif [ "$@" = "-v" ]; then # Needed to enable clang-specific options for certain build systems (e.g. linux) echo "clang version 3.5.0 (fake toolchain)" diff --git a/fake-toolchain/Unix/cxx b/fake-toolchain/Unix/cxx index 2b302dbdc5..3db8744404 100755 --- a/fake-toolchain/Unix/cxx +++ b/fake-toolchain/Unix/cxx @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh if [[ ! -z "$YCM_CONFIG_GEN_CXX_PASSTHROUGH" ]]; then # Cmake determines compiler properties by compiling a test file, so call clang for this case $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@ -elif [[ "$@" == "-v" ]]; then +elif [ "$@" = "-v" ]; then # Needed to enable clang-specific options for certain build systems (e.g. linux) echo "clang version 3.5.0 (fake toolchain)" From 009e23b0500d42a428fafbabc3620eccff816e1f Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Fri, 19 Jun 2015 16:18:01 +1000 Subject: [PATCH 16/17] Replaced /bin/true with a shell script, since /bin/true may not exist on non-FHS compliant distros. See #19 --- fake-toolchain/Unix/ar | 2 +- fake-toolchain/Unix/as | 2 +- fake-toolchain/Unix/g++ | 1 + fake-toolchain/Unix/ld | 2 +- fake-toolchain/Unix/nm | 2 +- fake-toolchain/Unix/true | 4 ++++ 6 files changed, 9 insertions(+), 4 deletions(-) create mode 120000 fake-toolchain/Unix/g++ create mode 100755 fake-toolchain/Unix/true diff --git a/fake-toolchain/Unix/ar b/fake-toolchain/Unix/ar index 63b10de421..f32a5804e2 120000 --- a/fake-toolchain/Unix/ar +++ b/fake-toolchain/Unix/ar @@ -1 +1 @@ -/bin/true \ No newline at end of file +true \ No newline at end of file diff --git a/fake-toolchain/Unix/as b/fake-toolchain/Unix/as index 63b10de421..f32a5804e2 120000 --- a/fake-toolchain/Unix/as +++ b/fake-toolchain/Unix/as @@ -1 +1 @@ -/bin/true \ No newline at end of file +true \ No newline at end of file diff --git a/fake-toolchain/Unix/g++ b/fake-toolchain/Unix/g++ new file mode 120000 index 0000000000..34836c6976 --- /dev/null +++ b/fake-toolchain/Unix/g++ @@ -0,0 +1 @@ +cxx \ No newline at end of file diff --git a/fake-toolchain/Unix/ld b/fake-toolchain/Unix/ld index 63b10de421..f32a5804e2 120000 --- a/fake-toolchain/Unix/ld +++ b/fake-toolchain/Unix/ld @@ -1 +1 @@ -/bin/true \ No newline at end of file +true \ No newline at end of file diff --git a/fake-toolchain/Unix/nm b/fake-toolchain/Unix/nm index 63b10de421..f32a5804e2 120000 --- a/fake-toolchain/Unix/nm +++ b/fake-toolchain/Unix/nm @@ -1 +1 @@ -/bin/true \ No newline at end of file +true \ No newline at end of file diff --git a/fake-toolchain/Unix/true b/fake-toolchain/Unix/true new file mode 100755 index 0000000000..420376f58a --- /dev/null +++ b/fake-toolchain/Unix/true @@ -0,0 +1,4 @@ +#!/bin/sh +# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS +exit 0 + From 80646233a630017277841f14fcc65d48aa3686a0 Mon Sep 17 00:00:00 2001 From: Reuben D'Netto Date: Thu, 25 Jun 2015 00:03:11 +1000 Subject: [PATCH 17/17] Updated README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad268131f8..1ae4050877 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,19 @@ Some flags present in the resulting configuration file may be mutually exclusive ## Documentation & Support * run ```./config_gen.py --help``` to see the complete list of supported options. * if you receive the error message ```ERROR: No commands were logged to the build logs```, try using the ```--verbose``` flag to see any error messages + + some build systems require certain environment variables to be set. Note that these will *not* be used by YCM-Generator by default, unless `--preserve-environment` is used + if you open an issue regarding this error message, please include the output when running with ```--verbose``` and a link to the project repo (if possible) ## Development Patches are welcome. Please submit pull requests against the ```develop``` branch. ### Windows support -The script is currently supported under Unices (Linux, BSD, OS X) only. +The script is currently supported under Unices (Linux, NixOS[1], BSD, OS X) only. Implementing Windows support consists of porting the contents of ```fake-toolchain/Unix```. If you are interested in implementing/testing this, please open a pull request. +[1] May require `--preserve-environment` - see [#19](https://github.com/rdnetto/YCM-Generator/issues/19) + ### Test Cases The following projects are used for testing: