Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw: split windows and linux recipes #8307

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions recipes/mingw-w64/8.1/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sources:
"8.1":
posix:
seh:
url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"
sha256: "853970527b5de4a55ec8ca4d3fd732c00ae1c69974cc930c82604396d43e79f8"
sjlj:
url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z"
sha256: "0e994b33dc92576ba92377e2c18c0f96a04c684fa2d7a3546890819964275a1f"
win32:
seh:
url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z"
sha256: "73797b9a1d0b007dbdd6f010e6064dc0aa4df835b042f6947f73a3bf9cc348c5"
sjlj:
url: "https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z"
sha256: "e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa"
82 changes: 82 additions & 0 deletions recipes/mingw-w64/8.1/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import os
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration


class MingwConan(ConanFile):
name = "mingw-w64"
description = "MinGW is a contraction of Minimalist GNU for Windows"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://mingw-w64.org/doku.php"
license = "ZPL-2.1", "MIT", "GPL-2.0-or-later"
topics = ("gcc", "gnu", "unix", "mingw32", "binutils")
settings = "os", "arch"
options = {"threads": ["posix", "win32"], "exception": ["seh", "sjlj"]}
default_options = {"threads": "posix", "exception": "seh"}

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def validate(self):
valid_os = ["Windows"]
if str(self.settings.os) not in valid_os:
raise ConanInvalidConfiguration("MinGW {} is only supported for the following operating systems: {}"
.format(self.version, valid_os))
valid_arch = ["x86_64"]
if str(self.settings.arch) not in valid_arch:
raise ConanInvalidConfiguration("MinGW {} is only supported for the following architectures on {}: {}"
.format(self.version, str(self.settings.os), valid_arch))

def build_requirements(self):
self.build_requires("7zip/19.00")

def build(self):
# Source should be downloaded in the build step since it depends on specific options
url = self.conan_data["sources"][self.version][str(self.options.threads)][str(self.options.exception)]
self.output.info("Downloading: %s" % url["url"])
tools.download(url["url"], "file.7z", sha256=url["sha256"])
self.run("7z x file.7z")
os.remove('file.7z')


def package(self):
target = "mingw64" if self.settings.arch == "x86_64" else "mingw32"
self.copy("*", dst="", src=target)
tools.rmdir(target)
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
if getattr(self, "settings_target", None):
if self.settings_target.compiler != "gcc":
raise ConanInvalidConfiguration("Only GCC is allowed as compiler.")
if str(self.settings_target.compiler.threads) != str(self.options.threads):
raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc "
"with threads={}, your profile:host declares "
"threads={}, please use the same value for both."
.format(self.options.threads,
self.settings_target.compiler.threads))
if str(self.settings_target.compiler.exception) != str(self.options.exception):
raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc "
"with exception={}, your profile:host declares "
"exception={}, please use the same value for both."
.format(self.options.exception,
self.settings_target.compiler.exception))

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var with : {}".format(bin_path))
self.env_info.PATH.append(bin_path)
self.env_info.MINGW_HOME = str(self.package_folder)

self.env_info.CONAN_CMAKE_GENERATOR = "MinGW Makefiles"
self.env_info.CXX = os.path.join(self.package_folder, "bin", "g++.exe").replace("\\", "/")
self.env_info.CC = os.path.join(self.package_folder, "bin", "gcc.exe").replace("\\", "/")
self.env_info.LD = os.path.join(self.package_folder, "bin", "ld.exe").replace("\\", "/")
self.env_info.NM = os.path.join(self.package_folder, "bin", "nm.exe").replace("\\", "/")
self.env_info.AR = os.path.join(self.package_folder, "bin", "ar.exe").replace("\\", "/")
self.env_info.AS = os.path.join(self.package_folder, "bin", "as.exe").replace("\\", "/")
self.env_info.STRIP = os.path.join(self.package_folder, "bin", "strip.exe").replace("\\", "/")
self.env_info.RANLIB = os.path.join(self.package_folder, "bin", "ranlib.exe").replace("\\", "/")
self.env_info.STRINGS = os.path.join(self.package_folder, "bin", "strings.exe").replace("\\", "/")
self.env_info.OBJDUMP = os.path.join(self.package_folder, "bin", "objdump.exe").replace("\\", "/")
self.env_info.GCOV = os.path.join(self.package_folder, "bin", "gcov.exe").replace("\\", "/")
16 changes: 16 additions & 0 deletions recipes/mingw-w64/8.1/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from conans import ConanFile, tools


class MinGWTestConan(ConanFile):
generators = "gcc"
settings = "os", "arch", "compiler", "build_type"

def build(self):
source_file = os.path.join(self.source_folder, "main.cpp")
self.run("gcc.exe {} @conanbuildinfo.gcc -lstdc++ -o main".format(source_file), run_environment=True)

def test(self):
if not tools.cross_building(self):
self.run("gcc.exe --version", run_environment=True)
self.run("main")
7 changes: 7 additions & 0 deletions recipes/mingw-w64/8.1/test_package/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include <gnumake.h> // test if we can include one of MinGW bundled header

int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
2 changes: 1 addition & 1 deletion recipes/mingw-w64/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
versions:
"8.1":
folder: "all"
folder: "8.1"
"8.0.2":
folder: "all"