tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] url2pkg: learn to identify scons, add test cases



Honestly only looked at identifying a real-world scons4.
The only way I could tell it should be scons4 and not 3 is that it
wanted newer python and our scons3 is python 2.
---
 pkgtools/url2pkg/files/url2pkg.py      |  8 ++++++++
 pkgtools/url2pkg/files/url2pkg_test.py | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/pkgtools/url2pkg/files/url2pkg.py b/pkgtools/url2pkg/files/url2pkg.py
index ca41cc21a7e..b35a6deb862 100644
--- a/pkgtools/url2pkg/files/url2pkg.py
+++ b/pkgtools/url2pkg/files/url2pkg.py
@@ -1090,6 +1090,13 @@ class Adjuster:
 
         self.includes.append('../../lang/rust/cargo.mk')
 
+    def adjust_scons(self):
+        if self.wrksrc_isfile('SConstruct'):
+            if self.wrksrc_grep('SConstruct', r'EnsurePythonVersion\(3'):
+                self.includes.append('../../devel/scons4/build.mk')
+            else:
+                self.includes.append('../../devel/scons/buildlink3.mk')
+
     def adjust_pkg_config(self):
         def relevant(filename: str) -> bool:
             return filename.endswith('.pc.in') \
@@ -1267,6 +1274,7 @@ class Adjuster:
         self.adjust_perl_module()
         self.adjust_python_module()
         self.adjust_cargo()
+        self.adjust_scons()
         self.adjust_pkg_config()
         self.adjust_po()
         self.adjust_use_languages()
diff --git a/pkgtools/url2pkg/files/url2pkg_test.py b/pkgtools/url2pkg/files/url2pkg_test.py
index 420e600e48f..07bd40c6f7f 100644
--- a/pkgtools/url2pkg/files/url2pkg_test.py
+++ b/pkgtools/url2pkg/files/url2pkg_test.py
@@ -1043,6 +1043,27 @@ def test_Adjuster_adjust_configure__GNU(tmp_path: Path):
         'GNU_CONFIGURE=yes',
     ]
 
+def test_Adjuster_adjust_scons_old(tmp_path: Path):
+    adjuster = Adjuster(g, '', Lines())
+    adjuster.abs_wrksrc = tmp_path
+    adjuster.wrksrc_files.append('SConstruct')
+    (tmp_path / 'SConstruct').write_text('EnsureSConsVersion(3, 0, 0)\nEnsurePythonVersion(2, 7)\n')
+
+    adjuster.adjust_scons()
+    assert adjuster.includes == [
+        '../../devel/scons/buildlink3.mk',
+    ]
+
+def test_Adjuster_adjust_scons4(tmp_path: Path):
+    adjuster = Adjuster(g, '', Lines())
+    adjuster.abs_wrksrc = tmp_path
+    adjuster.wrksrc_files.append('SConstruct')
+    (tmp_path / 'SConstruct').write_text('EnsureSConsVersion(3, 0, 0)\nEnsurePythonVersion(3, 6)\n')
+
+    adjuster.adjust_scons()
+    assert adjuster.includes == [
+        '../../devel/scons4/build.mk',
+    ]
 
 def test_Adjuster_adjust_configure__other(tmp_path: Path):
     adjuster = Adjuster(g, '', Lines())
-- 
2.43.0



Home | Main Index | Thread Index | Old Index