From 7161d75691a2e65fa978459b287c601b9f7f2b58 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Fri, 8 Dec 2017 11:00:33 -0500 Subject: [PATCH 1/2] Add .default.nix and .envrc --- .default.nix | 19 +++++++++++++++++++ .envrc | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 .default.nix create mode 100644 .envrc diff --git a/.default.nix b/.default.nix new file mode 100644 index 0000000..a49ec1f --- /dev/null +++ b/.default.nix @@ -0,0 +1,19 @@ +with import {}; { + autocmakeEnv = stdenv.mkDerivation { + name = "Autocmake"; + buildInputs = [ + atlas + ccache + clang + cmake + doxygen + gfortran + liblapack + openmpi + python35Packages.pep8 + python35Packages.pytest + python35Packages.pyyaml + zlib + ]; + }; +} diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..016678b --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +use nix .default.nix +export SOURCE_DATE_EPOCH=$(date +%s) +dir_hash=autocmake-$(echo -n autocmake | shasum | cut -d ' ' -f 1) +direnv_layout_dir=$XDG_CACHE_HOME/direnv/layouts/$dir_hash +layout python `type -P python` --system-site-packages +pip install -r requirements.txt +export NINJA_STATUS="[Built edge %f of %t in %e sec]" From 0a8e7eb3258583b5aed9925678ddd20be80fe861 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Fri, 8 Dec 2017 11:40:56 -0500 Subject: [PATCH 2/2] Get setup to reproduce use of bare CMake --- .gitignore | 1 + autocmake/configure.py | 32 +------------------------------- autocmake/generate.py | 4 ++-- modules/cc.cmake | 3 +-- modules/cxx.cmake | 3 +-- modules/fc.cmake | 3 +-- modules/fc_optional.cmake | 3 +-- 7 files changed, 8 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index acb6d6b..c1109a1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ test/*/cmake/update.py test/*/cmake/autocmake/ test/*/cmake/downloaded/ test/*/setup +test/*/cmake_output # generated by doc/extract_rst.py doc/module-reference.rst diff --git a/autocmake/configure.py b/autocmake/configure.py index 3a3e4fd..d658b1f 100644 --- a/autocmake/configure.py +++ b/autocmake/configure.py @@ -48,34 +48,6 @@ def setup_build_path(build_path): os.makedirs(build_path, 0o755) -def test_adapt_cmake_command_to_platform(): - - cmake_command = "FC=foo CC=bar CXX=RABOOF cmake -DTHIS -DTHAT='this and that cmake' .." - res = adapt_cmake_command_to_platform(cmake_command, 'linux') - assert res == cmake_command - res = adapt_cmake_command_to_platform(cmake_command, 'win32') - assert res == "set FC=foo && set CC=bar && set CXX=RABOOF && cmake -DTHIS -DTHAT='this and that cmake' .." - - cmake_command = "cmake -DTHIS -DTHAT='this and that cmake' .." - res = adapt_cmake_command_to_platform(cmake_command, 'linux') - assert res == cmake_command - res = adapt_cmake_command_to_platform(cmake_command, 'win32') - assert res == cmake_command - - -def adapt_cmake_command_to_platform(cmake_command, platform): - """ - Adapt CMake command to MS Windows platform. - """ - if platform == 'win32': - pos = cmake_command.find('cmake') - s = ['set {0} &&'.format(e) for e in cmake_command[:pos].split()] - s.append(cmake_command[pos:]) - return ' '.join(s) - else: - return cmake_command - - def run_cmake(command, build_path, default_build_path): """ Execute CMake command. @@ -84,7 +56,6 @@ def run_cmake(command, build_path, default_build_path): from shutil import rmtree topdir = os.getcwd() - os.chdir(build_path) p = Popen(command, shell=True, stdin=PIPE, @@ -164,8 +135,7 @@ def configure(root_directory, build_path, cmake_command, only_show): if not only_show: setup_build_path(build_path) - cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform) - + cmake_command += ' -B' + build_path print('{0}\n'.format(cmake_command)) if only_show: sys.exit(0) diff --git a/autocmake/generate.py b/autocmake/generate.py index d64f902..244f647 100644 --- a/autocmake/generate.py +++ b/autocmake/generate.py @@ -20,7 +20,7 @@ def gen_cmake_command(config): 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(" 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']:") @@ -110,7 +110,7 @@ def gen_setup(config, default_build_type, relative_path, setup_script_name): 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("cmake_command = '{0} -H{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'])") diff --git a/modules/cc.cmake b/modules/cc.cmake index 343ca3e..ec1248c 100644 --- a/modules/cc.cmake +++ b/modules/cc.cmake @@ -25,8 +25,7 @@ # 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'])" +# define: "'-DCMAKE_C_COMPILER={0} -DEXTRA_CFLAGS=\"{1}\"'.format(arguments['--cc'], arguments['--extra-cc-flags'])" if(NOT DEFINED CMAKE_C_COMPILER_ID) message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") diff --git a/modules/cxx.cmake b/modules/cxx.cmake index faa07d0..7ddc936 100644 --- a/modules/cxx.cmake +++ b/modules/cxx.cmake @@ -25,8 +25,7 @@ # 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'])" +# define: "'-DCMAKE_CXX_COMPILER={0} -DEXTRA_CXXFLAGS=\"{1}\"'.format(arguments['--cxx'], arguments['--extra-cxx-flags'])" if(NOT DEFINED CMAKE_CXX_COMPILER_ID) message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID variable is not defined!") diff --git a/modules/fc.cmake b/modules/fc.cmake index ed1d010..68a78bf 100644 --- a/modules/fc.cmake +++ b/modules/fc.cmake @@ -29,8 +29,7 @@ # 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'])" +# define: "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])" set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules) include_directories(${PROJECT_BINARY_DIR}/modules) diff --git a/modules/fc_optional.cmake b/modules/fc_optional.cmake index 5af2002..e7b8aa9 100644 --- a/modules/fc_optional.cmake +++ b/modules/fc_optional.cmake @@ -35,9 +35,8 @@ # - "--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'])" +# - "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])" # - "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])" option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON)