From d66fe341a352ef1d5bf8c14b68d1e2437f496d2d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 11 Feb 2016 19:51:54 +0100 Subject: [PATCH 001/127] more robust regex --- modules/git_info/git_info_sub.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git_info/git_info_sub.cmake b/modules/git_info/git_info_sub.cmake index de2a6ad..03505c9 100644 --- a/modules/git_info/git_info_sub.cmake +++ b/modules/git_info/git_info_sub.cmake @@ -30,7 +30,7 @@ if(GIT_FOUND) ) if(_git_last_commit) - string(REGEX MATCH "Author: +(.+) <.*@" temp "${_git_last_commit}") + string(REGEX MATCH "Author: +([^<]*) <" temp "${_git_last_commit}") set(_git_last_commit_author ${CMAKE_MATCH_1}) string(STRIP ${_git_last_commit_author} _git_last_commit_author) string(REGEX MATCH "Date: +(.+[0-9][0-9][0-9][0-9] [+-][0-9][0-9][0-9][0-9])" temp "${_git_last_commit}") From 62f9dd1b9552c3c2f05e219cf8077d601128f200 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 11 Feb 2016 20:15:46 +0100 Subject: [PATCH 002/127] adapt to new dir structure within Google Test --- modules/googletest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/googletest.cmake b/modules/googletest.cmake index edbb0db..3bdbd40 100644 --- a/modules/googletest.cmake +++ b/modules/googletest.cmake @@ -8,9 +8,9 @@ # # autocmake.cfg configuration:: # -# define: '-DGOOGLETEST_ROOT=external/googletest' +# define: '-DGOOGLETEST_ROOT=external/googletest/googletest' -set(GOOGLETEST_ROOT external/googletest CACHE STRING "Google Test source root") +set(GOOGLETEST_ROOT external/googletest/googletest CACHE STRING "Google Test source root") message(STATUS "GOOGLETEST_ROOT set to ${GOOGLETEST_ROOT}") From 1f91f303e5f40e2cafbc30a8e712e17b04f09484 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 12 Feb 2016 18:37:12 +0100 Subject: [PATCH 003/127] update links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff072f9..bcd963a 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ See http://autocmake.org. ### Projects using Autocmake -- [Numgrid](https://github.com/bast/numgrid/) -- [XCint](https://github.com/bast/xcint/) +- [Numgrid](https://github.com/dftlibs/numgrid/) +- [XCint](https://github.com/dftlibs/xcint/) - [DIRAC](http://diracprogram.org) - [mathlib-tester](https://github.com/miroi/mathlibs-tester) - [Fortran Input Reader](https://github.com/miroi/fortran_input_reader) From d0234917f4fef7bb8341fa7575ccada754249e97 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 12 Feb 2016 18:42:15 +0100 Subject: [PATCH 004/127] trim --- LICENSE | 1 - 1 file changed, 1 deletion(-) diff --git a/LICENSE b/LICENSE index 30c24f6..c88e8de 100644 --- a/LICENSE +++ b/LICENSE @@ -25,4 +25,3 @@ 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. - From a8c8bc30c76bc2abb2723e5e5ff6a56abeb5d841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Ilia=C5=A1?= Date: Fri, 18 Mar 2016 20:01:34 +0100 Subject: [PATCH 005/127] update the %path% variable so that it can find git.exe command (is hidden in the default %path% variable ) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 6b8f9a6..9f19e3b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ version: 1.0.{build} # prepare environment environment: # set custom path (will be more extended later in build_script section) - path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files\7-Zip;C:\Program Files (x86)\CMake\bin + path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files\7-Zip;C:\Program Files (x86)\CMake\bin;%path% # set MinGw-w64 (64-bit) version 5.1.0 download URL url: http://kent.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.1.0/threads-posix/seh/x86_64-5.1.0-release-posix-seh-rt_v4-rev0.7z matrix: From cdf8d4ef40b47d26de4fe079242fba28bd0954a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Ilia=C5=A1?= Date: Fri, 18 Mar 2016 21:03:31 +0100 Subject: [PATCH 006/127] fix openblas package download because the old link for downloading expired, I provided new link for downloading --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9f19e3b..f0729ec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,7 +32,7 @@ build_script: - set path=%path%;C:\software\mingw64\bin # download and unpack the OpenBLAS library, integer*4 (or i32lp64) version -- ps: wget http://skylink.dl.sourceforge.net/project/openblas/v0.2.14/OpenBLAS-v0.2.14-Win64-int32.zip -OutFile OpenBLAS-v0.2.14-Win64-int32.zip +- ps: wget http://web-docs.gsi.de/~milias/openblas-package/OpenBLAS-v0.2.14-Win64-int32.zip -OutFile OpenBLAS-v0.2.14-Win64-int32.zip - 7z x OpenBLAS-v0.2.14-Win64-int32.zip > NUL # add both OpenBLAS dynamic (libopenblas.dll) and static (libopenblas.a) library files dir to path - set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib;C:\software\OpenBLAS-v0.2.14-Win64-int32\include From 7380b9c284cd95c79649619c3199788d145a56b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Ilia=C5=A1?= Date: Fri, 18 Mar 2016 21:25:48 +0100 Subject: [PATCH 007/127] update path variable so that there will be no conflicts between cmake and git --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f0729ec..2d276e6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,8 +9,8 @@ version: 1.0.{build} # prepare environment environment: # set custom path (will be more extended later in build_script section) - path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files\7-Zip;C:\Program Files (x86)\CMake\bin;%path% -# set MinGw-w64 (64-bit) version 5.1.0 download URL + path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\7-Zip;C:\Program Files (x86)\CMake\bin + # set MinGw-w64 (64-bit) version 5.1.0 download URL url: http://kent.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.1.0/threads-posix/seh/x86_64-5.1.0-release-posix-seh-rt_v4-rev0.7z matrix: # - python: C:\Python27;C:\Python27\Scripts From 5be6e6603867d186ddb622aa28cf0cda1a8cd754 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 19 Mar 2016 17:43:42 +0100 Subject: [PATCH 008/127] preparing for yaml --- update.py | 112 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 23 deletions(-) diff --git a/update.py b/update.py index f3e78f7..442ffe8 100644 --- a/update.py +++ b/update.py @@ -10,7 +10,6 @@ import collections # for compatibility with Python < 2.7 if sys.version_info[0] > 2: from io import StringIO - from configparser import ConfigParser import urllib.request class URLopener(urllib.request.FancyURLopener): @@ -19,7 +18,6 @@ if sys.version_info[0] > 2: sys.exit(-1) else: from StringIO import StringIO - from ConfigParser import ConfigParser import urllib class URLopener(urllib.FancyURLopener): @@ -33,6 +31,47 @@ AUTOCMAKE_GITHUB_URL = 'https://github.com/scisoft/autocmake' # ------------------------------------------------------------------------------ +def replace(s, d): + from re import findall + if isinstance(s, str): + for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): + s = s.replace("%({})".format(var), d[var]) + return s + + +def test_replace(): + assert replace('hey %(foo) ho %(bar)', + {'foo': 'hey', 'bar': 'ho'}) == 'hey hey ho ho' + +# ------------------------------------------------------------------------------ + + +def interpolate(d, d_map): + from collections import Mapping + for k, v in d.items(): + if isinstance(v, Mapping): + d[k] = interpolate(d[k], d_map) + else: + d[k] = replace(d[k], d_map) + return d + + +def test_interpolate(): + d = {'foo': 'hey', + 'bar': 'ho', + 'one': 'hey %(foo) ho %(bar)', + 'two': {'one': 'hey %(foo) ho %(bar)', + 'two': 'raboof'}} + d_interpolated = {'foo': 'hey', + 'bar': 'ho', + 'one': 'hey hey ho ho', + 'two': {'one': 'hey hey ho ho', + 'two': 'raboof'}} + assert interpolate(d, d) == d_interpolated + +# ------------------------------------------------------------------------------ + + def fetch_url(src, dst): """ Fetch file from URL src and save it to dst. @@ -48,6 +87,33 @@ def fetch_url(src, dst): # ------------------------------------------------------------------------------ +def parse_yaml(file_name): + import yaml + + def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): + class OrderedLoader(Loader): + pass + def construct_mapping(loader, node): + loader.flatten_mapping(node) + return object_pairs_hook(loader.construct_pairs(node)) + OrderedLoader.add_constructor( + yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, + construct_mapping) + return yaml.load(stream, OrderedLoader) + + with open("autocmake.yml", 'r') as stream: + try: + config = ordered_load(stream, yaml.SafeLoader) + except yaml.YAMLError as exc: + print(exc) + sys.exit(-1) + + config = interpolate(config, config) + return config + +# ------------------------------------------------------------------------------ + + def print_progress_bar(text, done, total, width): """ Print progress bar. @@ -335,7 +401,7 @@ def fetch_modules(config, relative_path): width=30 ) if config.has_option(section, 'fetch'): - # when we fetch directly from autocmake.cfg + # when we fetch directly from autocmake.yml # we download into downloaded/ for src in config.get(section, 'fetch').split('\n'): dst = os.path.join(download_directory, os.path.basename(src)) @@ -374,11 +440,11 @@ def main(argv): if argv[1] == '--self': # update self - if not os.path.isfile('autocmake.cfg'): - print('- fetching example autocmake.cfg') + if not os.path.isfile('autocmake.yml'): + print('- fetching example autocmake.yml') # FIXME fetch_url( - src='%s/raw/master/example/autocmake.cfg' % AUTOCMAKE_GITHUB_URL, - dst='autocmake.cfg' + src='%s/raw/master/example/autocmake.yml' % AUTOCMAKE_GITHUB_URL, + dst='autocmake.yml' ) if not os.path.isfile('.gitignore'): print('- creating .gitignore') @@ -407,27 +473,26 @@ def main(argv): sys.exit(-1) # read config file - print('- parsing autocmake.cfg') - config = ConfigParser(dict_type=collections.OrderedDict) - config.read('autocmake.cfg') + print('- parsing autocmake.yml') + config = parse_yaml('autocmake.yml') - if not config.has_option('project', 'name'): - sys.stderr.write("ERROR: you have to specify the project name\n") - sys.stderr.write(" in autocmake.cfg under [project]\n") + if 'name' in config: + project_name = config['name'] + else: + sys.stderr.write("ERROR: you have to specify the project name in autocmake.yml\n") sys.exit(-1) - project_name = config.get('project', 'name') if ' ' in project_name.rstrip(): sys.stderr.write("ERROR: project name contains a space\n") sys.exit(-1) - if not config.has_option('project', 'min_cmake_version'): - sys.stderr.write("ERROR: you have to specify the min_cmake_version for CMake\n") - sys.stderr.write(" in autocmake.cfg under [project]\n") + if 'min_cmake_version' in config: + min_cmake_version = config['min_cmake_version'] + else: + sys.stderr.write("ERROR: you have to specify min_cmake_version in autocmake.yml\n") sys.exit(-1) - min_cmake_version = config.get('project', 'min_cmake_version') - if config.has_option('project', 'setup_script'): - setup_script_name = config.get('project', 'setup_script') + if 'setup_script' in config: + setup_script_name = config['setup_script'] else: setup_script_name = 'setup' @@ -468,7 +533,7 @@ def parse_cmake_module(s_in, defaults={}): parsed_config = collections.defaultdict(lambda: None) - if 'autocmake.cfg configuration::' not in s_in: + if 'autocmake.yml configuration::' not in s_in: return parsed_config s_out = [] @@ -485,9 +550,10 @@ def parse_cmake_module(s_in, defaults={}): if '#.rst:' in line: is_rst_line = True - autocmake_entry = '\n'.join(s_out).split('autocmake.cfg configuration::')[1] + autocmake_entry = '\n'.join(s_out).split('autocmake.yml configuration::')[1] autocmake_entry = autocmake_entry.replace('\n ', '\n') + # FIXME # we prepend a fake section heading so that we can parse it with configparser autocmake_entry = '[foo]\n' + autocmake_entry @@ -511,7 +577,7 @@ def test_parse_cmake_module(): # # Foo ... # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # # docopt: --cxx= C++ compiler [default: g++]. # --extra-cxx-flags= Extra C++ compiler flags [default: '']. From 5615da7c78183e43999abd7fd787397f26fd88b7 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 19 Mar 2016 17:46:50 +0100 Subject: [PATCH 009/127] do not hardcode file name --- update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.py b/update.py index 442ffe8..c17198e 100644 --- a/update.py +++ b/update.py @@ -101,7 +101,7 @@ def parse_yaml(file_name): construct_mapping) return yaml.load(stream, OrderedLoader) - with open("autocmake.yml", 'r') as stream: + with open(file_name, 'r') as stream: try: config = ordered_load(stream, yaml.SafeLoader) except yaml.YAMLError as exc: From 497d647746a3a654cff4756afb314079d4ef21b2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 19 Mar 2016 17:50:40 +0100 Subject: [PATCH 010/127] create requirements.txt --- .gitignore | 2 ++ requirements.txt | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 3bc3d39..2eaf211 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.cache/ +venv/ *.pyc __pycache__/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d4a8e60 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pep8 +pytest From 777a57908cf2c88093fb6c2ed8155f60a61259c3 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 19 Mar 2016 17:51:39 +0100 Subject: [PATCH 011/127] add pyyaml --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d4a8e60..35fd7f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ pep8 pytest +pyyaml From 0c3f91ba8e90b4c8564b1cec33260ca63dc833ac Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 29 Mar 2016 07:02:05 +0200 Subject: [PATCH 012/127] disable appveyor support; fixes #112, fixes #167 --- appveyor.yml | 57 ---------------------------------------------------- test/test.py | 9 --------- 2 files changed, 66 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 2d276e6..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,57 +0,0 @@ -# OS: 64-bit Windows Server 2012 R2 -# Compilers: 64-bit MinGw-w64 5.1.0 (downloaded during script execution) -# Python: 2.7, 64-bit -# "ps:" commands are executed in PowerShell - -# build version format: 1.0.1, 1.0.2, ... -version: 1.0.{build} - -# prepare environment -environment: -# set custom path (will be more extended later in build_script section) - path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\7-Zip;C:\Program Files (x86)\CMake\bin - # set MinGw-w64 (64-bit) version 5.1.0 download URL - url: http://kent.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.1.0/threads-posix/seh/x86_64-5.1.0-release-posix-seh-rt_v4-rev0.7z - matrix: -# - python: C:\Python27;C:\Python27\Scripts - - python: C:\Python27-x64;C:\Python27-x64\Scripts -# - python: C:\Python34;C:\Python34\Scripts -# - python: C:\Python34-x64;C:\Python34-x64\Scripts - -build_script: -# add location of used Python to path -- set path=%path%;%python% - -# create dir for custom software and move there -- mkdir C:\software && cd C:\software - -# download and unpack MinGw-w64 compilers -- ps: wget $env:url -OutFile MinGW.7z -- 7z x MinGW.7z > NUL -# add compilers binary dir to path -- set path=%path%;C:\software\mingw64\bin - -# download and unpack the OpenBLAS library, integer*4 (or i32lp64) version -- ps: wget http://web-docs.gsi.de/~milias/openblas-package/OpenBLAS-v0.2.14-Win64-int32.zip -OutFile OpenBLAS-v0.2.14-Win64-int32.zip -- 7z x OpenBLAS-v0.2.14-Win64-int32.zip > NUL -# add both OpenBLAS dynamic (libopenblas.dll) and static (libopenblas.a) library files dir to path -- set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib;C:\software\OpenBLAS-v0.2.14-Win64-int32\include - -# download and upgrade pip -- ps: wget https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py -- python get-pip.py - -# install py.test -- pip install pytest - -# go back to project source dir -- cd %APPVEYOR_BUILD_FOLDER% - -test_script: -# show environment -- echo %path% -- py.test --version -# run tests -- py.test -vv update.py -- py.test -vv test/test.py -- py.test -vv lib/config.py diff --git a/test/test.py b/test/test.py index 69fa309..77e0981 100644 --- a/test/test.py +++ b/test/test.py @@ -10,7 +10,6 @@ import pytest HERE = os.path.abspath(os.path.dirname(__file__)) -skip_on_windows = pytest.mark.skipif('sys.platform == "win32"', reason="not working on windows") skip_on_osx = pytest.mark.skipif('sys.platform == "darwin"', reason="not working on osx") skip_on_linux = pytest.mark.skipif('sys.platform == "linux2"', reason="not working on linux") skip_always = pytest.mark.skipif('1 == 1', reason="tests are broken") @@ -119,24 +118,20 @@ def test_fc_omp(): configure_build_and_exe('fc_omp', 'python setup --omp --fc=gfortran') -@skip_on_windows def test_fc_blas(): configure_build_and_exe('fc_blas', 'python setup --fc=gfortran --blas') -@skip_on_windows def test_fc_lapack(): configure_build_and_exe('fc_lapack', 'python setup --fc=gfortran --lapack') @skip_on_osx -@skip_on_windows def test_cxx_cblas(): configure_build_and_exe('cxx_cblas', 'python setup --cxx=g++ --cblas') @skip_on_linux -@skip_on_windows def test_cxx_accelerate(): configure_build_and_exe('cxx_accelerate', 'python setup --cxx=g++ --accelerate') @@ -150,23 +145,19 @@ def test_python_interpreter_custom(): configure_build_and_exe('python_interpreter_custom', setup) -@skip_on_windows def test_python_libs(): configure_build_and_exe('python_libs', 'python setup --cxx=g++') -@skip_on_windows def test_python_libs_custom(): python_executable = sys.executable configure_build_and_exe('python_libs_custom', 'python setup --cxx=g++ --python={}'.format(python_executable)) -@skip_on_windows def test_boost_header_only(): configure_build_and_exe('boost_header_only', 'python setup --cxx=g++') @skip_on_osx -@skip_on_windows def test_boost_libs(): configure_build_and_exe('boost_libs', 'python setup --cxx=g++ --mpi') From 1ab86a0d02bc6fae8e48f8e3020790142a49059a Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 29 Mar 2016 07:14:30 +0200 Subject: [PATCH 013/127] rm leftovers --- README.md | 1 - doc/contributors/testing.rst | 3 --- 2 files changed, 4 deletions(-) diff --git a/README.md b/README.md index bcd963a..6a5c965 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![Build Status](https://travis-ci.org/scisoft/autocmake.svg?branch=master)](https://travis-ci.org/scisoft/autocmake/builds) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/scisoft/autocmake?branch=master&svg=true)](https://ci.appveyor.com/project/bast/autocmake/history) [![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=latest)](http://autocmake.readthedocs.org) [![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE) diff --git a/doc/contributors/testing.rst b/doc/contributors/testing.rst index f4843ae..6f5b040 100644 --- a/doc/contributors/testing.rst +++ b/doc/contributors/testing.rst @@ -21,6 +21,3 @@ For more options, see the ``py.test`` flags. This test set is run upon each push to the central repository. See also the `Travis `__ build and test history. - -In addition we also test Autocmake on a Windows CI server: `Appveyor `__. -This is controlled by `Appveyor `__. From 431a329e2b1dbec33998c33286ca77265b49c57f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sun, 10 Apr 2016 16:49:32 +0200 Subject: [PATCH 014/127] use with statement for I/O --- lib/config.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/config.py b/lib/config.py index a635d40..84e8b2a 100644 --- a/lib/config.py +++ b/lib/config.py @@ -101,9 +101,8 @@ def run_cmake(command, build_path, default_build_path): # print cmake output to screen print(stdout) # write cmake output to file - f = open('cmake_output', 'w') - f.write(stdout) - f.close() + with open('cmake_output', 'w') as f: + f.write(stdout) # change directory and return os.chdir(topdir) if 'Configuring incomplete' in stdout: @@ -136,9 +135,8 @@ def save_setup_command(argv, build_path): Save setup command to a file. """ file_name = os.path.join(build_path, 'setup_command') - f = open(file_name, 'w') - f.write(' '.join(argv[:]) + '\n') - f.close() + with open(file_name, 'w') as f: + f.write(' '.join(argv[:]) + '\n') def configure(root_directory, build_path, cmake_command, only_show): From 7bfa3fb6dbfc92153cbdd105bcf7d28b003d83d6 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sun, 10 Apr 2016 17:03:41 +0200 Subject: [PATCH 015/127] more local imports --- lib/config.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/config.py b/lib/config.py index 84e8b2a..bad6347 100644 --- a/lib/config.py +++ b/lib/config.py @@ -3,10 +3,8 @@ # See https://github.com/scisoft/autocmake/blob/master/LICENSE -import subprocess import os import sys -import shutil def module_exists(module_name): @@ -23,10 +21,12 @@ def check_cmake_exists(cmake_command): Check whether CMake is installed. If not, print informative error message and quits. """ - p = subprocess.Popen('%s --version' % cmake_command, - shell=True, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE) + from subprocess import Popen, PIPE + + p = Popen('%s --version' % cmake_command, + shell=True, + stdin=PIPE, + stdout=PIPE) if not ('cmake version' in p.communicate()[0].decode('UTF-8')): sys.stderr.write(' This code is built using CMake\n\n') sys.stderr.write(' CMake is not found\n') @@ -85,13 +85,16 @@ def run_cmake(command, build_path, default_build_path): """ Execute CMake command. """ + from subprocess import Popen, PIPE + from shutil import rmtree + topdir = os.getcwd() os.chdir(build_path) - p = subprocess.Popen(command, - shell=True, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + p = Popen(command, + shell=True, + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) stdout_coded, stderr_coded = p.communicate() stdout = stdout_coded.decode('UTF-8') stderr = stderr_coded.decode('UTF-8') @@ -110,7 +113,7 @@ def run_cmake(command, build_path, default_build_path): if (build_path == default_build_path): # remove build_path iff not set by the user # otherwise removal can be dangerous - shutil.rmtree(default_build_path) + rmtree(default_build_path) else: # configuration was successful save_setup_command(sys.argv, build_path) From 8edce7af967d39ecbc85e6a7adc59a1ab309e469 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sun, 10 Apr 2016 17:20:01 +0200 Subject: [PATCH 016/127] use format() instead of % --- lib/config.py | 8 +++--- update.py | 75 +++++++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/lib/config.py b/lib/config.py index bad6347..71de04e 100644 --- a/lib/config.py +++ b/lib/config.py @@ -23,7 +23,7 @@ def check_cmake_exists(cmake_command): """ from subprocess import Popen, PIPE - p = Popen('%s --version' % cmake_command, + p = Popen('{} --version'.format(cmake_command), shell=True, stdin=PIPE, stdout=PIPE) @@ -46,7 +46,7 @@ def setup_build_path(build_path): fname = os.path.join(build_path, 'CMakeCache.txt') if os.path.exists(fname): sys.stderr.write('aborting setup\n') - sys.stderr.write('build directory %s which contains CMakeCache.txt already exists\n' % build_path) + sys.stderr.write('build directory {} which contains CMakeCache.txt already exists\n'.format(build_path)) sys.stderr.write('remove the build directory and then rerun setup\n') sys.exit(1) else: @@ -74,7 +74,7 @@ def adapt_cmake_command_to_platform(cmake_command, platform): """ if platform == 'win32': pos = cmake_command.find('cmake') - s = ['set %s &&' % e for e in cmake_command[:pos].split()] + s = ['set {} &&'.format(e) for e in cmake_command[:pos].split()] s.append(cmake_command[pos:]) return ' '.join(s) else: @@ -159,7 +159,7 @@ def configure(root_directory, build_path, cmake_command, only_show): cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform) - print('%s\n' % cmake_command) + print('{}\n'.format(cmake_command)) if only_show: sys.exit(0) diff --git a/update.py b/update.py index f3e78f7..fc26890 100644 --- a/update.py +++ b/update.py @@ -15,7 +15,7 @@ if sys.version_info[0] > 2: class URLopener(urllib.request.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch %s\n" % url) + sys.stderr.write("ERROR: could not fetch {}\n".format(url)) sys.exit(-1) else: from StringIO import StringIO @@ -24,7 +24,7 @@ else: class URLopener(urllib.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch %s\n" % url) + sys.stderr.write("ERROR: could not fetch {}\n".format(url)) sys.exit(-1) @@ -53,7 +53,7 @@ def print_progress_bar(text, done, total, width): Print progress bar. """ n = int(float(width) * float(done) / float(total)) - sys.stdout.write("\r%s [%s%s] (%i/%i)" % (text, '#' * n, + sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, ' ' * (width - n), done, total)) sys.stdout.flush() @@ -70,7 +70,7 @@ def align_options(options): l = len(opt[0]) s = [] for opt in options: - s.append(' %s%s %s' % (opt[0], ' ' * (l - len(opt[0])), opt[1])) + s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1])) return '\n'.join(s) # ------------------------------------------------------------------------------ @@ -92,20 +92,20 @@ def gen_cmake_command(config): for section in config.sections(): if config.has_option(section, 'export'): for env in config.get(section, 'export').split('\n'): - s.append(' command.append(%s)' % env) + s.append(' command.append({})'.format(env)) - s.append(" command.append('%s' % arguments['--cmake-executable'])") + s.append(" command.append(arguments['--cmake-executable'])") # take care of cmake definitions for section in config.sections(): if config.has_option(section, 'define'): for definition in config.get(section, 'define').split('\n'): - s.append(' command.append(%s)' % definition) + s.append(' command.append({})'.format(definition)) - s.append(" command.append('-DCMAKE_BUILD_TYPE=%s' % arguments['--type'])") - s.append(" command.append('-G \"%s\"' % arguments['--generator'])") + s.append(" command.append('-DCMAKE_BUILD_TYPE={}'.format(arguments['--type']))") + s.append(" command.append('-G \"{}\"'.format(arguments['--generator']))") s.append(" if arguments['--cmake-options'] != \"''\":") - s.append(" command.append('%s' % arguments['--cmake-options'])") + s.append(" command.append(arguments['--cmake-options'])") s.append(" if arguments['--prefix']:") s.append(" command.append('-DCMAKE_INSTALL_PREFIX=\"{0}\"'.format(arguments['--prefix']))") @@ -117,14 +117,11 @@ def gen_cmake_command(config): def autogenerated_notice(): - start_year = 2015 - year_range = str(start_year) current_year = datetime.date.today().year - if current_year > start_year: - year_range += '-%s' % current_year + year_range = '2015-{}'.format(current_year) s = [] s.append('# This file is autogenerated by Autocmake http://autocmake.org') - s.append('# Copyright (c) %s by Radovan Bast and Jonas Juselius' % year_range) + s.append('# Copyright (c) {} by Radovan Bast and Jonas Juselius'.format(year_range)) return '\n'.join(s) # ------------------------------------------------------------------------------ @@ -136,7 +133,7 @@ def gen_setup(config, relative_path, setup_script_name): """ s = [] s.append('#!/usr/bin/env python') - s.append('\n%s' % autogenerated_notice()) + s.append('\n{}'.format(autogenerated_notice())) s.append('\nimport os') s.append('import sys') @@ -181,7 +178,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append("try:") s.append(" arguments = docopt.docopt(options, argv=None)") s.append("except docopt.DocoptExit:") - s.append(r" sys.stderr.write('ERROR: bad input to %s\n' % sys.argv[0])") + s.append(r" sys.stderr.write('ERROR: bad input to {}\n'.format(sys.argv[0]))") s.append(" sys.stderr.write(options)") s.append(" sys.exit(-1)") s.append("\n") @@ -195,7 +192,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append("build_path = arguments['']") s.append("\n") s.append("# create cmake command") - s.append("cmake_command = '%s %s' % (gen_cmake_command(options, arguments), root_directory)") + s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)") s.append("\n") s.append("# run cmake") s.append("config.configure(root_directory, build_path, cmake_command, arguments['--show'])") @@ -214,10 +211,10 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): s.append(autogenerated_notice()) s.append('\n# set minimum cmake version') - s.append('cmake_minimum_required(VERSION %s FATAL_ERROR)' % min_cmake_version) + s.append('cmake_minimum_required(VERSION {} FATAL_ERROR)'.format(min_cmake_version)) s.append('\n# project name') - s.append('project(%s)' % project_name) + s.append('project({})'.format(project_name)) s.append('\n# do not rebuild if rules (compiler flags) change') s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)') @@ -238,12 +235,12 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): rel_cmake_module_path = os.path.join(relative_path, directory) # on windows cmake corrects this so we have to make it wrong again rel_cmake_module_path = rel_cmake_module_path.replace('\\', '/') - s.append('set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/%s)' % rel_cmake_module_path) + s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{})'.format(rel_cmake_module_path)) if len(modules) > 0: s.append('\n# included cmake modules') for module in modules: - s.append('include(%s)' % os.path.splitext(module.name)[0]) + s.append('include({})'.format(os.path.splitext(module.name)[0])) return s @@ -258,7 +255,7 @@ def prepend_or_set(config, section, option, value, defaults): """ if value: if config.has_option(section, option): - value += '\n%s' % config.get(section, option, 0, defaults) + value += '\n{}'.format(config.get(section, option, 0, defaults)) config.set(section, option, value) return config @@ -293,8 +290,8 @@ def fetch_modules(config, relative_path): module_name = os.path.basename(src) if 'http' in src: path = download_directory - name = 'autocmake_%s' % module_name - dst = os.path.join(download_directory, 'autocmake_%s' % module_name) + name = 'autocmake_{}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{}'.format(module_name)) fetch_url(src, dst) file_name = dst fetch_dst_directory = download_directory @@ -305,7 +302,7 @@ def fetch_modules(config, relative_path): file_name = src fetch_dst_directory = path else: - sys.stderr.write("ERROR: %s does not exist\n" % src) + sys.stderr.write("ERROR: {} does not exist\n".format(src)) sys.exit(-1) if config.has_option(section, 'override'): @@ -343,7 +340,7 @@ def fetch_modules(config, relative_path): print('') if warnings != []: - print('- %s' % '\n- '.join(warnings)) + print('- {}'.format('\n- '.join(warnings))) return modules @@ -358,11 +355,11 @@ def main(argv): sys.stderr.write("\nYou can update a project in two steps.\n\n") sys.stderr.write("Step 1: Update or create infrastructure files\n") sys.stderr.write(" which will be needed to configure and build the project:\n") - sys.stderr.write(" $ %s --self\n\n" % argv[0]) + sys.stderr.write(" $ {} --self\n\n".format(argv[0])) sys.stderr.write("Step 2: Create CMakeLists.txt and setup script in PROJECT_ROOT:\n") - sys.stderr.write(" $ %s \n" % argv[0]) + sys.stderr.write(" $ {} \n".format(argv[0])) sys.stderr.write(" example:\n") - sys.stderr.write(" $ %s ..\n" % argv[0]) + sys.stderr.write(" $ {} ..\n".format(argv[0])) sys.exit(-1) if argv[1] in ['-h', '--help']: @@ -377,7 +374,7 @@ def main(argv): if not os.path.isfile('autocmake.cfg'): print('- fetching example autocmake.cfg') fetch_url( - src='%s/raw/master/example/autocmake.cfg' % AUTOCMAKE_GITHUB_URL, + src='{}/raw/master/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), dst='autocmake.cfg' ) if not os.path.isfile('.gitignore'): @@ -386,24 +383,24 @@ def main(argv): f.write('*.pyc\n') print('- fetching lib/config.py') fetch_url( - src='%s/raw/master/lib/config.py' % AUTOCMAKE_GITHUB_URL, + src='{}/raw/master/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/config.py' ) print('- fetching lib/docopt/docopt.py') fetch_url( - src='%s/raw/master/lib/docopt/docopt.py' % AUTOCMAKE_GITHUB_URL, + src='{}/raw/master/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/docopt/docopt.py' ) print('- fetching update.py') fetch_url( - src='%s/raw/master/update.py' % AUTOCMAKE_GITHUB_URL, + src='{}/raw/master/update.py'.format(AUTOCMAKE_GITHUB_URL), dst='update.py' ) sys.exit(0) project_root = argv[1] if not os.path.isdir(project_root): - sys.stderr.write("ERROR: %s is not a directory\n" % project_root) + sys.stderr.write("ERROR: {} is not a directory\n".format(project_root)) sys.exit(-1) # read config file @@ -441,14 +438,14 @@ def main(argv): print('- generating CMakeLists.txt') s = gen_cmakelists(project_name, min_cmake_version, relative_path, modules) with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f: - f.write('%s\n' % '\n'.join(s)) + f.write('{}\n'.format('\n'.join(s))) # create setup script print('- generating setup script') s = gen_setup(config, relative_path, setup_script_name) file_path = os.path.join(project_root, setup_script_name) with open(file_path, 'w') as f: - f.write('%s\n' % '\n'.join(s)) + f.write('{}\n'.format('\n'.join(s))) if sys.platform != 'win32': make_executable(file_path) @@ -515,8 +512,8 @@ def test_parse_cmake_module(): # # docopt: --cxx= C++ compiler [default: g++]. # --extra-cxx-flags= Extra C++ compiler flags [default: '']. -# export: 'CXX=%s' % arguments['--cxx'] -# define: '-DEXTRA_CXXFLAGS="%s"' % arguments['--extra-cxx-flags'] +# export: 'CXX={}'.format(arguments['--cxx']) +# define: '-DEXTRA_CXXFLAGS="{}"'.format(arguments['--extra-cxx-flags']) enable_language(CXX) From ea962bf0742cedc727a997e9b7b25738f0cdf465 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sun, 10 Apr 2016 17:24:49 +0200 Subject: [PATCH 017/127] update --cmake-options example; fixes #169 --- doc/users/faq.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/users/faq.rst b/doc/users/faq.rst index b46e833..1efae3e 100644 --- a/doc/users/faq.rst +++ b/doc/users/faq.rst @@ -47,4 +47,8 @@ How can I select CMake options via the setup script? Like this:: - $ python setup --cmake-options="-DTHIS_OPTION=ON -DTHAT_OPTION=OFF" + $ python setup --cmake-options='"-DTHIS_OPTION=ON -DTHAT_OPTION=OFF"' + +We use two sets of quotes because the shell swallows one set of them +before passing the arguments to Python. If you do not use two sets +of quotes then the setup command may end up incorrectly saved in `build/setup_command`. From 49e2dda540aaebbb5ea4744418c986c94540830e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 11 Apr 2016 13:05:00 +0200 Subject: [PATCH 018/127] pep8 --- update.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/update.py b/update.py index fc26890..70c6bb5 100644 --- a/update.py +++ b/update.py @@ -53,8 +53,7 @@ def print_progress_bar(text, done, total, width): Print progress bar. """ n = int(float(width) * float(done) / float(total)) - sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, - ' ' * (width - n), done, total)) + sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, ' ' * (width - n), done, total)) sys.stdout.flush() # ------------------------------------------------------------------------------ From aebb3f7e6013e86dcc82ddab267aa0d9d7cd2994 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 11 Apr 2016 13:06:59 +0200 Subject: [PATCH 019/127] module for saving compiler flags to cache --- modules/save_flags.cmake | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 modules/save_flags.cmake diff --git a/modules/save_flags.cmake b/modules/save_flags.cmake new file mode 100644 index 0000000..d3dd677 --- /dev/null +++ b/modules/save_flags.cmake @@ -0,0 +1,43 @@ +#.rst: +# +# Take care of updating the cache for fresh configurations. +# +# Variables modified (provided the corresponding language is enabled):: +# +# DEFAULT_Fortran_FLAGS_SET +# DEFAULT_C_FLAGS_SET +# DEFAULT_CXX_FLAGS_SET + +macro(save_compiler_flags lang) + if (NOT DEFINED DEFAULT_${lang}_FLAGS_SET) + mark_as_advanced(DEFAULT_${lang}_FLAGS_SET) + + set (DEFAULT_${lang}_FLAGS_SET ON + CACHE INTERNAL + "Flag that the default ${lang} compiler flags have been set.") + + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" + CACHE STRING + "Flags used by the compiler during all builds." FORCE) + + set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}" + CACHE STRING + "Flags used by the compiler during debug builds." FORCE) + + set(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE}" + CACHE STRING + "Flags used by the compiler during release builds." FORCE) + endif() +endmacro() + +if(DEFINED CMAKE_Fortran_COMPILER_ID) + save_compiler_flags(Fortran) +endif() + +if(DEFINED CMAKE_C_COMPILER_ID) + save_compiler_flags(C) +endif() + +if(DEFINED CMAKE_CXX_COMPILER_ID) + save_compiler_flags(CXX) +endif() From 8319d41ba782910acbedb3267f2ded5fe8435bb3 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 14 Apr 2016 12:12:41 +0200 Subject: [PATCH 020/127] use {0} instead of {} in format --- lib/config.py | 8 +++---- test/test.py | 2 +- update.py | 62 +++++++++++++++++++++++++-------------------------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/config.py b/lib/config.py index 71de04e..399f9c3 100644 --- a/lib/config.py +++ b/lib/config.py @@ -23,7 +23,7 @@ def check_cmake_exists(cmake_command): """ from subprocess import Popen, PIPE - p = Popen('{} --version'.format(cmake_command), + p = Popen('{0} --version'.format(cmake_command), shell=True, stdin=PIPE, stdout=PIPE) @@ -46,7 +46,7 @@ def setup_build_path(build_path): fname = os.path.join(build_path, 'CMakeCache.txt') if os.path.exists(fname): sys.stderr.write('aborting setup\n') - sys.stderr.write('build directory {} which contains CMakeCache.txt already exists\n'.format(build_path)) + sys.stderr.write('build directory {0} which contains CMakeCache.txt already exists\n'.format(build_path)) sys.stderr.write('remove the build directory and then rerun setup\n') sys.exit(1) else: @@ -74,7 +74,7 @@ def adapt_cmake_command_to_platform(cmake_command, platform): """ if platform == 'win32': pos = cmake_command.find('cmake') - s = ['set {} &&'.format(e) for e in cmake_command[:pos].split()] + s = ['set {0} &&'.format(e) for e in cmake_command[:pos].split()] s.append(cmake_command[pos:]) return ' '.join(s) else: @@ -159,7 +159,7 @@ def configure(root_directory, build_path, cmake_command, only_show): cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform) - print('{}\n'.format(cmake_command)) + print('{0}\n'.format(cmake_command)) if only_show: sys.exit(0) diff --git a/test/test.py b/test/test.py index 77e0981..dd703f9 100644 --- a/test/test.py +++ b/test/test.py @@ -151,7 +151,7 @@ def test_python_libs(): def test_python_libs_custom(): python_executable = sys.executable - configure_build_and_exe('python_libs_custom', 'python setup --cxx=g++ --python={}'.format(python_executable)) + configure_build_and_exe('python_libs_custom', 'python setup --cxx=g++ --python={0}'.format(python_executable)) def test_boost_header_only(): diff --git a/update.py b/update.py index 70c6bb5..85cebcb 100644 --- a/update.py +++ b/update.py @@ -15,7 +15,7 @@ if sys.version_info[0] > 2: class URLopener(urllib.request.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {}\n".format(url)) + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) sys.exit(-1) else: from StringIO import StringIO @@ -24,7 +24,7 @@ else: class URLopener(urllib.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {}\n".format(url)) + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) sys.exit(-1) @@ -91,7 +91,7 @@ def gen_cmake_command(config): for section in config.sections(): if config.has_option(section, 'export'): for env in config.get(section, 'export').split('\n'): - s.append(' command.append({})'.format(env)) + s.append(' command.append({0})'.format(env)) s.append(" command.append(arguments['--cmake-executable'])") @@ -99,10 +99,10 @@ def gen_cmake_command(config): for section in config.sections(): if config.has_option(section, 'define'): for definition in config.get(section, 'define').split('\n'): - s.append(' command.append({})'.format(definition)) + s.append(' command.append({0})'.format(definition)) - s.append(" command.append('-DCMAKE_BUILD_TYPE={}'.format(arguments['--type']))") - s.append(" command.append('-G \"{}\"'.format(arguments['--generator']))") + s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") + s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))") s.append(" if arguments['--cmake-options'] != \"''\":") s.append(" command.append(arguments['--cmake-options'])") s.append(" if arguments['--prefix']:") @@ -117,10 +117,10 @@ def gen_cmake_command(config): def autogenerated_notice(): current_year = datetime.date.today().year - year_range = '2015-{}'.format(current_year) + year_range = '2015-{0}'.format(current_year) s = [] s.append('# This file is autogenerated by Autocmake http://autocmake.org') - s.append('# Copyright (c) {} by Radovan Bast and Jonas Juselius'.format(year_range)) + s.append('# Copyright (c) {0} by Radovan Bast and Jonas Juselius'.format(year_range)) return '\n'.join(s) # ------------------------------------------------------------------------------ @@ -132,7 +132,7 @@ def gen_setup(config, relative_path, setup_script_name): """ s = [] s.append('#!/usr/bin/env python') - s.append('\n{}'.format(autogenerated_notice())) + s.append('\n{0}'.format(autogenerated_notice())) s.append('\nimport os') s.append('import sys') @@ -177,7 +177,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append("try:") s.append(" arguments = docopt.docopt(options, argv=None)") s.append("except docopt.DocoptExit:") - s.append(r" sys.stderr.write('ERROR: bad input to {}\n'.format(sys.argv[0]))") + s.append(r" sys.stderr.write('ERROR: bad input to {0}\n'.format(sys.argv[0]))") s.append(" sys.stderr.write(options)") s.append(" sys.exit(-1)") s.append("\n") @@ -210,10 +210,10 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): s.append(autogenerated_notice()) s.append('\n# set minimum cmake version') - s.append('cmake_minimum_required(VERSION {} FATAL_ERROR)'.format(min_cmake_version)) + s.append('cmake_minimum_required(VERSION {0} FATAL_ERROR)'.format(min_cmake_version)) s.append('\n# project name') - s.append('project({})'.format(project_name)) + s.append('project({0})'.format(project_name)) s.append('\n# do not rebuild if rules (compiler flags) change') s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)') @@ -234,12 +234,12 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): rel_cmake_module_path = os.path.join(relative_path, directory) # on windows cmake corrects this so we have to make it wrong again rel_cmake_module_path = rel_cmake_module_path.replace('\\', '/') - s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{})'.format(rel_cmake_module_path)) + s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{0})'.format(rel_cmake_module_path)) if len(modules) > 0: s.append('\n# included cmake modules') for module in modules: - s.append('include({})'.format(os.path.splitext(module.name)[0])) + s.append('include({0})'.format(os.path.splitext(module.name)[0])) return s @@ -254,7 +254,7 @@ def prepend_or_set(config, section, option, value, defaults): """ if value: if config.has_option(section, option): - value += '\n{}'.format(config.get(section, option, 0, defaults)) + value += '\n{0}'.format(config.get(section, option, 0, defaults)) config.set(section, option, value) return config @@ -289,8 +289,8 @@ def fetch_modules(config, relative_path): module_name = os.path.basename(src) if 'http' in src: path = download_directory - name = 'autocmake_{}'.format(module_name) - dst = os.path.join(download_directory, 'autocmake_{}'.format(module_name)) + name = 'autocmake_{0}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) fetch_url(src, dst) file_name = dst fetch_dst_directory = download_directory @@ -301,7 +301,7 @@ def fetch_modules(config, relative_path): file_name = src fetch_dst_directory = path else: - sys.stderr.write("ERROR: {} does not exist\n".format(src)) + sys.stderr.write("ERROR: {0} does not exist\n".format(src)) sys.exit(-1) if config.has_option(section, 'override'): @@ -339,7 +339,7 @@ def fetch_modules(config, relative_path): print('') if warnings != []: - print('- {}'.format('\n- '.join(warnings))) + print('- {0}'.format('\n- '.join(warnings))) return modules @@ -354,11 +354,11 @@ def main(argv): sys.stderr.write("\nYou can update a project in two steps.\n\n") sys.stderr.write("Step 1: Update or create infrastructure files\n") sys.stderr.write(" which will be needed to configure and build the project:\n") - sys.stderr.write(" $ {} --self\n\n".format(argv[0])) + sys.stderr.write(" $ {0} --self\n\n".format(argv[0])) sys.stderr.write("Step 2: Create CMakeLists.txt and setup script in PROJECT_ROOT:\n") - sys.stderr.write(" $ {} \n".format(argv[0])) + sys.stderr.write(" $ {0} \n".format(argv[0])) sys.stderr.write(" example:\n") - sys.stderr.write(" $ {} ..\n".format(argv[0])) + sys.stderr.write(" $ {0} ..\n".format(argv[0])) sys.exit(-1) if argv[1] in ['-h', '--help']: @@ -373,7 +373,7 @@ def main(argv): if not os.path.isfile('autocmake.cfg'): print('- fetching example autocmake.cfg') fetch_url( - src='{}/raw/master/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/master/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), dst='autocmake.cfg' ) if not os.path.isfile('.gitignore'): @@ -382,24 +382,24 @@ def main(argv): f.write('*.pyc\n') print('- fetching lib/config.py') fetch_url( - src='{}/raw/master/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/master/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/config.py' ) print('- fetching lib/docopt/docopt.py') fetch_url( - src='{}/raw/master/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/master/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/docopt/docopt.py' ) print('- fetching update.py') fetch_url( - src='{}/raw/master/update.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/master/update.py'.format(AUTOCMAKE_GITHUB_URL), dst='update.py' ) sys.exit(0) project_root = argv[1] if not os.path.isdir(project_root): - sys.stderr.write("ERROR: {} is not a directory\n".format(project_root)) + sys.stderr.write("ERROR: {0} is not a directory\n".format(project_root)) sys.exit(-1) # read config file @@ -437,14 +437,14 @@ def main(argv): print('- generating CMakeLists.txt') s = gen_cmakelists(project_name, min_cmake_version, relative_path, modules) with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f: - f.write('{}\n'.format('\n'.join(s))) + f.write('{0}\n'.format('\n'.join(s))) # create setup script print('- generating setup script') s = gen_setup(config, relative_path, setup_script_name) file_path = os.path.join(project_root, setup_script_name) with open(file_path, 'w') as f: - f.write('{}\n'.format('\n'.join(s))) + f.write('{0}\n'.format('\n'.join(s))) if sys.platform != 'win32': make_executable(file_path) @@ -511,8 +511,8 @@ def test_parse_cmake_module(): # # docopt: --cxx= C++ compiler [default: g++]. # --extra-cxx-flags= Extra C++ compiler flags [default: '']. -# export: 'CXX={}'.format(arguments['--cxx']) -# define: '-DEXTRA_CXXFLAGS="{}"'.format(arguments['--extra-cxx-flags']) +# export: 'CXX={0}'.format(arguments['--cxx']) +# define: '-DEXTRA_CXXFLAGS="{0}"'.format(arguments['--extra-cxx-flags']) enable_language(CXX) From d6f552ce3e85fbfba90a75162fcfc0752d16d7ed Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 14 Apr 2016 12:13:28 +0200 Subject: [PATCH 021/127] setup script runs with python 2.6 --- doc/general/requirements.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/doc/general/requirements.rst b/doc/general/requirements.rst index 5c81f63..6143cb4 100644 --- a/doc/general/requirements.rst +++ b/doc/general/requirements.rst @@ -7,9 +7,5 @@ Autocmake update and test scripts require Python 2.7 or higher. We try to also support Python 3 (tested with Python 3.4). If the script fails with Python 3, consider this a bug and please file an issue. -The generated setup script runs with Python >= 2.7 (also tested with Python +The generated setup script runs with Python >= 2.6 (also tested with Python 3.4; probably also lower). - -.. todo:: - - Figure out lower Python version bound for setup. From 6926c30b3c05852517daf57cf929bdd9a7a09aa8 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 11:44:08 +0200 Subject: [PATCH 022/127] extend interpolation to lists --- update.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/update.py b/update.py index 4c35eca..1aa1278 100644 --- a/update.py +++ b/update.py @@ -47,16 +47,25 @@ def test_replace(): def interpolate(d, d_map): - from collections import Mapping + from collections import Mapping, Iterable for k, v in d.items(): if isinstance(v, Mapping): d[k] = interpolate(d[k], d_map) + elif not isinstance(v, str) and isinstance(v, Iterable): + l = [] + for x in v: + if isinstance(x, Mapping): + l.append(interpolate(x, d_map)) + else: + l.append(replace(x, d_map)) + d[k] = l.copy() else: d[k] = replace(d[k], d_map) return d def test_interpolate(): + from collections import OrderedDict d = {'foo': 'hey', 'bar': 'ho', 'one': 'hey %(foo) ho %(bar)', @@ -68,6 +77,10 @@ def test_interpolate(): 'two': {'one': 'hey hey ho ho', 'two': 'raboof'}} assert interpolate(d, d) == d_interpolated + d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} + d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} + assert interpolate(d2, d2) == d2_interpolated + # ------------------------------------------------------------------------------ @@ -89,6 +102,7 @@ def fetch_url(src, dst): def parse_yaml(file_name): import yaml + from collections import OrderedDict def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): class OrderedLoader(Loader): From e784ff88e0f1f22dc854f511b1d1867164b8b64a Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 11:57:13 +0200 Subject: [PATCH 023/127] go back to unordered dict parsing for simplicity ordering is guaranteed by lists --- update.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/update.py b/update.py index 09ab9bc..eb9f1b9 100644 --- a/update.py +++ b/update.py @@ -65,7 +65,6 @@ def interpolate(d, d_map): def test_interpolate(): - from collections import OrderedDict d = {'foo': 'hey', 'bar': 'ho', 'one': 'hey %(foo) ho %(bar)', @@ -102,22 +101,10 @@ def fetch_url(src, dst): def parse_yaml(file_name): import yaml - from collections import OrderedDict - - def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): - class OrderedLoader(Loader): - pass - def construct_mapping(loader, node): - loader.flatten_mapping(node) - return object_pairs_hook(loader.construct_pairs(node)) - OrderedLoader.add_constructor( - yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, - construct_mapping) - return yaml.load(stream, OrderedLoader) with open(file_name, 'r') as stream: try: - config = ordered_load(stream, yaml.SafeLoader) + config = yaml.load(stream, yaml.SafeLoader) except yaml.YAMLError as exc: print(exc) sys.exit(-1) From 95042c02ba62d20f4a42835ecdbf29ac7e7f48fe Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 16:53:37 +0200 Subject: [PATCH 024/127] update copyright notice --- LICENSE | 2 +- doc/conf.py | 4 ++-- lib/config.py | 5 ----- update.py | 6 ++++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/LICENSE b/LICENSE index c88e8de..65d6739 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2016, Jonas Juselius and Radovan Bast +Copyright (c) 2015-2016 by Radovan Bast, Jonas Juselius, and contributors. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/doc/conf.py b/doc/conf.py index fcdcf21..0166b7c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -52,8 +52,8 @@ master_doc = 'index' # General information about the project. project = u'Autocmake' -copyright = u'2015, Radovan Bast and Jonas Juselius' -author = u'Radovan Bast and Jonas Juselius' +copyright = u'2015-2016, Radovan Bast, Jonas Juselius, and contributors' +author = u'Radovan Bast, Jonas Juselius, and contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/lib/config.py b/lib/config.py index 399f9c3..9ca39b3 100644 --- a/lib/config.py +++ b/lib/config.py @@ -1,8 +1,3 @@ - -# Copyright (c) 2015 by Radovan Bast and Jonas Juselius -# See https://github.com/scisoft/autocmake/blob/master/LICENSE - - import os import sys diff --git a/update.py b/update.py index 85cebcb..8595ef9 100644 --- a/update.py +++ b/update.py @@ -6,6 +6,8 @@ import datetime import ast import collections +__version__ = 'X.Y.Z' + # we do not use the nicer sys.version_info.major # for compatibility with Python < 2.7 if sys.version_info[0] > 2: @@ -119,8 +121,8 @@ def autogenerated_notice(): current_year = datetime.date.today().year year_range = '2015-{0}'.format(current_year) s = [] - s.append('# This file is autogenerated by Autocmake http://autocmake.org') - s.append('# Copyright (c) {0} by Radovan Bast and Jonas Juselius'.format(year_range)) + s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__)) + s.append('# Copyright (c) {0} by Radovan Bast, Jonas Juselius, and contributors.'.format(year_range)) return '\n'.join(s) # ------------------------------------------------------------------------------ From edf124576056b33d5e6fbf8cd1a895f6147b03a8 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 16:58:53 +0200 Subject: [PATCH 025/127] adapt example configuration file --- example/{autocmake.cfg => autocmake.yml} | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename example/{autocmake.cfg => autocmake.yml} (55%) diff --git a/example/autocmake.cfg b/example/autocmake.yml similarity index 55% rename from example/autocmake.cfg rename to example/autocmake.yml index cb9b3db..3cf4a9f 100644 --- a/example/autocmake.cfg +++ b/example/autocmake.yml @@ -1,7 +1,5 @@ # CMakeLists.txt and setup script will be generated from this file # see: http://autocmake.readthedocs.org/en/latest/developers/configuration.html - -# uncomment the following three lines and set the project name -# [project] -# name: myproject -# min_cmake_version: 2.8 +# adapt the following lines and expand +name: myproject +min_cmake_version: 2.8 From 4a20af4af9715bc51f8d95b86213083387f4315f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 17:00:18 +0200 Subject: [PATCH 026/127] save work on migration to yaml --- update.py | 209 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 109 insertions(+), 100 deletions(-) diff --git a/update.py b/update.py index eb9f1b9..9df40d0 100644 --- a/update.py +++ b/update.py @@ -51,7 +51,7 @@ def interpolate(d, d_map): for k, v in d.items(): if isinstance(v, Mapping): d[k] = interpolate(d[k], d_map) - elif not isinstance(v, str) and isinstance(v, Iterable): + elif isinstance(v, Iterable) and not isinstance(v, str): l = [] for x in v: if isinstance(x, Mapping): @@ -99,15 +99,14 @@ def fetch_url(src, dst): # ------------------------------------------------------------------------------ -def parse_yaml(file_name): +def parse_yaml(stream): import yaml - with open(file_name, 'r') as stream: - try: - config = yaml.load(stream, yaml.SafeLoader) - except yaml.YAMLError as exc: - print(exc) - sys.exit(-1) + try: + config = yaml.load(stream, yaml.SafeLoader) + except yaml.YAMLError as exc: + print(exc) + sys.exit(-1) config = interpolate(config, config) return config @@ -154,19 +153,13 @@ def gen_cmake_command(config): s.append(' """') s.append(" command = []") - # take care of environment variables - for section in config.sections(): - if config.has_option(section, 'export'): - for env in config.get(section, 'export').split('\n'): - s.append(' command.append({0})'.format(env)) + for env in extract_list(config, 'export'): + s.append(' command.append({0})'.format(env)) s.append(" command.append(arguments['--cmake-executable'])") - # take care of cmake definitions - for section in config.sections(): - if config.has_option(section, 'define'): - for definition in config.get(section, 'define').split('\n'): - s.append(' command.append({0})'.format(definition)) + for definition in extract_list(config, 'define'): + s.append(' command.append({0})'.format(definition)) s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))") @@ -217,12 +210,11 @@ def gen_setup(config, relative_path, setup_script_name): s.append('\nOptions:') options = [] - for section in config.sections(): - if config.has_option(section, 'docopt'): - for opt in config.get(section, 'docopt').split('\n'): - first = opt.split()[0].strip() - rest = ' '.join(opt.split()[1:]).strip() - options.append([first, rest]) + + for opt in extract_list(config, 'docopt'): + first = opt.split()[0].strip() + rest = ' '.join(opt.split()[1:]).strip() + options.append([first, rest]) options.append(['--type=', 'Set the CMake build type (debug, release, or relwithdeb) [default: release].']) options.append(['--generator=', 'Set the CMake build system generator [default: Unix Makefiles].']) @@ -328,81 +320,98 @@ def prepend_or_set(config, section, option, value, defaults): # ------------------------------------------------------------------------------ +def extract_list(config, section): + from collections import Iterable + l = [] + if 'modules' in config: + for module in config['modules']: + for k, v in module.items(): + for x in v: + if section in x: + if isinstance(x[section], Iterable) and not isinstance(x[section], str): + for y in x[section]: + l.append(y) + else: + l.append(x[section]) + return l + +# ------------------------------------------------------------------------------ + + def fetch_modules(config, relative_path): """ Assemble modules which will be included in CMakeLists.txt. """ + from collections import Iterable download_directory = 'downloaded' if not os.path.exists(download_directory): os.makedirs(download_directory) - l = list(filter(lambda x: config.has_option(x, 'source'), - config.sections())) - n = len(l) + # here we get the list of sources to fetch + sources = extract_list(config, 'source') modules = [] Module = collections.namedtuple('Module', 'path name') warnings = [] - if n > 0: # otherwise division by zero in print_progress_bar - i = 0 - print_progress_bar(text='- assembling modules:', done=0, total=n, width=30) - for section in config.sections(): - if config.has_option(section, 'source'): - for src in config.get(section, 'source').split('\n'): - module_name = os.path.basename(src) - if 'http' in src: - path = download_directory - name = 'autocmake_{0}'.format(module_name) - dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) - fetch_url(src, dst) - file_name = dst - fetch_dst_directory = download_directory - else: - if os.path.exists(src): - path = os.path.dirname(src) - name = module_name - file_name = src - fetch_dst_directory = path - else: - sys.stderr.write("ERROR: {0} does not exist\n".format(src)) - sys.exit(-1) + if len(sources) > 0: # otherwise division by zero in print_progress_bar + print_progress_bar(text='- assembling modules:', done=0, total=len(sources), width=30) + for i, src in enumerate(sources): + module_name = os.path.basename(src) + if 'http' in src: + path = download_directory + name = 'autocmake_{0}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) + fetch_url(src, dst) + file_name = dst + fetch_dst_directory = download_directory + else: + if os.path.exists(src): + path = os.path.dirname(src) + name = module_name + file_name = src + fetch_dst_directory = path + else: + sys.stderr.write("ERROR: {0} does not exist\n".format(src)) + sys.exit(-1) - if config.has_option(section, 'override'): - defaults = ast.literal_eval(config.get(section, 'override')) - else: - defaults = {} + # FIXME + # if config.has_option(section, 'override'): + # defaults = ast.literal_eval(config.get(section, 'override')) + # else: + # defaults = {} - # we infer config from the module documentation - with open(file_name, 'r') as f: - parsed_config = parse_cmake_module(f.read(), defaults) - if parsed_config['warning']: - warnings.append('WARNING from {0}: {1}'.format(module_name, parsed_config['warning'])) - config = prepend_or_set(config, section, 'docopt', parsed_config['docopt'], defaults) - config = prepend_or_set(config, section, 'define', parsed_config['define'], defaults) - config = prepend_or_set(config, section, 'export', parsed_config['export'], defaults) - if parsed_config['fetch']: - for src in parsed_config['fetch'].split('\n'): - dst = os.path.join(fetch_dst_directory, os.path.basename(src)) - fetch_url(src, dst) + # FIXME + # we infer config from the module documentation + # with open(file_name, 'r') as f: + # parsed_config = parse_cmake_module(f.read(), defaults) + # if parsed_config['warning']: + # warnings.append('WARNING from {0}: {1}'.format(module_name, parsed_config['warning'])) + # config = prepend_or_set(config, section, 'docopt', parsed_config['docopt'], defaults) + # config = prepend_or_set(config, section, 'define', parsed_config['define'], defaults) + # config = prepend_or_set(config, section, 'export', parsed_config['export'], defaults) + # if parsed_config['fetch']: + # for src in parsed_config['fetch'].split('\n'): + # dst = os.path.join(fetch_dst_directory, os.path.basename(src)) + # fetch_url(src, dst) - modules.append(Module(path=path, name=name)) - i += 1 - print_progress_bar( - text='- assembling modules:', - done=i, - total=n, - width=30 - ) - if config.has_option(section, 'fetch'): - # when we fetch directly from autocmake.yml - # we download into downloaded/ - for src in config.get(section, 'fetch').split('\n'): - dst = os.path.join(download_directory, os.path.basename(src)) - fetch_url(src, dst) + modules.append(Module(path=path, name=name)) + print_progress_bar( + text='- assembling modules:', + done=(i + 1), + total=len(sources), + width=30 + ) + # FIXME + # if config.has_option(section, 'fetch'): + # # when we fetch directly from autocmake.yml + # # we download into downloaded/ + # for src in config.get(section, 'fetch').split('\n'): + # dst = os.path.join(download_directory, os.path.basename(src)) + # fetch_url(src, dst) print('') if warnings != []: @@ -438,9 +447,9 @@ def main(argv): if argv[1] == '--self': # update self if not os.path.isfile('autocmake.yml'): - print('- fetching example autocmake.yml') # FIXME + print('- fetching example autocmake.yml') fetch_url( - src='{0}/raw/master/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/master/example/autocmake.yml'.format(AUTOCMAKE_GITHUB_URL), dst='autocmake.yml' ) if not os.path.isfile('.gitignore'): @@ -471,7 +480,8 @@ def main(argv): # read config file print('- parsing autocmake.yml') - config = parse_yaml('autocmake.yml') + with open('autocmake.yml', 'r') as stream: + config = parse_yaml(stream) if 'name' in config: project_name = config['name'] @@ -526,7 +536,8 @@ def make_executable(path): # ------------------------------------------------------------------------------ -def parse_cmake_module(s_in, defaults={}): +def parse_cmake_module(s_in): + from collections import Mapping, Iterable parsed_config = collections.defaultdict(lambda: None) @@ -550,18 +561,15 @@ def parse_cmake_module(s_in, defaults={}): autocmake_entry = '\n'.join(s_out).split('autocmake.yml configuration::')[1] autocmake_entry = autocmake_entry.replace('\n ', '\n') - # FIXME - # we prepend a fake section heading so that we can parse it with configparser - autocmake_entry = '[foo]\n' + autocmake_entry - buf = StringIO(autocmake_entry) - config = ConfigParser(dict_type=collections.OrderedDict) - config.readfp(buf) + config = parse_yaml(buf) - for section in config.sections(): - for s in ['docopt', 'define', 'export', 'fetch', 'warning']: - if config.has_option(section, s): - parsed_config[s] = config.get(section, s, 0, defaults) + for s in ['docopt', 'define', 'export', 'fetch', 'warning']: + if s in config: + if isinstance(config[s], Iterable) and not isinstance(config[s], str): + parsed_config[s] = [x for x in config[s]] + else: + parsed_config[s] = [config[s]] return parsed_config @@ -570,16 +578,17 @@ def parse_cmake_module(s_in, defaults={}): def test_parse_cmake_module(): - s = '''#.rst: + s = r'''#.rst: # # Foo ... # # autocmake.yml configuration:: # -# docopt: --cxx= C++ compiler [default: g++]. -# --extra-cxx-flags= Extra C++ compiler flags [default: '']. -# export: 'CXX={0}'.format(arguments['--cxx']) -# define: '-DEXTRA_CXXFLAGS="{0}"'.format(arguments['--extra-cxx-flags']) +# docopt: +# - "--cxx= C++ compiler [default: g++]." +# - "--extra-cxx-flags= Extra C++ compiler flags [default: '']." +# export: "'CXX={0}'.format(arguments['--cxx'])" +# define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])" enable_language(CXX) @@ -588,7 +597,7 @@ if(NOT DEFINED CMAKE_C_COMPILER_ID) endif()''' parsed_config = parse_cmake_module(s) - assert parsed_config['docopt'] == "--cxx= C++ compiler [default: g++].\n--extra-cxx-flags= Extra C++ compiler flags [default: '']." + assert parsed_config['docopt'] == ["--cxx= C++ compiler [default: g++].", "--extra-cxx-flags= Extra C++ compiler flags [default: '']."] s = '''#.rst: # From 4e8a1dbac68ca4c74e6facba44588df53e523200 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 17:31:50 +0200 Subject: [PATCH 027/127] implement override --- update.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/update.py b/update.py index 928f5e2..4731ef5 100644 --- a/update.py +++ b/update.py @@ -37,7 +37,7 @@ def replace(s, d): from re import findall if isinstance(s, str): for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): - s = s.replace("%({})".format(var), d[var]) + s = s.replace("%({})".format(var), str(d[var])) return s @@ -101,7 +101,7 @@ def fetch_url(src, dst): # ------------------------------------------------------------------------------ -def parse_yaml(stream): +def parse_yaml(stream, override={}): import yaml try: @@ -110,6 +110,10 @@ def parse_yaml(stream): print(exc) sys.exit(-1) + for k in config: + if k in override: + config[k] = override[k] + config = interpolate(config, config) return config @@ -538,7 +542,7 @@ def make_executable(path): # ------------------------------------------------------------------------------ -def parse_cmake_module(s_in): +def parse_cmake_module(s_in, override={}): from collections import Mapping, Iterable parsed_config = collections.defaultdict(lambda: None) @@ -564,14 +568,13 @@ def parse_cmake_module(s_in): autocmake_entry = autocmake_entry.replace('\n ', '\n') buf = StringIO(autocmake_entry) - config = parse_yaml(buf) + config = parse_yaml(buf, override) - for s in ['docopt', 'define', 'export', 'fetch', 'warning']: - if s in config: - if isinstance(config[s], Iterable) and not isinstance(config[s], str): - parsed_config[s] = [x for x in config[s]] - else: - parsed_config[s] = [config[s]] + for k, v in config.items(): + if isinstance(v, Iterable) and not isinstance(v, str): + parsed_config[k] = [x for x in config[k]] + else: + parsed_config[k] = [config[k]] return parsed_config @@ -601,6 +604,9 @@ endif()''' parsed_config = parse_cmake_module(s) assert parsed_config['docopt'] == ["--cxx= C++ compiler [default: g++].", "--extra-cxx-flags= Extra C++ compiler flags [default: '']."] + +def test_parse_cmake_module_no_key(): + s = '''#.rst: # # Foo ... @@ -616,6 +622,53 @@ endif()''' parsed_config = parse_cmake_module(s) assert parsed_config['docopt'] is None + +def test_parse_cmake_module_interpolate(): + + s = r'''#.rst: +# +# Foo ... +# +# autocmake.yml configuration:: +# +# major: 1 +# minor: 2 +# patch: 3 +# a: v%(major) +# b: v%(minor) +# c: v%(patch) + +enable_language(CXX)''' + + parsed_config = parse_cmake_module(s) + assert parsed_config['a'] == ['v1'] + assert parsed_config['b'] == ['v2'] + assert parsed_config['c'] == ['v3'] + + +def test_parse_cmake_module_override(): + + s = r'''#.rst: +# +# Foo ... +# +# autocmake.yml configuration:: +# +# major: 1 +# minor: 2 +# patch: 3 +# a: v%(major) +# b: v%(minor) +# c: v%(patch) + +enable_language(CXX)''' + + d = {'minor': 4} + parsed_config = parse_cmake_module(s, d) + assert parsed_config['a'] == ['v1'] + assert parsed_config['b'] == ['v4'] + assert parsed_config['c'] == ['v3'] + # ------------------------------------------------------------------------------ From 7e6aeca79239a0e1eca3e4d7d68d9ba710c37888 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Apr 2016 22:08:51 +0200 Subject: [PATCH 028/127] update docopt to 0.6.2 --- lib/docopt/docopt.py | 228 +++++++++++++++++++++---------------------- 1 file changed, 113 insertions(+), 115 deletions(-) diff --git a/lib/docopt/docopt.py b/lib/docopt/docopt.py index 2e43f7c..7b927e2 100644 --- a/lib/docopt/docopt.py +++ b/lib/docopt/docopt.py @@ -11,7 +11,7 @@ import re __all__ = ['docopt'] -__version__ = '0.6.1' +__version__ = '0.6.2' class DocoptLanguageError(Exception): @@ -47,18 +47,18 @@ class Pattern(object): if not hasattr(self, 'children'): return self uniq = list(set(self.flat())) if uniq is None else uniq - for i, child in enumerate(self.children): - if not hasattr(child, 'children'): - assert child in uniq - self.children[i] = uniq[uniq.index(child)] + for i, c in enumerate(self.children): + if not hasattr(c, 'children'): + assert c in uniq + self.children[i] = uniq[uniq.index(c)] else: - child.fix_identities(uniq) + c.fix_identities(uniq) def fix_repeating_arguments(self): """Fix elements that should accumulate/increment values.""" - either = [list(child.children) for child in transform(self).children] + either = [list(c.children) for c in self.either.children] for case in either: - for e in [child for child in case if case.count(child) > 1]: + for e in [c for c in case if case.count(c) > 1]: if type(e) is Argument or type(e) is Option and e.argcount: if e.value is None: e.value = [] @@ -68,40 +68,47 @@ class Pattern(object): e.value = 0 return self - -def transform(pattern): - """Expand pattern into an (almost) equivalent one, but with single Either. - - Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d) - Quirks: [-a] => (-a), (-a...) => (-a -a) - - """ - result = [] - groups = [[pattern]] - while groups: - children = groups.pop(0) - parents = [Required, Optional, OptionsShortcut, Either, OneOrMore] - if any(t in map(type, children) for t in parents): - child = [c for c in children if type(c) in parents][0] - children.remove(child) - if type(child) is Either: - for c in child.children: + @property + def either(self): + """Transform pattern into an equivalent, with only top-level Either.""" + # Currently the pattern will not be equivalent, but more "narrow", + # although good enough to reason about list arguments. + ret = [] + groups = [[self]] + while groups: + children = groups.pop(0) + types = [type(c) for c in children] + if Either in types: + either = [c for c in children if type(c) is Either][0] + children.pop(children.index(either)) + for c in either.children: groups.append([c] + children) - elif type(child) is OneOrMore: - groups.append(child.children * 2 + children) + elif Required in types: + required = [c for c in children if type(c) is Required][0] + children.pop(children.index(required)) + groups.append(list(required.children) + children) + elif Optional in types: + optional = [c for c in children if type(c) is Optional][0] + children.pop(children.index(optional)) + groups.append(list(optional.children) + children) + elif AnyOptions in types: + optional = [c for c in children if type(c) is AnyOptions][0] + children.pop(children.index(optional)) + groups.append(list(optional.children) + children) + elif OneOrMore in types: + oneormore = [c for c in children if type(c) is OneOrMore][0] + children.pop(children.index(oneormore)) + groups.append(list(oneormore.children) * 2 + children) else: - groups.append(child.children + children) - else: - result.append(children) - return Either(*[Required(*e) for e in result]) + ret.append(children) + return Either(*[Required(*e) for e in ret]) -class LeafPattern(Pattern): - - """Leaf/terminal node of a pattern tree.""" +class ChildPattern(Pattern): def __init__(self, name, value=None): - self.name, self.value = name, value + self.name = name + self.value = value def __repr__(self): return '%s(%r, %r)' % (self.__class__.__name__, self.name, self.value) @@ -130,9 +137,7 @@ class LeafPattern(Pattern): return True, left_, collected + [match] -class BranchPattern(Pattern): - - """Branch/inner node of a pattern tree.""" +class ParentPattern(Pattern): def __init__(self, *children): self.children = list(children) @@ -144,15 +149,15 @@ class BranchPattern(Pattern): def flat(self, *types): if type(self) in types: return [self] - return sum([child.flat(*types) for child in self.children], []) + return sum([c.flat(*types) for c in self.children], []) -class Argument(LeafPattern): +class Argument(ChildPattern): def single_match(self, left): - for n, pattern in enumerate(left): - if type(pattern) is Argument: - return n, Argument(self.name, pattern.value) + for n, p in enumerate(left): + if type(p) is Argument: + return n, Argument(self.name, p.value) return None, None @classmethod @@ -165,23 +170,25 @@ class Argument(LeafPattern): class Command(Argument): def __init__(self, name, value=False): - self.name, self.value = name, value + self.name = name + self.value = value def single_match(self, left): - for n, pattern in enumerate(left): - if type(pattern) is Argument: - if pattern.value == self.name: + for n, p in enumerate(left): + if type(p) is Argument: + if p.value == self.name: return n, Command(self.name, True) else: break return None, None -class Option(LeafPattern): +class Option(ChildPattern): def __init__(self, short=None, long=None, argcount=0, value=False): assert argcount in (0, 1) - self.short, self.long, self.argcount = short, long, argcount + self.short, self.long = short, long + self.argcount, self.value = argcount, value self.value = None if value is False and argcount else value @classmethod @@ -202,9 +209,9 @@ class Option(LeafPattern): return class_(short, long, argcount, value) def single_match(self, left): - for n, pattern in enumerate(left): - if self.name == pattern.name: - return n, pattern + for n, p in enumerate(left): + if self.name == p.name: + return n, p return None, None @property @@ -216,34 +223,34 @@ class Option(LeafPattern): self.argcount, self.value) -class Required(BranchPattern): +class Required(ParentPattern): def match(self, left, collected=None): collected = [] if collected is None else collected l = left c = collected - for pattern in self.children: - matched, l, c = pattern.match(l, c) + for p in self.children: + matched, l, c = p.match(l, c) if not matched: return False, left, collected return True, l, c -class Optional(BranchPattern): +class Optional(ParentPattern): def match(self, left, collected=None): collected = [] if collected is None else collected - for pattern in self.children: - m, left, collected = pattern.match(left, collected) + for p in self.children: + m, left, collected = p.match(left, collected) return True, left, collected -class OptionsShortcut(Optional): +class AnyOptions(Optional): """Marker/placeholder for [options] shortcut.""" -class OneOrMore(BranchPattern): +class OneOrMore(ParentPattern): def match(self, left, collected=None): assert len(self.children) == 1 @@ -265,13 +272,13 @@ class OneOrMore(BranchPattern): return False, left, collected -class Either(BranchPattern): +class Either(ParentPattern): def match(self, left, collected=None): collected = [] if collected is None else collected outcomes = [] - for pattern in self.children: - matched, _, _ = outcome = pattern.match(left, collected) + for p in self.children: + matched, _, _ = outcome = p.match(left, collected) if matched: outcomes.append(outcome) if outcomes: @@ -279,18 +286,12 @@ class Either(BranchPattern): return False, left, collected -class Tokens(list): +class TokenStream(list): - def __init__(self, source, error=DocoptExit): + def __init__(self, source, error): self += source.split() if hasattr(source, 'split') else source self.error = error - @staticmethod - def from_pattern(source): - source = re.sub(r'([\[\]\(\)\|]|\.\.\.)', r' \1 ', source) - source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s] - return Tokens(source, error=DocoptLanguageError) - def move(self): return self.pop(0) if len(self) else None @@ -323,7 +324,7 @@ def parse_long(tokens, options): raise tokens.error('%s must not have an argument' % o.long) else: if value is None: - if tokens.current() in [None, '--']: + if tokens.current() is None: raise tokens.error('%s requires argument' % o.long) value = tokens.move() if tokens.error is DocoptExit: @@ -354,7 +355,7 @@ def parse_shorts(tokens, options): value = None if o.argcount != 0: if left == '': - if tokens.current() in [None, '--']: + if tokens.current() is None: raise tokens.error('%s requires argument' % short) value = tokens.move() else: @@ -367,7 +368,8 @@ def parse_shorts(tokens, options): def parse_pattern(source, options): - tokens = Tokens.from_pattern(source) + tokens = TokenStream(re.sub(r'([\[\]\(\)\|]|\.\.\.)', r' \1 ', source), + DocoptLanguageError) result = parse_expr(tokens, options) if tokens.current() is not None: raise tokens.error('unexpected ending: %r' % ' '.join(tokens)) @@ -414,7 +416,7 @@ def parse_atom(tokens, options): return [result] elif token == 'options': tokens.move() - return [OptionsShortcut()] + return [AnyOptions()] elif token.startswith('--') and token != '--': return parse_long(tokens, options) elif token.startswith('-') and token not in ('-', '--'): @@ -450,26 +452,27 @@ def parse_argv(tokens, options, options_first=False): def parse_defaults(doc): - defaults = [] - for s in parse_section('options:', doc): - # FIXME corner case "bla: options: --foo" - _, _, s = s.partition(':') # get rid of "options:" - split = re.split('\n[ \t]*(-\S+?)', '\n' + s)[1:] - split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] - options = [Option.parse(s) for s in split if s.startswith('-')] - defaults += options - return defaults + # in python < 2.7 you can't pass flags=re.MULTILINE + split = re.split('\n *(<\S+?>|-\S+?)', doc)[1:] + split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] + options = [Option.parse(s) for s in split if s.startswith('-')] + #arguments = [Argument.parse(s) for s in split if s.startswith('<')] + #return options, arguments + return options -def parse_section(name, source): - pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', - re.IGNORECASE | re.MULTILINE) - return [s.strip() for s in pattern.findall(source)] +def printable_usage(doc): + # in python < 2.7 you can't pass flags=re.IGNORECASE + usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc) + if len(usage_split) < 3: + raise DocoptLanguageError('"usage:" (case-insensitive) not found.') + if len(usage_split) > 3: + raise DocoptLanguageError('More than one "usage:" (case-insensitive).') + return re.split(r'\n\s*\n', ''.join(usage_split[1:]))[0].strip() -def formal_usage(section): - _, _, section = section.partition(':') # drop "usage:" - pu = section.split() +def formal_usage(printable_usage): + pu = printable_usage.split()[1:] # split and drop "usage:" return '( ' + ' '.join(') | (' if s == pu[0] else s for s in pu[1:]) + ' )' @@ -509,7 +512,7 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False): If passed, the object will be printed if --version is in `argv`. options_first : bool (default: False) - Set to True to require options precede positional arguments, + Set to True to require options preceed positional arguments, i.e. to forbid options and positional arguments intermix. Returns @@ -523,15 +526,15 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False): ------- >>> from docopt import docopt >>> doc = ''' - ... Usage: - ... my_program tcp [--timeout=] - ... my_program serial [--baud=] [--timeout=] - ... my_program (-h | --help | --version) - ... - ... Options: - ... -h, --help Show this screen and exit. - ... --baud= Baudrate [default: 9600] - ... ''' + Usage: + my_program tcp [--timeout=] + my_program serial [--baud=] [--timeout=] + my_program (-h | --help | --version) + + Options: + -h, --help Show this screen and exit. + --baud= Baudrate [default: 9600] + ''' >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30'] >>> docopt(doc, argv) {'--baud': '9600', @@ -550,15 +553,9 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False): at https://github.com/docopt/docopt#readme """ - argv = sys.argv[1:] if argv is None else argv - - usage_sections = parse_section('usage:', doc) - if len(usage_sections) == 0: - raise DocoptLanguageError('"usage:" (case-insensitive) not found.') - if len(usage_sections) > 1: - raise DocoptLanguageError('More than one "usage:" (case-insensitive).') - DocoptExit.usage = usage_sections[0] - + if argv is None: + argv = sys.argv[1:] + DocoptExit.usage = printable_usage(doc) options = parse_defaults(doc) pattern = parse_pattern(formal_usage(DocoptExit.usage), options) # [default] syntax for argument is disabled @@ -566,13 +563,14 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False): # same_name = [d for d in arguments if d.name == a.name] # if same_name: # a.value = same_name[0].value - argv = parse_argv(Tokens(argv), list(options), options_first) + argv = parse_argv(TokenStream(argv, DocoptExit), list(options), + options_first) pattern_options = set(pattern.flat(Option)) - for options_shortcut in pattern.flat(OptionsShortcut): + for ao in pattern.flat(AnyOptions): doc_options = parse_defaults(doc) - options_shortcut.children = list(set(doc_options) - pattern_options) + ao.children = list(set(doc_options) - pattern_options) #if any_options: - # options_shortcut.children += [Option(o.short, o.long, o.argcount) + # ao.children += [Option(o.short, o.long, o.argcount) # for o in argv if type(o) is Option] extras(help, version, argv, doc) matched, left, collected = pattern.fix().match(argv) From a772d29106f8c6f86fbf237612acedfcb8b33f63 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 12:30:32 +0200 Subject: [PATCH 029/127] s/scisoft/coderefinery/ --- AUTHORS.md | 2 +- README.md | 2 +- doc/contributors/doc.rst | 4 +-- doc/contributors/testing.rst | 4 +-- doc/developers/bootstrap.rst | 4 +-- doc/developers/configuration.rst | 42 +++++++++++++------------- doc/developers/customizing-modules.rst | 6 ++-- doc/developers/example.rst | 8 ++--- doc/developers/faq.rst | 2 +- doc/developers/updating-modules.rst | 4 +-- doc/extract_rst.py | 2 +- modules/boost/boost.cmake | 16 +++++----- modules/git_info/git_info.cmake | 4 +-- modules/math/accelerate.cmake | 4 +-- modules/math/cblas.cmake | 4 +-- modules/math/lapacke.cmake | 4 +-- update.py | 2 +- 17 files changed, 57 insertions(+), 57 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index b6e517b..df70378 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -10,4 +10,4 @@ - Dan Jonsson (idea for configuration file approach) - Roberto Di Remigio (design ideas and testing, OS X testing, Boost) -For a list of all the contributions see https://github.com/scisoft/autocmake/contributors. +For a list of all the contributions see https://github.com/coderefinery/autocmake/contributors. diff --git a/README.md b/README.md index 6a5c965..c782e2c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/scisoft/autocmake.svg?branch=master)](https://travis-ci.org/scisoft/autocmake/builds) +[![Build Status](https://travis-ci.org/coderefinery/autocmake.svg?branch=master)](https://travis-ci.org/coderefinery/autocmake/builds) [![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=latest)](http://autocmake.readthedocs.org) [![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE) diff --git a/doc/contributors/doc.rst b/doc/contributors/doc.rst index 4e789fd..4e7eaeb 100644 --- a/doc/contributors/doc.rst +++ b/doc/contributors/doc.rst @@ -10,11 +10,11 @@ This documentation is refreshed upon each push to the central repository. The module reference documentation is generated from the module sources using ``#.rst:`` tags (compare for instance http://autocmake.readthedocs.org/en/latest/module-reference.html#cc-cmake with -https://github.com/scisoft/autocmake/blob/master/modules/cc.cmake). +https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake). Please note that the lines following ``# autocmake.cfg configuration::`` are understood by the ``update.py`` script to infer autocmake.cfg code from the documentation. As an example consider -https://github.com/scisoft/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. diff --git a/doc/contributors/testing.rst b/doc/contributors/testing.rst index 6f5b040..43e02c7 100644 --- a/doc/contributors/testing.rst +++ b/doc/contributors/testing.rst @@ -5,7 +5,7 @@ Testing Autocmake You will need to install `pytest `__. -Check also the `Travis `__ +Check also the `Travis `__ build and test recipe for other requirements. Your contributions and changes should preserve the test set. You can run locally all tests with:: @@ -19,5 +19,5 @@ You can also select individual tests, for example those with ``fc_blas`` string For more options, see the ``py.test`` flags. This test set is run upon each push to the central repository. -See also the `Travis `__ +See also the `Travis `__ build and test history. diff --git a/doc/developers/bootstrap.rst b/doc/developers/bootstrap.rst index fe9b303..d0d6918 100644 --- a/doc/developers/bootstrap.rst +++ b/doc/developers/bootstrap.rst @@ -12,12 +12,12 @@ infrastructure files which will be needed to build the project:: $ mkdir cmake # does not have to be called "cmake" - take the name you prefer $ cd cmake - $ wget https://github.com/scisoft/autocmake/raw/master/update.py + $ wget https://github.com/coderefinery/autocmake/raw/master/update.py $ python update.py --self On the MS Windows system, you can use the PowerShell wget-replacement:: - $ Invoke-WebRequest https://github.com/scisoft/autocmake/raw/master/update.py -OutFile update.py + $ Invoke-WebRequest https://github.com/coderefinery/autocmake/raw/master/update.py -OutFile update.py This creates (or updates) the following files (an existing ``autocmake.cfg`` is not overwritten by the script):: diff --git a/doc/developers/configuration.rst b/doc/developers/configuration.rst index c45caa7..7e91681 100644 --- a/doc/developers/configuration.rst +++ b/doc/developers/configuration.rst @@ -13,38 +13,38 @@ below:: min_cmake_version: 2.8 [fc] - source: https://github.com/scisoft/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake [cc] - source: https://github.com/scisoft/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake [cxx] - source: https://github.com/scisoft/autocmake/raw/master/modules/cxx.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake [flags] - source: https://github.com/scisoft/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/scisoft/autocmake/raw/master/compilers/Intel.CXX.cmake + source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake + https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake [rpath] source: custom/rpath.cmake [definitions] - source: https://github.com/scisoft/autocmake/raw/master/modules/definitions.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/definitions.cmake [coverage] - source: https://github.com/scisoft/autocmake/raw/master/modules/code_coverage.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/code_coverage.cmake [safeguards] - source: https://github.com/scisoft/autocmake/raw/master/modules/safeguards.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/safeguards.cmake [default_build_paths] - source: https://github.com/scisoft/autocmake/raw/master/modules/default_build_paths.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/default_build_paths.cmake [src] - source: https://github.com/scisoft/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake [googletest] - source: https://github.com/scisoft/autocmake/raw/master/modules/googletest.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/googletest.cmake [custom] source: custom/api.cmake @@ -71,13 +71,13 @@ The names of the other sections do not matter to Autocmake. You could name them min_cmake_version: 2.8 [one] - source: https://github.com/scisoft/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake [two] - source: https://github.com/scisoft/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake [whatever] - source: https://github.com/scisoft/autocmake/raw/master/modules/cxx.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake But it would not make much sense. It is better to choose names that are meaningful to you. @@ -163,7 +163,7 @@ The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.cfg`` and using the ``source`` option:: [fc] - source: https://github.com/scisoft/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake This will download ``fc.cmake`` and include it in ``CMakeLists.txt``. @@ -175,8 +175,8 @@ You can also include local CMake modules, e.g.:: It is also OK to include several modules at once:: [flags] - source: https://github.com/scisoft/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/scisoft/autocmake/raw/master/compilers/Intel.CXX.cmake + source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake + https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake The modules will be included in the same order as they appear in ``autocmake.cfg``. @@ -187,7 +187,7 @@ Fetching files without including them in CMakeLists.txt Sometimes you want to fetch a file without including it in ``CMakeLists.txt``. This can be done with the ``fetch`` option. This is for instance done by the ``git_info.cmake`` module (see -https://github.com/scisoft/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L11). +https://github.com/coderefinery/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L11). If ``fetch`` is invoked in ``autocmake.cfg``, then the fetched file is placed under ``downloaded/``. If ``fetch`` is invoked from within a CMake module @@ -241,7 +241,7 @@ for many core modules which come with own options once you have sourced them. The lines following ``# autocmake.cfg configuration::`` are understood by the ``update.py`` script to infer ``autocmake.cfg`` code from the documentation. As an example consider -https://github.com/scisoft/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. @@ -251,6 +251,6 @@ Overriding documented configurations Configurable documented defaults can be achieved using interpolations. See for instance -https://github.com/scisoft/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. +https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. These can be modified within ``autocmake.cfg`` with a dictionary, e.g.: -https://github.com/scisoft/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 +https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 diff --git a/doc/developers/customizing-modules.rst b/doc/developers/customizing-modules.rst index 0f3066b..30036df 100644 --- a/doc/developers/customizing-modules.rst +++ b/doc/developers/customizing-modules.rst @@ -38,9 +38,9 @@ Overriding defaults ------------------- Some modules use interpolations to set defaults, see for instance -https://github.com/scisoft/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. +https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. These can be modified within ``autocmake.cfg``, e.g.: -https://github.com/scisoft/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 +https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 Create own CMake modules @@ -54,5 +54,5 @@ Contribute customizations to the "standard library" If you think that your customization will be useful for other users as well, you may consider contributing the changes directly to -https://github.com/scisoft/autocmake/. We very much encourage such +https://github.com/coderefinery/autocmake/. We very much encourage such contributions. But we also strive for generality and portability. diff --git a/doc/developers/example.rst b/doc/developers/example.rst index 2ef3f6d..8898fe6 100644 --- a/doc/developers/example.rst +++ b/doc/developers/example.rst @@ -25,7 +25,7 @@ Now we create ``cmake/`` and fetch ``update.py``:: $ mkdir cmake $ cd cmake/ - $ wget https://raw.githubusercontent.com/scisoft/autocmake/master/update.py + $ wget https://raw.githubusercontent.com/coderefinery/autocmake/master/update.py $ python update.py --self Now from top-level our file tree looks like this:: @@ -50,13 +50,13 @@ Now we edit ``cmake/autocmake.cfg`` to look like this:: min_cmake_version: 2.8 [fc] - source: https://github.com/scisoft/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake [cc] - source: https://github.com/scisoft/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake [src] - source: https://github.com/scisoft/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake What we have specified here is the project name and that we wish Fortran and C support. The ``src.cmake`` module tells CMake to include a ``src/CMakeLists.txt``. diff --git a/doc/developers/faq.rst b/doc/developers/faq.rst index 2c7da9a..0524dce 100644 --- a/doc/developers/faq.rst +++ b/doc/developers/faq.rst @@ -107,7 +107,7 @@ overwritten at some point. A good standard is to organize your sources under can include the latter in ``autocmake.cfg`` using:: [src] - source: https://github.com/scisoft/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake If you really don't like to do it this way, you can describe your sources and targets in a custom module in a local file and include it like this:: diff --git a/doc/developers/updating-modules.rst b/doc/developers/updating-modules.rst index 7eeca52..7fdd8be 100644 --- a/doc/developers/updating-modules.rst +++ b/doc/developers/updating-modules.rst @@ -21,10 +21,10 @@ rather fetch an older version, for example with the hash ``abcd123``. To achieve this, instead of:: [foo] - source: https://github.com/scisoft/autocmake/raw/master/modules/foo.cmake + source: https://github.com/coderefinery/autocmake/raw/master/modules/foo.cmake pin the version to ``abcd123`` (you do not need to specify the full Git hash, a unique beginning will do):: [foo] - source: https://github.com/scisoft/autocmake/raw/abcd123/modules/foo.cmake + source: https://github.com/coderefinery/autocmake/raw/abcd123/modules/foo.cmake diff --git a/doc/extract_rst.py b/doc/extract_rst.py index 9a788f7..436a168 100644 --- a/doc/extract_rst.py +++ b/doc/extract_rst.py @@ -73,7 +73,7 @@ def main(): if s_out != '': output.append('\n\n%s' % file_name) output.append('-'*len(file_name)) - output.append('`[Source code] `__' % full_file_name) + output.append('`[Source code] `__' % full_file_name) output.append(s_out) with open(os.path.join(THIS_DIR, 'module-reference.rst'), 'w') as f: diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index a4e0b38..e3e9c74 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -9,7 +9,7 @@ # # [boost] # override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'} -# source: https://github.com/scisoft/autocmake/raw/master/modules/boost/boost.cmake +# source: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake # # Cross-dependencies between required components are not checked for. # For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you @@ -49,13 +49,13 @@ # minor=48 # patch=0 # components='' -# fetch: https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_unpack.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_userconfig.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_configure.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_build.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_install.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_headers.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/boost/boost_cleanup.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_unpack.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_userconfig.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_configure.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_build.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_install.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_headers.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_cleanup.cmake # http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip # docopt: --boost-headers= Include directories for Boost [default: '']. # --boost-libraries= Library directories for Boost [default: '']. diff --git a/modules/git_info/git_info.cmake b/modules/git_info/git_info.cmake index f33895c..1b609c2 100644 --- a/modules/git_info/git_info.cmake +++ b/modules/git_info/git_info.cmake @@ -7,8 +7,8 @@ # # autocmake.cfg configuration:: # -# fetch: https://github.com/scisoft/autocmake/raw/master/modules/git_info/git_info_sub.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/git_info/git_info.h.in +# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info_sub.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info.h.in # CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2 # see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675 diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index 2e6a277..36eb3ce 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -12,8 +12,8 @@ # # docopt: --accelerate Find and link to ACCELERATE [default: False]. # define: '-DENABLE_ACCELERATE=%s' % arguments['--accelerate'] -# fetch: https://github.com/scisoft/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake option(ENABLE_ACCELERATE "Find and link to ACCELERATE" OFF) diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index a5b57b0..378cf9b 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -12,8 +12,8 @@ # # docopt: --cblas Find and link to CBLAS [default: False]. # define: '-DENABLE_CBLAS=%s' % arguments['--cblas'] -# fetch: https://github.com/scisoft/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake option(ENABLE_CBLAS "Find and link to CBLAS" OFF) diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index a05d5e2..3afbeab 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -12,8 +12,8 @@ # # docopt: --lapacke Find and link to LAPACKE [default: False]. # define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke'] -# fetch: https://github.com/scisoft/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/scisoft/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF) diff --git a/update.py b/update.py index 8595ef9..8200411 100644 --- a/update.py +++ b/update.py @@ -30,7 +30,7 @@ else: sys.exit(-1) -AUTOCMAKE_GITHUB_URL = 'https://github.com/scisoft/autocmake' +AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake' # ------------------------------------------------------------------------------ From 2d858a2a5a396fad16a4465936a81c81f95fe590 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 21:38:41 +0200 Subject: [PATCH 030/127] absorb branch name in AUTOCMAKE_GITHUB_URL --- update.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/update.py b/update.py index 95ce83f..182c584 100644 --- a/update.py +++ b/update.py @@ -28,7 +28,7 @@ else: sys.exit(-1) -AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake' +AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/master/' # ------------------------------------------------------------------------------ @@ -455,7 +455,7 @@ def main(argv): if not os.path.isfile('autocmake.yml'): print('- fetching example autocmake.yml') fetch_url( - src='{0}/raw/master/example/autocmake.yml'.format(AUTOCMAKE_GITHUB_URL), + src='{0}example/autocmake.yml'.format(AUTOCMAKE_GITHUB_URL), dst='autocmake.yml' ) if not os.path.isfile('.gitignore'): @@ -464,17 +464,17 @@ def main(argv): f.write('*.pyc\n') print('- fetching lib/config.py') fetch_url( - src='{0}/raw/master/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}lib/config.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/config.py' ) print('- fetching lib/docopt/docopt.py') fetch_url( - src='{0}/raw/master/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/docopt/docopt.py' ) print('- fetching update.py') fetch_url( - src='{0}/raw/master/update.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}update.py'.format(AUTOCMAKE_GITHUB_URL), dst='update.py' ) sys.exit(0) From cc6b374b937051fc37bfdf7014ab2bcc53a85b3f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 21:57:41 +0200 Subject: [PATCH 031/127] less code repetition --- update.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/update.py b/update.py index 182c584..3ba1710 100644 --- a/update.py +++ b/update.py @@ -462,21 +462,12 @@ def main(argv): print('- creating .gitignore') with open('.gitignore', 'w') as f: f.write('*.pyc\n') - print('- fetching lib/config.py') - fetch_url( - src='{0}lib/config.py'.format(AUTOCMAKE_GITHUB_URL), - dst='lib/config.py' - ) - print('- fetching lib/docopt/docopt.py') - fetch_url( - src='{0}lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), - dst='lib/docopt/docopt.py' - ) - print('- fetching update.py') - fetch_url( - src='{0}update.py'.format(AUTOCMAKE_GITHUB_URL), - dst='update.py' - ) + for f in ['lib/config.py', 'lib/docopt/docopt.py', 'update.py']: + print('- fetching {0}'.format(f)) + fetch_url( + src='{0}{1}'.format(AUTOCMAKE_GITHUB_URL, f), + dst='{0}'.format(f) + ) sys.exit(0) project_root = argv[1] From cfb842e7bb5574e98816735c1d63f17304340861 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 21:57:57 +0200 Subject: [PATCH 032/127] point AUTOCMAKE_GITHUB_URL to yaml --- update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.py b/update.py index 3ba1710..45a1a37 100644 --- a/update.py +++ b/update.py @@ -28,7 +28,7 @@ else: sys.exit(-1) -AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/master/' +AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' # ------------------------------------------------------------------------------ From 653a4fafcb7933dfb90ad6713c6ddabb51e5bb32 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 21:58:53 +0200 Subject: [PATCH 033/127] deactivate tests --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef3b798..1b0c9c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,15 +45,15 @@ install: - source venv/bin/activate - pip install pep8 pytest -script: - # pep8 tests - - pep8 --ignore=E501 update.py - - pep8 --ignore=E501 test/test.py - - pep8 --ignore=E501 lib/config.py - # unit tests - - py.test -vv update.py - - py.test -vv test/test.py - - py.test -vv lib/config.py +#script: +# # pep8 tests +# - pep8 --ignore=E501 update.py +# - pep8 --ignore=E501 test/test.py +# - pep8 --ignore=E501 lib/config.py +# # unit tests +# - py.test -vv update.py +# - py.test -vv test/test.py +# - py.test -vv lib/config.py notifications: email: false From 1543af1a3ee74a28fccfb7b507cea436c44b855e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:04:53 +0200 Subject: [PATCH 034/127] reorg --- autocmake/__init__.py | 0 {lib => autocmake}/config.py | 0 {lib/docopt => autocmake/external}/LICENSE-MIT | 0 {lib/docopt => autocmake/external}/docopt.py | 0 update.py | 13 +++++++------ 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 autocmake/__init__.py rename {lib => autocmake}/config.py (100%) rename {lib/docopt => autocmake/external}/LICENSE-MIT (100%) rename {lib/docopt => autocmake/external}/docopt.py (100%) diff --git a/autocmake/__init__.py b/autocmake/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lib/config.py b/autocmake/config.py similarity index 100% rename from lib/config.py rename to autocmake/config.py diff --git a/lib/docopt/LICENSE-MIT b/autocmake/external/LICENSE-MIT similarity index 100% rename from lib/docopt/LICENSE-MIT rename to autocmake/external/LICENSE-MIT diff --git a/lib/docopt/docopt.py b/autocmake/external/docopt.py similarity index 100% rename from lib/docopt/docopt.py rename to autocmake/external/docopt.py diff --git a/update.py b/update.py index 45a1a37..e99c0c1 100644 --- a/update.py +++ b/update.py @@ -203,11 +203,9 @@ def gen_setup(config, relative_path, setup_script_name): s.append('import sys') s.append("\nsys.path.insert(0, '{0}')".format(relative_path)) - s.append("sys.path.insert(0, '{0}')".format(os.path.join(relative_path, 'lib'))) - s.append("sys.path.insert(0, '{0}')".format(os.path.join(relative_path, 'lib', 'docopt'))) - s.append('import config') - s.append('import docopt') + s.append('from autocmake import config') + s.append('from autocmake.external import docopt') s.append('\n\noptions = """') s.append('Usage:') @@ -445,7 +443,7 @@ def main(argv): if argv[1] in ['-h', '--help']: print('Usage:') - print(' python update.py --self Update this script and fetch or update infrastructure files under lib/.') + print(' python update.py --self Update this script and fetch or update infrastructure files under autocmake/.') print(' python update.py (Re)generate CMakeLists.txt and setup script and fetch or update CMake modules.') print(' python update.py (-h | --help) Show this help text.') sys.exit(0) @@ -462,7 +460,10 @@ def main(argv): print('- creating .gitignore') with open('.gitignore', 'w') as f: f.write('*.pyc\n') - for f in ['lib/config.py', 'lib/docopt/docopt.py', 'update.py']: + for f in ['autocmake/config.py', + 'autocmake/external/docopt.py', + 'autocmake/__init__.py', + 'update.py']: print('- fetching {0}'.format(f)) fetch_url( src='{0}{1}'.format(AUTOCMAKE_GITHUB_URL, f), From ffacd0378b99507dcb271bd34d14b5e50eb9e2c4 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:10:14 +0200 Subject: [PATCH 035/127] rename --- autocmake/{config.py => configure.py} | 0 update.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename autocmake/{config.py => configure.py} (100%) diff --git a/autocmake/config.py b/autocmake/configure.py similarity index 100% rename from autocmake/config.py rename to autocmake/configure.py diff --git a/update.py b/update.py index e99c0c1..941ff8d 100644 --- a/update.py +++ b/update.py @@ -204,7 +204,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append("\nsys.path.insert(0, '{0}')".format(relative_path)) - s.append('from autocmake import config') + s.append('from autocmake import configure') s.append('from autocmake.external import docopt') s.append('\n\noptions = """') @@ -245,7 +245,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append(" sys.exit(-1)") s.append("\n") s.append("# use extensions to validate/post-process args") - s.append("if config.module_exists('extensions'):") + s.append("if configure.module_exists('extensions'):") s.append(" import extensions") s.append(" arguments = extensions.postprocess_args(sys.argv, arguments)") s.append("\n") @@ -257,7 +257,7 @@ def gen_setup(config, relative_path, setup_script_name): s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)") s.append("\n") s.append("# run cmake") - s.append("config.configure(root_directory, build_path, cmake_command, arguments['--show'])") + s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])") return s @@ -460,7 +460,7 @@ def main(argv): print('- creating .gitignore') with open('.gitignore', 'w') as f: f.write('*.pyc\n') - for f in ['autocmake/config.py', + for f in ['autocmake/configure.py', 'autocmake/external/docopt.py', 'autocmake/__init__.py', 'update.py']: From 3a5192eed8b06edc18834cab0f32de12b23085f0 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:19:18 +0200 Subject: [PATCH 036/127] simplify pep8 testing --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b0c9c9..3e095f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,11 +45,10 @@ install: - source venv/bin/activate - pip install pep8 pytest -#script: -# # pep8 tests -# - pep8 --ignore=E501 update.py -# - pep8 --ignore=E501 test/test.py -# - pep8 --ignore=E501 lib/config.py +script: + # pep8 tests +# - pep8 --ignore E501 update.py + - pep8 --ignore E501,E265 autocmake # # unit tests # - py.test -vv update.py # - py.test -vv test/test.py From e2fee845814ab8dbfb03683973515abf7dc518d9 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:20:16 +0200 Subject: [PATCH 037/127] pyaml is required --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e095f7..0780bb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ install: fi - virtualenv venv - source venv/bin/activate - - pip install pep8 pytest + - pip install pep8 pytest pyaml script: # pep8 tests From 9e63f3e04223d5e2c0120010acdb9b914c40e287 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:21:46 +0200 Subject: [PATCH 038/127] reactivate some tests --- .travis.yml | 6 +++--- update.py | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0780bb9..9a1fee1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,12 +47,12 @@ install: script: # pep8 tests -# - pep8 --ignore E501 update.py + - pep8 --ignore E501 update.py - pep8 --ignore E501,E265 autocmake # # unit tests -# - py.test -vv update.py + - py.test -vv update.py + - py.test -vv autocmake/* # - py.test -vv test/test.py -# - py.test -vv lib/config.py notifications: email: false diff --git a/update.py b/update.py index 941ff8d..897ce48 100644 --- a/update.py +++ b/update.py @@ -382,25 +382,25 @@ def fetch_modules(config, relative_path): sys.stderr.write("ERROR: {0} does not exist\n".format(src)) sys.exit(-1) - # FIXME - # if config.has_option(section, 'override'): - # defaults = ast.literal_eval(config.get(section, 'override')) - # else: - # defaults = {} +# FIXME +# if config.has_option(section, 'override'): +# defaults = ast.literal_eval(config.get(section, 'override')) +# else: +# defaults = {} - # FIXME - # we infer config from the module documentation - # with open(file_name, 'r') as f: - # parsed_config = parse_cmake_module(f.read(), defaults) - # if parsed_config['warning']: - # warnings.append('WARNING from {0}: {1}'.format(module_name, parsed_config['warning'])) - # config = prepend_or_set(config, section, 'docopt', parsed_config['docopt'], defaults) - # config = prepend_or_set(config, section, 'define', parsed_config['define'], defaults) - # config = prepend_or_set(config, section, 'export', parsed_config['export'], defaults) - # if parsed_config['fetch']: - # for src in parsed_config['fetch'].split('\n'): - # dst = os.path.join(fetch_dst_directory, os.path.basename(src)) - # fetch_url(src, dst) +# FIXME +# # we infer config from the module documentation +# with open(file_name, 'r') as f: +# parsed_config = parse_cmake_module(f.read(), defaults) +# if parsed_config['warning']: +# warnings.append('WARNING from {0}: {1}'.format(module_name, parsed_config['warning'])) +# config = prepend_or_set(config, section, 'docopt', parsed_config['docopt'], defaults) +# config = prepend_or_set(config, section, 'define', parsed_config['define'], defaults) +# config = prepend_or_set(config, section, 'export', parsed_config['export'], defaults) +# if parsed_config['fetch']: +# for src in parsed_config['fetch'].split('\n'): +# dst = os.path.join(fetch_dst_directory, os.path.basename(src)) +# fetch_url(src, dst) modules.append(Module(path=path, name=name)) print_progress_bar( @@ -409,13 +409,13 @@ def fetch_modules(config, relative_path): total=len(sources), width=30 ) - # FIXME - # if config.has_option(section, 'fetch'): - # # when we fetch directly from autocmake.yml - # # we download into downloaded/ - # for src in config.get(section, 'fetch').split('\n'): - # dst = os.path.join(download_directory, os.path.basename(src)) - # fetch_url(src, dst) +# FIXME +# if config.has_option(section, 'fetch'): +# # when we fetch directly from autocmake.yml +# # we download into downloaded/ +# for src in config.get(section, 'fetch').split('\n'): +# dst = os.path.join(download_directory, os.path.basename(src)) +# fetch_url(src, dst) print('') if warnings != []: From 1a2bd4507b74f0445745e7949806f4c8b03d35d1 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:27:27 +0200 Subject: [PATCH 039/127] use copy.copy(l) instead of l.copy() --- update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update.py b/update.py index 897ce48..ff31978 100644 --- a/update.py +++ b/update.py @@ -50,6 +50,7 @@ def test_replace(): def interpolate(d, d_map): from collections import Mapping, Iterable + from copy import copy for k, v in d.items(): if isinstance(v, Mapping): d[k] = interpolate(d[k], d_map) @@ -60,7 +61,7 @@ def interpolate(d, d_map): l.append(interpolate(x, d_map)) else: l.append(replace(x, d_map)) - d[k] = l.copy() + d[k] = copy(l) else: d[k] = replace(d[k], d_map) return d From f2ef8bf39339b32360722c15dfde45571181c23a Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:52:39 +0200 Subject: [PATCH 040/127] more structure --- autocmake/http.py | 28 +++++ autocmake/interpolate.py | 47 ++++++++ autocmake/parse_rst.py | 133 +++++++++++++++++++++ autocmake/parse_yaml.py | 16 +++ update.py | 242 +-------------------------------------- 5 files changed, 229 insertions(+), 237 deletions(-) create mode 100644 autocmake/http.py create mode 100644 autocmake/interpolate.py create mode 100644 autocmake/parse_rst.py create mode 100644 autocmake/parse_yaml.py diff --git a/autocmake/http.py b/autocmake/http.py new file mode 100644 index 0000000..4ef6b1d --- /dev/null +++ b/autocmake/http.py @@ -0,0 +1,28 @@ +def fetch_url(src, dst): + """ + Fetch file from URL src and save it to dst. + """ + # we do not use the nicer sys.version_info.major + # for compatibility with Python < 2.7 + if sys.version_info[0] > 2: + import urllib.request + + class URLopener(urllib.request.FancyURLopener): + def http_error_default(self, url, fp, errcode, errmsg, headers): + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) + sys.exit(-1) + else: + import urllib + + class URLopener(urllib.FancyURLopener): + def http_error_default(self, url, fp, errcode, errmsg, headers): + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) + sys.exit(-1) + + dirname = os.path.dirname(dst) + if dirname != '': + if not os.path.isdir(dirname): + os.makedirs(dirname) + + opener = URLopener() + opener.retrieve(src, dst) diff --git a/autocmake/interpolate.py b/autocmake/interpolate.py new file mode 100644 index 0000000..0d371ab --- /dev/null +++ b/autocmake/interpolate.py @@ -0,0 +1,47 @@ +def replace(s, d): + from re import findall + if isinstance(s, str): + for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): + s = s.replace("%({})".format(var), str(d[var])) + return s + + +def test_replace(): + assert replace('hey %(foo) ho %(bar)', + {'foo': 'hey', 'bar': 'ho'}) == 'hey hey ho ho' + + +def interpolate(d, d_map): + from collections import Mapping, Iterable + from copy import copy + for k, v in d.items(): + if isinstance(v, Mapping): + d[k] = interpolate(d[k], d_map) + elif isinstance(v, Iterable) and not isinstance(v, str): + l = [] + for x in v: + if isinstance(x, Mapping): + l.append(interpolate(x, d_map)) + else: + l.append(replace(x, d_map)) + d[k] = copy(l) + else: + d[k] = replace(d[k], d_map) + return d + + +def test_interpolate(): + d = {'foo': 'hey', + 'bar': 'ho', + 'one': 'hey %(foo) ho %(bar)', + 'two': {'one': 'hey %(foo) ho %(bar)', + 'two': 'raboof'}} + d_interpolated = {'foo': 'hey', + 'bar': 'ho', + 'one': 'hey hey ho ho', + 'two': {'one': 'hey hey ho ho', + 'two': 'raboof'}} + assert interpolate(d, d) == d_interpolated + d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} + d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} + assert interpolate(d2, d2) == d2_interpolated diff --git a/autocmake/parse_rst.py b/autocmake/parse_rst.py new file mode 100644 index 0000000..70a2151 --- /dev/null +++ b/autocmake/parse_rst.py @@ -0,0 +1,133 @@ +def parse_cmake_module(s_in, override={}): + import sys + from collections import Mapping, Iterable, defaultdict + from autocmake.parse_yaml import parse_yaml + + # we do not use the nicer sys.version_info.major + # for compatibility with Python < 2.7 + if sys.version_info[0] > 2: + from io import StringIO + else: + from StringIO import StringIO + + parsed_config = defaultdict(lambda: None) + + if 'autocmake.yml configuration::' not in s_in: + return parsed_config + + s_out = [] + is_rst_line = False + for line in s_in.split('\n'): + if is_rst_line: + if len(line) > 0: + if line[0] != '#': + is_rst_line = False + else: + is_rst_line = False + if is_rst_line: + s_out.append(line[2:]) + if '#.rst:' in line: + is_rst_line = True + + autocmake_entry = '\n'.join(s_out).split('autocmake.yml configuration::')[1] + autocmake_entry = autocmake_entry.replace('\n ', '\n') + + buf = StringIO(autocmake_entry) + config = parse_yaml(buf, override) + + for k, v in config.items(): + if isinstance(v, Iterable) and not isinstance(v, str): + parsed_config[k] = [x for x in config[k]] + else: + parsed_config[k] = [config[k]] + + return parsed_config + + +def test_parse_cmake_module(): + + s = r'''#.rst: +# +# Foo ... +# +# autocmake.yml configuration:: +# +# docopt: +# - "--cxx= C++ compiler [default: g++]." +# - "--extra-cxx-flags= Extra C++ compiler flags [default: '']." +# export: "'CXX={0}'.format(arguments['--cxx'])" +# define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])" + +enable_language(CXX) + +if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") +endif()''' + + parsed_config = parse_cmake_module(s) + assert parsed_config['docopt'] == ["--cxx= C++ compiler [default: g++].", "--extra-cxx-flags= Extra C++ compiler flags [default: '']."] + + +def test_parse_cmake_module_no_key(): + + s = '''#.rst: +# +# Foo ... +# +# Bar ... + +enable_language(CXX) + +if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") +endif()''' + + parsed_config = parse_cmake_module(s) + assert parsed_config['docopt'] is None + + +def test_parse_cmake_module_interpolate(): + + s = r'''#.rst: +# +# Foo ... +# +# autocmake.yml configuration:: +# +# major: 1 +# minor: 2 +# patch: 3 +# a: v%(major) +# b: v%(minor) +# c: v%(patch) + +enable_language(CXX)''' + + parsed_config = parse_cmake_module(s) + assert parsed_config['a'] == ['v1'] + assert parsed_config['b'] == ['v2'] + assert parsed_config['c'] == ['v3'] + + +def test_parse_cmake_module_override(): + + s = r'''#.rst: +# +# Foo ... +# +# autocmake.yml configuration:: +# +# major: 1 +# minor: 2 +# patch: 3 +# a: v%(major) +# b: v%(minor) +# c: v%(patch) + +enable_language(CXX)''' + + d = {'minor': 4} + parsed_config = parse_cmake_module(s, d) + assert parsed_config['a'] == ['v1'] + assert parsed_config['b'] == ['v4'] + assert parsed_config['c'] == ['v3'] diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py new file mode 100644 index 0000000..1824b38 --- /dev/null +++ b/autocmake/parse_yaml.py @@ -0,0 +1,16 @@ +def parse_yaml(stream, override={}): + import yaml + from autocmake.interpolate import interpolate + + try: + config = yaml.load(stream, yaml.SafeLoader) + except yaml.YAMLError as exc: + print(exc) + sys.exit(-1) + + for k in config: + if k in override: + config[k] = override[k] + + config = interpolate(config, config) + return config diff --git a/update.py b/update.py index ff31978..56a5238 100644 --- a/update.py +++ b/update.py @@ -8,119 +8,12 @@ import collections __version__ = 'X.Y.Z' -# we do not use the nicer sys.version_info.major -# for compatibility with Python < 2.7 -if sys.version_info[0] > 2: - from io import StringIO - import urllib.request - - class URLopener(urllib.request.FancyURLopener): - def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) - sys.exit(-1) -else: - from StringIO import StringIO - import urllib - - class URLopener(urllib.FancyURLopener): - def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) - sys.exit(-1) - AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' # ------------------------------------------------------------------------------ -def replace(s, d): - from re import findall - if isinstance(s, str): - for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): - s = s.replace("%({})".format(var), str(d[var])) - return s - - -def test_replace(): - assert replace('hey %(foo) ho %(bar)', - {'foo': 'hey', 'bar': 'ho'}) == 'hey hey ho ho' - -# ------------------------------------------------------------------------------ - - -def interpolate(d, d_map): - from collections import Mapping, Iterable - from copy import copy - for k, v in d.items(): - if isinstance(v, Mapping): - d[k] = interpolate(d[k], d_map) - elif isinstance(v, Iterable) and not isinstance(v, str): - l = [] - for x in v: - if isinstance(x, Mapping): - l.append(interpolate(x, d_map)) - else: - l.append(replace(x, d_map)) - d[k] = copy(l) - else: - d[k] = replace(d[k], d_map) - return d - - -def test_interpolate(): - d = {'foo': 'hey', - 'bar': 'ho', - 'one': 'hey %(foo) ho %(bar)', - 'two': {'one': 'hey %(foo) ho %(bar)', - 'two': 'raboof'}} - d_interpolated = {'foo': 'hey', - 'bar': 'ho', - 'one': 'hey hey ho ho', - 'two': {'one': 'hey hey ho ho', - 'two': 'raboof'}} - assert interpolate(d, d) == d_interpolated - d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} - d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} - assert interpolate(d2, d2) == d2_interpolated - - -# ------------------------------------------------------------------------------ - - -def fetch_url(src, dst): - """ - Fetch file from URL src and save it to dst. - """ - dirname = os.path.dirname(dst) - if dirname != '': - if not os.path.isdir(dirname): - os.makedirs(dirname) - - opener = URLopener() - opener.retrieve(src, dst) - -# ------------------------------------------------------------------------------ - - -def parse_yaml(stream, override={}): - import yaml - - try: - config = yaml.load(stream, yaml.SafeLoader) - except yaml.YAMLError as exc: - print(exc) - sys.exit(-1) - - for k in config: - if k in override: - config[k] = override[k] - - config = interpolate(config, config) - return config - -# ------------------------------------------------------------------------------ - - def print_progress_bar(text, done, total, width): """ Print progress bar. @@ -349,6 +242,7 @@ def fetch_modules(config, relative_path): be included in CMakeLists.txt. """ from collections import Iterable + from autocmake.http import fetch_url download_directory = 'downloaded' if not os.path.exists(download_directory): @@ -431,6 +325,9 @@ def main(argv): """ Main function. """ + from autocmake.parse_yaml import parse_yaml + from autocmake.http import fetch_url + if len(argv) != 2: sys.stderr.write("\nYou can update a project in two steps.\n\n") sys.stderr.write("Step 1: Update or create infrastructure files\n") @@ -464,6 +361,7 @@ def main(argv): for f in ['autocmake/configure.py', 'autocmake/external/docopt.py', 'autocmake/__init__.py', + 'autocmake/interpolate.py', 'update.py']: print('- fetching {0}'.format(f)) fetch_url( @@ -535,135 +433,5 @@ def make_executable(path): # ------------------------------------------------------------------------------ -def parse_cmake_module(s_in, override={}): - from collections import Mapping, Iterable - - parsed_config = collections.defaultdict(lambda: None) - - if 'autocmake.yml configuration::' not in s_in: - return parsed_config - - s_out = [] - is_rst_line = False - for line in s_in.split('\n'): - if is_rst_line: - if len(line) > 0: - if line[0] != '#': - is_rst_line = False - else: - is_rst_line = False - if is_rst_line: - s_out.append(line[2:]) - if '#.rst:' in line: - is_rst_line = True - - autocmake_entry = '\n'.join(s_out).split('autocmake.yml configuration::')[1] - autocmake_entry = autocmake_entry.replace('\n ', '\n') - - buf = StringIO(autocmake_entry) - config = parse_yaml(buf, override) - - for k, v in config.items(): - if isinstance(v, Iterable) and not isinstance(v, str): - parsed_config[k] = [x for x in config[k]] - else: - parsed_config[k] = [config[k]] - - return parsed_config - -# ------------------------------------------------------------------------------ - - -def test_parse_cmake_module(): - - s = r'''#.rst: -# -# Foo ... -# -# autocmake.yml configuration:: -# -# docopt: -# - "--cxx= C++ compiler [default: g++]." -# - "--extra-cxx-flags= Extra C++ compiler flags [default: '']." -# export: "'CXX={0}'.format(arguments['--cxx'])" -# define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])" - -enable_language(CXX) - -if(NOT DEFINED CMAKE_C_COMPILER_ID) - message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") -endif()''' - - parsed_config = parse_cmake_module(s) - assert parsed_config['docopt'] == ["--cxx= C++ compiler [default: g++].", "--extra-cxx-flags= Extra C++ compiler flags [default: '']."] - - -def test_parse_cmake_module_no_key(): - - s = '''#.rst: -# -# Foo ... -# -# Bar ... - -enable_language(CXX) - -if(NOT DEFINED CMAKE_C_COMPILER_ID) - message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") -endif()''' - - parsed_config = parse_cmake_module(s) - assert parsed_config['docopt'] is None - - -def test_parse_cmake_module_interpolate(): - - s = r'''#.rst: -# -# Foo ... -# -# autocmake.yml configuration:: -# -# major: 1 -# minor: 2 -# patch: 3 -# a: v%(major) -# b: v%(minor) -# c: v%(patch) - -enable_language(CXX)''' - - parsed_config = parse_cmake_module(s) - assert parsed_config['a'] == ['v1'] - assert parsed_config['b'] == ['v2'] - assert parsed_config['c'] == ['v3'] - - -def test_parse_cmake_module_override(): - - s = r'''#.rst: -# -# Foo ... -# -# autocmake.yml configuration:: -# -# major: 1 -# minor: 2 -# patch: 3 -# a: v%(major) -# b: v%(minor) -# c: v%(patch) - -enable_language(CXX)''' - - d = {'minor': 4} - parsed_config = parse_cmake_module(s, d) - assert parsed_config['a'] == ['v1'] - assert parsed_config['b'] == ['v4'] - assert parsed_config['c'] == ['v3'] - -# ------------------------------------------------------------------------------ - - if __name__ == '__main__': main(sys.argv) From 2dff9674970695f3f7de833215ed18eb7622f498 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 22:53:50 +0200 Subject: [PATCH 041/127] fetch more files --- update.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/update.py b/update.py index 56a5238..c56c817 100644 --- a/update.py +++ b/update.py @@ -362,6 +362,9 @@ def main(argv): 'autocmake/external/docopt.py', 'autocmake/__init__.py', 'autocmake/interpolate.py', + 'autocmake/http.py', + 'autocmake/parse_rst.py', + 'autocmake/parse_yaml.py', 'update.py']: print('- fetching {0}'.format(f)) fetch_url( From e36af9059b54cb7e62ccb1b43edac1449553b698 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 19 Apr 2016 23:00:10 +0200 Subject: [PATCH 042/127] do not test update.py --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a1fee1..3a94345 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,6 @@ script: - pep8 --ignore E501 update.py - pep8 --ignore E501,E265 autocmake # # unit tests - - py.test -vv update.py - py.test -vv autocmake/* # - py.test -vv test/test.py From c4dcaaf0f85d9963bfd73db30eb5f94fd031d70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Ilia=C5=A1?= Date: Mon, 16 May 2016 20:44:45 +0200 Subject: [PATCH 043/127] Add "-ldl" for static linking Hi Rado, to fix dirac.x static linking ( OpenMPI+GNU+OPENBLAS ) I had to inser -ldl after -lpthread command. Please proprage it into DIRAC repo. Thanks. --- modules/math_libs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/math_libs.cmake b/modules/math_libs.cmake index e3d3bf2..b3a21b0 100644 --- a/modules/math_libs.cmake +++ b/modules/math_libs.cmake @@ -506,7 +506,7 @@ if (ENABLE_STATIC_LINKING) BLAS_TYPE MATCHES SYSTEM_NATIVE OR BLAS_TYPE MATCHES OPENBLAS) #cc_blas_static with ATLAS on travis-ci needs -lm - set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm) + set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -ldl -Wl,--no-whole-archive -lm) endif() if (LAPACK_TYPE MATCHES MKL OR BLAS_TYPE MATCHES MKL) From c2fb14b22e92021831ec29e2ade209982265a51f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 21:48:08 +0200 Subject: [PATCH 044/127] restore --self --- autocmake/http.py | 28 --------- update.py | 156 ++++++++++++++++++++++++---------------------- 2 files changed, 82 insertions(+), 102 deletions(-) delete mode 100644 autocmake/http.py diff --git a/autocmake/http.py b/autocmake/http.py deleted file mode 100644 index 4ef6b1d..0000000 --- a/autocmake/http.py +++ /dev/null @@ -1,28 +0,0 @@ -def fetch_url(src, dst): - """ - Fetch file from URL src and save it to dst. - """ - # we do not use the nicer sys.version_info.major - # for compatibility with Python < 2.7 - if sys.version_info[0] > 2: - import urllib.request - - class URLopener(urllib.request.FancyURLopener): - def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) - sys.exit(-1) - else: - import urllib - - class URLopener(urllib.FancyURLopener): - def http_error_default(self, url, fp, errcode, errmsg, headers): - sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) - sys.exit(-1) - - dirname = os.path.dirname(dst) - if dirname != '': - if not os.path.isdir(dirname): - os.makedirs(dirname) - - opener = URLopener() - opener.retrieve(src, dst) diff --git a/update.py b/update.py index c56c817..74c2801 100644 --- a/update.py +++ b/update.py @@ -11,8 +11,6 @@ __version__ = 'X.Y.Z' AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' -# ------------------------------------------------------------------------------ - def print_progress_bar(text, done, total, width): """ @@ -22,8 +20,6 @@ def print_progress_bar(text, done, total, width): sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, ' ' * (width - n), done, total)) sys.stdout.flush() -# ------------------------------------------------------------------------------ - def align_options(options): """ @@ -38,8 +34,6 @@ def align_options(options): s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1])) return '\n'.join(s) -# ------------------------------------------------------------------------------ - def gen_cmake_command(config): """ @@ -72,8 +66,6 @@ def gen_cmake_command(config): return '\n'.join(s) -# ------------------------------------------------------------------------------ - def autogenerated_notice(): current_year = datetime.date.today().year @@ -83,8 +75,6 @@ def autogenerated_notice(): s.append('# Copyright (c) {0} by Radovan Bast, Jonas Juselius, and contributors.'.format(year_range)) return '\n'.join(s) -# ------------------------------------------------------------------------------ - def gen_setup(config, relative_path, setup_script_name): """ @@ -155,8 +145,6 @@ def gen_setup(config, relative_path, setup_script_name): return s -# ------------------------------------------------------------------------------ - def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): """ @@ -200,8 +188,6 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): return s -# ------------------------------------------------------------------------------ - def prepend_or_set(config, section, option, value, defaults): """ @@ -215,8 +201,6 @@ def prepend_or_set(config, section, option, value, defaults): config.set(section, option, value) return config -# ------------------------------------------------------------------------------ - def extract_list(config, section): from collections import Iterable @@ -233,8 +217,6 @@ def extract_list(config, section): l.append(x[section]) return l -# ------------------------------------------------------------------------------ - def fetch_modules(config, relative_path): """ @@ -242,7 +224,6 @@ def fetch_modules(config, relative_path): be included in CMakeLists.txt. """ from collections import Iterable - from autocmake.http import fetch_url download_directory = 'downloaded' if not os.path.exists(download_directory): @@ -318,60 +299,9 @@ def fetch_modules(config, relative_path): return modules -# ------------------------------------------------------------------------------ - -def main(argv): - """ - Main function. - """ +def process_yaml(): from autocmake.parse_yaml import parse_yaml - from autocmake.http import fetch_url - - if len(argv) != 2: - sys.stderr.write("\nYou can update a project in two steps.\n\n") - sys.stderr.write("Step 1: Update or create infrastructure files\n") - sys.stderr.write(" which will be needed to configure and build the project:\n") - sys.stderr.write(" $ {0} --self\n\n".format(argv[0])) - sys.stderr.write("Step 2: Create CMakeLists.txt and setup script in PROJECT_ROOT:\n") - sys.stderr.write(" $ {0} \n".format(argv[0])) - sys.stderr.write(" example:\n") - sys.stderr.write(" $ {0} ..\n".format(argv[0])) - sys.exit(-1) - - if argv[1] in ['-h', '--help']: - print('Usage:') - print(' python update.py --self Update this script and fetch or update infrastructure files under autocmake/.') - print(' python update.py (Re)generate CMakeLists.txt and setup script and fetch or update CMake modules.') - print(' python update.py (-h | --help) Show this help text.') - sys.exit(0) - - if argv[1] == '--self': - # update self - if not os.path.isfile('autocmake.yml'): - print('- fetching example autocmake.yml') - fetch_url( - src='{0}example/autocmake.yml'.format(AUTOCMAKE_GITHUB_URL), - dst='autocmake.yml' - ) - if not os.path.isfile('.gitignore'): - print('- creating .gitignore') - with open('.gitignore', 'w') as f: - f.write('*.pyc\n') - for f in ['autocmake/configure.py', - 'autocmake/external/docopt.py', - 'autocmake/__init__.py', - 'autocmake/interpolate.py', - 'autocmake/http.py', - 'autocmake/parse_rst.py', - 'autocmake/parse_yaml.py', - 'update.py']: - print('- fetching {0}'.format(f)) - fetch_url( - src='{0}{1}'.format(AUTOCMAKE_GITHUB_URL, f), - dst='{0}'.format(f) - ) - sys.exit(0) project_root = argv[1] if not os.path.isdir(project_root): @@ -424,16 +354,94 @@ def main(argv): if sys.platform != 'win32': make_executable(file_path) -# ------------------------------------------------------------------------------ + +def main(argv): + """ + Main function. + """ + + if len(argv) != 2: + sys.stderr.write("\nYou can update a project in two steps.\n\n") + sys.stderr.write("Step 1: Update or create infrastructure files\n") + sys.stderr.write(" which will be needed to configure and build the project:\n") + sys.stderr.write(" $ {0} --self\n\n".format(argv[0])) + sys.stderr.write("Step 2: Create CMakeLists.txt and setup script in PROJECT_ROOT:\n") + sys.stderr.write(" $ {0} \n".format(argv[0])) + sys.stderr.write(" example:\n") + sys.stderr.write(" $ {0} ..\n".format(argv[0])) + sys.exit(-1) + + if argv[1] in ['-h', '--help']: + print('Usage:') + print(' python update.py --self Update this script and fetch or update infrastructure files under autocmake/.') + print(' python update.py (Re)generate CMakeLists.txt and setup script and fetch or update CMake modules.') + print(' python update.py (-h | --help) Show this help text.') + sys.exit(0) + + if argv[1] == '--self': + # update self + if not os.path.isfile('autocmake.yml'): + print('- fetching example autocmake.yml') + fetch_url( + src='{0}example/autocmake.yml'.format(AUTOCMAKE_GITHUB_URL), + dst='autocmake.yml' + ) + if not os.path.isfile('.gitignore'): + print('- creating .gitignore') + with open('.gitignore', 'w') as f: + f.write('*.pyc\n') + for f in ['autocmake/configure.py', + 'autocmake/external/docopt.py', + 'autocmake/__init__.py', + 'autocmake/interpolate.py', + 'autocmake/parse_rst.py', + 'autocmake/parse_yaml.py', + 'update.py']: + print('- fetching {0}'.format(f)) + fetch_url( + src='{0}{1}'.format(AUTOCMAKE_GITHUB_URL, f), + dst='{0}'.format(f) + ) + sys.exit(0) + + process_yaml() -# http://stackoverflow.com/a/30463972 def make_executable(path): + # http://stackoverflow.com/a/30463972 mode = os.stat(path).st_mode mode |= (mode & 0o444) >> 2 # copy R bits to X os.chmod(path, mode) -# ------------------------------------------------------------------------------ + +def fetch_url(src, dst): + """ + Fetch file from URL src and save it to dst. + """ + # we do not use the nicer sys.version_info.major + # for compatibility with Python < 2.7 + if sys.version_info[0] > 2: + import urllib.request + + class URLopener(urllib.request.FancyURLopener): + def http_error_default(self, url, fp, errcode, errmsg, headers): + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) + sys.exit(-1) + else: + import urllib + + class URLopener(urllib.FancyURLopener): + def http_error_default(self, url, fp, errcode, errmsg, headers): + sys.stderr.write("ERROR: could not fetch {0}\n".format(url)) + sys.exit(-1) + + dirname = os.path.dirname(dst) + if dirname != '': + if not os.path.isdir(dirname): + os.makedirs(dirname) + + opener = URLopener() + opener.retrieve(src, dst) if __name__ == '__main__': From 7def4fa31860d216d752b13c19a2062f22595c8c Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 21:54:05 +0200 Subject: [PATCH 045/127] helptext --- update.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/update.py b/update.py index 74c2801..8d72342 100644 --- a/update.py +++ b/update.py @@ -373,9 +373,13 @@ def main(argv): if argv[1] in ['-h', '--help']: print('Usage:') - print(' python update.py --self Update this script and fetch or update infrastructure files under autocmake/.') - print(' python update.py (Re)generate CMakeLists.txt and setup script and fetch or update CMake modules.') - print(' python update.py (-h | --help) Show this help text.') + for t, h in [('python update.py --self', + 'Update this script and fetch or update infrastructure files under autocmake/.'), + ('python update.py ', + '(Re)generate CMakeLists.txt and setup script and fetch or update CMake modules.'), + ('python update.py (-h | --help)', + 'Show this help text.')]: + print(' {0:30} {1}'.format(t, h)) sys.exit(0) if argv[1] == '--self': From 3565e2d8852c8db3e10c71e57d75c09cd5e22b9b Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:12:22 +0200 Subject: [PATCH 046/127] pass argv --- update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update.py b/update.py index 8d72342..ad217b5 100644 --- a/update.py +++ b/update.py @@ -300,7 +300,7 @@ def fetch_modules(config, relative_path): return modules -def process_yaml(): +def process_yaml(argv): from autocmake.parse_yaml import parse_yaml project_root = argv[1] @@ -408,7 +408,7 @@ def main(argv): ) sys.exit(0) - process_yaml() + process_yaml(argv) def make_executable(path): From d7df3417939c6d5f5bb2dced20f1d5ce42304226 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:12:37 +0200 Subject: [PATCH 047/127] add test for parse_yaml --- autocmake/parse_yaml.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index 1824b38..447d16d 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -1,5 +1,6 @@ def parse_yaml(stream, override={}): import yaml + import sys from autocmake.interpolate import interpolate try: @@ -14,3 +15,23 @@ def parse_yaml(stream, override={}): config = interpolate(config, config) return config + + +def test_parse_yaml(): + import tempfile + import os + + text = """foo: bar +this: that +var: '%(foo)'""" + + # we save this text to a temporary file + file_name = tempfile.mkstemp()[1] + with open(file_name, 'w') as f: + f.write(text) + + with open(file_name, 'r') as f: + assert parse_yaml(f) == {'foo': 'bar', 'this': 'that', 'var': 'bar'} + + # we remove the temporary file + os.unlink(file_name) From 923116a11308d8d046c5b92207a07d45a1c3e157 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:15:49 +0200 Subject: [PATCH 048/127] more air --- autocmake/interpolate.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autocmake/interpolate.py b/autocmake/interpolate.py index 0d371ab..50121c7 100644 --- a/autocmake/interpolate.py +++ b/autocmake/interpolate.py @@ -1,5 +1,6 @@ def replace(s, d): from re import findall + if isinstance(s, str): for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): s = s.replace("%({})".format(var), str(d[var])) @@ -14,6 +15,7 @@ def test_replace(): def interpolate(d, d_map): from collections import Mapping, Iterable from copy import copy + for k, v in d.items(): if isinstance(v, Mapping): d[k] = interpolate(d[k], d_map) @@ -31,17 +33,22 @@ def interpolate(d, d_map): def test_interpolate(): + d = {'foo': 'hey', 'bar': 'ho', 'one': 'hey %(foo) ho %(bar)', 'two': {'one': 'hey %(foo) ho %(bar)', 'two': 'raboof'}} + d_interpolated = {'foo': 'hey', 'bar': 'ho', 'one': 'hey hey ho ho', 'two': {'one': 'hey hey ho ho', 'two': 'raboof'}} + assert interpolate(d, d) == d_interpolated + d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} + assert interpolate(d2, d2) == d2_interpolated From f4112a758ac00cd25b744227e84ffdd076d07ca5 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:18:10 +0200 Subject: [PATCH 049/127] simplify test --- autocmake/parse_yaml.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index 447d16d..c613364 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -18,20 +18,8 @@ def parse_yaml(stream, override={}): def test_parse_yaml(): - import tempfile - import os - text = """foo: bar this: that var: '%(foo)'""" - # we save this text to a temporary file - file_name = tempfile.mkstemp()[1] - with open(file_name, 'w') as f: - f.write(text) - - with open(file_name, 'r') as f: - assert parse_yaml(f) == {'foo': 'bar', 'this': 'that', 'var': 'bar'} - - # we remove the temporary file - os.unlink(file_name) + assert parse_yaml(text) == {'foo': 'bar', 'this': 'that', 'var': 'bar'} From 07d431607ff54d9b8313e335a9250df20eb4b71a Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:20:42 +0200 Subject: [PATCH 050/127] improve test --- autocmake/parse_yaml.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index c613364..989a48a 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -20,6 +20,12 @@ def parse_yaml(stream, override={}): def test_parse_yaml(): text = """foo: bar this: that -var: '%(foo)'""" +var: '%(foo)' +list: + - a: '%(foo)' + - b: '%(foo)' + - c: '%(foo)'""" - assert parse_yaml(text) == {'foo': 'bar', 'this': 'that', 'var': 'bar'} + print(parse_yaml(text)) + assert parse_yaml(text) == {'foo': 'bar', 'this': 'that', 'var': 'bar', + 'list': [{'a': 'bar'}, {'b': 'bar'}, {'c': 'bar'}]} From 8d7a0dc79c4b31b9f70a2f5ccda8488884c0eee9 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:24:32 +0200 Subject: [PATCH 051/127] rm print --- autocmake/parse_yaml.py | 1 - 1 file changed, 1 deletion(-) diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index 989a48a..893a85a 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -26,6 +26,5 @@ list: - b: '%(foo)' - c: '%(foo)'""" - print(parse_yaml(text)) assert parse_yaml(text) == {'foo': 'bar', 'this': 'that', 'var': 'bar', 'list': [{'a': 'bar'}, {'b': 'bar'}, {'c': 'bar'}]} From 1b0f6647354cb0fa10aead2f6b1c1aedcf184c9c Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:24:39 +0200 Subject: [PATCH 052/127] trim text --- autocmake/parse_rst.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autocmake/parse_rst.py b/autocmake/parse_rst.py index 70a2151..cbcd1ee 100644 --- a/autocmake/parse_rst.py +++ b/autocmake/parse_rst.py @@ -126,8 +126,7 @@ def test_parse_cmake_module_override(): enable_language(CXX)''' - d = {'minor': 4} - parsed_config = parse_cmake_module(s, d) + parsed_config = parse_cmake_module(s, {'minor': 4}) assert parsed_config['a'] == ['v1'] assert parsed_config['b'] == ['v4'] assert parsed_config['c'] == ['v3'] From 88ddf9a1d1f4ce7b7ccd243b7396bea84b742678 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:30:47 +0200 Subject: [PATCH 053/127] oursource more functions --- autocmake/generate.py | 152 +++++++++++++++++++++++++++++++++++++++++ update.py | 154 ------------------------------------------ 2 files changed, 152 insertions(+), 154 deletions(-) create mode 100644 autocmake/generate.py diff --git a/autocmake/generate.py b/autocmake/generate.py new file mode 100644 index 0000000..f83b0b1 --- /dev/null +++ b/autocmake/generate.py @@ -0,0 +1,152 @@ +def gen_cmake_command(config): + """ + Generate CMake command. + """ + s = [] + + s.append("\n\ndef gen_cmake_command(options, arguments):") + s.append(' """') + s.append(" Generate CMake command based on options and arguments.") + s.append(' """') + s.append(" command = []") + + for env in extract_list(config, 'export'): + s.append(' command.append({0})'.format(env)) + + s.append(" command.append(arguments['--cmake-executable'])") + + for definition in extract_list(config, 'define'): + s.append(' command.append({0})'.format(definition)) + + s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") + s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))") + s.append(" if arguments['--cmake-options'] != \"''\":") + s.append(" command.append(arguments['--cmake-options'])") + s.append(" if arguments['--prefix']:") + s.append(" command.append('-DCMAKE_INSTALL_PREFIX=\"{0}\"'.format(arguments['--prefix']))") + + s.append("\n return ' '.join(command)") + + return '\n'.join(s) + + +def autogenerated_notice(): + current_year = datetime.date.today().year + year_range = '2015-{0}'.format(current_year) + s = [] + s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__)) + s.append('# Copyright (c) {0} by Radovan Bast, Jonas Juselius, and contributors.'.format(year_range)) + return '\n'.join(s) + + +def gen_setup(config, relative_path, setup_script_name): + """ + Generate setup script. + """ + s = [] + s.append('#!/usr/bin/env python') + s.append('\n{0}'.format(autogenerated_notice())) + s.append('\nimport os') + s.append('import sys') + + s.append("\nsys.path.insert(0, '{0}')".format(relative_path)) + + s.append('from autocmake import configure') + s.append('from autocmake.external import docopt') + + s.append('\n\noptions = """') + s.append('Usage:') + s.append(' ./{0} [options] []'.format(setup_script_name)) + s.append(' ./{0} (-h | --help)'.format(setup_script_name)) + s.append('\nOptions:') + + options = [] + + for opt in extract_list(config, 'docopt'): + first = opt.split()[0].strip() + rest = ' '.join(opt.split()[1:]).strip() + options.append([first, rest]) + + options.append(['--type=', 'Set the CMake build type (debug, release, or relwithdeb) [default: release].']) + options.append(['--generator=', 'Set the CMake build system generator [default: Unix Makefiles].']) + options.append(['--show', 'Show CMake command and exit.']) + options.append(['--cmake-executable=', 'Set the CMake executable [default: cmake].']) + options.append(['--cmake-options=', "Define options to CMake [default: '']."]) + options.append(['--prefix=', 'Set the install path for make install.']) + options.append(['', 'Build directory.']) + options.append(['-h --help', 'Show this screen.']) + + s.append(align_options(options)) + + s.append('"""') + + s.append(gen_cmake_command(config)) + + s.append("\n") + s.append("# parse command line args") + s.append("try:") + s.append(" arguments = docopt.docopt(options, argv=None)") + s.append("except docopt.DocoptExit:") + s.append(r" sys.stderr.write('ERROR: bad input to {0}\n'.format(sys.argv[0]))") + s.append(" sys.stderr.write(options)") + s.append(" sys.exit(-1)") + s.append("\n") + s.append("# use extensions to validate/post-process args") + s.append("if configure.module_exists('extensions'):") + s.append(" import extensions") + s.append(" arguments = extensions.postprocess_args(sys.argv, arguments)") + s.append("\n") + s.append("root_directory = os.path.dirname(os.path.realpath(__file__))") + s.append("\n") + s.append("build_path = arguments['']") + s.append("\n") + s.append("# create cmake command") + s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)") + s.append("\n") + s.append("# run cmake") + s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])") + + return s + + +def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): + """ + Generate CMakeLists.txt. + """ + s = [] + + s.append(autogenerated_notice()) + + s.append('\n# set minimum cmake version') + s.append('cmake_minimum_required(VERSION {0} FATAL_ERROR)'.format(min_cmake_version)) + + s.append('\n# project name') + s.append('project({0})'.format(project_name)) + + s.append('\n# do not rebuild if rules (compiler flags) change') + s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)') + + s.append('\n# if CMAKE_BUILD_TYPE undefined, we set it to Debug') + s.append('if(NOT CMAKE_BUILD_TYPE)') + s.append(' set(CMAKE_BUILD_TYPE "Debug")') + s.append('endif()') + + if len(modules) > 0: + s.append('\n# directories which hold included cmake modules') + + module_paths = [module.path for module in modules] + module_paths.append('downloaded') # this is done to be able to find fetched modules when testing + module_paths = list(set(module_paths)) + module_paths.sort() # we do this to always get the same order and to minimize diffs + for directory in module_paths: + rel_cmake_module_path = os.path.join(relative_path, directory) + # on windows cmake corrects this so we have to make it wrong again + rel_cmake_module_path = rel_cmake_module_path.replace('\\', '/') + s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{0})'.format(rel_cmake_module_path)) + + if len(modules) > 0: + s.append('\n# included cmake modules') + for module in modules: + s.append('include({0})'.format(os.path.splitext(module.name)[0])) + + return s diff --git a/update.py b/update.py index ad217b5..c021161 100644 --- a/update.py +++ b/update.py @@ -35,160 +35,6 @@ def align_options(options): return '\n'.join(s) -def gen_cmake_command(config): - """ - Generate CMake command. - """ - s = [] - - s.append("\n\ndef gen_cmake_command(options, arguments):") - s.append(' """') - s.append(" Generate CMake command based on options and arguments.") - s.append(' """') - s.append(" command = []") - - for env in extract_list(config, 'export'): - s.append(' command.append({0})'.format(env)) - - s.append(" command.append(arguments['--cmake-executable'])") - - for definition in extract_list(config, 'define'): - s.append(' command.append({0})'.format(definition)) - - s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") - s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))") - s.append(" if arguments['--cmake-options'] != \"''\":") - s.append(" command.append(arguments['--cmake-options'])") - s.append(" if arguments['--prefix']:") - s.append(" command.append('-DCMAKE_INSTALL_PREFIX=\"{0}\"'.format(arguments['--prefix']))") - - s.append("\n return ' '.join(command)") - - return '\n'.join(s) - - -def autogenerated_notice(): - current_year = datetime.date.today().year - year_range = '2015-{0}'.format(current_year) - s = [] - s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__)) - s.append('# Copyright (c) {0} by Radovan Bast, Jonas Juselius, and contributors.'.format(year_range)) - return '\n'.join(s) - - -def gen_setup(config, relative_path, setup_script_name): - """ - Generate setup script. - """ - s = [] - s.append('#!/usr/bin/env python') - s.append('\n{0}'.format(autogenerated_notice())) - s.append('\nimport os') - s.append('import sys') - - s.append("\nsys.path.insert(0, '{0}')".format(relative_path)) - - s.append('from autocmake import configure') - s.append('from autocmake.external import docopt') - - s.append('\n\noptions = """') - s.append('Usage:') - s.append(' ./{0} [options] []'.format(setup_script_name)) - s.append(' ./{0} (-h | --help)'.format(setup_script_name)) - s.append('\nOptions:') - - options = [] - - for opt in extract_list(config, 'docopt'): - first = opt.split()[0].strip() - rest = ' '.join(opt.split()[1:]).strip() - options.append([first, rest]) - - options.append(['--type=', 'Set the CMake build type (debug, release, or relwithdeb) [default: release].']) - options.append(['--generator=', 'Set the CMake build system generator [default: Unix Makefiles].']) - options.append(['--show', 'Show CMake command and exit.']) - options.append(['--cmake-executable=', 'Set the CMake executable [default: cmake].']) - options.append(['--cmake-options=', "Define options to CMake [default: '']."]) - options.append(['--prefix=', 'Set the install path for make install.']) - options.append(['', 'Build directory.']) - options.append(['-h --help', 'Show this screen.']) - - s.append(align_options(options)) - - s.append('"""') - - s.append(gen_cmake_command(config)) - - s.append("\n") - s.append("# parse command line args") - s.append("try:") - s.append(" arguments = docopt.docopt(options, argv=None)") - s.append("except docopt.DocoptExit:") - s.append(r" sys.stderr.write('ERROR: bad input to {0}\n'.format(sys.argv[0]))") - s.append(" sys.stderr.write(options)") - s.append(" sys.exit(-1)") - s.append("\n") - s.append("# use extensions to validate/post-process args") - s.append("if configure.module_exists('extensions'):") - s.append(" import extensions") - s.append(" arguments = extensions.postprocess_args(sys.argv, arguments)") - s.append("\n") - s.append("root_directory = os.path.dirname(os.path.realpath(__file__))") - s.append("\n") - s.append("build_path = arguments['']") - s.append("\n") - s.append("# create cmake command") - s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)") - s.append("\n") - s.append("# run cmake") - s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])") - - return s - - -def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): - """ - Generate CMakeLists.txt. - """ - s = [] - - s.append(autogenerated_notice()) - - s.append('\n# set minimum cmake version') - s.append('cmake_minimum_required(VERSION {0} FATAL_ERROR)'.format(min_cmake_version)) - - s.append('\n# project name') - s.append('project({0})'.format(project_name)) - - s.append('\n# do not rebuild if rules (compiler flags) change') - s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)') - - s.append('\n# if CMAKE_BUILD_TYPE undefined, we set it to Debug') - s.append('if(NOT CMAKE_BUILD_TYPE)') - s.append(' set(CMAKE_BUILD_TYPE "Debug")') - s.append('endif()') - - if len(modules) > 0: - s.append('\n# directories which hold included cmake modules') - - module_paths = [module.path for module in modules] - module_paths.append('downloaded') # this is done to be able to find fetched modules when testing - module_paths = list(set(module_paths)) - module_paths.sort() # we do this to always get the same order and to minimize diffs - for directory in module_paths: - rel_cmake_module_path = os.path.join(relative_path, directory) - # on windows cmake corrects this so we have to make it wrong again - rel_cmake_module_path = rel_cmake_module_path.replace('\\', '/') - s.append('set(CMAKE_MODULE_PATH ${{CMAKE_MODULE_PATH}} ${{PROJECT_SOURCE_DIR}}/{0})'.format(rel_cmake_module_path)) - - if len(modules) > 0: - s.append('\n# included cmake modules') - for module in modules: - s.append('include({0})'.format(os.path.splitext(module.name)[0])) - - return s - - def prepend_or_set(config, section, option, value, defaults): """ If option is already set, then value is prepended. From 0d500bc8383167f8b6ad8cc55dd878c197decc16 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:34:06 +0200 Subject: [PATCH 054/127] import datetime --- autocmake/generate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autocmake/generate.py b/autocmake/generate.py index f83b0b1..777050c 100644 --- a/autocmake/generate.py +++ b/autocmake/generate.py @@ -31,7 +31,8 @@ def gen_cmake_command(config): def autogenerated_notice(): - current_year = datetime.date.today().year + from datetime import date + current_year = date.today().year year_range = '2015-{0}'.format(current_year) s = [] s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__)) From e0b81c551690401384cc04a0087ec8565c3a61d6 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:43:32 +0200 Subject: [PATCH 055/127] reorg --- autocmake/__init__.py | 1 + autocmake/extract.py | 14 ++++++++++++++ autocmake/generate.py | 25 ++++++++++++++++++++++++- update.py | 39 +++++---------------------------------- 4 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 autocmake/extract.py diff --git a/autocmake/__init__.py b/autocmake/__init__.py index e69de29..87c0951 100644 --- a/autocmake/__init__.py +++ b/autocmake/__init__.py @@ -0,0 +1 @@ +__version__ = 'X.Y.Z' diff --git a/autocmake/extract.py b/autocmake/extract.py new file mode 100644 index 0000000..1b26002 --- /dev/null +++ b/autocmake/extract.py @@ -0,0 +1,14 @@ +def extract_list(config, section): + from collections import Iterable + l = [] + if 'modules' in config: + for module in config['modules']: + for k, v in module.items(): + for x in v: + if section in x: + if isinstance(x[section], Iterable) and not isinstance(x[section], str): + for y in x[section]: + l.append(y) + else: + l.append(x[section]) + return l diff --git a/autocmake/generate.py b/autocmake/generate.py index 777050c..f54bbde 100644 --- a/autocmake/generate.py +++ b/autocmake/generate.py @@ -2,8 +2,9 @@ def gen_cmake_command(config): """ Generate CMake command. """ - s = [] + from autocmake.extract import extract_list + s = [] s.append("\n\ndef gen_cmake_command(options, arguments):") s.append(' """') s.append(" Generate CMake command based on options and arguments.") @@ -32,11 +33,15 @@ def gen_cmake_command(config): def autogenerated_notice(): from datetime import date + from . import __version__ + current_year = date.today().year year_range = '2015-{0}'.format(current_year) + s = [] s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__)) s.append('# Copyright (c) {0} by Radovan Bast, Jonas Juselius, and contributors.'.format(year_range)) + return '\n'.join(s) @@ -44,6 +49,8 @@ def gen_setup(config, relative_path, setup_script_name): """ Generate setup script. """ + from autocmake.extract import extract_list + s = [] s.append('#!/usr/bin/env python') s.append('\n{0}'.format(autogenerated_notice())) @@ -114,6 +121,8 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): """ Generate CMakeLists.txt. """ + import os + s = [] s.append(autogenerated_notice()) @@ -151,3 +160,17 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): s.append('include({0})'.format(os.path.splitext(module.name)[0])) return s + + +def align_options(options): + """ + Indents flags and aligns help texts. + """ + l = 0 + for opt in options: + if len(opt[0]) > l: + l = len(opt[0]) + s = [] + for opt in options: + s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1])) + return '\n'.join(s) diff --git a/update.py b/update.py index c021161..5a31141 100644 --- a/update.py +++ b/update.py @@ -2,12 +2,9 @@ import os import sys -import datetime import ast import collections -__version__ = 'X.Y.Z' - AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' @@ -21,20 +18,6 @@ def print_progress_bar(text, done, total, width): sys.stdout.flush() -def align_options(options): - """ - Indents flags and aligns help texts. - """ - l = 0 - for opt in options: - if len(opt[0]) > l: - l = len(opt[0]) - s = [] - for opt in options: - s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1])) - return '\n'.join(s) - - def prepend_or_set(config, section, option, value, defaults): """ If option is already set, then value is prepended. @@ -48,28 +31,13 @@ def prepend_or_set(config, section, option, value, defaults): return config -def extract_list(config, section): - from collections import Iterable - l = [] - if 'modules' in config: - for module in config['modules']: - for k, v in module.items(): - for x in v: - if section in x: - if isinstance(x[section], Iterable) and not isinstance(x[section], str): - for y in x[section]: - l.append(y) - else: - l.append(x[section]) - return l - - def fetch_modules(config, relative_path): """ Assemble modules which will be included in CMakeLists.txt. """ from collections import Iterable + from autocmake.extract import extract_list download_directory = 'downloaded' if not os.path.exists(download_directory): @@ -148,6 +116,7 @@ def fetch_modules(config, relative_path): def process_yaml(argv): from autocmake.parse_yaml import parse_yaml + from autocmake.generate import gen_cmakelists, gen_setup project_root = argv[1] if not os.path.isdir(project_root): @@ -241,8 +210,10 @@ def main(argv): with open('.gitignore', 'w') as f: f.write('*.pyc\n') for f in ['autocmake/configure.py', - 'autocmake/external/docopt.py', 'autocmake/__init__.py', + 'autocmake/external/docopt.py', + 'autocmake/generate.py', + 'autocmake/extract.py', 'autocmake/interpolate.py', 'autocmake/parse_rst.py', 'autocmake/parse_yaml.py', From d5e44a5bced06d45147e3d4c257e2e2bfdc1f941 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 22:45:11 +0200 Subject: [PATCH 056/127] rm redundant imports --- update.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/update.py b/update.py index 5a31141..c45f3ee 100644 --- a/update.py +++ b/update.py @@ -2,8 +2,6 @@ import os import sys -import ast -import collections AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' @@ -36,7 +34,7 @@ def fetch_modules(config, relative_path): Assemble modules which will be included in CMakeLists.txt. """ - from collections import Iterable + from collections import Iterable, namedtuple from autocmake.extract import extract_list download_directory = 'downloaded' @@ -47,7 +45,7 @@ def fetch_modules(config, relative_path): sources = extract_list(config, 'source') modules = [] - Module = collections.namedtuple('Module', 'path name') + Module = namedtuple('Module', 'path name') warnings = [] From bcafc815fcf39893f2dd375a0ac6c45eb849dde2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 23:05:54 +0200 Subject: [PATCH 057/127] update authors list --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index df70378..5b355ae 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -7,7 +7,7 @@ - Miroslav Ilias (Windows, portability, earliest adopter testing and feedback, math library testing) - Ivan Hrasko (Windows, Appveyor testing) -- Dan Jonsson (idea for configuration file approach) +- Dan Jonsson (idea for configuration file approach which preceded yaml solution) - Roberto Di Remigio (design ideas and testing, OS X testing, Boost) For a list of all the contributions see https://github.com/coderefinery/autocmake/contributors. From 24ff4c430ee15cb42ab111f06819e7484676f3c7 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 18 May 2016 23:38:06 +0200 Subject: [PATCH 058/127] change to yaml format --- modules/fc_optional.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/fc_optional.cmake b/modules/fc_optional.cmake index aec0d7e..8019c08 100644 --- a/modules/fc_optional.cmake +++ b/modules/fc_optional.cmake @@ -26,14 +26,16 @@ # # FCFLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --fc= Fortran compiler [default: gfortran]. -# --extra-fc-flags= Extra Fortran compiler flags [default: '']. -# --fc-support= Toggle Fortran language support (ON/OFF) [default: ON]. -# export: 'FC={0}'.format(arguments['--fc']) -# define: '-DEXTRA_FCFLAGS="{0}"'.format(arguments['--extra-fc-flags']) -# '-DENABLE_FC_SUPPORT="{0}"'.format(arguments['--fc-support']) +# docopt: +# - "--fc= Fortran compiler [default: gfortran]." +# - "--extra-fc-flags= Extra Fortran compiler flags [default: '']." +# - "--fc-support= Toggle Fortran language support (ON/OFF) [default: ON]." +# export: "'FC={0}'.format(arguments['--fc'])" +# define: +# - "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])" +# - "'-DENABLE_FC_SUPPORT=\"{0}\"'.format(arguments['--fc-support'])" option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON) From 90b89354db482a6abe0850f470388a92d5c5f7b5 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 18:46:12 +0200 Subject: [PATCH 059/127] more work on parsing --- autocmake/extract.py | 32 ++++++++ autocmake/parse_rst.py | 6 +- autocmake/parse_yaml.py | 6 +- update.py | 168 +++++++++++++++++++++------------------- 4 files changed, 125 insertions(+), 87 deletions(-) diff --git a/autocmake/extract.py b/autocmake/extract.py index 1b26002..5213ae5 100644 --- a/autocmake/extract.py +++ b/autocmake/extract.py @@ -12,3 +12,35 @@ def extract_list(config, section): else: l.append(x[section]) return l + + +def to_d(l): + """ + Converts list of dicts to dict. + """ + _d = {} + for x in l: + for k, v in x.items(): + _d[k] = v + return _d + + +def test_to_d(): + l = [{'a': 'b'}, {'c': 'd'}] + d = {'a': 'b', 'c': 'd'} + assert to_d(l) == d + + +def to_l(x): + """ + Converts list of dicts to dict. + """ + if isinstance(x, str): + return [x] + else: + return x + + +def test_to_l(): + assert to_l('foo') == ['foo'] + assert to_l(['foo', 'bar']) == ['foo', 'bar'] diff --git a/autocmake/parse_rst.py b/autocmake/parse_rst.py index cbcd1ee..a5fede4 100644 --- a/autocmake/parse_rst.py +++ b/autocmake/parse_rst.py @@ -1,4 +1,4 @@ -def parse_cmake_module(s_in, override={}): +def parse_cmake_module(s_in, overrides={}): import sys from collections import Mapping, Iterable, defaultdict from autocmake.parse_yaml import parse_yaml @@ -33,7 +33,7 @@ def parse_cmake_module(s_in, override={}): autocmake_entry = autocmake_entry.replace('\n ', '\n') buf = StringIO(autocmake_entry) - config = parse_yaml(buf, override) + config = parse_yaml(buf, overrides) for k, v in config.items(): if isinstance(v, Iterable) and not isinstance(v, str): @@ -109,7 +109,7 @@ enable_language(CXX)''' assert parsed_config['c'] == ['v3'] -def test_parse_cmake_module_override(): +def test_parse_cmake_module_overrides(): s = r'''#.rst: # diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index 893a85a..ded3656 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -1,4 +1,4 @@ -def parse_yaml(stream, override={}): +def parse_yaml(stream, overrides={}): import yaml import sys from autocmake.interpolate import interpolate @@ -10,8 +10,8 @@ def parse_yaml(stream, override={}): sys.exit(-1) for k in config: - if k in override: - config[k] = override[k] + if k in overrides: + config[k] = overrides[k] config = interpolate(config, config) return config diff --git a/update.py b/update.py index c45f3ee..a536a57 100644 --- a/update.py +++ b/update.py @@ -11,110 +11,99 @@ def print_progress_bar(text, done, total, width): """ Print progress bar. """ - n = int(float(width) * float(done) / float(total)) - sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, ' ' * (width - n), done, total)) - sys.stdout.flush() + if total > 0: + n = int(float(width) * float(done) / float(total)) + sys.stdout.write("\r{0} [{1}{2}] ({3}/{4})".format(text, '#' * n, ' ' * (width - n), done, total)) + sys.stdout.flush() -def prepend_or_set(config, section, option, value, defaults): - """ - If option is already set, then value is prepended. - If option is not set, then it is created and set to value. - This is used to prepend options with values which come from the module documentation. - """ - if value: - if config.has_option(section, option): - value += '\n{0}'.format(config.get(section, option, 0, defaults)) - config.set(section, option, value) - return config +def flat_add(l, x): + if isinstance(x, str): + l.append(x) + return l + else: + return l + x -def fetch_modules(config, relative_path): +def fetch_modules(config, relative_path, download_directory): """ Assemble modules which will be included in CMakeLists.txt. """ - from collections import Iterable, namedtuple - from autocmake.extract import extract_list + from collections import Iterable, namedtuple, defaultdict + from autocmake.extract import extract_list, to_d, to_l + from autocmake.parse_rst import parse_cmake_module - download_directory = 'downloaded' - if not os.path.exists(download_directory): - os.makedirs(download_directory) - - # here we get the list of sources to fetch - sources = extract_list(config, 'source') + cleaned_config = defaultdict(lambda: []) modules = [] Module = namedtuple('Module', 'path name') - warnings = [] + num_sources = len(extract_list(config, 'source')) - if len(sources) > 0: # otherwise division by zero in print_progress_bar - print_progress_bar(text='- assembling modules:', done=0, total=len(sources), width=30) - for i, src in enumerate(sources): - module_name = os.path.basename(src) - if 'http' in src: - path = download_directory - name = 'autocmake_{0}'.format(module_name) - dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) - fetch_url(src, dst) - file_name = dst - fetch_dst_directory = download_directory - else: - if os.path.exists(src): - path = os.path.dirname(src) - name = module_name - file_name = src - fetch_dst_directory = path + print_progress_bar(text='- assembling modules:', + done=0, + total=num_sources, + width=30) + + i = 0 + for t in config['modules']: + for k, v in t.items(): + + i += 1 + d = to_d(v) + for _k, _v in to_d(v).items(): + cleaned_config[_k] = flat_add(cleaned_config[_k], _v) + + # fetch sources and parse them + for src in to_l(d['source']): + + # we download the file + module_name = os.path.basename(src) + if 'http' in src: + path = download_directory + name = 'autocmake_{0}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) + fetch_url(src, dst) + file_name = dst + fetch_dst_directory = download_directory else: - sys.stderr.write("ERROR: {0} does not exist\n".format(src)) - sys.exit(-1) + if os.path.exists(src): + path = os.path.dirname(src) + name = module_name + file_name = src + fetch_dst_directory = path + else: + sys.stderr.write("ERROR: {0} does not exist\n".format(src)) + sys.exit(-1) -# FIXME -# if config.has_option(section, 'override'): -# defaults = ast.literal_eval(config.get(section, 'override')) -# else: -# defaults = {} + # we infer config from the module documentation + # dictionary d overrides the configuration in the module documentation + # this allows to override interpolation inside the module + with open(file_name, 'r') as f: + parsed_config = parse_cmake_module(f.read(), d) + for _k2, _v2 in parsed_config.items(): + if _k2 not in to_d(v): + # we add to clean_config only if the entry does not exist + # in parent autocmake.yml already + # this allows to override + cleaned_config[_k2] = flat_add(cleaned_config[_k2], _v2) -# FIXME -# # we infer config from the module documentation -# with open(file_name, 'r') as f: -# parsed_config = parse_cmake_module(f.read(), defaults) -# if parsed_config['warning']: -# warnings.append('WARNING from {0}: {1}'.format(module_name, parsed_config['warning'])) -# config = prepend_or_set(config, section, 'docopt', parsed_config['docopt'], defaults) -# config = prepend_or_set(config, section, 'define', parsed_config['define'], defaults) -# config = prepend_or_set(config, section, 'export', parsed_config['export'], defaults) -# if parsed_config['fetch']: -# for src in parsed_config['fetch'].split('\n'): -# dst = os.path.join(fetch_dst_directory, os.path.basename(src)) -# fetch_url(src, dst) + modules.append(Module(path=path, name=name)) + print_progress_bar(text='- assembling modules:', + done=i, + total=num_sources, + width=30) - modules.append(Module(path=path, name=name)) - print_progress_bar( - text='- assembling modules:', - done=(i + 1), - total=len(sources), - width=30 - ) -# FIXME -# if config.has_option(section, 'fetch'): -# # when we fetch directly from autocmake.yml -# # we download into downloaded/ -# for src in config.get(section, 'fetch').split('\n'): -# dst = os.path.join(download_directory, os.path.basename(src)) -# fetch_url(src, dst) - print('') + print('') - if warnings != []: - print('- {0}'.format('\n- '.join(warnings))) - - return modules + return modules, cleaned_config def process_yaml(argv): from autocmake.parse_yaml import parse_yaml from autocmake.generate import gen_cmakelists, gen_setup + from autocmake.extract import extract_list project_root = argv[1] if not os.path.isdir(project_root): @@ -149,8 +138,25 @@ def process_yaml(argv): # get relative path from setup script to this directory relative_path = os.path.relpath(os.path.abspath('.'), project_root) + download_directory = 'downloaded' + if not os.path.exists(download_directory): + os.makedirs(download_directory) + # fetch modules from the web or from relative paths - modules = fetch_modules(config, relative_path) + modules, cleaned_config = fetch_modules(config, relative_path, download_directory) + +# FIXME +# for k, v in cleaned_config.items(): +# print(k, v) + + # fetch files which are not parsed + for src in extract_list(config, 'fetch'): + dst = os.path.join(download_directory, os.path.basename(src)) + fetch_url(src, dst) + + # print warnings + for warning in extract_list(config, 'warning'): + print('- WARNING: {0}'.format(warning)) # create CMakeLists.txt print('- generating CMakeLists.txt') From f447153eebc5523a18332c6daf73bc200c79f16b Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 22:43:39 +0200 Subject: [PATCH 060/127] save work --- autocmake/generate.py | 6 +++--- update.py | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/autocmake/generate.py b/autocmake/generate.py index f54bbde..79fb1e8 100644 --- a/autocmake/generate.py +++ b/autocmake/generate.py @@ -11,12 +11,12 @@ def gen_cmake_command(config): s.append(' """') s.append(" command = []") - for env in extract_list(config, 'export'): + for env in config['export']: s.append(' command.append({0})'.format(env)) s.append(" command.append(arguments['--cmake-executable'])") - for definition in extract_list(config, 'define'): + for definition in config['define']: s.append(' command.append({0})'.format(definition)) s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") @@ -70,7 +70,7 @@ def gen_setup(config, relative_path, setup_script_name): options = [] - for opt in extract_list(config, 'docopt'): + for opt in config['docopt']: first = opt.split()[0].strip() rest = ' '.join(opt.split()[1:]).strip() options.append([first, rest]) diff --git a/update.py b/update.py index a536a57..c4a457d 100644 --- a/update.py +++ b/update.py @@ -145,17 +145,13 @@ def process_yaml(argv): # fetch modules from the web or from relative paths modules, cleaned_config = fetch_modules(config, relative_path, download_directory) -# FIXME -# for k, v in cleaned_config.items(): -# print(k, v) - # fetch files which are not parsed - for src in extract_list(config, 'fetch'): + for src in cleaned_config['fetch']: dst = os.path.join(download_directory, os.path.basename(src)) fetch_url(src, dst) # print warnings - for warning in extract_list(config, 'warning'): + for warning in cleaned_config['warning']: print('- WARNING: {0}'.format(warning)) # create CMakeLists.txt @@ -166,7 +162,7 @@ def process_yaml(argv): # create setup script print('- generating setup script') - s = gen_setup(config, relative_path, setup_script_name) + s = gen_setup(cleaned_config, relative_path, setup_script_name) file_path = os.path.join(project_root, setup_script_name) with open(file_path, 'w') as f: f.write('{0}\n'.format('\n'.join(s))) From ebc1ecc127984cff6086f2c19e8bd0f53e14d7aa Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:03:00 +0200 Subject: [PATCH 061/127] convert few modules to yaml --- modules/cc.cmake | 11 ++++++----- modules/cxx.cmake | 11 ++++++----- modules/fc.cmake | 11 ++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/modules/cc.cmake b/modules/cc.cmake index 06e6e42..2975024 100644 --- a/modules/cc.cmake +++ b/modules/cc.cmake @@ -17,12 +17,13 @@ # # CFLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --cc= C compiler [default: gcc]. -# --extra-cc-flags= Extra C compiler flags [default: '']. -# export: 'CC={0}'.format(arguments['--cc']) -# define: '-DEXTRA_CFLAGS="{0}"'.format(arguments['--extra-cc-flags']) +# docopt: +# - "--cc= C compiler [default: gcc]." +# - "--extra-cc-flags= Extra C compiler flags [default: '']." +# export: "'CC={0}'.format(arguments['--cc'])" +# define: "'-DEXTRA_CFLAGS=\"{0}\"'.format(arguments['--extra-cc-flags'])" enable_language(C) diff --git a/modules/cxx.cmake b/modules/cxx.cmake index d81ff3e..5ec6bf2 100644 --- a/modules/cxx.cmake +++ b/modules/cxx.cmake @@ -17,12 +17,13 @@ # # CXXFLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --cxx= C++ compiler [default: g++]. -# --extra-cxx-flags= Extra C++ compiler flags [default: '']. -# export: 'CXX={0}'.format(arguments['--cxx']) -# define: '-DEXTRA_CXXFLAGS="{0}"'.format(arguments['--extra-cxx-flags']) +# docopt: +# - "--cxx= C++ compiler [default: g++]." +# - "--extra-cxx-flags= Extra C++ compiler flags [default: '']." +# export: "'CXX={0}'.format(arguments['--cxx'])" +# define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])" enable_language(CXX) diff --git a/modules/fc.cmake b/modules/fc.cmake index 657a06b..5832571 100644 --- a/modules/fc.cmake +++ b/modules/fc.cmake @@ -21,12 +21,13 @@ # # FCFLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --fc= Fortran compiler [default: gfortran]. -# --extra-fc-flags= Extra Fortran compiler flags [default: '']. -# export: 'FC={0}'.format(arguments['--fc']) -# define: '-DEXTRA_FCFLAGS="{0}"'.format(arguments['--extra-fc-flags']) +# docopt: +# - "--fc= Fortran compiler [default: gfortran]." +# - "--extra-fc-flags= Extra Fortran compiler flags [default: '']." +# export: "'FC={0}'.format(arguments['--fc'])" +# define: "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])" enable_language(Fortran) From 91c79f9d3c7041e8906fbccaad991147e779e4e2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:07:31 +0200 Subject: [PATCH 062/127] testing interpolation --- modules/fc_optional.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/fc_optional.cmake b/modules/fc_optional.cmake index 8019c08..64b5640 100644 --- a/modules/fc_optional.cmake +++ b/modules/fc_optional.cmake @@ -28,8 +28,9 @@ # # autocmake.yml configuration:: # +# foo: "hey ho" # docopt: -# - "--fc= Fortran compiler [default: gfortran]." +# - "--fc= %(foo) compiler [default: gfortran]." # - "--extra-fc-flags= Extra Fortran compiler flags [default: '']." # - "--fc-support= Toggle Fortran language support (ON/OFF) [default: ON]." # export: "'FC={0}'.format(arguments['--fc'])" From 45fc08f37b53566e3c80cc7eb31b6dc6cd65e1ff Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:10:37 +0200 Subject: [PATCH 063/127] Revert "testing interpolation" This reverts commit 91c79f9d3c7041e8906fbccaad991147e779e4e2. --- modules/fc_optional.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/fc_optional.cmake b/modules/fc_optional.cmake index 64b5640..8019c08 100644 --- a/modules/fc_optional.cmake +++ b/modules/fc_optional.cmake @@ -28,9 +28,8 @@ # # autocmake.yml configuration:: # -# foo: "hey ho" # docopt: -# - "--fc= %(foo) compiler [default: gfortran]." +# - "--fc= Fortran compiler [default: gfortran]." # - "--extra-fc-flags= Extra Fortran compiler flags [default: '']." # - "--fc-support= Toggle Fortran language support (ON/OFF) [default: ON]." # export: "'FC={0}'.format(arguments['--fc'])" From 83c0c3fabd2372e59020d99b4dc4be6244cb0f65 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:14:17 +0200 Subject: [PATCH 064/127] fix progress bar --- update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.py b/update.py index c4a457d..a10d6ea 100644 --- a/update.py +++ b/update.py @@ -50,13 +50,13 @@ def fetch_modules(config, relative_path, download_directory): for t in config['modules']: for k, v in t.items(): - i += 1 d = to_d(v) for _k, _v in to_d(v).items(): cleaned_config[_k] = flat_add(cleaned_config[_k], _v) # fetch sources and parse them for src in to_l(d['source']): + i += 1 # we download the file module_name = os.path.basename(src) From 104f64cb1cb39d70ec70830fdd261fc4d014ca6b Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:17:23 +0200 Subject: [PATCH 065/127] convert ccache module to yml --- modules/ccache.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ccache.cmake b/modules/ccache.cmake index ced3027..1bcaf1e 100644 --- a/modules/ccache.cmake +++ b/modules/ccache.cmake @@ -10,10 +10,10 @@ # # CCACHE_FOUND # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --ccache= Toggle use of ccache [default: ON]. -# define: '-DUSE_CCACHE="{0}"'.format(arguments['--ccache']) +# docopt: "--ccache= Toggle use of ccache [default: ON]." +# define: "'-DUSE_CCACHE=\"{0}\"'.format(arguments['--ccache'])" if(USE_CCACHE) find_program(CCACHE_FOUND ccache) From d09aa22623decdb9d4a7316638a81448d770d543 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:22:28 +0200 Subject: [PATCH 066/127] covert two modules to yaml --- modules/code_coverage.cmake | 6 +++--- modules/definitions.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/code_coverage.cmake b/modules/code_coverage.cmake index d617945..a685cf5 100644 --- a/modules/code_coverage.cmake +++ b/modules/code_coverage.cmake @@ -8,10 +8,10 @@ # CMAKE_C_FLAGS # CMAKE_CXX_FLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --coverage Enable code coverage [default: False]. -# define: '-DENABLE_CODE_COVERAGE=%s' % arguments['--coverage'] +# docopt: "--coverage Enable code coverage [default: False]." +# define: "'-DENABLE_CODE_COVERAGE=\"{0}\"'.format(arguments['--coverage'])" option(ENABLE_CODE_COVERAGE "Enable code coverage" OFF) diff --git a/modules/definitions.cmake b/modules/definitions.cmake index 4d4f75c..23e5fc2 100644 --- a/modules/definitions.cmake +++ b/modules/definitions.cmake @@ -7,10 +7,10 @@ # # PREPROCESSOR_DEFINITIONS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --add-definitions= Add preprocesor definitions [default: '']. -# define: '-DPREPROCESSOR_DEFINITIONS="%s"' % arguments['--add-definitions'] +# docopt: "--add-definitions= Add preprocesor definitions [default: '']." +# define: "'-DPREPROCESSOR_DEFINITIONS=\"{0}\"'.format(arguments['--add-definitions'])" if(NOT "${PREPROCESSOR_DEFINITIONS}" STREQUAL "") add_definitions(${PREPROCESSOR_DEFINITIONS}) From 4eb5dee93696bf24de7090912800f41c556042ce Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:24:49 +0200 Subject: [PATCH 067/127] update googletest.cmake to yaml --- modules/googletest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/googletest.cmake b/modules/googletest.cmake index 3bdbd40..353acaf 100644 --- a/modules/googletest.cmake +++ b/modules/googletest.cmake @@ -6,9 +6,9 @@ # # GOOGLETEST_ROOT # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# define: '-DGOOGLETEST_ROOT=external/googletest/googletest' +# define: "'-DGOOGLETEST_ROOT=external/googletest/googletest'" set(GOOGLETEST_ROOT external/googletest/googletest CACHE STRING "Google Test source root") From 0c6976a70d4e23da097c9f267a5881c8a1f3fedc Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:39:13 +0200 Subject: [PATCH 068/127] simplify --- modules/ccache.cmake | 2 +- modules/code_coverage.cmake | 2 +- modules/fc_optional.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ccache.cmake b/modules/ccache.cmake index 1bcaf1e..3979fa2 100644 --- a/modules/ccache.cmake +++ b/modules/ccache.cmake @@ -13,7 +13,7 @@ # autocmake.yml configuration:: # # docopt: "--ccache= Toggle use of ccache [default: ON]." -# define: "'-DUSE_CCACHE=\"{0}\"'.format(arguments['--ccache'])" +# define: "'-DUSE_CCACHE={0}'.format(arguments['--ccache'])" if(USE_CCACHE) find_program(CCACHE_FOUND ccache) diff --git a/modules/code_coverage.cmake b/modules/code_coverage.cmake index a685cf5..650f983 100644 --- a/modules/code_coverage.cmake +++ b/modules/code_coverage.cmake @@ -11,7 +11,7 @@ # autocmake.yml configuration:: # # docopt: "--coverage Enable code coverage [default: False]." -# define: "'-DENABLE_CODE_COVERAGE=\"{0}\"'.format(arguments['--coverage'])" +# define: "'-DENABLE_CODE_COVERAGE={0}'.format(arguments['--coverage'])" option(ENABLE_CODE_COVERAGE "Enable code coverage" OFF) diff --git a/modules/fc_optional.cmake b/modules/fc_optional.cmake index 8019c08..c7cf6c6 100644 --- a/modules/fc_optional.cmake +++ b/modules/fc_optional.cmake @@ -35,7 +35,7 @@ # export: "'FC={0}'.format(arguments['--fc'])" # define: # - "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])" -# - "'-DENABLE_FC_SUPPORT=\"{0}\"'.format(arguments['--fc-support'])" +# - "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])" option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON) From 5b7ad87479d6db0550341b68004fd3439e13c92d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:46:32 +0200 Subject: [PATCH 069/127] switch to .format() --- modules/int64.cmake | 2 +- modules/math/accelerate.cmake | 2 +- modules/math/acml.cmake | 2 +- modules/math/atlas.cmake | 2 +- modules/math/blas.cmake | 2 +- modules/math/cblas.cmake | 2 +- modules/math/goto.cmake | 2 +- modules/math/lapack.cmake | 2 +- modules/math/lapacke.cmake | 2 +- modules/math_libs.cmake | 6 +++--- modules/mpi.cmake | 2 +- modules/omp.cmake | 2 +- modules/python_interpreter.cmake | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/int64.cmake b/modules/int64.cmake index 944ea3b..45f4b23 100644 --- a/modules/int64.cmake +++ b/modules/int64.cmake @@ -9,7 +9,7 @@ # autocmake.cfg configuration:: # # docopt: --int64 Enable 64bit integers [default: False]. -# define: '-DENABLE_64BIT_INTEGERS=%s' % arguments['--int64'] +# define: '-DENABLE_64BIT_INTEGERS={0}'.format(arguments['--int64']) option(ENABLE_64BIT_INTEGERS "Enable 64-bit integers" OFF) diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index 36eb3ce..529f9c2 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --accelerate Find and link to ACCELERATE [default: False]. -# define: '-DENABLE_ACCELERATE=%s' % arguments['--accelerate'] +# define: '-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate']) # fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake # https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake diff --git a/modules/math/acml.cmake b/modules/math/acml.cmake index 01a375c..a533adf 100644 --- a/modules/math/acml.cmake +++ b/modules/math/acml.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --acml Find and link to ACML [default: False]. -# define: '-DENABLE_ACML=%s' % arguments['--acml'] +# define: '-DENABLE_ACML={0}'.format(arguments['--acml']) option(ENABLE_ACML "Find and link to ACML" OFF) diff --git a/modules/math/atlas.cmake b/modules/math/atlas.cmake index 64c5bab..37b47c2 100644 --- a/modules/math/atlas.cmake +++ b/modules/math/atlas.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --atlas Find and link to ATLAS [default: False]. -# define: '-DENABLE_ATLAS=%s' % arguments['--atlas'] +# define: '-DENABLE_ATLAS={0}'.format(arguments['--atlas']) option(ENABLE_ATLAS "Find and link to ATLAS" OFF) diff --git a/modules/math/blas.cmake b/modules/math/blas.cmake index fdcda94..47da0b1 100644 --- a/modules/math/blas.cmake +++ b/modules/math/blas.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --blas Find and link to BLAS [default: False]. -# define: '-DENABLE_BLAS=%s' % arguments['--blas'] +# define: '-DENABLE_BLAS={0}'.format(arguments['--blas']) option(ENABLE_BLAS "Find and link to BLAS" OFF) diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index 378cf9b..4d2fe09 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --cblas Find and link to CBLAS [default: False]. -# define: '-DENABLE_CBLAS=%s' % arguments['--cblas'] +# define: '-DENABLE_CBLAS={0}'.format(arguments['--cblas']) # fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake # https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake diff --git a/modules/math/goto.cmake b/modules/math/goto.cmake index df9fb6d..0c3e269 100644 --- a/modules/math/goto.cmake +++ b/modules/math/goto.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --goto Find and link to GOTO [default: False]. -# define: '-DENABLE_GOTO=%s' % arguments['--goto'] +# define: '-DENABLE_GOTO={0}'.format(arguments['--goto']) option(ENABLE_GOTO "Find and link to GOTO" OFF) diff --git a/modules/math/lapack.cmake b/modules/math/lapack.cmake index e86e53e..799eee4 100644 --- a/modules/math/lapack.cmake +++ b/modules/math/lapack.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --lapack Find and link to LAPACK [default: False]. -# define: '-DENABLE_LAPACK=%s' % arguments['--lapack'] +# define: '-DENABLE_LAPACK={0}'.format(arguments['--lapack']) option(ENABLE_LAPACK "Find and link to LAPACK" OFF) diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index 3afbeab..5d93ff5 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -11,7 +11,7 @@ # autocmake.cfg configuration:: # # docopt: --lapacke Find and link to LAPACKE [default: False]. -# define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke'] +# define: '-DENABLE_LAPACKE={0}'.format(arguments['--lapacke']) # fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake # https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake diff --git a/modules/math_libs.cmake b/modules/math_libs.cmake index e3d3bf2..23c64c9 100644 --- a/modules/math_libs.cmake +++ b/modules/math_libs.cmake @@ -42,9 +42,9 @@ # docopt: --blas= Detect and link BLAS library (auto or off) [default: auto]. # --lapack= Detect and link LAPACK library (auto or off) [default: auto]. # --mkl= Pass MKL flag to the Intel compiler and linker and skip BLAS/LAPACK detection (sequential, parallel, cluster, or off) [default: off]. -# define: '-DENABLE_BLAS=%s' % arguments['--blas'] -# '-DENABLE_LAPACK=%s' % arguments['--lapack'] -# '-DMKL_FLAG=%s' % arguments['--mkl'] +# define: '-DENABLE_BLAS={0}'.format(arguments['--blas']) +# '-DENABLE_LAPACK={0}'.format(arguments['--lapack']) +# '-DMKL_FLAG={0}'.format(arguments['--mkl']) # '-DMATH_LIB_SEARCH_ORDER="MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE"' # '-DBLAS_LANG=Fortran' # '-DLAPACK_LANG=Fortran' diff --git a/modules/mpi.cmake b/modules/mpi.cmake index 7f73eac..cb64a41 100644 --- a/modules/mpi.cmake +++ b/modules/mpi.cmake @@ -16,7 +16,7 @@ # autocmake.cfg configuration:: # # docopt: --mpi Enable MPI parallelization [default: False]. -# define: '-DENABLE_MPI=%s' % arguments['--mpi'] +# define: '-DENABLE_MPI={0}'.format(arguments['--mpi']) option(ENABLE_MPI "Enable MPI parallelization" OFF) diff --git a/modules/omp.cmake b/modules/omp.cmake index 9784868..1a6e9b4 100644 --- a/modules/omp.cmake +++ b/modules/omp.cmake @@ -16,7 +16,7 @@ # autocmake.cfg configuration:: # # docopt: --omp Enable OpenMP parallelization [default: False]. -# define: '-DENABLE_OPENMP=%s' % arguments['--omp'] +# define: '-DENABLE_OPENMP={0}'.format(arguments['--omp']) option(ENABLE_OPENMP "Enable OpenMP parallelization" OFF) diff --git a/modules/python_interpreter.cmake b/modules/python_interpreter.cmake index a726da9..54509a0 100644 --- a/modules/python_interpreter.cmake +++ b/modules/python_interpreter.cmake @@ -18,7 +18,7 @@ # autocmake.cfg configuration:: # # docopt: --python= The Python interpreter (development version) to use. [default: '']. -# define: '-DPYTHON_INTERPRETER="%s"' % arguments['--python'] +# define: '-DPYTHON_INTERPRETER="{0}"'.format(arguments['--python']) if("${PYTHON_INTERPRETER}" STREQUAL "") find_package(PythonInterp REQUIRED) From ac03dc7998fe935391e3ba6b19b5d2397746f348 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:52:48 +0200 Subject: [PATCH 070/127] convert math lib code to yaml --- modules/math/accelerate.cmake | 11 ++++++----- modules/math/acml.cmake | 6 +++--- modules/math/atlas.cmake | 6 +++--- modules/math/blas.cmake | 6 +++--- modules/math/cblas.cmake | 11 ++++++----- modules/math/goto.cmake | 6 +++--- modules/math/lapack.cmake | 6 +++--- modules/math/lapacke.cmake | 11 ++++++----- 8 files changed, 33 insertions(+), 30 deletions(-) diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index 529f9c2..7fb9511 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -8,12 +8,13 @@ # ACCELERATE_LIBRARIES - describe me, uncached # ACCELERATE_INCLUDE_DIR - describe me, uncached # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --accelerate Find and link to ACCELERATE [default: False]. -# define: '-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate']) -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# docopt: "--accelerate Find and link to ACCELERATE [default: False]." +# define: "'-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate'])" +# fetch: +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" option(ENABLE_ACCELERATE "Find and link to ACCELERATE" OFF) diff --git a/modules/math/acml.cmake b/modules/math/acml.cmake index a533adf..e5c230d 100644 --- a/modules/math/acml.cmake +++ b/modules/math/acml.cmake @@ -8,10 +8,10 @@ # ACML_LIBRARIES # ACML_INCLUDE_DIR # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --acml Find and link to ACML [default: False]. -# define: '-DENABLE_ACML={0}'.format(arguments['--acml']) +# docopt: "--acml Find and link to ACML [default: False]." +# define: "'-DENABLE_ACML={0}'.format(arguments['--acml'])" option(ENABLE_ACML "Find and link to ACML" OFF) diff --git a/modules/math/atlas.cmake b/modules/math/atlas.cmake index 37b47c2..23565fa 100644 --- a/modules/math/atlas.cmake +++ b/modules/math/atlas.cmake @@ -8,10 +8,10 @@ # ATLAS_LIBRARIES # ATLAS_INCLUDE_DIR # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --atlas Find and link to ATLAS [default: False]. -# define: '-DENABLE_ATLAS={0}'.format(arguments['--atlas']) +# docopt: "--atlas Find and link to ATLAS [default: False]." +# define: "'-DENABLE_ATLAS={0}'.format(arguments['--atlas'])" option(ENABLE_ATLAS "Find and link to ATLAS" OFF) diff --git a/modules/math/blas.cmake b/modules/math/blas.cmake index 47da0b1..9014fb7 100644 --- a/modules/math/blas.cmake +++ b/modules/math/blas.cmake @@ -8,10 +8,10 @@ # BLAS_LIBRARIES # BLAS_INCLUDE_DIR # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --blas Find and link to BLAS [default: False]. -# define: '-DENABLE_BLAS={0}'.format(arguments['--blas']) +# docopt: "--blas Find and link to BLAS [default: False]." +# define: "'-DENABLE_BLAS={0}'.format(arguments['--blas'])" option(ENABLE_BLAS "Find and link to BLAS" OFF) diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index 4d2fe09..a5024cb 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -8,12 +8,13 @@ # CBLAS_LIBRARIES - describe me, uncached # CBLAS_INCLUDE_DIR - describe me, uncached # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --cblas Find and link to CBLAS [default: False]. -# define: '-DENABLE_CBLAS={0}'.format(arguments['--cblas']) -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# docopt: "--cblas Find and link to CBLAS [default: False]." +# define: "'-DENABLE_CBLAS={0}'.format(arguments['--cblas'])" +# fetch: +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" option(ENABLE_CBLAS "Find and link to CBLAS" OFF) diff --git a/modules/math/goto.cmake b/modules/math/goto.cmake index 0c3e269..9d5586e 100644 --- a/modules/math/goto.cmake +++ b/modules/math/goto.cmake @@ -8,10 +8,10 @@ # GOTO_LIBRARIES # GOTO_INCLUDE_DIR # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --goto Find and link to GOTO [default: False]. -# define: '-DENABLE_GOTO={0}'.format(arguments['--goto']) +# docopt: "--goto Find and link to GOTO [default: False]." +# define: "'-DENABLE_GOTO={0}'.format(arguments['--goto'])" option(ENABLE_GOTO "Find and link to GOTO" OFF) diff --git a/modules/math/lapack.cmake b/modules/math/lapack.cmake index 799eee4..7f3ac52 100644 --- a/modules/math/lapack.cmake +++ b/modules/math/lapack.cmake @@ -8,10 +8,10 @@ # LAPACK_LIBRARIES # LAPACK_INCLUDE_DIR # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --lapack Find and link to LAPACK [default: False]. -# define: '-DENABLE_LAPACK={0}'.format(arguments['--lapack']) +# docopt: "--lapack Find and link to LAPACK [default: False]." +# define: "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])" option(ENABLE_LAPACK "Find and link to LAPACK" OFF) diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index 5d93ff5..2258a6e 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -8,12 +8,13 @@ # LAPACKE_LIBRARIES - describe me, uncached # LAPACKE_INCLUDE_DIR - describe me, uncached # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --lapacke Find and link to LAPACKE [default: False]. -# define: '-DENABLE_LAPACKE={0}'.format(arguments['--lapacke']) -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# docopt: "--lapacke Find and link to LAPACKE [default: False]." +# define: "'-DENABLE_LAPACKE={0}'.format(arguments['--lapacke'])" +# fetch: +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF) From 51cdb55c53c64967ae6eb4023e8dd6b445ffd2c5 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 19 May 2016 23:57:24 +0200 Subject: [PATCH 071/127] convert more modules to yaml --- modules/git_info/git_info.cmake | 7 ++++--- modules/int64.cmake | 6 +++--- modules/math_libs.cmake | 24 +++++++++++++----------- modules/mpi.cmake | 6 +++--- modules/omp.cmake | 6 +++--- modules/python_interpreter.cmake | 6 +++--- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/modules/git_info/git_info.cmake b/modules/git_info/git_info.cmake index 1b609c2..c5185d3 100644 --- a/modules/git_info/git_info.cmake +++ b/modules/git_info/git_info.cmake @@ -5,10 +5,11 @@ # Git repository version and status information # to the program output. # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info_sub.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info.h.in +# fetch: +# - "https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info_sub.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info.h.in" # CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2 # see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675 diff --git a/modules/int64.cmake b/modules/int64.cmake index 45f4b23..b8847fa 100644 --- a/modules/int64.cmake +++ b/modules/int64.cmake @@ -6,10 +6,10 @@ # # CMAKE_Fortran_FLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --int64 Enable 64bit integers [default: False]. -# define: '-DENABLE_64BIT_INTEGERS={0}'.format(arguments['--int64']) +# docopt: "--int64 Enable 64bit integers [default: False]." +# define: "'-DENABLE_64BIT_INTEGERS={0}'.format(arguments['--int64'])" option(ENABLE_64BIT_INTEGERS "Enable 64-bit integers" OFF) diff --git a/modules/math_libs.cmake b/modules/math_libs.cmake index 23c64c9..9b85a2d 100644 --- a/modules/math_libs.cmake +++ b/modules/math_libs.cmake @@ -37,18 +37,20 @@ # MKL_ROOT # MKLROOT # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --blas= Detect and link BLAS library (auto or off) [default: auto]. -# --lapack= Detect and link LAPACK library (auto or off) [default: auto]. -# --mkl= Pass MKL flag to the Intel compiler and linker and skip BLAS/LAPACK detection (sequential, parallel, cluster, or off) [default: off]. -# define: '-DENABLE_BLAS={0}'.format(arguments['--blas']) -# '-DENABLE_LAPACK={0}'.format(arguments['--lapack']) -# '-DMKL_FLAG={0}'.format(arguments['--mkl']) -# '-DMATH_LIB_SEARCH_ORDER="MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE"' -# '-DBLAS_LANG=Fortran' -# '-DLAPACK_LANG=Fortran' -# warning: 'This module is deprecated and will be removed in future versions' +# docopt: +# - "--blas= Detect and link BLAS library (auto or off) [default: auto]." +# - "--lapack= Detect and link LAPACK library (auto or off) [default: auto]." +# - "--mkl= Pass MKL flag to the Intel compiler and linker and skip BLAS/LAPACK detection (sequential, parallel, cluster, or off) [default: off]." +# define: +# - "'-DENABLE_BLAS={0}'.format(arguments['--blas'])" +# - "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])" +# - "'-DMKL_FLAG={0}'.format(arguments['--mkl'])" +# - "'-DMATH_LIB_SEARCH_ORDER=\"MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE\"'" +# - "'-DBLAS_LANG=Fortran'" +# - "'-DLAPACK_LANG=Fortran'" +# warning: "This module is deprecated and will be removed in future versions" #------------------------------------------------------------------------------- # ENABLE_STATIC_LINKING diff --git a/modules/mpi.cmake b/modules/mpi.cmake index cb64a41..418975e 100644 --- a/modules/mpi.cmake +++ b/modules/mpi.cmake @@ -13,10 +13,10 @@ # CMAKE_C_FLAGS # CMAKE_CXX_FLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --mpi Enable MPI parallelization [default: False]. -# define: '-DENABLE_MPI={0}'.format(arguments['--mpi']) +# docopt: "--mpi Enable MPI parallelization [default: False]." +# define: "'-DENABLE_MPI={0}'.format(arguments['--mpi'])" option(ENABLE_MPI "Enable MPI parallelization" OFF) diff --git a/modules/omp.cmake b/modules/omp.cmake index 1a6e9b4..1719afe 100644 --- a/modules/omp.cmake +++ b/modules/omp.cmake @@ -13,10 +13,10 @@ # CMAKE_C_FLAGS # CMAKE_CXX_FLAGS # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --omp Enable OpenMP parallelization [default: False]. -# define: '-DENABLE_OPENMP={0}'.format(arguments['--omp']) +# docopt: "--omp Enable OpenMP parallelization [default: False]." +# define: "'-DENABLE_OPENMP={0}'.format(arguments['--omp'])" option(ENABLE_OPENMP "Enable OpenMP parallelization" OFF) diff --git a/modules/python_interpreter.cmake b/modules/python_interpreter.cmake index 54509a0..6d200ef 100644 --- a/modules/python_interpreter.cmake +++ b/modules/python_interpreter.cmake @@ -15,10 +15,10 @@ # PYTHON_VERSION_MINOR - Python minor version found e.g. 5 # PYTHON_VERSION_PATCH - Python patch version found e.g. 2 # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# docopt: --python= The Python interpreter (development version) to use. [default: '']. -# define: '-DPYTHON_INTERPRETER="{0}"'.format(arguments['--python']) +# docopt: "--python= The Python interpreter (development version) to use. [default: '']." +# define: "'-DPYTHON_INTERPRETER=\"{0}\"'.format(arguments['--python'])" if("${PYTHON_INTERPRETER}" STREQUAL "") find_package(PythonInterp REQUIRED) From d0dc52c7a9c64bcf85757c6b5c58c6eb8ec013d3 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 00:02:32 +0200 Subject: [PATCH 072/127] convert boost module to yaml --- modules/boost/boost.cmake | 56 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index e3e9c74..6b82fa1 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -5,11 +5,14 @@ # Autocmake update time. # Note that the build-up commands are not Windows-compatible! # -# Your autocmake.cfg should look like this:: +# Your autocmake.cfg should contain:: # -# [boost] -# override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'} -# source: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake +# - boost: +# - major: 1 +# - minor: 59 +# - patch: 0 +# - components: "chrono;timer;system" +# - source: "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake" # # Cross-dependencies between required components are not checked for. # For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you @@ -43,28 +46,31 @@ # MPI_FOUND # BUILD_CUSTOM_BOOST # -# autocmake.cfg configuration:: +# autocmake.yml configuration:: # -# major=1 -# minor=48 -# patch=0 -# components='' -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_unpack.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_userconfig.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_configure.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_build.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_install.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_headers.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_cleanup.cmake -# http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip -# docopt: --boost-headers= Include directories for Boost [default: '']. -# --boost-libraries= Library directories for Boost [default: '']. -# --build-boost= Deactivate Boost detection and build on-the-fly [default: OFF]. -# define: '-DBOOST_INCLUDEDIR="{0}"'.format(arguments['--boost-headers']) -# '-DBOOST_LIBRARYDIR="{0}"'.format(arguments['--boost-libraries']) -# '-DFORCE_CUSTOM_BOOST="{0}"'.format(arguments['--build-boost']) -# '-DBOOST_MINIMUM_REQUIRED="%(major)s.%(minor)s.%(patch)s"' -# '-DBOOST_COMPONENTS_REQUIRED="%(components)s"' +# major: 1 +# minor: 48 +# patch: 0 +# components: "" +# fetch: +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_unpack.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_userconfig.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_configure.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_build.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_install.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_headers.cmake" +# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_cleanup.cmake" +# - "http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip" +# docopt: +# - "--boost-headers= Include directories for Boost [default: '']." +# - "--boost-libraries= Library directories for Boost [default: '']." +# - "--build-boost= Deactivate Boost detection and build on-the-fly [default: OFF]." +# define: +# - "'-DBOOST_INCLUDEDIR=\"{0}\"'.format(arguments['--boost-headers'])" +# - "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])" +# - "'-DFORCE_CUSTOM_BOOST=\"{0}\"'.format(arguments['--build-boost'])" +# - "'-DBOOST_MINIMUM_REQUIRED="%(major)s.%(minor)s.%(patch)s"'" +# - "'-DBOOST_COMPONENTS_REQUIRED="%(components)s"'" # FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency # on its own) and soft-fail (self-build of Boost) From 5dc2bb28802d082242848923b3dcbfa27a4e2084 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 00:08:53 +0200 Subject: [PATCH 073/127] adapt url_root for fetch directives --- modules/boost/boost.cmake | 17 +++++++++-------- modules/git_info/git_info.cmake | 5 +++-- modules/math/accelerate.cmake | 5 +++-- modules/math/cblas.cmake | 5 +++-- modules/math/lapacke.cmake | 5 +++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index 6b82fa1..48e049e 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -12,7 +12,7 @@ # - minor: 59 # - patch: 0 # - components: "chrono;timer;system" -# - source: "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake" +# - source: "https://github.com/coderefinery/autocmake/raw/yaml/modules/boost/boost.cmake" # # Cross-dependencies between required components are not checked for. # For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you @@ -48,18 +48,19 @@ # # autocmake.yml configuration:: # +# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ # major: 1 # minor: 48 # patch: 0 # components: "" # fetch: -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_unpack.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_userconfig.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_configure.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_build.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_install.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_headers.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_cleanup.cmake" +# - "%(url_root)modules/boost/boost_unpack.cmake" +# - "%(url_root)modules/boost/boost_userconfig.cmake" +# - "%(url_root)modules/boost/boost_configure.cmake" +# - "%(url_root)modules/boost/boost_build.cmake" +# - "%(url_root)modules/boost/boost_install.cmake" +# - "%(url_root)modules/boost/boost_headers.cmake" +# - "%(url_root)modules/boost/boost_cleanup.cmake" # - "http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip" # docopt: # - "--boost-headers= Include directories for Boost [default: '']." diff --git a/modules/git_info/git_info.cmake b/modules/git_info/git_info.cmake index c5185d3..9ee81f4 100644 --- a/modules/git_info/git_info.cmake +++ b/modules/git_info/git_info.cmake @@ -7,9 +7,10 @@ # # autocmake.yml configuration:: # +# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ # fetch: -# - "https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info_sub.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info.h.in" +# - "%(url_root)modules/git_info/git_info_sub.cmake" +# - "%(url_root)modules/git_info/git_info.h.in" # CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2 # see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675 diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index 7fb9511..f03b160 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -10,11 +10,12 @@ # # autocmake.yml configuration:: # +# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ # docopt: "--accelerate Find and link to ACCELERATE [default: False]." # define: "'-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate'])" # fetch: -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" +# - "%(url_root)modules/find/find_libraries.cmake" +# - "%(url_root)modules/find/find_include_files.cmake" option(ENABLE_ACCELERATE "Find and link to ACCELERATE" OFF) diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index a5024cb..305c3cc 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -10,11 +10,12 @@ # # autocmake.yml configuration:: # +# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ # docopt: "--cblas Find and link to CBLAS [default: False]." # define: "'-DENABLE_CBLAS={0}'.format(arguments['--cblas'])" # fetch: -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" +# - "%(url_root)modules/find/find_libraries.cmake" +# - "%(url_root)modules/find/find_include_files.cmake" option(ENABLE_CBLAS "Find and link to CBLAS" OFF) diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index 2258a6e..e561ba6 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -10,11 +10,12 @@ # # autocmake.yml configuration:: # +# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ # docopt: "--lapacke Find and link to LAPACKE [default: False]." # define: "'-DENABLE_LAPACKE={0}'.format(arguments['--lapacke'])" # fetch: -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake" -# - "https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake" +# - "%(url_root)modules/find/find_libraries.cmake" +# - "%(url_root)modules/find/find_include_files.cmake" option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF) From 9531ac499ef701f1189341020e0aa7ae90593aa2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 00:44:48 +0200 Subject: [PATCH 074/127] not every module has 'source:' --- update.py | 71 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/update.py b/update.py index a10d6ea..748b45a 100644 --- a/update.py +++ b/update.py @@ -55,45 +55,46 @@ def fetch_modules(config, relative_path, download_directory): cleaned_config[_k] = flat_add(cleaned_config[_k], _v) # fetch sources and parse them - for src in to_l(d['source']): - i += 1 + if 'source' in d: + for src in to_l(d['source']): + i += 1 - # we download the file - module_name = os.path.basename(src) - if 'http' in src: - path = download_directory - name = 'autocmake_{0}'.format(module_name) - dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) - fetch_url(src, dst) - file_name = dst - fetch_dst_directory = download_directory - else: - if os.path.exists(src): - path = os.path.dirname(src) - name = module_name - file_name = src - fetch_dst_directory = path + # we download the file + module_name = os.path.basename(src) + if 'http' in src: + path = download_directory + name = 'autocmake_{0}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) + fetch_url(src, dst) + file_name = dst + fetch_dst_directory = download_directory else: - sys.stderr.write("ERROR: {0} does not exist\n".format(src)) - sys.exit(-1) + if os.path.exists(src): + path = os.path.dirname(src) + name = module_name + file_name = src + fetch_dst_directory = path + else: + sys.stderr.write("ERROR: {0} does not exist\n".format(src)) + sys.exit(-1) - # we infer config from the module documentation - # dictionary d overrides the configuration in the module documentation - # this allows to override interpolation inside the module - with open(file_name, 'r') as f: - parsed_config = parse_cmake_module(f.read(), d) - for _k2, _v2 in parsed_config.items(): - if _k2 not in to_d(v): - # we add to clean_config only if the entry does not exist - # in parent autocmake.yml already - # this allows to override - cleaned_config[_k2] = flat_add(cleaned_config[_k2], _v2) + # we infer config from the module documentation + # dictionary d overrides the configuration in the module documentation + # this allows to override interpolation inside the module + with open(file_name, 'r') as f: + parsed_config = parse_cmake_module(f.read(), d) + for _k2, _v2 in parsed_config.items(): + if _k2 not in to_d(v): + # we add to clean_config only if the entry does not exist + # in parent autocmake.yml already + # this allows to override + cleaned_config[_k2] = flat_add(cleaned_config[_k2], _v2) - modules.append(Module(path=path, name=name)) - print_progress_bar(text='- assembling modules:', - done=i, - total=num_sources, - width=30) + modules.append(Module(path=path, name=name)) + print_progress_bar(text='- assembling modules:', + done=i, + total=num_sources, + width=30) print('') From a32c9d6f4674491bf9a356318c9f90603c6079c2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 00:45:35 +0200 Subject: [PATCH 075/127] more descriptive warning --- modules/math_libs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/math_libs.cmake b/modules/math_libs.cmake index 02ec8e1..5040fa8 100644 --- a/modules/math_libs.cmake +++ b/modules/math_libs.cmake @@ -50,7 +50,7 @@ # - "'-DMATH_LIB_SEARCH_ORDER=\"MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE\"'" # - "'-DBLAS_LANG=Fortran'" # - "'-DLAPACK_LANG=Fortran'" -# warning: "This module is deprecated and will be removed in future versions" +# warning: "the math_libs.cmake module is deprecated and will be removed in future versions" #------------------------------------------------------------------------------- # ENABLE_STATIC_LINKING From d26389b0a10542c10b3cbccbb3e132101440c544 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:17:59 +0200 Subject: [PATCH 076/127] s/master/stable-0.x/ --- README.md | 6 ++-- doc/contributors/doc.rst | 4 +-- doc/contributors/testing.rst | 2 +- doc/developers/bootstrap.rst | 4 +-- doc/developers/configuration.rst | 42 +++++++++++++------------- doc/developers/customizing-modules.rst | 4 +-- doc/developers/example.rst | 8 ++--- doc/developers/faq.rst | 2 +- doc/developers/updating-modules.rst | 2 +- doc/extract_rst.py | 2 +- modules/boost/boost.cmake | 16 +++++----- modules/git_info/git_info.cmake | 4 +-- modules/math/accelerate.cmake | 4 +-- modules/math/cblas.cmake | 4 +-- modules/math/lapacke.cmake | 4 +-- update.py | 8 ++--- 16 files changed, 58 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index c782e2c..b0f128e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -[![Build Status](https://travis-ci.org/coderefinery/autocmake.svg?branch=master)](https://travis-ci.org/coderefinery/autocmake/builds) +[![Build Status](https://travis-ci.org/coderefinery/autocmake.svg?branch=stable-0.x)](https://travis-ci.org/coderefinery/autocmake/builds) [![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=latest)](http://autocmake.readthedocs.org) -[![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE) +[![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../stable-0.x/LICENSE) # Autocmake A CMake plugin composer. -Licensed under [BSD-3](../master/LICENSE). +Licensed under [BSD-3](../stable-0.x/LICENSE). See http://autocmake.org. diff --git a/doc/contributors/doc.rst b/doc/contributors/doc.rst index 4e7eaeb..fbf2329 100644 --- a/doc/contributors/doc.rst +++ b/doc/contributors/doc.rst @@ -10,11 +10,11 @@ This documentation is refreshed upon each push to the central repository. The module reference documentation is generated from the module sources using ``#.rst:`` tags (compare for instance http://autocmake.readthedocs.org/en/latest/module-reference.html#cc-cmake with -https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake). +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake). Please note that the lines following ``# autocmake.cfg configuration::`` are understood by the ``update.py`` script to infer autocmake.cfg code from the documentation. As an example consider -https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake#L20-L25. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. diff --git a/doc/contributors/testing.rst b/doc/contributors/testing.rst index 43e02c7..5d99083 100644 --- a/doc/contributors/testing.rst +++ b/doc/contributors/testing.rst @@ -5,7 +5,7 @@ Testing Autocmake You will need to install `pytest `__. -Check also the `Travis `__ +Check also the `Travis `__ build and test recipe for other requirements. Your contributions and changes should preserve the test set. You can run locally all tests with:: diff --git a/doc/developers/bootstrap.rst b/doc/developers/bootstrap.rst index d0d6918..bb34573 100644 --- a/doc/developers/bootstrap.rst +++ b/doc/developers/bootstrap.rst @@ -12,12 +12,12 @@ infrastructure files which will be needed to build the project:: $ mkdir cmake # does not have to be called "cmake" - take the name you prefer $ cd cmake - $ wget https://github.com/coderefinery/autocmake/raw/master/update.py + $ wget https://github.com/coderefinery/autocmake/raw/stable-0.x/update.py $ python update.py --self On the MS Windows system, you can use the PowerShell wget-replacement:: - $ Invoke-WebRequest https://github.com/coderefinery/autocmake/raw/master/update.py -OutFile update.py + $ Invoke-WebRequest https://github.com/coderefinery/autocmake/raw/stable-0.x/update.py -OutFile update.py This creates (or updates) the following files (an existing ``autocmake.cfg`` is not overwritten by the script):: diff --git a/doc/developers/configuration.rst b/doc/developers/configuration.rst index 7e91681..aace625 100644 --- a/doc/developers/configuration.rst +++ b/doc/developers/configuration.rst @@ -13,38 +13,38 @@ below:: min_cmake_version: 2.8 [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake [cc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake [cxx] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cxx.cmake [flags] - source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/GNU.CXX.cmake + https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/Intel.CXX.cmake [rpath] source: custom/rpath.cmake [definitions] - source: https://github.com/coderefinery/autocmake/raw/master/modules/definitions.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/definitions.cmake [coverage] - source: https://github.com/coderefinery/autocmake/raw/master/modules/code_coverage.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/code_coverage.cmake [safeguards] - source: https://github.com/coderefinery/autocmake/raw/master/modules/safeguards.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/safeguards.cmake [default_build_paths] - source: https://github.com/coderefinery/autocmake/raw/master/modules/default_build_paths.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/default_build_paths.cmake [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake [googletest] - source: https://github.com/coderefinery/autocmake/raw/master/modules/googletest.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/googletest.cmake [custom] source: custom/api.cmake @@ -71,13 +71,13 @@ The names of the other sections do not matter to Autocmake. You could name them min_cmake_version: 2.8 [one] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake [two] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake [whatever] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cxx.cmake But it would not make much sense. It is better to choose names that are meaningful to you. @@ -163,7 +163,7 @@ The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.cfg`` and using the ``source`` option:: [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake This will download ``fc.cmake`` and include it in ``CMakeLists.txt``. @@ -175,8 +175,8 @@ You can also include local CMake modules, e.g.:: It is also OK to include several modules at once:: [flags] - source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/GNU.CXX.cmake + https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/Intel.CXX.cmake The modules will be included in the same order as they appear in ``autocmake.cfg``. @@ -187,7 +187,7 @@ Fetching files without including them in CMakeLists.txt Sometimes you want to fetch a file without including it in ``CMakeLists.txt``. This can be done with the ``fetch`` option. This is for instance done by the ``git_info.cmake`` module (see -https://github.com/coderefinery/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L11). +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/git_info/git_info.cmake#L10-L11). If ``fetch`` is invoked in ``autocmake.cfg``, then the fetched file is placed under ``downloaded/``. If ``fetch`` is invoked from within a CMake module @@ -241,7 +241,7 @@ for many core modules which come with own options once you have sourced them. The lines following ``# autocmake.cfg configuration::`` are understood by the ``update.py`` script to infer ``autocmake.cfg`` code from the documentation. As an example consider -https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake#L20-L25. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. @@ -251,6 +251,6 @@ Overriding documented configurations Configurable documented defaults can be achieved using interpolations. See for instance -https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/boost/boost.cmake#L33-L36. These can be modified within ``autocmake.cfg`` with a dictionary, e.g.: -https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 +https://github.com/coderefinery/autocmake/blob/stable-0.x/test/boost_libs/cmake/autocmake.cfg#L9 diff --git a/doc/developers/customizing-modules.rst b/doc/developers/customizing-modules.rst index 30036df..6f2d810 100644 --- a/doc/developers/customizing-modules.rst +++ b/doc/developers/customizing-modules.rst @@ -38,9 +38,9 @@ Overriding defaults ------------------- Some modules use interpolations to set defaults, see for instance -https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. +https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/boost/boost.cmake#L33-L36. These can be modified within ``autocmake.cfg``, e.g.: -https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 +https://github.com/coderefinery/autocmake/blob/stable-0.x/test/boost_libs/cmake/autocmake.cfg#L9 Create own CMake modules diff --git a/doc/developers/example.rst b/doc/developers/example.rst index 8898fe6..5294bc5 100644 --- a/doc/developers/example.rst +++ b/doc/developers/example.rst @@ -25,7 +25,7 @@ Now we create ``cmake/`` and fetch ``update.py``:: $ mkdir cmake $ cd cmake/ - $ wget https://raw.githubusercontent.com/coderefinery/autocmake/master/update.py + $ wget https://raw.githubusercontent.com/coderefinery/autocmake/stable-0.x/update.py $ python update.py --self Now from top-level our file tree looks like this:: @@ -50,13 +50,13 @@ Now we edit ``cmake/autocmake.cfg`` to look like this:: min_cmake_version: 2.8 [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake [cc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake What we have specified here is the project name and that we wish Fortran and C support. The ``src.cmake`` module tells CMake to include a ``src/CMakeLists.txt``. diff --git a/doc/developers/faq.rst b/doc/developers/faq.rst index 0524dce..6077bf3 100644 --- a/doc/developers/faq.rst +++ b/doc/developers/faq.rst @@ -107,7 +107,7 @@ overwritten at some point. A good standard is to organize your sources under can include the latter in ``autocmake.cfg`` using:: [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake If you really don't like to do it this way, you can describe your sources and targets in a custom module in a local file and include it like this:: diff --git a/doc/developers/updating-modules.rst b/doc/developers/updating-modules.rst index 7fdd8be..52eac99 100644 --- a/doc/developers/updating-modules.rst +++ b/doc/developers/updating-modules.rst @@ -21,7 +21,7 @@ rather fetch an older version, for example with the hash ``abcd123``. To achieve this, instead of:: [foo] - source: https://github.com/coderefinery/autocmake/raw/master/modules/foo.cmake + source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/foo.cmake pin the version to ``abcd123`` (you do not need to specify the full Git hash, a unique beginning will do):: diff --git a/doc/extract_rst.py b/doc/extract_rst.py index 436a168..1e09f44 100644 --- a/doc/extract_rst.py +++ b/doc/extract_rst.py @@ -73,7 +73,7 @@ def main(): if s_out != '': output.append('\n\n%s' % file_name) output.append('-'*len(file_name)) - output.append('`[Source code] `__' % full_file_name) + output.append('`[Source code] `__' % full_file_name) output.append(s_out) with open(os.path.join(THIS_DIR, 'module-reference.rst'), 'w') as f: diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index e3e9c74..18476fd 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -9,7 +9,7 @@ # # [boost] # override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'} -# source: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake +# source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost.cmake # # Cross-dependencies between required components are not checked for. # For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you @@ -49,13 +49,13 @@ # minor=48 # patch=0 # components='' -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_unpack.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_userconfig.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_configure.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_build.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_install.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_headers.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost_cleanup.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_unpack.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_userconfig.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_configure.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_build.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_install.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_headers.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_cleanup.cmake # http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip # docopt: --boost-headers= Include directories for Boost [default: '']. # --boost-libraries= Library directories for Boost [default: '']. diff --git a/modules/git_info/git_info.cmake b/modules/git_info/git_info.cmake index 1b609c2..c1b38d4 100644 --- a/modules/git_info/git_info.cmake +++ b/modules/git_info/git_info.cmake @@ -7,8 +7,8 @@ # # autocmake.cfg configuration:: # -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info_sub.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/git_info/git_info.h.in +# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/git_info/git_info_sub.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/git_info/git_info.h.in # CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2 # see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675 diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index 36eb3ce..7cce4db 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -12,8 +12,8 @@ # # docopt: --accelerate Find and link to ACCELERATE [default: False]. # define: '-DENABLE_ACCELERATE=%s' % arguments['--accelerate'] -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake option(ENABLE_ACCELERATE "Find and link to ACCELERATE" OFF) diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index 378cf9b..29f91ca 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -12,8 +12,8 @@ # # docopt: --cblas Find and link to CBLAS [default: False]. # define: '-DENABLE_CBLAS=%s' % arguments['--cblas'] -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake option(ENABLE_CBLAS "Find and link to CBLAS" OFF) diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index 3afbeab..244356c 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -12,8 +12,8 @@ # # docopt: --lapacke Find and link to LAPACKE [default: False]. # define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke'] -# fetch: https://github.com/coderefinery/autocmake/raw/master/modules/find/find_libraries.cmake -# https://github.com/coderefinery/autocmake/raw/master/modules/find/find_include_files.cmake +# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake +# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF) diff --git a/update.py b/update.py index 8200411..2ce6bae 100644 --- a/update.py +++ b/update.py @@ -375,7 +375,7 @@ def main(argv): if not os.path.isfile('autocmake.cfg'): print('- fetching example autocmake.cfg') fetch_url( - src='{0}/raw/master/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/stable-0.x/example/autocmake.cfg'.format(AUTOCMAKE_GITHUB_URL), dst='autocmake.cfg' ) if not os.path.isfile('.gitignore'): @@ -384,17 +384,17 @@ def main(argv): f.write('*.pyc\n') print('- fetching lib/config.py') fetch_url( - src='{0}/raw/master/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/stable-0.x/lib/config.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/config.py' ) print('- fetching lib/docopt/docopt.py') fetch_url( - src='{0}/raw/master/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/stable-0.x/lib/docopt/docopt.py'.format(AUTOCMAKE_GITHUB_URL), dst='lib/docopt/docopt.py' ) print('- fetching update.py') fetch_url( - src='{0}/raw/master/update.py'.format(AUTOCMAKE_GITHUB_URL), + src='{0}/raw/stable-0.x/update.py'.format(AUTOCMAKE_GITHUB_URL), dst='update.py' ) sys.exit(0) From ea8563327182070eb5c2be89e0764587c9e8bc0d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:19:46 +0200 Subject: [PATCH 077/127] set version to 0.5.0 --- doc/conf.py | 4 ++-- update.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 0166b7c..1b2cbfe 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -60,9 +60,9 @@ author = u'Radovan Bast, Jonas Juselius, and contributors' # built documents. # # The short X.Y version. -version = '0.0' +version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.0' +release = '0.5.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/update.py b/update.py index 2ce6bae..01a0f6b 100644 --- a/update.py +++ b/update.py @@ -6,7 +6,7 @@ import datetime import ast import collections -__version__ = 'X.Y.Z' +__version__ = '0.5.0' # we do not use the nicer sys.version_info.major # for compatibility with Python < 2.7 From 512f1d3877680ba40bf955e93d111d9a1b846512 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:22:15 +0200 Subject: [PATCH 078/127] relocate badge to stable-0.x --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0f128e..4ac4f28 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.org/coderefinery/autocmake.svg?branch=stable-0.x)](https://travis-ci.org/coderefinery/autocmake/builds) -[![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=latest)](http://autocmake.readthedocs.org) +[![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=stable-0.x)](http://autocmake.readthedocs.org) [![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../stable-0.x/LICENSE) From 648bc2c20d3100920e49339fb8bac065e2f8c0fb Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:27:56 +0200 Subject: [PATCH 079/127] links to documentation --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c782e2c..8d3682e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,13 @@ Licensed under [BSD-3](../master/LICENSE). See http://autocmake.org. -### Projects using Autocmake +## Documentation + +- [Latest stable code](http://autocmake.readthedocs.io/en/stable-0.x/) +- [Bleeding edge code](http://autocmake.readthedocs.io/en/latest/) + + +## Projects using Autocmake - [Numgrid](https://github.com/dftlibs/numgrid/) - [XCint](https://github.com/dftlibs/xcint/) From 369e0a49376d2cafe95cc7c71ecbc041f54e3c3c Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:28:08 +0200 Subject: [PATCH 080/127] s/org/io/ --- doc/contributors/doc.rst | 2 +- example/autocmake.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/contributors/doc.rst b/doc/contributors/doc.rst index 4e7eaeb..2cdfd7c 100644 --- a/doc/contributors/doc.rst +++ b/doc/contributors/doc.rst @@ -9,7 +9,7 @@ This documentation is refreshed upon each push to the central repository. The module reference documentation is generated from the module sources using ``#.rst:`` tags (compare for instance -http://autocmake.readthedocs.org/en/latest/module-reference.html#cc-cmake with +http://autocmake.readthedocs.io/en/latest/module-reference.html#cc-cmake with https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake). Please note that the lines following ``# autocmake.cfg configuration::`` are diff --git a/example/autocmake.cfg b/example/autocmake.cfg index cb9b3db..211d3e5 100644 --- a/example/autocmake.cfg +++ b/example/autocmake.cfg @@ -1,5 +1,5 @@ # CMakeLists.txt and setup script will be generated from this file -# see: http://autocmake.readthedocs.org/en/latest/developers/configuration.html +# see: http://autocmake.readthedocs.io/en/latest/developers/configuration.html # uncomment the following three lines and set the project name # [project] From d1545b9379cc798e1da81a0a0006e113e482c155 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:30:54 +0200 Subject: [PATCH 081/127] set version to 1.0.0-alpha-x --- autocmake/__init__.py | 2 +- doc/conf.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autocmake/__init__.py b/autocmake/__init__.py index 87c0951..db05cea 100644 --- a/autocmake/__init__.py +++ b/autocmake/__init__.py @@ -1 +1 @@ -__version__ = 'X.Y.Z' +__version__ = '1.0.0-alpha-x' diff --git a/doc/conf.py b/doc/conf.py index 0166b7c..ef2d51e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -60,9 +60,9 @@ author = u'Radovan Bast, Jonas Juselius, and contributors' # built documents. # # The short X.Y version. -version = '0.0' +version = '1.0' # The full version, including alpha/beta/rc tags. -release = '0.0' +release = '1.0.0-alpha-x' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 23de8f4703799ed189662fd099de17d4a0e0c0a1 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:32:46 +0200 Subject: [PATCH 082/127] pep8 fix --- autocmake/extract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autocmake/extract.py b/autocmake/extract.py index 5213ae5..4595f90 100644 --- a/autocmake/extract.py +++ b/autocmake/extract.py @@ -20,8 +20,8 @@ def to_d(l): """ _d = {} for x in l: - for k, v in x.items(): - _d[k] = v + for k, v in x.items(): + _d[k] = v return _d From 5d70c2f2ccd10d53f6ce8faae1d0230fba325cdb Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 11:46:48 +0200 Subject: [PATCH 083/127] more doc about stable/latest --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d3682e..71635d0 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ See http://autocmake.org. ## Documentation -- [Latest stable code](http://autocmake.readthedocs.io/en/stable-0.x/) -- [Bleeding edge code](http://autocmake.readthedocs.io/en/latest/) +- [Latest stable code](http://autocmake.readthedocs.io/en/stable-0.x/) (stable-0.x branch) +- [Bleeding edge code](http://autocmake.readthedocs.io/en/latest/) (master branch) ## Projects using Autocmake From ed4dcbb138a477a52a631f394aea5c4fd4deb8f4 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 15:02:49 +0200 Subject: [PATCH 084/127] s/cfg/yml/ --- modules/boost/boost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index 48e049e..88bcd4c 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -5,7 +5,7 @@ # Autocmake update time. # Note that the build-up commands are not Windows-compatible! # -# Your autocmake.cfg should contain:: +# Your autocmake.yml should contain:: # # - boost: # - major: 1 From 939de1edb0fda431a9d22ddcd55d513ca04d258f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 15:35:13 +0200 Subject: [PATCH 085/127] reactivate one real test --- .gitignore | 2 +- .travis.yml | 2 +- .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 test/fc/cmake/autocmake.cfg | 12 --------- test/fc/cmake/autocmake.yml | 9 +++++++ .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 .../cmake/{autocmake.cfg => autocmake.yml} | 0 test/test.py | 25 ++++++++++++------- 20 files changed, 27 insertions(+), 23 deletions(-) rename test/boost_header_only/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/boost_libs/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/cxx/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/cxx_accelerate/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/cxx_cblas/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/extra_cmake_options/cmake/{autocmake.cfg => autocmake.yml} (100%) delete mode 100644 test/fc/cmake/autocmake.cfg create mode 100644 test/fc/cmake/autocmake.yml rename test/fc_blas/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/fc_git_info/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/fc_int64/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/fc_lapack/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/fc_omp/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/python_interpreter/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/python_interpreter_custom/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/python_libs/cmake/{autocmake.cfg => autocmake.yml} (100%) rename test/python_libs_custom/cmake/{autocmake.cfg => autocmake.yml} (100%) diff --git a/.gitignore b/.gitignore index 2eaf211..acb6d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ __pycache__/ test/*/CMakeLists.txt test/*/build*/ test/*/cmake/update.py -test/*/cmake/lib/ +test/*/cmake/autocmake/ test/*/cmake/downloaded/ test/*/setup diff --git a/.travis.yml b/.travis.yml index 3a94345..8e1a508 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ script: - pep8 --ignore E501,E265 autocmake # # unit tests - py.test -vv autocmake/* -# - py.test -vv test/test.py + - py.test -vv test/test.py notifications: email: false diff --git a/test/boost_header_only/cmake/autocmake.cfg b/test/boost_header_only/cmake/autocmake.yml similarity index 100% rename from test/boost_header_only/cmake/autocmake.cfg rename to test/boost_header_only/cmake/autocmake.yml diff --git a/test/boost_libs/cmake/autocmake.cfg b/test/boost_libs/cmake/autocmake.yml similarity index 100% rename from test/boost_libs/cmake/autocmake.cfg rename to test/boost_libs/cmake/autocmake.yml diff --git a/test/cxx/cmake/autocmake.cfg b/test/cxx/cmake/autocmake.yml similarity index 100% rename from test/cxx/cmake/autocmake.cfg rename to test/cxx/cmake/autocmake.yml diff --git a/test/cxx_accelerate/cmake/autocmake.cfg b/test/cxx_accelerate/cmake/autocmake.yml similarity index 100% rename from test/cxx_accelerate/cmake/autocmake.cfg rename to test/cxx_accelerate/cmake/autocmake.yml diff --git a/test/cxx_cblas/cmake/autocmake.cfg b/test/cxx_cblas/cmake/autocmake.yml similarity index 100% rename from test/cxx_cblas/cmake/autocmake.cfg rename to test/cxx_cblas/cmake/autocmake.yml diff --git a/test/extra_cmake_options/cmake/autocmake.cfg b/test/extra_cmake_options/cmake/autocmake.yml similarity index 100% rename from test/extra_cmake_options/cmake/autocmake.cfg rename to test/extra_cmake_options/cmake/autocmake.yml diff --git a/test/fc/cmake/autocmake.cfg b/test/fc/cmake/autocmake.cfg deleted file mode 100644 index ca40fb4..0000000 --- a/test/fc/cmake/autocmake.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[project] -name: example -min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake diff --git a/test/fc/cmake/autocmake.yml b/test/fc/cmake/autocmake.yml new file mode 100644 index 0000000..7d2318c --- /dev/null +++ b/test/fc/cmake/autocmake.yml @@ -0,0 +1,9 @@ +name: example +min_cmake_version: 2.8 +modules: +- fc: + - source: ../../../modules/fc.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/fc_blas/cmake/autocmake.cfg b/test/fc_blas/cmake/autocmake.yml similarity index 100% rename from test/fc_blas/cmake/autocmake.cfg rename to test/fc_blas/cmake/autocmake.yml diff --git a/test/fc_git_info/cmake/autocmake.cfg b/test/fc_git_info/cmake/autocmake.yml similarity index 100% rename from test/fc_git_info/cmake/autocmake.cfg rename to test/fc_git_info/cmake/autocmake.yml diff --git a/test/fc_int64/cmake/autocmake.cfg b/test/fc_int64/cmake/autocmake.yml similarity index 100% rename from test/fc_int64/cmake/autocmake.cfg rename to test/fc_int64/cmake/autocmake.yml diff --git a/test/fc_lapack/cmake/autocmake.cfg b/test/fc_lapack/cmake/autocmake.yml similarity index 100% rename from test/fc_lapack/cmake/autocmake.cfg rename to test/fc_lapack/cmake/autocmake.yml diff --git a/test/fc_omp/cmake/autocmake.cfg b/test/fc_omp/cmake/autocmake.yml similarity index 100% rename from test/fc_omp/cmake/autocmake.cfg rename to test/fc_omp/cmake/autocmake.yml diff --git a/test/python_interpreter/cmake/autocmake.cfg b/test/python_interpreter/cmake/autocmake.yml similarity index 100% rename from test/python_interpreter/cmake/autocmake.cfg rename to test/python_interpreter/cmake/autocmake.yml diff --git a/test/python_interpreter_custom/cmake/autocmake.cfg b/test/python_interpreter_custom/cmake/autocmake.yml similarity index 100% rename from test/python_interpreter_custom/cmake/autocmake.cfg rename to test/python_interpreter_custom/cmake/autocmake.yml diff --git a/test/python_libs/cmake/autocmake.cfg b/test/python_libs/cmake/autocmake.yml similarity index 100% rename from test/python_libs/cmake/autocmake.cfg rename to test/python_libs/cmake/autocmake.yml diff --git a/test/python_libs_custom/cmake/autocmake.cfg b/test/python_libs_custom/cmake/autocmake.yml similarity index 100% rename from test/python_libs_custom/cmake/autocmake.cfg rename to test/python_libs_custom/cmake/autocmake.yml diff --git a/test/test.py b/test/test.py index dd703f9..07f8ceb 100644 --- a/test/test.py +++ b/test/test.py @@ -51,15 +51,7 @@ def configure_build_and_exe(name, setup_command, launcher=None): os.chdir(os.path.join(HERE, name, 'cmake')) shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py') - dst_dir = 'lib' - if not os.path.exists(dst_dir): - os.makedirs(dst_dir) - shutil.copy(os.path.join('..', '..', '..', dst_dir, 'config.py'), dst_dir) - - dst_dir = os.path.join('lib', 'docopt') - if not os.path.exists(dst_dir): - os.makedirs(dst_dir) - shutil.copy(os.path.join('..', '..', '..', dst_dir, 'docopt.py'), dst_dir) + shutil.copytree(os.path.join('..', '..', '..', 'autocmake'), 'autocmake') stdout, stderr = exe('python update.py ..') os.chdir(os.path.join(HERE, name)) @@ -92,10 +84,12 @@ def configure_build_and_exe(name, setup_command, launcher=None): # ------------------------------------------------------------------------------ +@skip_always def test_extra_cmake_options(): configure_build_and_exe('extra_cmake_options', 'python setup --cxx=g++ --cmake-options="-DENABLE_SOMETHING=OFF -DENABLE_FOO=ON"') +@skip_always def test_cxx(): configure_build_and_exe('cxx', 'python setup --cxx=g++') @@ -104,60 +98,73 @@ def test_fc(): configure_build_and_exe('fc', 'python setup --fc=gfortran') +@skip_always def test_fc_git_info(): configure_build_and_exe('fc_git_info', 'python setup --fc=gfortran') +@skip_always def test_fc_int64(): configure_build_and_exe('fc_int64', 'python setup --fc=gfortran --int64') +@skip_always @skip_on_osx def test_fc_omp(): os.environ['OMP_NUM_THREADS'] = '2' configure_build_and_exe('fc_omp', 'python setup --omp --fc=gfortran') +@skip_always def test_fc_blas(): configure_build_and_exe('fc_blas', 'python setup --fc=gfortran --blas') +@skip_always def test_fc_lapack(): configure_build_and_exe('fc_lapack', 'python setup --fc=gfortran --lapack') +@skip_always @skip_on_osx def test_cxx_cblas(): configure_build_and_exe('cxx_cblas', 'python setup --cxx=g++ --cblas') +@skip_always @skip_on_linux def test_cxx_accelerate(): configure_build_and_exe('cxx_accelerate', 'python setup --cxx=g++ --accelerate') +@skip_always def test_python_interpreter(): configure_build_and_exe('python_interpreter', 'python setup --cxx=g++') +@skip_always def test_python_interpreter_custom(): setup = 'python setup --cxx=g++ --python=%s' % sys.executable configure_build_and_exe('python_interpreter_custom', setup) +@skip_always def test_python_libs(): configure_build_and_exe('python_libs', 'python setup --cxx=g++') +@skip_always def test_python_libs_custom(): python_executable = sys.executable configure_build_and_exe('python_libs_custom', 'python setup --cxx=g++ --python={0}'.format(python_executable)) +@skip_always def test_boost_header_only(): configure_build_and_exe('boost_header_only', 'python setup --cxx=g++') +@skip_always @skip_on_osx def test_boost_libs(): configure_build_and_exe('boost_libs', 'python setup --cxx=g++ --mpi') From 28582ceba7ffe1dcf284bbd53118b87a74cf4865 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 15:37:22 +0200 Subject: [PATCH 086/127] reactivate test_cxx --- test/cxx/cmake/autocmake.yml | 17 +++++++---------- test/test.py | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/test/cxx/cmake/autocmake.yml b/test/cxx/cmake/autocmake.yml index ce3bf11..5bfe461 100644 --- a/test/cxx/cmake/autocmake.yml +++ b/test/cxx/cmake/autocmake.yml @@ -1,12 +1,9 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/test.py b/test/test.py index 07f8ceb..4424596 100644 --- a/test/test.py +++ b/test/test.py @@ -89,7 +89,6 @@ def test_extra_cmake_options(): configure_build_and_exe('extra_cmake_options', 'python setup --cxx=g++ --cmake-options="-DENABLE_SOMETHING=OFF -DENABLE_FOO=ON"') -@skip_always def test_cxx(): configure_build_and_exe('cxx', 'python setup --cxx=g++') From 4d005acaa090c9ec1b6fbb6a51003f8abd4f4ff9 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 17:40:45 +0200 Subject: [PATCH 087/127] add logo --- README.md | 2 ++ img/autocmake.png | Bin 0 -> 6132 bytes img/autocmake.svg | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 img/autocmake.png create mode 100644 img/autocmake.svg diff --git a/README.md b/README.md index 71635d0..a8039b8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ # Autocmake +![alt text](https://github.com/coderefinery/autocmake/raw/master/img/autocmake.png "Autocmake") + A CMake plugin composer. Licensed under [BSD-3](../master/LICENSE). See http://autocmake.org. diff --git a/img/autocmake.png b/img/autocmake.png new file mode 100644 index 0000000000000000000000000000000000000000..74b0247c90950d1e8f50419d83294d6859c54e5e GIT binary patch literal 6132 zcmeHLc{J4T{vVTNiqe!Miqb+6l9a6>hO|h9nZnGdn2?>UV~8?Ynz|(|w!ZW&CT3K2 zX2!0NB}-ulStrKQm<(p_GvE9Do_p`PfBnw={dt`;$N9XU=e<7f_xpLhpS!j;R_oU( zu7f}z>#a{(T!28JXb42?K1>o&{EsL<0sq7UPFUN)z+VLH8VP)_^*wnh0POD({lreF zKMw)KZGlL1;6)#|z+e}DS4ePhu$H^GXTVh#Uso+3fBf?qV?_vLtDm)nnO#WgG|S|M zvwPT=xp52z6G{3_{d~5%yW7u0e>-`;qnWhZefu6WxAjN0`oDNZW%sM*uQ->SdeH0; zyr@%YiM>u$)cPBWiyIb9~aVRoNqOL)uAv>Qkp^%gNXb{NX*8Y$5-$vqW zF9xD>gYwz>hnJ6qMQv%}C^}t}Fx@H~)R{(+^JSYCs0vTsg}xY&aie9aIH zP#YdDqgq$qZPjKZGL{j8NrOwW!Xtu3A`w5th1$6!Y`k8_5i}9!>r28OdZrx3EaQP; z#wHc=j3tVcbfpy2SX{m>UM&uf4b2@M9_v+NjA4!G1+&W#yS=oidS})EiPA@9@bwZV zukG)47%(246|gi4LcLvI@Sv|x;lz@R4ACo7T~jiCTi}P3$-}GRDEUZ4)Bzy2BrB%! zHumac3JMX_ADsZv|`}1Pf`P%T{^<`^X zK(w-SCHr@)I=pI1rV9u_)k$EUVQ*{cEqhl<4b|bH@`N-+S=-x8sNy?4<+|nI;ENc~ zGNX9TuCpLx~kMyaM?vi83zYzXS$=pYd>_+4(vNU z@`X{5wkUuw5`nOXp}+Aj)M=pMa1N{BEKJWFsQplJ>qvfx1km~d>`(<>o>4pP7h=S* zq31fr!X;VJV=&E3xGd*K{m1zqaWV7{#?jmf7E8fi=m|+)3znWPpx_H$aLgC<-D0ZK zNoOhMB@k0m^Ad$L)u5NEJF!8}3@B<0v-p$~S_IqO>>}2(5p6pCDevsafKe&l_TWJv zrd(X!wp?}w^K?1>GdpoS)u9*(6Y&)`4Jao*;bgXxNWqI*wYQU!zjr|*(wI<>6q9et zhlKJ&*X8DBizsN*N|6M^d|ZOBSA-XSdf>7PXEP~>TK{)$aDyjDY4QlLYBO(kP99t zdsLzrMcs@x%~MuG#LRXYx2mq>S{1F0Rs>Gy_h|Xlc1UE<0Ne0|nQ0do5XQ{;W%ilBGFOvJMVVxFW<7@T`a`SmYD+l!CXjK^n1V9LDg(I8>6bu z&!{GnEQ|D_T||_u`h471Rq?XZI5BsJR}YVsd~Nyxj3xz-_fAHDT z9(g!;qh+VB1W<4na18hN>dnvzIR(5X><}6GT=Wo}%A; zW2!m1S!~l^#LfT-jq2S2QQM)?=r8BZqPcBpv8K>y3C-^xUk3PjjYo`d94}())&y^Y zt_6DU%g!7jau28ut5Gps^JTK$9KGW-*+*75G3lk*$b~gCaJV+(wHoac_1s8WrF3D1 zzK%%pNhQ%r24m%IQBPz@pZ+eIf=ES7IO=lfU@PO7wHI~T<^=9MRQgF@A4>l!Z@AQ9 zV0l4%s{B@vaBQ>}qog1iEzz8pH(f;{rD(IuZxs@+mKXI%-T~Dg;5h-Z}@1+N!gCvCI{5 zd7Tu;9<6%NH@XLe$Rrd^6;xpY9Bl60?n@^98d_-eB&>#WN^VIsp92a*!$R`9c)}{Y zwg+KV36(as;Scf>p2J{GEemIt#^=5wD&CA1B392=q8g&+lk^dS?BDSnYxb7Y3N~d) zrpK=gFKAcsqF}nd+zf@DjZZ8zAv7NS&c}Ts~gAGCS;`NaBIdh8f1@$ z!>RXHFN@3X79ksu#s9_4uJ0Z$7TBY*$|f3q?pZAtt{^-xYau@qn8SsFSu8+JPvQ=q z_*XRLCYeBbLdYa^Gd#7L&O&7#5_!H?-Y?CmHF#;?S|spMj0}F*R{C6CXAe8;65?XU zmc4TvWt%VmZsnbRsq5XlI*CH8o6-prwrK}aa`0W;wZ5>*OGggLrB;sp5F6FXqq2np z`B3tu^8)xnv+@~rJ;E7|`)^n~X9 zsA|2Ssk_2xWVhr#dam#mk#gf~{|_BDzN`_Syt?Xak>U-z&K{5PSMXQK%$IfN`8Ae& z=S}n3uAc1i5zVs^lFod=&B;4a7X&7sl^tUt5YS~Hrn=D*ko(Q|ji|{c&Fed}$VamS zSKZ={NB$lt3Z7df8;LV3=l?oCpDL9dhjjN&HSKu z9>aU)_cilN-v=EC>&e(-%3G@$Wsu56EWLxebW@+(FZzZ!Mjv61>$36BTC%**kN)Fe zK3%%@tMK$&p^;nKTKC}v$7_(1yWGMfh|jgS!2Jjny!(~e%I`#CVAJ)5k#qO@Fybxz zpVUa=@6__yB%i|hu!M>RRryPUZ{(La6CL9ztCxb@3C?_8>gwSVQc|Y`EE}qy&6IgdKElI-;XWZ{+7)te zGg`+NfWnA{;(J#NFL{LTM=Y>72bl<_#2NjoQ` zMWSWaDJ(G}!s+v=-0-lFgY{c_L`|)VX<|^(ySORRtjl=P7F!1z#Icf6)}n6IgZlUH0RlZk{%OTJ0yi&>cHmFWfmCi{M? z{1Y;867YRNlvlYDZ?FO zm;0JdwpY>PWjWY{(Yx3J9lJ=rOJ&fy zL1f5OR$S3qm)GL*GIm>4Kr@|xxMFx2-MV3YS&c2wo0&ZNGUS)HK_6L?M- zD){DA*U+44*9wQOZEy0!mOr{Vl~=Tbn90MyvKF|Anh(X;e>T(&nLRA?5V$in9~EvP z%s~FKZ%vJph}lEKMWy#^vx)p2Gn8MATQn8+L`$p*m|OAar$-h5xn{z1{s?YWWhL72 z>3a|-0I?;ppdd^)-cLo$uPkd)EEH74K={ zjbV9&Z!?VnF*%u%fhZy6W2@qI;v~#>({QGI9e_4lDl04JF3RhYzvQH;T4)0Q`|0JM%Ah~~Es ztAZARU8s`{_70dq(hX&$CCz}WpYF_6yX1q_%3S-1?-s!d;=nZD_l%y!O&&r054XJ` zk;;918WwLCf=uc>gEJcv0jtXCq@tAbmy(|r9Cxl#OyZZiO55$GW%{1muv~0{w$E^* zss5oMUJVclCc@m_`{7B_IaP-P(6+|W61SDAZ`z4A+58rq^X=+kNVEjfQIR|hutP7V z-sw~&z~Wb~5)`G5YKw}-5-Pp!W=ObNH!7tMEax7dE%iw^kd=<#N6W+!(m>Dz%yGJN z9YCb6o6)wkB8twu5f zM$2L0M{ftcMIO5}@2PO=yPDFvE}jvL;_baSx2~H%^>&Tb3tOQ5{kuYCpK0%+%0x@9 zSL5mw!H0Q^x%(O)Jaubs5Y?%fwV57SgXvws0){#7+`BidFKMA_iL zK3Xn;KwkbBon^Zd(Qf;Vc`q4Zt zNRmCkiTi((?AI7Xep%2!t4ZB^ys#Sc0vrq}!1FU0OF^&gknw6XQ5~Lq0i3@L4#Rk0 zFyZA~n`I3#AM{Ir)Xc4cb;H(Xph9ZO6LhM91Dg;ZY)M%$ZNqjUabN z1P4LbGuCQOlwP6Y>?;yxOP(C!Z62d#4vNeF{4#%SJ9*{@$dk)5p`uxI(&g!pj5%JeiC>w@Y2rGH&+pzY#Scz0U3|cOp04F{r>Ke z{&!_R|Jxlr1wKf!b0+&E!fAZx*dqtCkxFb=?8{j2{x*>VPC;eXDJX$vSG4v;1~A@k z(n`;6ngW`lF?R?&Y!E5_3;O8EYH|-i|lLIc`nkS_(AdM%UzAz@XnPnl0K?Q=wUkEx07=lc$ zep|Y+_a6(uIE*kF0N66Lc?1m}e~V5?n1QBfh-y1=(`9M+EduG8w#;E1+$M3q~OuBgV$ zw5f<>tAnX2!1%zcbl1Rm1I-CpC4Spx@I)kB{q(B9cv}OgA#|EnUGGQ#zNXwH4K$WF zJeuN1;6?N`LEQ9uSAIQwOVltM(z@{myf4j57X%6V^&Z#bvDxXGNuXu&dwYzF4U + + + + + + + + + image/svg+xml + + + + + + + + + + + Autocmake + + + From ee07ecb83e3d9cc9afd9eda77e57e8ee016d34b4 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 17:41:24 +0200 Subject: [PATCH 088/127] rm title --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index a8039b8..8221195 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ [![Documentation Status](https://readthedocs.org/projects/autocmake/badge/?version=latest)](http://autocmake.readthedocs.org) [![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE) - -# Autocmake - ![alt text](https://github.com/coderefinery/autocmake/raw/master/img/autocmake.png "Autocmake") A CMake plugin composer. From 37d430c0fd838f7d03394ffd9c86075dbd9c38c2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 20:43:08 +0200 Subject: [PATCH 089/127] workaround for problem with trying to copy to existing dir --- test/test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test.py b/test/test.py index 4424596..2f073c1 100644 --- a/test/test.py +++ b/test/test.py @@ -51,6 +51,8 @@ def configure_build_and_exe(name, setup_command, launcher=None): os.chdir(os.path.join(HERE, name, 'cmake')) shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py') + if os.path.exists('autocmake'): + shutil.rmtree('autocmake') shutil.copytree(os.path.join('..', '..', '..', 'autocmake'), 'autocmake') stdout, stderr = exe('python update.py ..') From 30ced00c4fce8b9b5f66c09edb5ed4eedbd9b0a9 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 20:45:13 +0200 Subject: [PATCH 090/127] restore tests on Python 2 --- autocmake/external/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 autocmake/external/__init__.py diff --git a/autocmake/external/__init__.py b/autocmake/external/__init__.py new file mode 100644 index 0000000..e69de29 From 6896da511c6bc130ff318f39f52c5851f80e1779 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 20:55:10 +0200 Subject: [PATCH 091/127] restore a couple of tests --- test/cxx_accelerate/cmake/autocmake.yml | 22 ++++++++------------ test/cxx_cblas/cmake/autocmake.yml | 22 ++++++++------------ test/extra_cmake_options/cmake/autocmake.yml | 17 +++++++-------- test/fc_blas/cmake/autocmake.yml | 22 ++++++++------------ test/fc_git_info/cmake/autocmake.yml | 22 ++++++++------------ test/fc_int64/cmake/autocmake.yml | 22 ++++++++------------ test/fc_lapack/cmake/autocmake.yml | 22 ++++++++------------ test/fc_omp/cmake/autocmake.yml | 22 ++++++++------------ test/test.py | 15 ------------- 9 files changed, 70 insertions(+), 116 deletions(-) diff --git a/test/cxx_accelerate/cmake/autocmake.yml b/test/cxx_accelerate/cmake/autocmake.yml index 5c91c67..c2fccf4 100644 --- a/test/cxx_accelerate/cmake/autocmake.yml +++ b/test/cxx_accelerate/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[math] -source: ../../../modules/math/accelerate.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- math: + - source: ../../../modules/math/accelerate.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/cxx_cblas/cmake/autocmake.yml b/test/cxx_cblas/cmake/autocmake.yml index b0d3897..6df6437 100644 --- a/test/cxx_cblas/cmake/autocmake.yml +++ b/test/cxx_cblas/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[math] -source: ../../../modules/math/cblas.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- math: + - source: ../../../modules/math/cblas.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/extra_cmake_options/cmake/autocmake.yml b/test/extra_cmake_options/cmake/autocmake.yml index ce3bf11..5bfe461 100644 --- a/test/extra_cmake_options/cmake/autocmake.yml +++ b/test/extra_cmake_options/cmake/autocmake.yml @@ -1,12 +1,9 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/fc_blas/cmake/autocmake.yml b/test/fc_blas/cmake/autocmake.yml index dd61239..0ed452b 100644 --- a/test/fc_blas/cmake/autocmake.yml +++ b/test/fc_blas/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[math] -source: ../../../modules/math/blas.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- fc: + - source: ../../../modules/fc.cmake +- math: + - source: ../../../modules/math/blas.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/fc_git_info/cmake/autocmake.yml b/test/fc_git_info/cmake/autocmake.yml index a1e1d12..a8d32dd 100644 --- a/test/fc_git_info/cmake/autocmake.yml +++ b/test/fc_git_info/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake - -[git_info] -source: ../../../modules/git_info/git_info.cmake +modules: +- fc: + - source: ../../../modules/fc.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake +- git_info: + - source: ../../../modules/git_info/git_info.cmake diff --git a/test/fc_int64/cmake/autocmake.yml b/test/fc_int64/cmake/autocmake.yml index 922c59c..0cc3d23 100644 --- a/test/fc_int64/cmake/autocmake.yml +++ b/test/fc_int64/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[int64] -source: ../../../modules/int64.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- fc: + - source: ../../../modules/fc.cmake +- int64: + - source: ../../../modules/int64.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/fc_lapack/cmake/autocmake.yml b/test/fc_lapack/cmake/autocmake.yml index 6d5ea5a..fa696e5 100644 --- a/test/fc_lapack/cmake/autocmake.yml +++ b/test/fc_lapack/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[math] -source: ../../../modules/math/lapack.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- fc: + - source: ../../../modules/fc.cmake +- math: + - source: ../../../modules/math/lapack.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/fc_omp/cmake/autocmake.yml b/test/fc_omp/cmake/autocmake.yml index 5f3475e..09596a6 100644 --- a/test/fc_omp/cmake/autocmake.yml +++ b/test/fc_omp/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[fc] -source: ../../../modules/fc.cmake - -[omp] -source: ../../../modules/omp.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- fc: + - source: ../../../modules/fc.cmake +- omp: + - source: ../../../modules/omp.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/test.py b/test/test.py index 2f073c1..b2c4562 100644 --- a/test/test.py +++ b/test/test.py @@ -15,9 +15,6 @@ skip_on_linux = pytest.mark.skipif('sys.platform == "linux2"', reason="not worki skip_always = pytest.mark.skipif('1 == 1', reason="tests are broken") -# ------------------------------------------------------------------------------ - - def exe(command): """ Executes command and returns string representations of stdout and stderr captured from the console. @@ -41,8 +38,6 @@ def exe(command): return stdout, stderr -# ------------------------------------------------------------------------------ - def configure_build_and_exe(name, setup_command, launcher=None): @@ -83,10 +78,7 @@ def configure_build_and_exe(name, setup_command, launcher=None): assert 'PASSED' in stdout -# ------------------------------------------------------------------------------ - -@skip_always def test_extra_cmake_options(): configure_build_and_exe('extra_cmake_options', 'python setup --cxx=g++ --cmake-options="-DENABLE_SOMETHING=OFF -DENABLE_FOO=ON"') @@ -99,40 +91,33 @@ def test_fc(): configure_build_and_exe('fc', 'python setup --fc=gfortran') -@skip_always def test_fc_git_info(): configure_build_and_exe('fc_git_info', 'python setup --fc=gfortran') -@skip_always def test_fc_int64(): configure_build_and_exe('fc_int64', 'python setup --fc=gfortran --int64') -@skip_always @skip_on_osx def test_fc_omp(): os.environ['OMP_NUM_THREADS'] = '2' configure_build_and_exe('fc_omp', 'python setup --omp --fc=gfortran') -@skip_always def test_fc_blas(): configure_build_and_exe('fc_blas', 'python setup --fc=gfortran --blas') -@skip_always def test_fc_lapack(): configure_build_and_exe('fc_lapack', 'python setup --fc=gfortran --lapack') -@skip_always @skip_on_osx def test_cxx_cblas(): configure_build_and_exe('cxx_cblas', 'python setup --cxx=g++ --cblas') -@skip_always @skip_on_linux def test_cxx_accelerate(): configure_build_and_exe('cxx_accelerate', 'python setup --cxx=g++ --accelerate') From bfeef557e702c722a1e4bc98f67868f01dacf064 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 20:58:43 +0200 Subject: [PATCH 092/127] convert python tests to new form --- test/python_interpreter/cmake/autocmake.yml | 24 ++++++++--------- .../cmake/autocmake.yml | 22 +++++++-------- test/python_libs/cmake/autocmake.yml | 27 ++++++++----------- test/python_libs_custom/cmake/autocmake.yml | 27 ++++++++----------- test/test.py | 6 ----- 5 files changed, 42 insertions(+), 64 deletions(-) diff --git a/test/python_interpreter/cmake/autocmake.yml b/test/python_interpreter/cmake/autocmake.yml index d77d2cf..560fd7e 100644 --- a/test/python_interpreter/cmake/autocmake.yml +++ b/test/python_interpreter/cmake/autocmake.yml @@ -1,15 +1,13 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[python_interpreter] -source: ../../../modules/python_interpreter.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- python_libs: + - source: ../../../modules/python_libs.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/python_interpreter_custom/cmake/autocmake.yml b/test/python_interpreter_custom/cmake/autocmake.yml index d77d2cf..1bb701d 100644 --- a/test/python_interpreter_custom/cmake/autocmake.yml +++ b/test/python_interpreter_custom/cmake/autocmake.yml @@ -1,15 +1,11 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[python_interpreter] -source: ../../../modules/python_interpreter.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/python_libs/cmake/autocmake.yml b/test/python_libs/cmake/autocmake.yml index df9c15d..560fd7e 100644 --- a/test/python_libs/cmake/autocmake.yml +++ b/test/python_libs/cmake/autocmake.yml @@ -1,18 +1,13 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[python_interpreter] -source: ../../../modules/python_interpreter.cmake - -[python_libs] -source: ../../../modules/python_libs.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- python_libs: + - source: ../../../modules/python_libs.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/python_libs_custom/cmake/autocmake.yml b/test/python_libs_custom/cmake/autocmake.yml index df9c15d..560fd7e 100644 --- a/test/python_libs_custom/cmake/autocmake.yml +++ b/test/python_libs_custom/cmake/autocmake.yml @@ -1,18 +1,13 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[python_interpreter] -source: ../../../modules/python_interpreter.cmake - -[python_libs] -source: ../../../modules/python_libs.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- python_libs: + - source: ../../../modules/python_libs.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake diff --git a/test/test.py b/test/test.py index b2c4562..d2a521a 100644 --- a/test/test.py +++ b/test/test.py @@ -123,34 +123,28 @@ def test_cxx_accelerate(): configure_build_and_exe('cxx_accelerate', 'python setup --cxx=g++ --accelerate') -@skip_always def test_python_interpreter(): configure_build_and_exe('python_interpreter', 'python setup --cxx=g++') -@skip_always def test_python_interpreter_custom(): setup = 'python setup --cxx=g++ --python=%s' % sys.executable configure_build_and_exe('python_interpreter_custom', setup) -@skip_always def test_python_libs(): configure_build_and_exe('python_libs', 'python setup --cxx=g++') -@skip_always def test_python_libs_custom(): python_executable = sys.executable configure_build_and_exe('python_libs_custom', 'python setup --cxx=g++ --python={0}'.format(python_executable)) -@skip_always def test_boost_header_only(): configure_build_and_exe('boost_header_only', 'python setup --cxx=g++') -@skip_always @skip_on_osx def test_boost_libs(): configure_build_and_exe('boost_libs', 'python setup --cxx=g++ --mpi') From 8af4e033d9b5dca75adcf46b36a32e8aa1dd90f5 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:02:16 +0200 Subject: [PATCH 093/127] convert boost tests to new form --- test/boost_header_only/cmake/autocmake.yml | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/boost_header_only/cmake/autocmake.yml b/test/boost_header_only/cmake/autocmake.yml index e76db41..43f5d47 100644 --- a/test/boost_header_only/cmake/autocmake.yml +++ b/test/boost_header_only/cmake/autocmake.yml @@ -1,16 +1,21 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[boost] -override: {'major': 1, 'minor': 48, 'patch': 0} -source: ../../../modules/boost/boost.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- mpi: + - source: ../../../modules/mpi.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- python_libs: + - source: ../../../modules/python_libs.cmake +- boost: + - major: 1 + - minor: 59 + - patch: 0 + - components: 'mpi;serialization;python' + - source: ../../../modules/boost/boost.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake From 931ab9b444e771b11b9e03596076f3c085a75662 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:05:53 +0200 Subject: [PATCH 094/127] allow flat_add to operate also on ints --- update.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/update.py b/update.py index 748b45a..080b822 100644 --- a/update.py +++ b/update.py @@ -18,7 +18,10 @@ def print_progress_bar(text, done, total, width): def flat_add(l, x): - if isinstance(x, str): + if isinstance(x, int): + l.append(x) + return l + elif isinstance(x, str): l.append(x) return l else: From 42e5192dc9f1276f63cc40b8919350d877c71fbd Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:16:01 +0200 Subject: [PATCH 095/127] fixes in boost.cmake --- modules/boost/boost.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index 88bcd4c..fda8f4d 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -5,7 +5,7 @@ # Autocmake update time. # Note that the build-up commands are not Windows-compatible! # -# Your autocmake.yml should contain:: +# Your autocmake.yml should look like this:: # # - boost: # - major: 1 @@ -61,7 +61,7 @@ # - "%(url_root)modules/boost/boost_install.cmake" # - "%(url_root)modules/boost/boost_headers.cmake" # - "%(url_root)modules/boost/boost_cleanup.cmake" -# - "http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip" +# - "http://sourceforge.net/projects/boost/files/boost/%(major).%(minor).%(patch)/boost_%(major)_%(minor)_%(patch).zip" # docopt: # - "--boost-headers= Include directories for Boost [default: '']." # - "--boost-libraries= Library directories for Boost [default: '']." @@ -70,8 +70,8 @@ # - "'-DBOOST_INCLUDEDIR=\"{0}\"'.format(arguments['--boost-headers'])" # - "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])" # - "'-DFORCE_CUSTOM_BOOST=\"{0}\"'.format(arguments['--build-boost'])" -# - "'-DBOOST_MINIMUM_REQUIRED="%(major)s.%(minor)s.%(patch)s"'" -# - "'-DBOOST_COMPONENTS_REQUIRED="%(components)s"'" +# - "'-DBOOST_MINIMUM_REQUIRED=\"%(major).%(minor).%(patch)\"'" +# - "'-DBOOST_COMPONENTS_REQUIRED=\"%(components)\"'" # FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency # on its own) and soft-fail (self-build of Boost) From ca8a86aa6128d40c9fe66c85353342a4ab228c9e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:20:01 +0200 Subject: [PATCH 096/127] indicate that doc is outdated --- doc/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index.rst b/doc/index.rst index e5693c1..5356a95 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,7 +1,7 @@ -Autocmake -========= +Autocmake (this documentation is outdated, see stable-0.x branch) +================================================================= General From 24d235ac1aebdf98e564facd799e236d97cd53c4 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:20:16 +0200 Subject: [PATCH 097/127] try to test python 2.7 and 3.5 --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e1a508..825500f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ -language: cpp +language: python sudo: false +python: + - 2.7 + - 3.5 + matrix: include: @@ -49,7 +53,7 @@ script: # pep8 tests - pep8 --ignore E501 update.py - pep8 --ignore E501,E265 autocmake -# # unit tests + # unit tests - py.test -vv autocmake/* - py.test -vv test/test.py From 6cf25bbd2bc8d5fb7a7cf8c76867fcebe3d72d88 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:32:22 +0200 Subject: [PATCH 098/127] extend tests --- autocmake/interpolate.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/autocmake/interpolate.py b/autocmake/interpolate.py index 50121c7..aeb54ed 100644 --- a/autocmake/interpolate.py +++ b/autocmake/interpolate.py @@ -33,22 +33,34 @@ def interpolate(d, d_map): def test_interpolate(): - d = {'foo': 'hey', 'bar': 'ho', 'one': 'hey %(foo) ho %(bar)', 'two': {'one': 'hey %(foo) ho %(bar)', 'two': 'raboof'}} - d_interpolated = {'foo': 'hey', 'bar': 'ho', 'one': 'hey hey ho ho', 'two': {'one': 'hey hey ho ho', 'two': 'raboof'}} - assert interpolate(d, d) == d_interpolated + +def test_interpolate_int(): + d = {'foo': 1, + 'bar': 2, + 'one': 'hey %(foo) ho %(bar)', + 'two': {'one': 'hey %(foo) ho %(bar)', + 'two': 'raboof'}} + d_interpolated = {'foo': 1, + 'bar': 2, + 'one': 'hey 1 ho 2', + 'two': {'one': 'hey 1 ho 2', + 'two': 'raboof'}} + assert interpolate(d, d) == d_interpolated + + +def test_interpolate_nested(): d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'} - assert interpolate(d2, d2) == d2_interpolated From 5b04d7a8a48c93dac0de3257e831bb9a4e0b236e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:42:07 +0200 Subject: [PATCH 099/127] if pyaml is not available, print a nice error message --- update.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/update.py b/update.py index 080b822..11c24f0 100644 --- a/update.py +++ b/update.py @@ -7,6 +7,14 @@ import sys AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' +def check_for_yaml(): + try: + import yaml + except: + sys.stderr.write("ERROR: you need to install the pyaml module\n") + sys.exit(-1) + + def print_progress_bar(text, done, total, width): """ Print progress bar. @@ -270,4 +278,5 @@ def fetch_url(src, dst): if __name__ == '__main__': + check_for_yaml() main(sys.argv) From 0c42f1a9afd08c41156924c0a4b877646b80bc66 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:44:45 +0200 Subject: [PATCH 100/127] another attempt to include python 2.7 and 3.5 --- .travis.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 825500f..fd7b9a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,36 @@ -language: python +language: cpp sudo: false -python: - - 2.7 - - 3.5 - matrix: include: - os: linux + python: 2.7 + compiler: gcc + env: SOURCES=ubuntu-toolchain-r-test + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + # compilers + - g++ + - gfortran + - cmake + # math libraries + - libblas-dev + - liblapack-dev + - libatlas-base-dev + # mpi + - openmpi-bin + - libopenmpi-dev + # python library, development version + - libpython2.7 + # boost + - libboost-all-dev + + - os: linux + python: 3.5 compiler: gcc env: SOURCES=ubuntu-toolchain-r-test addons: From 8b055107ca24219ade849f4f4daf74520528776e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 21:50:56 +0200 Subject: [PATCH 101/127] fix boost test autocmake.yml files --- test/boost_header_only/cmake/autocmake.yml | 9 +---- test/boost_libs/cmake/autocmake.yml | 42 ++++++++++------------ 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/test/boost_header_only/cmake/autocmake.yml b/test/boost_header_only/cmake/autocmake.yml index 43f5d47..3b319b1 100644 --- a/test/boost_header_only/cmake/autocmake.yml +++ b/test/boost_header_only/cmake/autocmake.yml @@ -3,17 +3,10 @@ min_cmake_version: 2.8 modules: - cxx: - source: ../../../modules/cxx.cmake -- mpi: - - source: ../../../modules/mpi.cmake -- python_interpreter: - - source: ../../../modules/python_interpreter.cmake -- python_libs: - - source: ../../../modules/python_libs.cmake - boost: - major: 1 - - minor: 59 + - minor: 48 - patch: 0 - - components: 'mpi;serialization;python' - source: ../../../modules/boost/boost.cmake - default_build_paths: - source: ../../../modules/default_build_paths.cmake diff --git a/test/boost_libs/cmake/autocmake.yml b/test/boost_libs/cmake/autocmake.yml index 02d73b0..43f5d47 100644 --- a/test/boost_libs/cmake/autocmake.yml +++ b/test/boost_libs/cmake/autocmake.yml @@ -1,25 +1,21 @@ -[project] name: example min_cmake_version: 2.8 - -[cxx] -source: ../../../modules/cxx.cmake - -[mpi] -source: ../../../modules/mpi.cmake - -[python_interpreter] -source: ../../../modules/python_interpreter.cmake - -[python_libs] -source: ../../../modules/python_libs.cmake - -[boost] -override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'mpi;serialization;python'} -source: ../../../modules/boost/boost.cmake - -[default_build_paths] -source: ../../../modules/default_build_paths.cmake - -[src] -source: ../../../modules/src.cmake +modules: +- cxx: + - source: ../../../modules/cxx.cmake +- mpi: + - source: ../../../modules/mpi.cmake +- python_interpreter: + - source: ../../../modules/python_interpreter.cmake +- python_libs: + - source: ../../../modules/python_libs.cmake +- boost: + - major: 1 + - minor: 59 + - patch: 0 + - components: 'mpi;serialization;python' + - source: ../../../modules/boost/boost.cmake +- default_build_paths: + - source: ../../../modules/default_build_paths.cmake +- src: + - source: ../../../modules/src.cmake From f4889cf134d2360b319a6c33fd642050c83cb5a8 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 22:03:19 +0200 Subject: [PATCH 102/127] typo --- update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.py b/update.py index 11c24f0..ccaa1ea 100644 --- a/update.py +++ b/update.py @@ -11,7 +11,7 @@ def check_for_yaml(): try: import yaml except: - sys.stderr.write("ERROR: you need to install the pyaml module\n") + sys.stderr.write("ERROR: you need to install the pyyaml package\n") sys.exit(-1) From 5a93ad74852eb8f47b58b524997d3fd258b1d8ee Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 22:15:38 +0200 Subject: [PATCH 103/127] also fetch external/__init__.py --- update.py | 1 + 1 file changed, 1 insertion(+) diff --git a/update.py b/update.py index ccaa1ea..006c84d 100644 --- a/update.py +++ b/update.py @@ -224,6 +224,7 @@ def main(argv): for f in ['autocmake/configure.py', 'autocmake/__init__.py', 'autocmake/external/docopt.py', + 'autocmake/external/__init__.py', 'autocmake/generate.py', 'autocmake/extract.py', 'autocmake/interpolate.py', From 28547c43f74c2b7696703c9c45ecd415c4b0ee73 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 22:39:40 +0200 Subject: [PATCH 104/127] more air --- example/autocmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/autocmake.yml b/example/autocmake.yml index 2a4365d..c57e39c 100644 --- a/example/autocmake.yml +++ b/example/autocmake.yml @@ -1,5 +1,7 @@ # CMakeLists.txt and setup script will be generated from this file # see: http://autocmake.readthedocs.io/en/latest/developers/configuration.html # adapt the following lines and expand + name: myproject + min_cmake_version: 2.8 From 3200b0022d4c69af7bb4d343a9bfc0afee3e167e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 20 May 2016 23:05:46 +0200 Subject: [PATCH 105/127] on linux try cmake 3.5.2 --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd7b9a1..9591dbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ matrix: # compilers - g++ - gfortran - - cmake # math libraries - libblas-dev - liblapack-dev @@ -66,10 +65,13 @@ install: pip install virtualenv elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then pip install --user virtualenv + curl https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | tar xvz + export PATH=~/cmake-3.5.2-Linux-x86_64/bin:$PATH + export LD_LIBARY_PATH=~/cmake-3.5.2-Linux-x86_64/lib:$LD_LIBRARY_PATH fi - virtualenv venv - source venv/bin/activate - - pip install pep8 pytest pyaml + - pip install -r requirements.txt script: # pep8 tests From 7a9af28fcabb4f978c84328e81210c8b439bf26f Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 21 May 2016 01:32:22 +0200 Subject: [PATCH 106/127] fix BOOST_ARCHIVE_LOCATION --- modules/boost/boost.cmake | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index fda8f4d..1754fbf 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -69,20 +69,18 @@ # define: # - "'-DBOOST_INCLUDEDIR=\"{0}\"'.format(arguments['--boost-headers'])" # - "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])" -# - "'-DFORCE_CUSTOM_BOOST=\"{0}\"'.format(arguments['--build-boost'])" +# - "'-DFORCE_CUSTOM_BOOST={0}'.format(arguments['--build-boost'])" # - "'-DBOOST_MINIMUM_REQUIRED=\"%(major).%(minor).%(patch)\"'" -# - "'-DBOOST_COMPONENTS_REQUIRED=\"%(components)\"'" +# - "'-DBOOST_COMPONENTS_REQUIRED=%(components)'" # FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency # on its own) and soft-fail (self-build of Boost) # Underscore-separated version number string(REGEX REPLACE "\\." "_" BOOSTVER ${BOOST_MINIMUM_REQUIRED}) + # Where the Boost .zip archive is located -# CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2 -# see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675 -# workaround: create CMAKE_CURRENT_LIST_DIR -get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -set(BOOST_ARCHIVE_LOCATION ${CMAKE_CURRENT_LIST_DIR}) +set(BOOST_ARCHIVE_LOCATION ${PROJECT_SOURCE_DIR}/cmake/downloaded) + set(BOOST_ARCHIVE boost_${BOOSTVER}.zip) # FIXME These are possibly not always good settings From be5d760555ea837d2e9dcc0bb3ad0d5e7f601b4c Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 21 May 2016 01:41:02 +0200 Subject: [PATCH 107/127] add quotes --- modules/boost/boost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index 1754fbf..656f7bd 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -71,7 +71,7 @@ # - "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])" # - "'-DFORCE_CUSTOM_BOOST={0}'.format(arguments['--build-boost'])" # - "'-DBOOST_MINIMUM_REQUIRED=\"%(major).%(minor).%(patch)\"'" -# - "'-DBOOST_COMPONENTS_REQUIRED=%(components)'" +# - "'-DBOOST_COMPONENTS_REQUIRED=\"%(components)\"'" # FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency # on its own) and soft-fail (self-build of Boost) From 9c9f001e57844e3abbaec16e69158c634c05d8ed Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 21 May 2016 12:23:20 +0200 Subject: [PATCH 108/127] s/yaml/master/ --- modules/boost/boost.cmake | 4 ++-- modules/git_info/git_info.cmake | 2 +- modules/math/accelerate.cmake | 2 +- modules/math/cblas.cmake | 2 +- modules/math/lapacke.cmake | 2 +- update.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/boost/boost.cmake b/modules/boost/boost.cmake index 656f7bd..a33665e 100644 --- a/modules/boost/boost.cmake +++ b/modules/boost/boost.cmake @@ -12,7 +12,7 @@ # - minor: 59 # - patch: 0 # - components: "chrono;timer;system" -# - source: "https://github.com/coderefinery/autocmake/raw/yaml/modules/boost/boost.cmake" +# - source: "https://github.com/coderefinery/autocmake/raw/master/modules/boost/boost.cmake" # # Cross-dependencies between required components are not checked for. # For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you @@ -48,7 +48,7 @@ # # autocmake.yml configuration:: # -# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ +# url_root: https://github.com/coderefinery/autocmake/raw/master/ # major: 1 # minor: 48 # patch: 0 diff --git a/modules/git_info/git_info.cmake b/modules/git_info/git_info.cmake index 9ee81f4..ee169c0 100644 --- a/modules/git_info/git_info.cmake +++ b/modules/git_info/git_info.cmake @@ -7,7 +7,7 @@ # # autocmake.yml configuration:: # -# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ +# url_root: https://github.com/coderefinery/autocmake/raw/master/ # fetch: # - "%(url_root)modules/git_info/git_info_sub.cmake" # - "%(url_root)modules/git_info/git_info.h.in" diff --git a/modules/math/accelerate.cmake b/modules/math/accelerate.cmake index f03b160..9483e5a 100644 --- a/modules/math/accelerate.cmake +++ b/modules/math/accelerate.cmake @@ -10,7 +10,7 @@ # # autocmake.yml configuration:: # -# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ +# url_root: https://github.com/coderefinery/autocmake/raw/master/ # docopt: "--accelerate Find and link to ACCELERATE [default: False]." # define: "'-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate'])" # fetch: diff --git a/modules/math/cblas.cmake b/modules/math/cblas.cmake index 305c3cc..86fa49f 100644 --- a/modules/math/cblas.cmake +++ b/modules/math/cblas.cmake @@ -10,7 +10,7 @@ # # autocmake.yml configuration:: # -# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ +# url_root: https://github.com/coderefinery/autocmake/raw/master/ # docopt: "--cblas Find and link to CBLAS [default: False]." # define: "'-DENABLE_CBLAS={0}'.format(arguments['--cblas'])" # fetch: diff --git a/modules/math/lapacke.cmake b/modules/math/lapacke.cmake index e561ba6..8b89044 100644 --- a/modules/math/lapacke.cmake +++ b/modules/math/lapacke.cmake @@ -10,7 +10,7 @@ # # autocmake.yml configuration:: # -# url_root: https://github.com/coderefinery/autocmake/raw/yaml/ +# url_root: https://github.com/coderefinery/autocmake/raw/master/ # docopt: "--lapacke Find and link to LAPACKE [default: False]." # define: "'-DENABLE_LAPACKE={0}'.format(arguments['--lapacke'])" # fetch: diff --git a/update.py b/update.py index 006c84d..5cbf0c7 100644 --- a/update.py +++ b/update.py @@ -4,7 +4,7 @@ import os import sys -AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/yaml/' +AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/master/' def check_for_yaml(): From a9ceb81f39bd26e070dc692e50274e03a644a85e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 17:39:29 +0200 Subject: [PATCH 109/127] update author info --- AUTHORS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 5b355ae..5978cc0 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -7,7 +7,8 @@ - Miroslav Ilias (Windows, portability, earliest adopter testing and feedback, math library testing) - Ivan Hrasko (Windows, Appveyor testing) -- Dan Jonsson (idea for configuration file approach which preceded yaml solution) +- Dan Jonsson (idea for configuration file approach which preceded YAML solution) - Roberto Di Remigio (design ideas and testing, OS X testing, Boost) -For a list of all the contributions see https://github.com/coderefinery/autocmake/contributors. +For a list of all the contributions, +see https://github.com/coderefinery/autocmake/contributors. From d08cd10e33809d1bb39496c83a8d7034b55b2ca0 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 17:46:03 +0200 Subject: [PATCH 110/127] update documentation after change to yml --- doc/contributors/doc.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/contributors/doc.rst b/doc/contributors/doc.rst index 2cdfd7c..36d85cc 100644 --- a/doc/contributors/doc.rst +++ b/doc/contributors/doc.rst @@ -12,9 +12,9 @@ The module reference documentation is generated from the module sources using http://autocmake.readthedocs.io/en/latest/module-reference.html#cc-cmake with https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake). -Please note that the lines following ``# autocmake.cfg configuration::`` are -understood by the ``update.py`` script to infer autocmake.cfg code from the +Please note that the lines following ``# autocmake.yml configuration::`` are +understood by the ``update.py`` script to infer autocmake.yml code from the documentation. As an example consider -https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L26. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. From 2dd36eb15dfee73c837177b7001097e1b2e22bdb Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 17:46:18 +0200 Subject: [PATCH 111/127] extend doc about testing --- doc/contributors/testing.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/contributors/testing.rst b/doc/contributors/testing.rst index 43e02c7..d320fca 100644 --- a/doc/contributors/testing.rst +++ b/doc/contributors/testing.rst @@ -8,9 +8,13 @@ You will need to install `pytest `__. Check also the `Travis `__ build and test recipe for other requirements. -Your contributions and changes should preserve the test set. You can run locally all tests with:: +Your contributions and changes should preserve the test set and be PEP8 conform. +You can run locally all tests with:: - $ py.test test/test.py + $ pep8 --ignore E501 update.py + $ pep8 --ignore E501,E265 autocmake + $ py.test -vv autocmake/* + $ py.test -vv test/test.py You can also select individual tests, for example those with ``fc_blas`` string in the name:: From 49d1652c984648c99cee9135dcec47447f8d2801 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 18:03:22 +0200 Subject: [PATCH 112/127] update parts of doc --- doc/developers/bootstrap.rst | 29 ++++++++++++-------------- doc/developers/configuration.rst | 2 +- doc/developers/customizing-modules.rst | 27 +++++++++++++++++------- doc/developers/example.rst | 2 +- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/doc/developers/bootstrap.rst b/doc/developers/bootstrap.rst index d0d6918..e8e2798 100644 --- a/doc/developers/bootstrap.rst +++ b/doc/developers/bootstrap.rst @@ -19,41 +19,38 @@ On the MS Windows system, you can use the PowerShell wget-replacement:: $ Invoke-WebRequest https://github.com/coderefinery/autocmake/raw/master/update.py -OutFile update.py -This creates (or updates) the following files (an existing ``autocmake.cfg`` is +This creates (or updates) the following files (an existing ``autocmake.yml`` is not overwritten by the script):: cmake/ - autocmake.cfg # edit this file + autocmake.yml # edit this file update.py # no need to edit - lib/ - config.py # no need to edit - docopt/ - docopt.py # no need to edit + autocmake/ # no need to edit + ... # no need to edit -Note that all other listed files are overwritten (use version control). +Note that ``update.py`` and files under ``autocmake/`` +are overwritten (use version control). Generating the CMake infrastructure ----------------------------------- -Now customize ``autocmake.cfg`` to your needs -(see :ref:`autocmake_cfg`) +Now customize ``autocmake.yml`` to your needs +(see :ref:`autocmake_yml`) and then run the ``update.py`` script which creates ``CMakeLists.txt`` and a setup script in the target path:: $ python update.py .. -The script also downloads external CMake modules specified in ``autocmake.cfg`` to a directory +The script also downloads external CMake modules specified in ``autocmake.yml`` to a directory called ``downloaded/``:: cmake/ - autocmake.cfg # edit this file + autocmake.yml # edit this file update.py # no need to edit - lib/ - config.py # no need to edit - docopt/ - docopt.py # no need to edit - downloaded/ # contains CMake modules fetched from the web + autocmake/ # no need to edit + ... # no need to edit + downloaded/ # contains CMake modules fetched from the web Building the project diff --git a/doc/developers/configuration.rst b/doc/developers/configuration.rst index 7e91681..5496923 100644 --- a/doc/developers/configuration.rst +++ b/doc/developers/configuration.rst @@ -1,5 +1,5 @@ -.. _autocmake_cfg: +.. _autocmake_yml: Configuring autocmake.cfg ========================= diff --git a/doc/developers/customizing-modules.rst b/doc/developers/customizing-modules.rst index 30036df..fd6a37b 100644 --- a/doc/developers/customizing-modules.rst +++ b/doc/developers/customizing-modules.rst @@ -3,7 +3,7 @@ Customizing CMake modules ========================= -The ``update.py`` script assembles modules listed in ``autocmake.cfg`` into +The ``update.py`` script assembles modules listed in ``autocmake.yml`` into ``CMakeLists.txt``. Those that are fetched from the web are placed inside ``downloaded/``. You have several options to customize downloaded CMake modules: @@ -22,7 +22,7 @@ Adapt local copies of CMake modules A slightly better solution is to download the CMake modules that you wish you customize to a separate directory (e.g. ``custom/``) and source the customized CMake -modules in ``autocmake.cfg``. Alternatively you can serve your custom modules +modules in ``autocmake.yml``. Alternatively you can serve your custom modules from your own http server. @@ -34,19 +34,30 @@ the branched customized versions. This will make it easier for you to stay up-to-date with upstream development. -Overriding defaults +Overriding settings ------------------- -Some modules use interpolations to set defaults, see for instance -https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. -These can be modified within ``autocmake.cfg``, e.g.: -https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 +If you source a module which contains directives such as +``define``, +``docopt``, +``export``, or +``fetch``, and you wish to modify those, +then you can override these settings in ``autocmake.yml``. +Settings in ``autocmake.yml`` take precedence over +settings imported by a sourced module. + +As an example consider the Boost module which defines and uses +interpolation variables ``major``, ``minor``, and ``patch``, see +https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L52-L54. + +The recommended way to customize these is in ``autocmake.yml``, e.g.: +https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.yml#L12-L17. Create own CMake modules ------------------------ -Of course you can also create own modules and source them in ``autocmake.cfg``. +Of course you can also create own modules and source them in ``autocmake.yml``. Contribute customizations to the "standard library" diff --git a/doc/developers/example.rst b/doc/developers/example.rst index 8898fe6..b07b66a 100644 --- a/doc/developers/example.rst +++ b/doc/developers/example.rst @@ -4,7 +4,7 @@ Example Hello World project =========================== This is a brief example for the busy and impatient programmer. For a longer -tour please see :ref:`autocmake_cfg`. +tour please see :ref:`autocmake_yml`. We start with a mixed Fortran-C project with the following sources:: From 0f86f0bea968dab4f37ec62f0aa73086d1b22548 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 18:06:50 +0200 Subject: [PATCH 113/127] update general doc --- doc/general/about.rst | 9 +++++---- doc/general/requirements.rst | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/general/about.rst b/doc/general/about.rst index 95f141c..ea6cb11 100644 --- a/doc/general/about.rst +++ b/doc/general/about.rst @@ -7,9 +7,10 @@ Building libraries and executables from sources can be a complex task. Several solutions exist to this problem: GNU Makefiles is the traditional approach. Today, CMake is one of the trendier alternatives which can generate Makefiles starting from a file called ``CMakeLists.txt``. + Autocmake composes CMake building blocks into a CMake project and generates ``CMakeLists.txt`` as well as a setup script, which serves as a front-end to -``CMakeLists.txt``. All this is done based on a lightweight ``autocmake.cfg`` +``CMakeLists.txt``. All this is done based on a lightweight ``autocmake.yml`` file:: python update.py --self @@ -19,14 +20,14 @@ file:: | and updates the update.py script | | | v Developer maintaining - autocmake.cfg Autocmake + autocmake.yml Autocmake | | | python update.py .. | | | v v CMakeLists.txt (and setup front-end) | | - | python setup | + | python setup or ./setup | | which invokes CMake | v User of the code Makefile (or something else) | @@ -37,7 +38,7 @@ file:: Build/install/test targets Our main motivation to create Autocmake as a CMake framework library and -CMake module composer was to simplify CMake code transfer between codes. We got +CMake module composer is to simplify CMake code transfer between codes. We got tired of manually diffing and copy-pasting boiler-plate CMake code and watching it diverge while maintaining the CMake infrastructure in a growing number of scientific projects which typically have very similar requirements: diff --git a/doc/general/requirements.rst b/doc/general/requirements.rst index 6143cb4..6d27d85 100644 --- a/doc/general/requirements.rst +++ b/doc/general/requirements.rst @@ -3,9 +3,8 @@ Requirements and dependencies ============================= -Autocmake update and test scripts require Python 2.7 or higher. We try to also -support Python 3 (tested with Python 3.4). If the script fails with Python 3, -consider this a bug and please file an issue. +Autocmake update and test scripts require Python 2.7 or higher. We also +support Python 3 (we automatically test with 2.7 and 3.5). The generated setup script runs with Python >= 2.6 (also tested with Python -3.4; probably also lower). +3.5). From 808d0944201601c29663065e16917f4df82f7355 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 28 May 2016 18:08:56 +0200 Subject: [PATCH 114/127] update user faq --- doc/users/faq.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/users/faq.rst b/doc/users/faq.rst index 1efae3e..d9e7ef2 100644 --- a/doc/users/faq.rst +++ b/doc/users/faq.rst @@ -50,5 +50,8 @@ Like this:: $ python setup --cmake-options='"-DTHIS_OPTION=ON -DTHAT_OPTION=OFF"' We use two sets of quotes because the shell swallows one set of them -before passing the arguments to Python. If you do not use two sets -of quotes then the setup command may end up incorrectly saved in `build/setup_command`. +before passing the arguments to Python. Yeah that's not nice, but nothing +we can do about it on the Python side. +If you do not use two sets +of quotes then the setup command may end up +incorrectly saved in `build/setup_command`. From 7c5f82bc8a4fb35f32ef2579aa88ba5e8b2b769d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 15 Jun 2016 22:16:21 +0200 Subject: [PATCH 115/127] add GRASP --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8221195..7d6de4f 100644 --- a/README.md +++ b/README.md @@ -23,5 +23,6 @@ See http://autocmake.org. - [mathlib-tester](https://github.com/miroi/mathlibs-tester) - [Fortran Input Reader](https://github.com/miroi/fortran_input_reader) - [PCMSolver](https://github.com/PCMSolver/pcmsolver) +- GRASP: General-purpose Relativistic Atomic Structure Program If you use Autocmake, please link to your project via a pull request. From dfd6e419460bdd624b3a2cd58630f8e0f0a5ca96 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 20 Jun 2016 15:35:58 +0200 Subject: [PATCH 116/127] first print stdout, then stderr; fixes #174 --- autocmake/configure.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autocmake/configure.py b/autocmake/configure.py index 9ca39b3..74cf7cf 100644 --- a/autocmake/configure.py +++ b/autocmake/configure.py @@ -93,16 +93,21 @@ def run_cmake(command, build_path, default_build_path): stdout_coded, stderr_coded = p.communicate() stdout = stdout_coded.decode('UTF-8') stderr = stderr_coded.decode('UTF-8') + + # print cmake output to screen + print(stdout) + if stderr: sys.stderr.write(stderr) sys.exit(1) - # print cmake output to screen - print(stdout) + # write cmake output to file with open('cmake_output', 'w') as f: f.write(stdout) + # change directory and return os.chdir(topdir) + if 'Configuring incomplete' in stdout: # configuration was not successful if (build_path == default_build_path): From 33ed130d3913d3ee958ff3e0cdc1c40f72e5729e Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 14 Jul 2016 16:58:07 +0200 Subject: [PATCH 117/127] make autocmake/external/__init__.py non-empty to avoid #175 --- autocmake/external/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autocmake/external/__init__.py b/autocmake/external/__init__.py index e69de29..6ff2a5b 100644 --- a/autocmake/external/__init__.py +++ b/autocmake/external/__init__.py @@ -0,0 +1 @@ +# empty - this line is here to avoid problem when fetching empty files from web From 003cff2dff8077a4250dba342b61282b147a8cf1 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 14 Jul 2016 18:19:39 +0200 Subject: [PATCH 118/127] add MRChem to the list of programs which use Autocmake --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d6de4f..91920b0 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,6 @@ See http://autocmake.org. - [Fortran Input Reader](https://github.com/miroi/fortran_input_reader) - [PCMSolver](https://github.com/PCMSolver/pcmsolver) - GRASP: General-purpose Relativistic Atomic Structure Program +- [MRChem](https://github.com/MRChemSoft/mrchem) If you use Autocmake, please link to your project via a pull request. From 6353a2e44067c99e0c1ea835624547dbb6b026f7 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 11:44:58 +0200 Subject: [PATCH 119/127] do not crash if autocmake.yml does not contain any modules --- update.py | 90 +++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/update.py b/update.py index 5cbf0c7..613109c 100644 --- a/update.py +++ b/update.py @@ -57,57 +57,57 @@ def fetch_modules(config, relative_path, download_directory): total=num_sources, width=30) - i = 0 - for t in config['modules']: - for k, v in t.items(): + if 'modules' in config: + i = 0 + for t in config['modules']: + for k, v in t.items(): - d = to_d(v) - for _k, _v in to_d(v).items(): - cleaned_config[_k] = flat_add(cleaned_config[_k], _v) + d = to_d(v) + for _k, _v in to_d(v).items(): + cleaned_config[_k] = flat_add(cleaned_config[_k], _v) - # fetch sources and parse them - if 'source' in d: - for src in to_l(d['source']): - i += 1 + # fetch sources and parse them + if 'source' in d: + for src in to_l(d['source']): + i += 1 - # we download the file - module_name = os.path.basename(src) - if 'http' in src: - path = download_directory - name = 'autocmake_{0}'.format(module_name) - dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) - fetch_url(src, dst) - file_name = dst - fetch_dst_directory = download_directory - else: - if os.path.exists(src): - path = os.path.dirname(src) - name = module_name - file_name = src - fetch_dst_directory = path + # we download the file + module_name = os.path.basename(src) + if 'http' in src: + path = download_directory + name = 'autocmake_{0}'.format(module_name) + dst = os.path.join(download_directory, 'autocmake_{0}'.format(module_name)) + fetch_url(src, dst) + file_name = dst + fetch_dst_directory = download_directory else: - sys.stderr.write("ERROR: {0} does not exist\n".format(src)) - sys.exit(-1) + if os.path.exists(src): + path = os.path.dirname(src) + name = module_name + file_name = src + fetch_dst_directory = path + else: + sys.stderr.write("ERROR: {0} does not exist\n".format(src)) + sys.exit(-1) - # we infer config from the module documentation - # dictionary d overrides the configuration in the module documentation - # this allows to override interpolation inside the module - with open(file_name, 'r') as f: - parsed_config = parse_cmake_module(f.read(), d) - for _k2, _v2 in parsed_config.items(): - if _k2 not in to_d(v): - # we add to clean_config only if the entry does not exist - # in parent autocmake.yml already - # this allows to override - cleaned_config[_k2] = flat_add(cleaned_config[_k2], _v2) + # we infer config from the module documentation + # dictionary d overrides the configuration in the module documentation + # this allows to override interpolation inside the module + with open(file_name, 'r') as f: + parsed_config = parse_cmake_module(f.read(), d) + for _k2, _v2 in parsed_config.items(): + if _k2 not in to_d(v): + # we add to clean_config only if the entry does not exist + # in parent autocmake.yml already + # this allows to override + cleaned_config[_k2] = flat_add(cleaned_config[_k2], _v2) - modules.append(Module(path=path, name=name)) - print_progress_bar(text='- assembling modules:', - done=i, - total=num_sources, - width=30) - - print('') + modules.append(Module(path=path, name=name)) + print_progress_bar(text='- assembling modules:', + done=i, + total=num_sources, + width=30) + print('') return modules, cleaned_config From 0da60d43ebc5906f8897e0b1d70bbbd58b734b0a Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 12:17:15 +0200 Subject: [PATCH 120/127] update documentation after API changes --- doc/developers/bootstrap.rst | 3 + doc/developers/configuration.rst | 202 +++++++++++-------------- doc/developers/customizing-modules.rst | 4 +- doc/developers/example.rst | 81 ++++++---- doc/developers/faq.rst | 72 +++++---- doc/developers/interpolation.rst | 34 +++++ doc/developers/updating-modules.rst | 8 +- doc/general/about.rst | 2 +- doc/general/requirements.rst | 3 + doc/index.rst | 5 +- doc/users/faq.rst | 10 +- 11 files changed, 239 insertions(+), 185 deletions(-) create mode 100644 doc/developers/interpolation.rst diff --git a/doc/developers/bootstrap.rst b/doc/developers/bootstrap.rst index e8e2798..051535b 100644 --- a/doc/developers/bootstrap.rst +++ b/doc/developers/bootstrap.rst @@ -13,6 +13,9 @@ infrastructure files which will be needed to build the project:: $ mkdir cmake # does not have to be called "cmake" - take the name you prefer $ cd cmake $ wget https://github.com/coderefinery/autocmake/raw/master/update.py + $ virtualenv venv + $ source venv/bin/activate + $ pip install pyyaml $ python update.py --self On the MS Windows system, you can use the PowerShell wget-replacement:: diff --git a/doc/developers/configuration.rst b/doc/developers/configuration.rst index 5496923..084a6b8 100644 --- a/doc/developers/configuration.rst +++ b/doc/developers/configuration.rst @@ -1,115 +1,101 @@ .. _autocmake_yml: -Configuring autocmake.cfg +Configuring autocmake.yml ========================= -The script ``autocmake.cfg`` is the high level place where you configure +The script ``autocmake.yml`` is the high level place where you configure your project. Here is an example. We will discuss it in detail further below:: - [project] name: numgrid + min_cmake_version: 2.8 - [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + url_root: https://github.com/coderefinery/autocmake/raw/master/ - [cc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake - - [cxx] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake - - [flags] - source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake - - [rpath] - source: custom/rpath.cmake - - [definitions] - source: https://github.com/coderefinery/autocmake/raw/master/modules/definitions.cmake - - [coverage] - source: https://github.com/coderefinery/autocmake/raw/master/modules/code_coverage.cmake - - [safeguards] - source: https://github.com/coderefinery/autocmake/raw/master/modules/safeguards.cmake - - [default_build_paths] - source: https://github.com/coderefinery/autocmake/raw/master/modules/default_build_paths.cmake - - [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake - - [googletest] - source: https://github.com/coderefinery/autocmake/raw/master/modules/googletest.cmake - - [custom] - source: custom/api.cmake - custom/test.cmake + modules: + - compilers: + - source: + - '%(url_root)modules/fc.cmake' + - '%(url_root)modules/cc.cmake' + - '%(url_root)modules/cxx.cmake' + - flags: + - source: + - '%(url_root)compilers/GNU.CXX.cmake' + - '%(url_root)compilers/Intel.CXX.cmake' + - 'compilers/Clang.CXX.cmake' + - plugins: + - source: + - '%(url_root)modules/ccache.cmake' + - 'custom/rpath.cmake' + - '%(url_root)modules/definitions.cmake' + - '%(url_root)modules/code_coverage.cmake' + - '%(url_root)modules/safeguards.cmake' + - '%(url_root)modules/default_build_paths.cmake' + - '%(url_root)modules/src.cmake' + - '%(url_root)modules/googletest.cmake' + - 'custom/api.cmake' + - 'custom/test.cmake' Name and order of sections -------------------------- -We see that the configuration file has sections. -The only section where the name matters is ``[project]``:: +First we define the project name (here "numgrid"). This section has to be there +and it has to be called "project" (but it does not have to be on top). - [project] - name: numgrid - min_cmake_version: 2.8 +We also have to define ``min_cmake_version``. -This is where we define the project name (here "numgrid"). This section has to -be there and it has to be called "project" (but it does not have to be on top). +The definition ``url_root`` is an interpolation (see :ref:`interpolation`) and +we use it to avoid retyping the same line over and over and to be able to +change it in one place. The explicit name "url_root" has no special meaning to +Autocmake and we could have chosen a different name. -The names of the other sections do not matter to Autocmake. You could name them like this:: +The section ``modules`` is a list of CMake plugins. The names of the list +elements (here "compilers", "flags", and "plugins") does not matter to +Autocmake. We could have called them "one", "two", and "whatever", but it would +not make much sense. It is better to choose names that are meaningful to you +and readers of your code. - [project] - name: numgrid - min_cmake_version: 2.8 - - [one] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake - - [two] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake - - [whatever] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cxx.cmake - -But it would not make much sense. It is better to choose names that are -meaningful to you. - -The order of the sections does matter and the sections will be processed in the -exact order as you specify them in ``autocmake.cfg``. +The order of the elements under ``modules`` does matter and the list will be +processed in the exact order as you specify them in ``autocmake.yml``. Minimal example --------------- -As a minimal example we take an ``autocmake.cfg`` which only contains:: +As a minimal example we take an ``autocmake.yml`` which only contains:: - [project] name: minime min_cmake_version: 2.8 +If you don't have the ``update.py`` script yet, you need to fetch it from the web:: + + $ wget https://github.com/coderefinery/autocmake/raw/master/update.py + First we make sure that the ``update.py`` script is up-to-date and that it has access to all libraries it needs:: $ python update.py --self - creating .gitignore - - fetching lib/config.py - - fetching lib/docopt/docopt.py + - fetching autocmake/configure.py + - fetching autocmake/__init__.py + - fetching autocmake/external/docopt.py + - fetching autocmake/external/__init__.py + - fetching autocmake/generate.py + - fetching autocmake/extract.py + - fetching autocmake/interpolate.py + - fetching autocmake/parse_rst.py + - fetching autocmake/parse_yaml.py - fetching update.py Good. Now we can generate ``CMakeLists.txt`` and the setup script:: - $ python update .. + $ python update.py .. - - parsing autocmake.cfg + - parsing autocmake.yml - generating CMakeLists.txt - generating setup script @@ -147,38 +133,38 @@ the following default options:: --show Show CMake command and exit. --cmake-executable= Set the CMake executable [default: cmake]. --cmake-options= Define options to CMake [default: '']. + --prefix= Set the install path for make install. Build directory. -h --help Show this screen. That's not too bad although currently we cannot do much with this since there are no sources listed, no targets, hence nothing to build. We need to flesh out -``CMakeLists.txt`` by extending ``autocmake.cfg`` -and this is what we will do in the next section. +``CMakeLists.txt`` by extending ``autocmake.yml`` and this is what we will do +in the next section. Assembling CMake plugins ------------------------ -The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.cfg`` +The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.yml`` and using the ``source`` option:: - [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + - compilers: + - source: + - '%(url_root)modules/fc.cmake' + - '%(url_root)modules/cc.cmake' + - '%(url_root)modules/cxx.cmake' -This will download ``fc.cmake`` and include it in ``CMakeLists.txt``. +This will download ``fc.cmake``, ``cc.cmake``, and ``cxx.cmake``, and include +them in ``CMakeLists.txt``, in this order. You can also include local CMake modules, e.g.:: - [rpath] - source: custom/rpath.cmake + - source: + - 'custom/rpath.cmake' -It is also OK to include several modules at once:: - - [flags] - source: https://github.com/coderefinery/autocmake/raw/master/compilers/GNU.CXX.cmake - https://github.com/coderefinery/autocmake/raw/master/compilers/Intel.CXX.cmake - -The modules will be included in the same order as they appear in ``autocmake.cfg``. +It is also OK to include several modules at once as we have seen above. The +modules will be included in the same order as they appear in ``autocmake.yml``. Fetching files without including them in CMakeLists.txt @@ -187,9 +173,9 @@ Fetching files without including them in CMakeLists.txt Sometimes you want to fetch a file without including it in ``CMakeLists.txt``. This can be done with the ``fetch`` option. This is for instance done by the ``git_info.cmake`` module (see -https://github.com/coderefinery/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L11). +https://github.com/coderefinery/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L13). -If ``fetch`` is invoked in ``autocmake.cfg``, then the fetched file is placed +If ``fetch`` is invoked in ``autocmake.yml``, then the fetched file is placed under ``downloaded/``. If ``fetch`` is invoked from within a CMake module documentation (see below), then the fetched file is placed into the same directory as the CMake module file which fetches it. @@ -199,11 +185,11 @@ Generating setup options ------------------------ Options for the setup script can be generated with the ``docopt`` -option. As an example, the following ``autocmake.cfg`` snippet will add a +option. As an example, the following ``autocmake.yml`` snippet will add a ``--something`` flag:: - [my_section] - docopt: --something Enable something [default: False]. + - my_section: + - docopt: "--something Enable something [default: False]." Setting CMake options @@ -213,9 +199,9 @@ Configure-time CMake options can be generated with the ``define`` option. Consider the following example which toggles the CMake variable ``ENABLE_SOMETHING``:: - [my_section] - docopt: --something Enable something [default: False]. - define: '-DENABLE_SOMETHING={0}'.format(arguments['--something']) + - my_section: + - docopt: "--something Enable something [default: False]." + - define: "'-DENABLE_SOMETHING={0}'.format(arguments['--enable-something'])" Setting environment variables @@ -224,33 +210,23 @@ Setting environment variables You can export environment variables at configure-time using the ``export`` option. Consider the following example:: - [cc] - docopt: --cc= C compiler [default: gcc]. - --extra-cc-flags= Extra C compiler flags [default: '']. - export: 'CC=%s' % arguments['--cc'] - define: '-DEXTRA_CFLAGS="%s"' % arguments['--extra-cc-flags'] + docopt: + - "--cc= C compiler [default: gcc]." + - "--extra-cc-flags= Extra C compiler flags [default: '']." + export: "'CC={0}'.format(arguments['--cc'])" + define: "'-DEXTRA_CFLAGS=\"{0}\"'.format(arguments['--extra-cc-flags'])" Auto-generating configurations from the documentation ----------------------------------------------------- -To avoid a boring re-typing of boilerplate ``autocmake.cfg`` code it is possible +To avoid a boring re-typing of boilerplate ``autocmake.yml`` code it is possible to auto-generate configurations from the documentation. This is the case for many core modules which come with own options once you have sourced them. -The lines following ``# autocmake.cfg configuration::`` are -understood by the ``update.py`` script to infer ``autocmake.cfg`` code from the +The lines following ``# autocmake.yml configuration::`` are +understood by the ``update.py`` script to infer ``autocmake.yml`` code from the documentation. As an example consider -https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L25. +https://github.com/coderefinery/autocmake/blob/master/modules/cc.cmake#L20-L26. Here, ``update.py`` will infer the configurations for ``docopt``, ``export``, and ``define``. - - -Overriding documented configurations ------------------------------------- - -Configurable documented defaults can be achieved using interpolations. See for -instance -https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L33-L36. -These can be modified within ``autocmake.cfg`` with a dictionary, e.g.: -https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.cfg#L9 diff --git a/doc/developers/customizing-modules.rst b/doc/developers/customizing-modules.rst index fd6a37b..5122396 100644 --- a/doc/developers/customizing-modules.rst +++ b/doc/developers/customizing-modules.rst @@ -47,8 +47,8 @@ Settings in ``autocmake.yml`` take precedence over settings imported by a sourced module. As an example consider the Boost module which defines and uses -interpolation variables ``major``, ``minor``, and ``patch``, see -https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L52-L54. +interpolation variables ``major``, ``minor``, ``patch``, and ``components``, see +https://github.com/coderefinery/autocmake/blob/master/modules/boost/boost.cmake#L52-L55. The recommended way to customize these is in ``autocmake.yml``, e.g.: https://github.com/coderefinery/autocmake/blob/master/test/boost_libs/cmake/autocmake.yml#L12-L17. diff --git a/doc/developers/example.rst b/doc/developers/example.rst index b07b66a..4d83150 100644 --- a/doc/developers/example.rst +++ b/doc/developers/example.rst @@ -1,6 +1,6 @@ -Example Hello World project +Example hello world project =========================== This is a brief example for the busy and impatient programmer. For a longer @@ -23,40 +23,49 @@ there. This is not necessary for Autocmake but it is a generally good practice:: Now we create ``cmake/`` and fetch ``update.py``:: - $ mkdir cmake - $ cd cmake/ - $ wget https://raw.githubusercontent.com/coderefinery/autocmake/master/update.py + $ mkdir cmake # does not have to be called "cmake" - take the name you prefer + $ cd cmake + $ wget https://github.com/coderefinery/autocmake/raw/master/update.py $ python update.py --self Now from top-level our file tree looks like this:: . |-- cmake - | |-- autocmake.cfg - | |-- lib - | | |-- config.py - | | `-- docopt - | | `-- docopt.py + | |-- autocmake + | | |-- __init__.py + | | |-- configure.py + | | |-- external + | | | |-- __init__.py + | | | `-- docopt.py + | | |-- extract.py + | | |-- generate.py + | | |-- interpolate.py + | | |-- parse_rst.py + | | `-- parse_yaml.py + | |-- autocmake.yml | `-- update.py `-- src |-- feature1.F90 |-- feature2.c `-- main.F90 -Now we edit ``cmake/autocmake.cfg`` to look like this:: +Now we edit ``cmake/autocmake.yml`` to look like this:: - [project] name: hello + min_cmake_version: 2.8 - [fc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/fc.cmake + url_root: https://github.com/coderefinery/autocmake/raw/master/ - [cc] - source: https://github.com/coderefinery/autocmake/raw/master/modules/cc.cmake - - [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake + modules: + - compilers: + - source: + - '%(url_root)modules/fc.cmake' + - '%(url_root)modules/cc.cmake' + - src_support: + - source: + - '%(url_root)modules/src.cmake' What we have specified here is the project name and that we wish Fortran and C support. The ``src.cmake`` module tells CMake to include a ``src/CMakeLists.txt``. @@ -76,20 +85,32 @@ Now we have everything to generate ``CMakeLists.txt`` and a setup script:: $ cd cmake $ python update .. + - parsing autocmake.yml + - assembling modules: [##############################] (3/3) + - generating CMakeLists.txt + - generating setup script + And this is what we got:: . |-- CMakeLists.txt |-- cmake - | |-- autocmake.cfg + | |-- autocmake + | | |-- __init__.py + | | |-- configure.py + | | |-- external + | | | |-- __init__.py + | | | `-- docopt.py + | | |-- extract.py + | | |-- generate.py + | | |-- interpolate.py + | | |-- parse_rst.py + | | `-- parse_yaml.py + | |-- autocmake.yml | |-- downloaded | | |-- autocmake_cc.cmake | | |-- autocmake_fc.cmake | | `-- autocmake_src.cmake - | |-- lib - | | |-- config.py - | | `-- docopt - | | `-- docopt.py | `-- update.py |-- setup `-- src @@ -100,12 +121,12 @@ And this is what we got:: Now we are ready to build:: - $ python setup --fc=gfortran --cc=gcc + $ ./setup --fc=gfortran --cc=gcc - FC=gfortran CC=gcc cmake -DEXTRA_FCFLAGS="''" -DENABLE_FC_SUPPORT="ON" -DEXTRA_CFLAGS="''" -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" None /home/user/example + FC=gfortran CC=gcc cmake -DEXTRA_FCFLAGS="''" -DEXTRA_CFLAGS="''" -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" /home/user/hello - -- The C compiler identification is GNU 4.9.2 - -- The CXX compiler identification is GNU 4.9.2 + -- The C compiler identification is GNU 6.1.1 + -- The CXX compiler identification is GNU 6.1.1 -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info @@ -118,7 +139,7 @@ Now we are ready to build:: -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done - -- The Fortran compiler identification is GNU 4.9.2 + -- The Fortran compiler identification is GNU 6.1.1 -- Check for working Fortran compiler: /usr/bin/gfortran -- Check for working Fortran compiler: /usr/bin/gfortran -- works -- Detecting Fortran compiler ABI info @@ -127,14 +148,14 @@ Now we are ready to build:: -- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes -- Configuring done -- Generating done - -- Build files have been written to: /home/user/example/build + -- Build files have been written to: /home/user/hello/build configure step is done now you need to compile the sources: $ cd build $ make - $ cd build/ + $ cd build $ make Scanning dependencies of target hello.x diff --git a/doc/developers/faq.rst b/doc/developers/faq.rst index 0524dce..0c8e4ef 100644 --- a/doc/developers/faq.rst +++ b/doc/developers/faq.rst @@ -4,6 +4,18 @@ FAQ for developers ================== +Which files do I need to edit? +------------------------------ + +Let us start with files which you normally never edit: ``CMakeLists.txt`` and +``setup`` - these are generated based on ``autocmake.yml``. Have a look in +``autocmake.yml`` and you will see all CMake files which are assembled into +``CMakeLists.txt``. You can edit those files. If you change the order of files +listed in ``autocmake.yml`` or if you add or remove CMake modules, then you +need to rerun the ``update.py`` script to refresh ``CMakeLists.txt`` and +``setup``. + + Autocmake does not do feature X - I really need feature X and a setup flag --X ------------------------------------------------------------------------------ @@ -19,18 +31,22 @@ naming):: cmake/custom/my_feature.cmake -And include this feature to the main ``CMakeLists.txt`` in ``autocmake.cfg``:: +And include this feature to the main ``CMakeLists.txt`` in ``autocmake.yml`` +under the ``modules`` section:: - [my_feature] - source: custom/my_feature.cmake + modules: + - my_feature: + - source: + - custom/my_feature.cmake Now your code is included in the main ``CMakeLists.txt``. Perhaps you also want a setup script flag to toggle the feature:: - [my_feature] - source: custom/my_feature.cmake - docopt: --my-feature Enable my feature [default: False]. - define: '-DENABLE_MY_FEATURE={0}'.format(arguments['--my-feature']) + - my_feature: + - docopt: "--enable-my-feature Enable my feature [default: False]." + - define: "'-DENABLE_MY_FEATURE={0}'.format(arguments['--enable-my-feature'])" + - source: + - custom/my_feature.cmake Implement your ideas, test them, and share them. If your module is portable, good code quality, and of general interest, you can suggest it to be part of @@ -43,17 +59,16 @@ How can I get a setup flag --X that toggles a CMake variable? The following will add a ``--something`` flag which toggles the CMake variable ``ENABLE_SOMETHING``:: - [my_section] - docopt: --something Enable something [default: False]. - define: '-DENABLE_SOMETHING={0}'.format(arguments['--something']) + - my_section: + - docopt: "--something Enable something [default: False]." + - define: "'-DENABLE_SOMETHING={0}'.format(arguments['--enable-something'])" Can I change the name of the setup script? ------------------------------------------ -Yes you can do that in ``autocmake.cfg``. Here we for instance change the name to "configure":: +Yes you can do that in ``autocmake.yml``. Here we for instance change the name to "configure":: - [project] name: myproject min_cmake_version: 2.8 setup_script: configure @@ -70,12 +85,13 @@ realized in Autocmake. Should I include and track also files generated by Autocmake in my repository? ------------------------------------------------------------------------------ -Yes, you probably want to do that. Autocmake generates a number of files which -in principle could be generated at configure- or build-time. However, you -probably do not want the users of your code to run any Autocmake scripts like -``update.py`` to generate the files they need to build the project. The users -of your code will run ``setup`` directly and expect everything to just work -(TM). +Yes, you probably want to do that. Autocmake downloads and generates a number +of files which in principle could be generated at configure- or build-time. +However, you probably do not want the users of your code to run any Autocmake +scripts like ``update.py`` to generate the files they need to build the +project. The users of your code will run ``setup`` directly and typically expect +everything to just work (TM). Note also that the users of your code will +not need to install the pyyaml package. The update.py script is overwriting my CMakeLists.txt and setup, isn't this bad? @@ -93,7 +109,7 @@ But I need to manually edit and customize CMakeLists.txt and setup every time I ----------------------------------------------------------------------------------------------- You typically never need to manually edit and customize ``CMakeLists.txt`` and -``setup`` directly. You can introduce customizations in ``autocmake.cfg`` +``setup`` directly. You can introduce customizations in ``autocmake.yml`` which get assembled into the front-end scripts. @@ -101,19 +117,21 @@ Where is a good place to list my sources and targets? ----------------------------------------------------- As mentioned above ``CMakeLists.txt`` is not a good place because this file is -generated from ``autocmake.cfg`` and your modifications would become +generated from ``autocmake.yml`` and your modifications would become overwritten at some point. A good standard is to organize your sources under ``src/`` and to list your sources and targets in ``src/CMakeLists.txt``. You -can include the latter in ``autocmake.cfg`` using:: +can include the latter in ``autocmake.yml`` using:: - [src] - source: https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake + - my_sources: + - source: + - https://github.com/coderefinery/autocmake/raw/master/modules/src.cmake -If you really don't like to do it this way, you can describe your sources and +If you really do not like to do it this way, you can describe your sources and targets in a custom module in a local file and include it like this:: - [my_sources] - source: custom/my_sources.cmake + - my_sources: + - source: + - custom/my_sources.cmake How can I do some more sophisticated validation of setup flags? @@ -121,7 +139,7 @@ How can I do some more sophisticated validation of setup flags? Sometimes you need to do more sophisticated validation and post-processing of setup flags. This can be done by placing a module called ``extensions.py`` -under ``cmake/`` (or wherever you have ``autocmake.cfg``). +under ``cmake/`` (or wherever you have ``autocmake.yml``). This file should implement a function with the following signature: .. code-block:: python diff --git a/doc/developers/interpolation.rst b/doc/developers/interpolation.rst new file mode 100644 index 0000000..1a2dff8 --- /dev/null +++ b/doc/developers/interpolation.rst @@ -0,0 +1,34 @@ + +.. _interpolation: + +Interpolation +============= + +In a custom extension to the YAML specification you can define and reuse +variables like this (observe how we interpolate ``url_root``, ``major``, +``minor``, ``patch``, and ``components`` in this example):: + + url_root: https://github.com/coderefinery/autocmake/raw/master/ + major: 1 + minor: 48 + patch: 0 + components: "" + fetch: + - "%(url_root)modules/boost/boost_unpack.cmake" + - "%(url_root)modules/boost/boost_userconfig.cmake" + - "%(url_root)modules/boost/boost_configure.cmake" + - "%(url_root)modules/boost/boost_build.cmake" + - "%(url_root)modules/boost/boost_install.cmake" + - "%(url_root)modules/boost/boost_headers.cmake" + - "%(url_root)modules/boost/boost_cleanup.cmake" + - "http://sourceforge.net/projects/boost/files/boost/%(major).%(minor).%(patch)/boost_%(major)_%(minor)_%(patch).zip" + docopt: + - "--boost-headers= Include directories for Boost [default: '']." + - "--boost-libraries= Library directories for Boost [default: '']." + - "--build-boost= Deactivate Boost detection and build on-the-fly [default: OFF]." + define: + - "'-DBOOST_INCLUDEDIR=\"{0}\"'.format(arguments['--boost-headers'])" + - "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])" + - "'-DFORCE_CUSTOM_BOOST={0}'.format(arguments['--build-boost'])" + - "'-DBOOST_MINIMUM_REQUIRED=\"%(major).%(minor).%(patch)\"'" + - "'-DBOOST_COMPONENTS_REQUIRED=\"%(components)\"'" diff --git a/doc/developers/updating-modules.rst b/doc/developers/updating-modules.rst index 7fdd8be..834aeb7 100644 --- a/doc/developers/updating-modules.rst +++ b/doc/developers/updating-modules.rst @@ -20,11 +20,11 @@ Sometimes you may want to avoid using the latest version of a CMake module and rather fetch an older version, for example with the hash ``abcd123``. To achieve this, instead of:: - [foo] - source: https://github.com/coderefinery/autocmake/raw/master/modules/foo.cmake + - my_feature: + - source: https://github.com/coderefinery/autocmake/raw/master/modules/foo.cmake pin the version to ``abcd123`` (you do not need to specify the full Git hash, a unique beginning will do):: - [foo] - source: https://github.com/coderefinery/autocmake/raw/abcd123/modules/foo.cmake + - my_feature: + - source: https://github.com/coderefinery/autocmake/raw/abcd123/modules/foo.cmake diff --git a/doc/general/about.rst b/doc/general/about.rst index ea6cb11..7a75ac2 100644 --- a/doc/general/about.rst +++ b/doc/general/about.rst @@ -38,7 +38,7 @@ file:: Build/install/test targets Our main motivation to create Autocmake as a CMake framework library and -CMake module composer is to simplify CMake code transfer between codes. We got +CMake module composer is to simplify CMake code transfer between programs. We got tired of manually diffing and copy-pasting boiler-plate CMake code and watching it diverge while maintaining the CMake infrastructure in a growing number of scientific projects which typically have very similar requirements: diff --git a/doc/general/requirements.rst b/doc/general/requirements.rst index 6d27d85..453c3a1 100644 --- a/doc/general/requirements.rst +++ b/doc/general/requirements.rst @@ -8,3 +8,6 @@ support Python 3 (we automatically test with 2.7 and 3.5). The generated setup script runs with Python >= 2.6 (also tested with Python 3.5). + +To generate ``CMakeLists.txt`` and the ``setup`` script, Autocmake +requires the pyyaml package. diff --git a/doc/index.rst b/doc/index.rst index 5356a95..e28c430 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,7 +1,7 @@ -Autocmake (this documentation is outdated, see stable-0.x branch) -================================================================= +Autocmake +========= General @@ -27,6 +27,7 @@ For developers who use Autocmake developers/example.rst developers/customizing-modules.rst developers/updating-modules.rst + developers/interpolation.rst For users of projects which use Autocmake diff --git a/doc/users/faq.rst b/doc/users/faq.rst index d9e7ef2..68d0822 100644 --- a/doc/users/faq.rst +++ b/doc/users/faq.rst @@ -49,9 +49,7 @@ Like this:: $ python setup --cmake-options='"-DTHIS_OPTION=ON -DTHAT_OPTION=OFF"' -We use two sets of quotes because the shell swallows one set of them -before passing the arguments to Python. Yeah that's not nice, but nothing -we can do about it on the Python side. -If you do not use two sets -of quotes then the setup command may end up -incorrectly saved in `build/setup_command`. +We use two sets of quotes because the shell swallows one set of them before +passing the arguments to Python. Yeah that's not nice, but nothing we can do +about it on the Python side. If you do not use two sets of quotes then the +setup command may end up incorrectly saved in `build/setup_command`. From 5dba22b8e791a9fdc34d1ad7efa6c27bb1099be2 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 14:58:52 +0200 Subject: [PATCH 121/127] sphinx doc version automatically follows __version__ --- doc/conf.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ef2d51e..45ebae7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -19,6 +19,9 @@ import shlex sys.path.append(os.path.relpath(os.path.abspath('.'))) import extract_rst +sys.path.append(os.path.relpath(os.path.abspath('..'))) +from autocmake import __version__ as _version + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -59,10 +62,10 @@ author = u'Radovan Bast, Jonas Juselius, and contributors' # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = '1.0' # The full version, including alpha/beta/rc tags. -release = '1.0.0-alpha-x' +release = _version +# The short X.Y version. +version = '.'.join(release.split('.')[0:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From d9287cf2a507c3c439831dd71b872ae881fd7675 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 15:04:00 +0200 Subject: [PATCH 122/127] rm unused import --- doc/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 45ebae7..713db0f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -14,7 +14,6 @@ import sys import os -import shlex sys.path.append(os.path.relpath(os.path.abspath('.'))) import extract_rst From 8ddd1a5f051c0676d81d55da9b4875911c879a06 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 15:09:30 +0200 Subject: [PATCH 123/127] rearrange --- doc/conf.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 713db0f..e32841a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,16 +15,14 @@ import sys import os -sys.path.append(os.path.relpath(os.path.abspath('.'))) -import extract_rst - -sys.path.append(os.path.relpath(os.path.abspath('..'))) -from autocmake import __version__ as _version - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('.')) +import extract_rst + +sys.path.insert(0, os.path.abspath('..')) +from autocmake import __version__ as _version # -- General configuration ------------------------------------------------ From 69927f195d29aaa3f3c3c8c649914869f9154d2d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Jul 2016 15:11:43 +0200 Subject: [PATCH 124/127] dry --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index e32841a..8eb64ba 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -228,7 +228,7 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'Autocmake.tex', u'Autocmake Documentation', - u'Radovan Bast and Jonas Juselius', 'manual'), + author, 'manual'), ] # The name of an image file (relative to this directory) to place at the top of From 2374f5bbedd096e491369776c07a98f688993bdd Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 23 Jul 2016 16:01:46 +0200 Subject: [PATCH 125/127] give nice error message if Python is 2.6; fixes #176 --- update.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/update.py b/update.py index 613109c..9508edd 100644 --- a/update.py +++ b/update.py @@ -4,6 +4,11 @@ import os import sys +if sys.version_info[0] == 2 and sys.version_info[1] < 7: + sys.stderr.write("ERROR: update.py requires at least Python 2.7\n") + sys.exit(-1) + + AUTOCMAKE_GITHUB_URL = 'https://github.com/coderefinery/autocmake/raw/master/' From 08d0a6837b3cfe87abc48c948e714bac60f9b904 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Sat, 23 Jul 2016 16:02:40 +0200 Subject: [PATCH 126/127] use position in format string --- autocmake/interpolate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocmake/interpolate.py b/autocmake/interpolate.py index aeb54ed..0a95793 100644 --- a/autocmake/interpolate.py +++ b/autocmake/interpolate.py @@ -3,7 +3,7 @@ def replace(s, d): if isinstance(s, str): for var in findall(r"%\(([A-Za-z0-9_]*)\)", s): - s = s.replace("%({})".format(var), str(d[var])) + s = s.replace("%({0})".format(var), str(d[var])) return s From 8ba73f5a1d4c7e403eccf846076dda9af7435d6d Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Wed, 24 Aug 2016 08:12:55 +0200 Subject: [PATCH 127/127] set Fortran OMP flags only if OpenMP_Fortran_FLAGS are not set; fixes #177 also fix Intel Fortran OMP depending on the version of the compiler thanks to Lori A. Burns for the changeset --- modules/omp.cmake | 49 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/modules/omp.cmake b/modules/omp.cmake index 1719afe..f33dd91 100644 --- a/modules/omp.cmake +++ b/modules/omp.cmake @@ -21,25 +21,6 @@ option(ENABLE_OPENMP "Enable OpenMP parallelization" OFF) if(ENABLE_OPENMP) - if(DEFINED CMAKE_Fortran_COMPILER_ID) - # we do this in a pedestrian way because the Fortran support is relatively recent - if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp") - endif() - if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -openmp") - endif() - if(CMAKE_Fortran_COMPILER_ID MATCHES PGI) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp") - endif() - if(CMAKE_Fortran_COMPILER_ID MATCHES XL) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp") - endif() - if(CMAKE_Fortran_COMPILER_ID MATCHES Cray) - # do nothing in this case - endif() - set(OPENMP_FOUND TRUE) - endif() if(NOT OPENMP_FOUND) find_package(OpenMP) @@ -53,5 +34,35 @@ if(ENABLE_OPENMP) if(DEFINED CMAKE_CXX_COMPILER_ID) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() + if(DEFINED CMAKE_Fortran_COMPILER_ID) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") + endif() + endif() + + if(DEFINED CMAKE_Fortran_COMPILER_ID AND NOT DEFINED OpenMP_Fortran_FLAGS) + # we do this in a pedestrian way because the Fortran support is relatively recent + if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp") + endif() + if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) + if(WIN32) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Qopenmp") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND + "${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -openmp") + else() + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopenmp") + endif() + endif() + if(CMAKE_Fortran_COMPILER_ID MATCHES PGI) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp") + endif() + if(CMAKE_Fortran_COMPILER_ID MATCHES XL) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp") + endif() + if(CMAKE_Fortran_COMPILER_ID MATCHES Cray) + # do nothing in this case + endif() + set(OPENMP_FOUND TRUE) endif() endif()