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

waf: make it work on macOS #2

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions recipes/waf/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"2.0.19":
url: "https://waf.io/waf-2.0.19.tar.bz2"
sha256: "d8402689b72fe75f759a83b5f6bdf9b4f34ca7fd6007d80680ecfcbef5c2bba5"
"2.0.25":
url: "https://waf.io/waf-2.0.25.tar.bz2"
sha256: "66cff7beed0e77db874e9232cc08874abb3e866c7f0f1f34ba2f959fde44fdd4"
valgur marked this conversation as resolved.
Show resolved Hide resolved
48 changes: 24 additions & 24 deletions recipes/waf/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import os
import shutil
from contextlib import contextmanager

from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout
from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import chdir


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
exports_sources = "a.cpp", "b.cpp", "main.c", "main.cpp", "wscript"

Expand All @@ -21,6 +19,23 @@ def build_requirements(self):
def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()

buildenv = VirtualBuildEnv(self)
buildenv.generate()

env = Environment()
for var in ["DYLD_LIBRARY_PATH", "LD_LIBRARY_PATH"]:
env.append_path(var, os.path.join(self.build_folder, "build"))
env.vars(self, scope="run").save_script("conanrun_macos_runtimepath")

runenv = VirtualRunEnv(self)
runenv.generate()

def build(self):
if not can_run(self):
return
Expand All @@ -33,26 +48,11 @@ def build(self):
self.run("waf configure")
self.run("waf")

@contextmanager
def _add_ld_search_path(self, extra_path):
if self.settings.os in ["Linux", "FreeBSD"]:
var = "LD_LIBRARY_PATH"
elif is_apple_os(self):
var = "DYLD_LIBRARY_PATH"
else:
yield
return
ld_path = os.environ.get(var, "")
os.environ[var] = f"{ld_path}{os.pathsep}{extra_path}"
yield
os.environ[var] = ld_path

def test(self):
if not can_run(self):
return
bin_dir = os.path.join(self.cpp.build.bindir, "build")
with self._add_ld_search_path(bin_dir):
bin_path = os.path.join(bin_dir, "app")
self.run(bin_path, env="conanrun")
bin_path = os.path.join(bin_dir, "app2")
self.run(bin_path, env="conanrun")
bin_dir = os.path.join(self.build_folder, "build")
bin_path = os.path.join(bin_dir, "app")
self.run(bin_path, env="conanrun")
bin_path = os.path.join(bin_dir, "app2")
self.run(bin_path, env="conanrun")
2 changes: 1 addition & 1 deletion recipes/waf/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"2.0.19":
"2.0.25":
folder: all
valgur marked this conversation as resolved.
Show resolved Hide resolved