Skip to content

Commit

Permalink
conan-io#50 Build Visual Studio 14
Browse files Browse the repository at this point in the history
- Add conanmsvc14 image
- Update docker compose to build windows image
- Update build script to support Windows

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Oct 3, 2018
1 parent 9397460 commit c30bf67
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 7 deletions.
17 changes: 10 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import logging
import subprocess
import platform


class ConanDockerTools(object):
Expand Down Expand Up @@ -40,15 +41,17 @@ def _get_variables(self):
os.environ["DOCKER_USERNAME"] = docker_username
os.environ["DOCKER_BUILD_TAG"] = docker_build_tag
gcc_versions = os.getenv("GCC_VERSIONS").split(",") if os.getenv("GCC_VERSIONS") else []
clang_versions = os.getenv("CLANG_VERSIONS").split(",") \
if os.getenv("CLANG_VERSIONS") else []
clang_versions = os.getenv("CLANG_VERSIONS").split(",") if os.getenv("CLANG_VERSIONS") else []
visual_versions = os.getenv("VISUAL_VERSIONS").split(",") if os.getenv("VISUAL_VERSIONS") else []
sudo_command = os.getenv("SUDO_COMMAND") or (("sudo" if platform.system() == "Linux" and os.geteuid() != 0) else "")

Variables = collections.namedtuple("Variables", "docker_upload, docker_password, "
"docker_username, gcc_versions, "
"clang_versions, build_server, docker_build_tag, "
"docker_archs")
"clang_versions, visual_versions, build_server, "
"docker_build_tag, docker_archs, sudo_command")
return Variables(docker_upload, docker_password, docker_username,
gcc_versions, clang_versions, build_server, docker_build_tag, docker_archs)
gcc_versions, clang_versions, visual_versions, build_server,
docker_build_tag, docker_archs, sudo_command)

def build(self, service):
"""Call docker build to create a image
Expand Down Expand Up @@ -81,8 +84,8 @@ def test(self, arch, compiler_name, compiler_version, service):
libcxx_list = ["libstdc++"] if compiler_name == "gcc" else ["libstdc++", "libc++"]
subprocess.check_call("docker run -t -d --name %s %s" % (service, image), shell=True)

subprocess.check_call("docker exec %s sudo pip -q install -U conan" % service, shell=True)
subprocess.check_call("docker exec %s sudo pip -q install -U conan_package_tools" % service, shell=True)
subprocess.check_call("docker exec %s %s pip -q install -U conan" % (service, self.variables.sudo_command), shell=True)
subprocess.check_call("docker exec %s %s pip -q install -U conan_package_tools" % (service, self.variables.sudo_command), shell=True)
subprocess.check_call("docker exec %s conan user" % service, shell=True)

subprocess.check_call("docker exec %s conan remote add conan-community "
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,10 @@ services:
dockerfile: Dockerfile
image: "${DOCKER_USERNAME}/conan_server:${DOCKER_BUILD_TAG}"
container_name: conan_server
conanmsvc14:
build:
context: msvc_14
dockerfile: Dockerfile
image: "${DOCKER_USERNAME}/conanmsvc14:${DOCKER_BUILD_TAG}"
container_name: conanmsvc14
tty: true
8 changes: 8 additions & 0 deletions msvc_14/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
.idea/

*.md
*.py
*.yml
**/*.sh
**/*.bat
34 changes: 34 additions & 0 deletions msvc_14/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM microsoft/windowsservercore:1803

LABEL maintainer="Luis Martinez de Bartolome <luism@jfrog.com>"

ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\buildtools.exe

RUN C:\TEMP\buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.Windows10SDK.17134 `
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop `
--add Microsoft.VisualStudio.Component.VC.140 `
--add Microsoft.VisualStudio.Component.VC.ATL `
--add Microsoft.VisualStudio.Component.VC.ATLMFC `
--add Microsoft.VisualStudio.Component.VC.CLI.Support `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0

SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]

ENV chocolateyUseWindowsCompression=false

RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

RUN choco install --yes python3 --params '"/InstallDir:C:\tools\python3"'

RUN pip install win-unicode-console

RUN pip install `
conan `
conan_package_tools `
--upgrade --force-reinstall --no-cache

WORKDIR "C:\Users\ContainerAdministrator"
1 change: 1 addition & 0 deletions msvc_14/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build --no-cache -t lasote/conanmsvc14 .
1 change: 1 addition & 0 deletions msvc_14/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run --rm -v %USERPROFILE%/.conan/data:C:/Users/ContainerAdministrator/.conan/data -it lasote/conanmsvc14
8 changes: 8 additions & 0 deletions msvc_14/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docker run -t -d --name conanmsvc14 lasote/conanmsvc14 && \
docker exec conanmsvc14 pip install -U conan_package_tools && \
docker exec conanmsvc14 pip install -U conan && \
docker exec conanmsvc14 conan user && \
docker exec conanmsvc14 conan install gtest/1.8.0@lasote/stable -s arch=x86_64 -s compiler="Visual Studio" -s compiler.version=14 -s compiler.runtime=MD --build && \
docker exec conanmsvc14 conan install gtest/1.8.0@lasote/stable -s arch=x86 -s compiler="Visual Studio" -s compiler.version=14 -s compiler.runtime=MD --build && \
docker stop conanmsvc14 && \
docker rm conanmsvc14

0 comments on commit c30bf67

Please sign in to comment.