Repository: conan-io/conan-center-index

Issue:
[package] libx264/20190605: build fail compiler.version setting required for vcvars not defined

### Package and Environment Details
  * Package Name/Version: **libx264/20190605**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Mingw GCC 8.1**
  * Docker image: **conanio/gcc8.1**
  * Conan version: **conan 1.21.0**
  * Python version: **Python 3.7.5**


### Conan profile
```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=14
compiler.exception=seh
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.version=8.1
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_CMAKE_GENERATOR=MinGW Makefiles
```

```
[requires]
libx264/20190605
```


### Steps to reproduce
Change `libx264/20190605@bincrafters/stable` to `libx264/20190605` build fail.
Failed in

```
ConanException: compiler.version setting required for vcvars not defined
```
Because of new `conanfile.py` without first determining whether it is `_is_msvc`.
In no `Visual Studio` environment, `tools.vcvars` due to the error.


### Fixed method
in line 94, change to:
```
    def build(self):
        if self._is_msvc:
            with tools.vcvars(self.settings):
                autotools = self._configure_autotools()
                autotools.make()
        else:
            autotools = self._configure_autotools()
            autotools.make()

    def package(self):
        if self._is_msvc:
            with tools.vcvars(self.settings):
                autotools = self._configure_autotools()
                autotools.install()
        else:
            autotools = self._configure_autotools()
            autotools.install()
        self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses')
        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
```


### Logs
<details><summary>Click to expand log</summary>

```
libx264/20190605: Applying build-requirement: nasm/2.14
libx264/20190605: Applying build-requirement: msys2/20190524
libx264/20190605: WARN: Build folder is dirty, removing it: C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
libx264/20190605: Copying sources to build folder
libx264/20190605: Building your package in C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
libx264/20190605: Generator txt created conanbuildinfo.txt
libx264/20190605: Calling build()
libx264/20190605: 
libx264/20190605: ERROR: Package '1a9b746db3232276ada4cf64b16512ba901fcf09' build failed
libx264/20190605: WARN: Build folder C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
ERROR: libx264/20190605: Error in build() method, line 95
	with tools.vcvars(self.settings):
	ConanException: compiler.version setting required for vcvars not defined

```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/libx264/all/conanfile.py b/recipes/libx264/all/conanfile.py
--- a/recipes/libx264/all/conanfile.py
+++ b/recipes/libx264/all/conanfile.py
@@ -90,12 +90,12 @@ def _configure_autotools(self):
         return self._autotools
 
     def build(self):
-        with tools.vcvars(self.settings):
+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
             autotools = self._configure_autotools()
             autotools.make()
 
     def package(self):
-        with tools.vcvars(self.settings):
+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
             autotools = self._configure_autotools()
             autotools.install()
         self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses')


Test patch: