#28 Read compiler from CC environment variable
Merged 4 years ago by jhutar. Opened 4 years ago by tbaeder.
tbaeder/rpmfluff master  into  master

file modified
+6 -4
@@ -34,6 +34,8 @@ 

  

  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 @@ 

          """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 @@ 

          """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 @@ 

              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'

Instead of hardcoding gcc

Makes it possible to build with clang.

There is only one hard-coded gcc left, in can_compile_m32(). I was not sure how to properly replace this.

Pull-Request has been merged by jhutar

4 years ago
Metadata