From a4138f1949cf92e186289ecb7b61b56bcb7675f4 Mon Sep 17 00:00:00 2001 From: Timm Bäder Date: Apr 01 2020 09:58:16 +0000 Subject: Read compiler from CC environment variable Instead of hardcoding gcc --- diff --git a/rpmfluff.py b/rpmfluff.py index 3af090e..8c9a333 100644 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -34,6 +34,8 @@ import subprocess UTF8ENCODE = None +CC = os.getenv("CC", "gcc") + def _which(cmd): """Hacked Python 3.3+ shutil.which() with limited functionality.""" path = os.environ.get("PATH", os.defpath) @@ -1205,7 +1207,7 @@ class SimpleRpmBuild(RpmBuild): """Add a simple source file to the sources, build it, and install it somewhere, using the given compilation flags""" _sourceId = self.add_source(SourceFile(sourceFileName, sourceContent)) self.section_build += "%if 0%{?__isa_bits} == 32\n%define mopt -m32\n%endif\n" - self.section_build += "gcc %%{?mopt} %s %s\n"%(compileFlags, sourceFileName) + self.section_build += CC + " %%{?mopt} %s %s\n"%(compileFlags, sourceFileName) if createParentDirs: self.create_parent_dirs(installPath) self.section_install += "cp a.out $RPM_BUILD_ROOT/%s\n"%installPath @@ -1224,7 +1226,7 @@ class SimpleRpmBuild(RpmBuild): """Add a simple source file to the sources, build it as a library, and install it somewhere, using the given compilation flags""" _sourceId = self.add_source(SourceFile(sourceFileName, sourceContent)) - self.section_build += "gcc --shared -fPIC -o %s %s %s\n"%(libraryName, compileFlags, sourceFileName) + self.section_build += CC + " --shared -fPIC -o %s %s %s\n"%(libraryName, compileFlags, sourceFileName) if createParentDirs: self.create_parent_dirs(installPath) self.section_install += "cp %s $RPM_BUILD_ROOT/%s\n" % (libraryName, installPath) @@ -1530,12 +1532,12 @@ class TestSimpleRpmBuild(unittest.TestCase): self.assert_enhances(rpmFile, 'test-enhancement') def test_add_buildrequires(self): - self.rpmbuild.add_build_requires("gcc") + self.rpmbuild.add_build_requires(CC) self.rpmbuild.make() srpmFile = self.rpmbuild.get_built_srpm() self.assert_is_file(srpmFile) - self.assert_requires(srpmFile, 'gcc') + self.assert_requires(srpmFile, CC) def test_add_vendor(self): vendor = 'My own RPM Lab'