|
@@ -1,20 +1,13 @@
|
|
|
#! /usr/bin/env python
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-
|
|
|
import os, urllib, subprocess, sys
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-
|
|
|
import archive_directory
|
|
|
import tool_directory
|
|
|
import dev_platform
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
# FOR PRINTING IN COLOR
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-
|
|
|
class bcolors:
|
|
|
HEADER = '\033[95m'
|
|
|
BLUE = '\033[94m'
|
|
@@ -28,20 +21,16 @@ class bcolors:
|
|
|
BOLD_GREEN = '\033[1m' + '\033[92m'
|
|
|
BOLD_RED = '\033[1m' + '\033[91m'
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-# DISTRIBUTION GCC
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|
|
|
+# DISTRIBUTION GCC
|
|
|
def distributionGCC () :
|
|
|
gcc = "gcc-arm-none-eabi-7-2017-q4-major"
|
|
|
if dev_platform.getPlatform () == "linux32" :
|
|
|
gcc = "gcc-arm-none-eabi-5_4-2016q3"
|
|
|
return gcc
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-# ARCHIVE URL (from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm)
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|
|
|
+# ARCHIVE URL (from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm)
|
|
|
def compilerArchiveURL () :
|
|
|
baseURL = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/"
|
|
|
PLATFORM = dev_platform.getPlatform ()
|
|
@@ -50,10 +39,8 @@ def compilerArchiveURL () :
|
|
|
distribution = "5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2"
|
|
|
return baseURL + distribution
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-# runCommand
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|
|
|
+# runCommand
|
|
|
def runCommand (cmd) :
|
|
|
str = "+"
|
|
|
for s in cmd:
|
|
@@ -63,10 +50,8 @@ def runCommand (cmd) :
|
|
|
if returncode != 0 :
|
|
|
sys.exit (returncode)
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-# ARCHIVE DOWNLOAD
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|
|
|
+# ARCHIVE DOWNLOAD
|
|
|
def downloadReportHook (a,b,fileSize):
|
|
|
# "," at the end of the line is important!
|
|
|
if fileSize < (1 << 10):
|
|
@@ -79,7 +64,6 @@ def downloadReportHook (a,b,fileSize):
|
|
|
print "% 3.1f%% of %sB\r" % (min(100.0, float(a * b) / fileSize * 100.0), sizeString),
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|
|
|
def downloadArchive (archiveURL, archivePath):
|
|
|
print ("URL: "+ archiveURL)
|
|
@@ -87,17 +71,15 @@ def downloadArchive (archiveURL, archivePath):
|
|
|
urllib.urlretrieve (archiveURL, archivePath, downloadReportHook)
|
|
|
print ""
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
# Install GCC
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
-
|
|
|
def install_gcc (INSTALL_DIR) :
|
|
|
print bcolors.BOLD_GREEN + "Install GCC tools..." + bcolors.ENDC
|
|
|
DISTRIBUTION = distributionGCC ()
|
|
|
- #------------------------------------------------------------------ Archive dir
|
|
|
+ # Archive dir
|
|
|
COMPILER_ARCHIVE_DIR = archive_directory.createAndGetArchiveDirectory ()
|
|
|
- #------------------------------------------------------------------ Download
|
|
|
+ # Download
|
|
|
if not os.path.exists (COMPILER_ARCHIVE_DIR + "/" + DISTRIBUTION + ".tar.bz2"):
|
|
|
+ print "Nothing found in" + COMPILER_ARCHIVE_DIR
|
|
|
url = compilerArchiveURL ()
|
|
|
runCommand (["rm", "-f", COMPILER_ARCHIVE_DIR + "/" + DISTRIBUTION + ".tar.bz2.downloading"])
|
|
|
downloadArchive (url, COMPILER_ARCHIVE_DIR + "/" + DISTRIBUTION + ".tar.bz2.downloading")
|
|
@@ -105,7 +87,7 @@ def install_gcc (INSTALL_DIR) :
|
|
|
COMPILER_ARCHIVE_DIR + "/" + DISTRIBUTION + ".tar.bz2.downloading",
|
|
|
COMPILER_ARCHIVE_DIR + "/" + DISTRIBUTION + ".tar.bz2"
|
|
|
])
|
|
|
- #------------------------------------------------------------------ Install
|
|
|
+ # Install
|
|
|
if not os.path.exists (INSTALL_DIR):
|
|
|
os.mkdir (INSTALL_DIR)
|
|
|
if not os.path.exists (INSTALL_DIR + "/" + DISTRIBUTION):
|
|
@@ -119,18 +101,17 @@ def install_gcc (INSTALL_DIR) :
|
|
|
os.chdir (savedCurrentDir)
|
|
|
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
+
|
|
|
# GET GCC TOOL DIRECTORY
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
+
|
|
|
|
|
|
def installGCCARMandGetToolDirectory () :
|
|
|
-#--- Absolute path of tool directory
|
|
|
+# Absolute path of tool directory
|
|
|
TOOL_DIRECTORY = tool_directory.toolDirectory () + "/" + distributionGCC ()
|
|
|
-#--- Install tool ?
|
|
|
+# Install tool ?
|
|
|
if not os.path.exists (TOOL_DIRECTORY) :
|
|
|
install_gcc (tool_directory.toolDirectory ())
|
|
|
-#--- Return tool directory
|
|
|
+# Return tool directory
|
|
|
return TOOL_DIRECTORY
|
|
|
|
|
|
-#——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————*
|
|
|
|