Debian Codegraph @

cmake/tribits/devtools_install/install-gcc.py

raw
1 #!/usr/bin/env python3
2
3 # @HEADER
4 # *****************************************************************************
5 # TriBITS: Tribal Build, Integrate, and Test System
6 #
7 # Copyright 2013-2016 NTESS and the TriBITS contributors.
8 # SPDX-License-Identifier: BSD-3-Clause
9 # *****************************************************************************
10 # @HEADER
11
12
13 #
14 # Defaults
15 #
16
17 gccBaseName = "gcc"
18 gccDefaultVersion = "4.8.3"
19 gccSupportedVersions = ["4.8.3"]
20
21 #
22 # Script code
23 #
24
25
26 from InstallProgramDriver import *
27 from GeneralScriptSupport import *
28
29
30 class GccInstall:
31
32 def __init__(self):
33 self.dummy = None
34
35 #
36 # Called before even knowing the product version
37 #
38
39 def getScriptName(self):
40 return "install-gcc.py"
41
42 def getProductBaseName(self):
43 return gccBaseName
44
45 def getProductDefaultVersion(self):
46 return gccDefaultVersion
47
48 def getProductSupportedVersions(self):
49 return gccSupportedVersions
50
51 #
52 # Called after knowing the product version but before parsing the
53 # command-line.
54 #
55
56 def getProductName(self, version):
57 return gccBaseName+"-"+version
58
59 def getBaseDirName(self, version):
60 return gccBaseName+"-"+version+"-base"
61
62 def getExtraHelpStr(self, version):
63 return """
64 This script builds """+self.getProductName(version)+""" from source compiled with the
65 configured C compilers in your path.
66
67 NOTE: The assumed directory structure of the download source provided by the
68 command --download-cmnd=<download-cmnd> is:
69
70 gcc-<version>-base/
71 gcc-<full-version>.tar.gz
72 """
73
74 def injectExtraCmndLineOptions(self, clp, version):
75 setStdDownloadCmndOption(self, clp, version)
76 clp.add_option(
77 "--extra-configure-options", dest="extraConfigureOptions", type="string", \
78 default="", \
79 help="Extra options to add to the 'configure' command for " \
80 + self.getProductName(version)+"." \
81 +" Note: This does not override the hard-coded configure options." )
82
83 def echoExtraCmndLineOptions(self, inOptions):
84 cmndLine = ""
85 cmndLine += " --download-cmnd='"+inOptions.downloadCmnd+"' \\\n"
86 cmndLine += " --extra-configure-options='"+inOptions.extraConfigureOptions+"' \\\n"
87 return cmndLine
88
89 #
90 # Called after parsing the command-line
91 #
92
93 def setup(self, inOptions):
94 self.inOptions = inOptions
95 self.baseDir = os.getcwd()
96 self.gccBaseDir = self.baseDir+"/"+self.getBaseDirName(self.inOptions.version)
97 self.gccSrcDir = "gcc-"+self.inOptions.version
98 self.gccBuildBaseDir = self.gccBaseDir+"/gcc-build"
99 self.scriptBaseDir = getScriptBaseDir()
100
101 #
102 # Called after setup()
103 #
104
105 def doDownload(self):
106 removeDirIfExists(self.gccBaseDir, True)
107 echoRunSysCmnd(self.inOptions.downloadCmnd)
108
109 def doUntar(self):
110 print "Nothing to untar!"
111
112 def doConfigure(self):
113 createDir(self.gccBuildBaseDir)
114 echoRunSysCmnd(
115 "../"+self.gccSrcDir+"/configure --disable-multilib --enable-languages='c,c++,fortran'"+\
116 " "+self.inOptions.extraConfigureOptions+\
117 " --prefix="+self.inOptions.installDir,
118 workingDir=self.gccBuildBaseDir,
119 extraEnv={"CFLAGS":"-O3"},
120 )
121
122 def doBuild(self):
123 echoChDir(self.gccBuildBaseDir)
124 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
125 + self.inOptions.makeOptions)
126
127 def doInstall(self):
128 echoChDir(self.gccBuildBaseDir)
129 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
130 + self.inOptions.makeOptions + " install")
131
132 def getFinalInstructions(self):
133 return """
134 To use the installed version of gcc-"""+self.inOptions.version+""" add the path:
135
136 """+self.inOptions.installDir+"""/bin
137
138 to your path and that should be it!
139
140 Also, when you link shared libs or executables, pass in:
141
142 -Wl,-rpath,"""+self.inOptions.installDir+"""/lib[64]
143
144 That will make it so that you don't need to add this GCC libs to your
145 LD_LIBRARY_PATH.
146 """
147
148
149 #
150 # Executable statements
151 #
152
153 gccInstaller = InstallProgramDriver(GccInstall())
154 gccInstaller.runDriver()