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

Add scons/3.1.2 recipe #814

Merged
merged 20 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions recipes/scons/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.1.2":
url: "http://prdownloads.sourceforge.net/scons/scons-3.1.2.tar.gz"
sha256: "7801f3f62f654528e272df780be10c0e9337e897650b62ddcee9f39fde13f8fb"
74 changes: 74 additions & 0 deletions recipes/scons/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from conans import ConanFile, tools
from conans.errors import ConanException
madebr marked this conversation as resolved.
Show resolved Hide resolved
import os
import shutil
import sys


class SConsConan(ConanFile):
name = "scons"
description = "SCons is an Open Source software construction tool—that is, a next-generation build tool"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index/"
homepage = "https://scons.org"
topics = ("conan", "scons", "build", "configuration", "development")
settings = "os_build" # Added to let the CI test this package on all os'es

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("scons-{}".format(self.version), self._source_subfolder)

def build(self):
with tools.chdir(self._source_subfolder):
self.run("{} setup.py build -j{}".format(sys.executable, tools.cpu_count()))

def package(self):
self.copy("LICENSE*", src=self._source_subfolder, dst="licenses")

# Mislead CI and create an empty header in the include directory
include_dir = os.path.join(self.package_folder, "include")
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
os.mkdir(include_dir)
tools.save(os.path.join(include_dir, "__nop.h"), "")

with tools.chdir(self._source_subfolder):
self.run("{} setup.py install --no-compile --prefix={}".format(sys.executable, self.package_folder))

tools.rmdir(os.path.join(self.package_folder, "man"))

if tools.os_info.is_windows:
# On Windows, scons installs the scripts in the folders `Scripts" and `Lib".
# Move these to the directories "bin" and "lib".
shutil.move(os.path.join(self.package_folder, "Scripts"),
os.path.join(self.package_folder, "bin"))
# Windows has case-insensitive paths, so do Lib -> lib2 -> lib
shutil.move(os.path.join(self.package_folder, "Lib"),
os.path.join(self.package_folder, "lib2"))
shutil.move(os.path.join(self.package_folder, "lib2"),
madebr marked this conversation as resolved.
Show resolved Hide resolved
os.path.join(self.package_folder, "lib"))

# Check for compiled python sources
for root, _, files in os.walk(self.package_folder):
madebr marked this conversation as resolved.
Show resolved Hide resolved
for file in files:
for ext in (".pyc", ".pyo", "pyd"):
if ext in file:
fullpath = os.path.join(root, file)
os.unlink(fullpath)
self.output.warn("Found compiled python code: {}".format(fullpath))

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []

bindir = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment var: {}".format(bindir))
self.env_info.PATH.append(bindir)

scons_pythonpath = os.path.join(self.package_folder, "lib", "site-packages", "scons")
self.output.info("Appending PYTHONPATH environment var: {}".format(scons_pythonpath))
self.env_info.PYTHONPATH.append(os.path.join(self.package_folder, "lib", "site-packages", "scons"))
1 change: 1 addition & 0 deletions recipes/scons/all/test_package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.dblite
madebr marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions recipes/scons/all/test_package/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SConstruct
import os

env = Environment()

conan = SConscript("SConscript_conan")
if not conan:
print("File `SConscript_conan` is missing.")
print("It should be generated by running `conan install`.")
sys.exit(1)

flags = conan["conan"]
env.MergeFlags(flags)

print("CC is: {}".format(env.subst('$CC')))

test_package = env.Program(["test_package.c"])
3 changes: 3 additions & 0 deletions recipes/scons/all/test_package/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SConscript('SConscript',
variant_dir = GetLaunchDir(),
duplicate = False)
27 changes: 27 additions & 0 deletions recipes/scons/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from conans import ConanFile, tools
from io import StringIO
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "scons"

def build(self):
scons_path = tools.which("scons")
assert scons_path.replace("\\", "/").startswith(self.deps_cpp_info["scons"].rootpath.replace("\\", "/"))

output = StringIO()
self.run("{} --version".format(scons_path), run_environment=True, output=output)
text = output.getvalue()
print(text)
madebr marked this conversation as resolved.
Show resolved Hide resolved
madebr marked this conversation as resolved.
Show resolved Hide resolved
assert self.requires["scons"].ref.version in text
madebr marked this conversation as resolved.
Show resolved Hide resolved
madebr marked this conversation as resolved.
Show resolved Hide resolved

self.output.info("TMP={}".format(os.environ.get("TMP")))
madebr marked this conversation as resolved.
Show resolved Hide resolved

self.run("scons -C \"{}\"".format(self.source_folder))

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join(".", "test_package")
self.run(bin_path, run_environment=True)
7 changes: 7 additions & 0 deletions recipes/scons/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* hello.c */
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello world\n");
return 0;
}
3 changes: 3 additions & 0 deletions recipes/scons/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.1.2":
folder: all