-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.py
126 lines (105 loc) · 4.67 KB
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
#----------------------------------------------------------------------
#--- Python Make file for application blink
#--- automatically generated by goil on Mon May 15 12:11:08 2023
#--- from root OIL file pfeMouhoubi.oil
#---
#--- Compiling a Trampoline application is done in 2 stages
#--- 1 - From the OIL file, a set of files is generated as long as
#--- build options. Among these files are the build.py and make.py
#--- files. make.py contains compilation rules when the OIL file
#--- and the included OIL files are modified. make.py is only
#--- written once when the goil command is typed.
#--- 2 - From all the C/assembly files (OS, Application, librairies,
#--- configuration, ...), the objects and the executable are
#--- produced. This is done by the build.py file.
#--- build.py is generated each time goil is called by make.py
#----------------------------------------------------------------------
from __future__ import print_function
import sys, os, subprocess, atexit, string
#--- Add the location of makefile.py to the import path
sys.path.append("/usr/share/trampoline-master//make")
#--- Import the makefile system in python
try:
import makefile, projfile
except ImportError:
#it defines inline the red color, as other are defined in the makefile.py
print("\033[91mThe OS->BUILD->TRAMPOLINE_BASE_PATH key is not set correctly in the oil file pfeMouhoubi.oil.")
print("Set the correct Trampoline installation path in the oil file and run goil again:\033[0m")
print("goil -t=cortex/armv6m/samd21/XPlainedPro --templates=/usr/share/trampoline-master/goil/templates/ pfeMouhoubi.oil")
sys.exit(1)
#--- To work with relative paths
scriptDir = os.path.dirname (os.path.abspath (sys.argv[0]))
os.chdir (scriptDir)
#--- Get goal as first argument
askedGoal = "all"
if len (sys.argv) > 1 :
askedGoal = sys.argv [1]
if askedGoal == "all" or askedGoal == "clean" :
goal = askedGoal
else :
goal = "all"
#--- Get max parallel jobs as second argument
maxParallelJobs = 0 # 0 means use host processor count
if len (sys.argv) > 2 :
maxParallelJobs = int (sys.argv [2])
#--- Instanciate a new makefile object
make = makefile.Make(goal)
#----------------------------------------------------------------------
#--- Various variables used after
#----------------------------------------------------------------------
oilFile = "pfeMouhoubi.oil"
oilFileDep = "build/" + oilFile + ".dep"
oilCompiler = "goil"
oilFlags = ["-t=cortex/armv6m/samd21/XPlainedPro", "--templates=/usr/share/trampoline-master/goil/templates/"]
trampoline_base_path = "/usr/share/trampoline-master//"
#----------------------------------------------------------------------
#--- Build the source files list
#----------------------------------------------------------------------
oilSourceList = []
sourceList = []
#--- Add generated files
sourceList.append("pfeMouhoubi/tpl_app_config.c")
sourceList.append("pfeMouhoubi/tpl_dispatch_table.c")
sourceList.append("pfeMouhoubi/tpl_invoque.S")
sourceList.append("pfeMouhoubi/tpl_primary_irq.S")
sourceList.append("pfeMouhoubi/tpl_vectors.c")
sourceList.append("pfeMouhoubi/tpl_external_interrupts.c")
sourceList.append("pfeMouhoubi/tpl_app_interrupts.c")
rule = makefile.Rule (sourceList, "Compiling OIL file " + oilFile)
rule.deleteTargetFileOnClean()
rule.mDeleteTargetOnError = True
rule.mDependences.append(oilFile)
rule.enterSecondaryDependanceFile(oilFileDep, make)
rule.mCommand.append("goil")
rule.mCommand += oilFlags
rule.mCommand.append(oilFile)
make.addRule (rule)
make.addGoal("all", sourceList, "Building all")
if goal == "all" or goal == "clean" :
make.runGoal(maxParallelJobs, maxParallelJobs == 1)
#----------------------------------------------------------------------
#--- Call the seconde stage of make
#----------------------------------------------------------------------
def cleanup():
if childProcess.poll () == None :
childProcess.kill ()
#--- Register a function for killing subprocess
atexit.register (cleanup)
#--- Get script absolute path
scriptDir = os.path.dirname (os.path.abspath (sys.argv [0]))
os.chdir (scriptDir)
#--- Launch build.py
# is there the 'python' executable?
import distutils.spawn
if distutils.spawn.find_executable("python"):
childProcess = subprocess.Popen (["python", "build.py", askedGoal, str(maxParallelJobs)])
else: #no python executable, maybe python3
childProcess = subprocess.Popen (["python3", "build.py", askedGoal, str(maxParallelJobs)])
#--- Wait for subprocess termination
if childProcess.poll () == None :
childProcess.wait ()
if childProcess.returncode != 0 :
sys.exit (childProcess.returncode)
#----------------------------------------------------------------------