diff --git a/conda_build/main_build.py b/conda_build/main_build.py index ac980750c8..46b14dbebb 100644 --- a/conda_build/main_build.py +++ b/conda_build/main_build.py @@ -223,7 +223,6 @@ def execute(args, parser): if not isdir(d): makedirs(d) update_index(d) - index = build.get_build_index(clear_cache=True) already_built = [] to_build_recursive = [] @@ -258,6 +257,7 @@ def execute(args, parser): m = render_recipe(recipe_dir, no_download_source=False) if m.get_value('build/noarch_python'): config.noarch = True + if args.check and len(args.recipe) > 1: print(m.path) m.check_fields() diff --git a/conda_build/windows.py b/conda_build/windows.py index c1d0d12415..0dd1ba762a 100644 --- a/conda_build/windows.py +++ b/conda_build/windows.py @@ -21,9 +21,8 @@ PROGRAM_FILES_PATH = os.environ['ProgramFiles'] # Note that we explicitly want "Program Files" and not "Program Files (x86)" -WIN_SDK_BAT_PATH = os.path.join(os.path.abspath(os.sep), - 'Program Files', 'Microsoft SDKs', - 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd') +WIN_SDK_BAT_PATH = os.path.join(PROGRAM_FILES_PATH.replace(" (x86)", ""), + 'Microsoft SDKs', 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd') VS_TOOLS_PY_LOCAL_PATH = os.path.join( os.getenv('localappdata', os.path.abspath(os.sep)), 'Programs', 'Common', 'Microsoft', 'Visual C++ for Python', '9.0', @@ -111,17 +110,19 @@ def msvc_env_cmd(bits, override=None): def build_vcvarsall_cmd(cmd, arch=arch_selector): return 'call "{cmd}" {arch}'.format(cmd=cmd, arch=arch) - msvc_env_lines.append('set VS_VERSION="{}"'.format(version)) - msvc_env_lines.append('set VS_MAJOR="{}"'.format(version.split('.')[0])) - msvc_env_lines.append('set VS_YEAR="{}"'.format(VS_VERSION_STRING[version][-4:])) - msvc_env_lines.append('set CMAKE_GENERATOR="{}"'.format(VS_VERSION_STRING[version] + + msvc_env_lines.append('set "VS_VERSION={}"'.format(version)) + msvc_env_lines.append('set "VS_MAJOR={}"'.format(version.split('.')[0])) + msvc_env_lines.append('set "VS_YEAR={}"'.format(VS_VERSION_STRING[version][-4:])) + msvc_env_lines.append('set "CMAKE_GENERATOR={}"'.format(VS_VERSION_STRING[version] + {64: ' Win64', 32: ''}[bits])) + # tell msys2 to ignore path conversions for issue-causing windows-style flags in build + # See https://github.com/conda-forge/icu-feedstock/pull/5 + msvc_env_lines.append('set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out;%MSYS2_ARG_CONV_EXCL%"') + msvc_env_lines.append('set "MSYS2_ENV_CONV_EXCL=CL"') if version == '10.0': - # Unfortunately, the Windows SDK takes a different command format for - # the arch selector - debug is default so explicitly set 'Release' - win_sdk_arch = '/x86 /Release' if bits == 32 else '/x64 /Release' + win_sdk_arch = '/Release /x86' if bits == 32 else '/Release /x64' win_sdk_cmd = build_vcvarsall_cmd(WIN_SDK_BAT_PATH, arch=win_sdk_arch) - + # Always call the Windows SDK first - if VS 2010 exists but was # installed using the broken installer then it will try and call the # vcvars script, which will fail but NOT EXIT 1. To work around this, @@ -129,12 +130,12 @@ def build_vcvarsall_cmd(cmd, arch=arch_selector): # will overwrite any environemnt variables it needs, if necessary. msvc_env_lines.append(win_sdk_cmd) msvc_env_lines.append(build_vcvarsall_cmd(vcvarsall_vs_path)) + elif version == '9.0': error1 = 'if errorlevel 1 {}' # First, check for Microsoft Visual C++ Compiler for Python 2.7 msvc_env_lines.append(build_vcvarsall_cmd(VS_TOOLS_PY_LOCAL_PATH)) - msvc_env_lines.append(error1.format( build_vcvarsall_cmd(VS_TOOLS_PY_COMMON_PATH))) # The Visual Studio 2008 Express edition does not properly contain @@ -149,6 +150,7 @@ def build_vcvarsall_cmd(cmd, arch=arch_selector): else: msvc_env_lines.append(error1.format( build_vcvarsall_cmd(vcvarsall_vs_path))) + else: # Visual Studio 14 or otherwise msvc_env_lines.append(build_vcvarsall_cmd(vcvarsall_vs_path)) diff --git a/tests/test-recipes/metadata/_cmake_generator/CMakeLists.txt b/tests/test-recipes/metadata/_cmake_generator/CMakeLists.txt new file mode 100644 index 0000000000..33670a0b7d --- /dev/null +++ b/tests/test-recipes/metadata/_cmake_generator/CMakeLists.txt @@ -0,0 +1,5 @@ +PROJECT(HELLO) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +add_executable(hello hello.c) diff --git a/tests/test-recipes/metadata/_cmake_generator/bld.bat b/tests/test-recipes/metadata/_cmake_generator/bld.bat new file mode 100644 index 0000000000..c4346a1d0d --- /dev/null +++ b/tests/test-recipes/metadata/_cmake_generator/bld.bat @@ -0,0 +1,7 @@ +where cl.exe +where link.exe +:: maybe informative for MinGW? +where gcc.exe + +cmake -G "%CMAKE_GENERATOR:"=%" "%RECIPE_DIR%" +cmake --build . --config Release diff --git a/tests/test-recipes/metadata/_cmake_generator/build.sh b/tests/test-recipes/metadata/_cmake_generator/build.sh new file mode 100644 index 0000000000..d1e4539764 --- /dev/null +++ b/tests/test-recipes/metadata/_cmake_generator/build.sh @@ -0,0 +1,2 @@ +cmake -G "$CMAKE_GENERATOR" $RECIPE_DIR +cmake --build . --config Release diff --git a/tests/test-recipes/metadata/_cmake_generator/hello.c b/tests/test-recipes/metadata/_cmake_generator/hello.c new file mode 100644 index 0000000000..7c1035f664 --- /dev/null +++ b/tests/test-recipes/metadata/_cmake_generator/hello.c @@ -0,0 +1,5 @@ +#include + +int main() { + printf("Hello world!\n"); +} diff --git a/tests/test-recipes/metadata/_cmake_generator/meta.yaml b/tests/test-recipes/metadata/_cmake_generator/meta.yaml new file mode 100644 index 0000000000..09ebfd4f32 --- /dev/null +++ b/tests/test-recipes/metadata/_cmake_generator/meta.yaml @@ -0,0 +1,7 @@ +package: + name: conda-build-test-cmake-generator + version: 1.0 + +requirements: + build: + - cmake diff --git a/tests/test_build_recipes.py b/tests/test_build_recipes.py index 7cee34d64f..6ff5515325 100644 --- a/tests/test_build_recipes.py +++ b/tests/test_build_recipes.py @@ -78,6 +78,20 @@ def test_checkout_tool_as_dependency(): shutil.rmtree(tmpdir) +platforms = ["64" if sys.maxsize > 2**32 else "32"] +if sys.platform=="win32": + platforms = set(["32",] + platforms) + compilers = ["2.7", "3.4", "3.5"] +else: + compilers = [".".join([str(sys.version_info.major), str(sys.version_info.minor)])] + +@pytest.mark.parametrize("platform", platforms) +@pytest.mark.parametrize("target_compiler", compilers) +def test_cmake_generator(platform, target_compiler): + # TODO: need a better way to specify compiler more directly on win + cmd = 'conda build --no-anaconda-upload {}/_cmake_generator --python={}'.format(metadata_dir, target_compiler) + subprocess.check_call(cmd.split()) + @pytest.mark.skipif(sys.platform=="win32", reason="No windows symlinks") @@ -89,6 +103,7 @@ def test_symlink_fail(): error = error.decode('utf-8') assert error.count("Error") == 6 + @pytest.mark.skipif(sys.platform=="win32", reason="Windows doesn't show this error") def test_broken_conda_meta(): diff --git a/tests/test_win_vs_activate.py b/tests/test_win_vs_activate.py index 106fe4f29e..f24b203b7b 100644 --- a/tests/test_win_vs_activate.py +++ b/tests/test_win_vs_activate.py @@ -96,10 +96,10 @@ def test_activation(bits, compiler): # this is effectively the test condition for all below tests. with open('tmp_call.bat', "w") as f: f.write(msvc_env_cmd(bits, compiler_version)) - f.write('\nif not %VS_VERSION% == "{}" exit /b 1'.format(compiler_version)) - f.write('\nif not %VS_MAJOR% == "{}" exit /b 1'.format(compiler_version.split('.')[0])) - f.write('\nif not %VS_YEAR% == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version][-4:])) - f.write('\nif not %CMAKE_GENERATOR% == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version] + + f.write('\nif not "%VS_VERSION%" == "{}" exit /b 1'.format(compiler_version)) + f.write('\nif not "%VS_MAJOR%" == "{}" exit /b 1'.format(compiler_version.split('.')[0])) + f.write('\nif not "%VS_YEAR%" == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version][-4:])) + f.write('\nif not "%CMAKE_GENERATOR%" == "{}" exit /b 1'.format(VS_VERSION_STRING[compiler_version] + {64: ' Win64', 32: ''}[bits])) try: subprocess.check_call(['cmd.exe', '/C', 'tmp_call.bat'], shell=True)