Skip to content

Commit d0be999

Browse files
committed
Exports and builds with progen yaml file
1 parent 850bbb0 commit d0be999

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

tools/export/exporters.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from contextlib import closing
99
from zipfile import ZipFile, ZIP_DEFLATED
1010
from operator import add
11+
import yaml
1112

1213
from tools.utils import mkdir
1314
from tools.toolchains import TOOLCHAIN_CLASSES
@@ -19,6 +20,7 @@
1920

2021
from tools.config import Config
2122

23+
2224
class OldLibrariesException(Exception): pass
2325

2426
class FailedBuildException(Exception) : pass
@@ -109,19 +111,33 @@ def progen_get_project_data(self):
109111
}
110112
return project_data
111113

114+
def progen_make_yaml(self, project_data, name):
115+
fname = os.path.join(project_data['common']['export_dir'][0], "projects.yaml")
116+
project_data['common']['export_dir'] = project_data['common']['export_dir'][0]
117+
new_data = {"projects":{name:project_data}}
118+
if os.path.isfile(fname):
119+
os.remove(fname)
120+
with open(fname, 'w+') as f:
121+
f.write(yaml.dump(new_data, default_flow_style=False))
122+
123+
return fname
124+
112125
def progen_gen_file(self, tool_name, project_data, progen_build=False):
113126
"""" Generate project using ProGen Project API """
114-
settings = ProjectSettings()
115-
project = Project(self.program_name, [project_data], settings)
116-
# TODO: Fix this, the inc_dirs are not valid (our scripts copy files), therefore progen
117-
# thinks it is not dict but a file, and adds them to workspace.
118-
project.project['common']['include_paths'] = self.resources.inc_dirs
119-
project.generate(tool_name, copied=not self.sources_relative)
120-
if progen_build:
121-
print("Project exported, building...")
122-
result = project.build(tool_name)
123-
if result == -1:
124-
raise FailedBuildException("Build Failed")
127+
#project_data['common']['include_paths'] = self.resources.inc_dirs
128+
yaml_file = self.progen_make_yaml(project_data, self.program_name)
129+
generator = Generator(yaml_file)
130+
131+
for project in generator.generate(''):
132+
#print diff(p, project.project)
133+
project.project['common']['include_paths'] = self.resources.inc_dirs
134+
if project.generate(tool_name, copied=not self.sources_relative) == -1:
135+
return -1
136+
if progen_build:
137+
print "Project exported, now building..."
138+
if project.build(tool_name) == -1:
139+
raise FailedBuildException("Build Failed")
140+
return 0
125141

126142
def __scan_all(self, path):
127143
resources = []

tools/test/export/build_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import argparse
2222
import os
2323
import shutil
24+
import yaml
2425
from os.path import join, abspath, dirname, exists, basename
2526
r=dirname(__file__)
2627
ROOT = abspath(join(r, "..","..",".."))
@@ -87,10 +88,18 @@ def handle_project_files(tool, project_dir, target, test, clean=False):
8788
return
8889

8990
#check if project files exist
90-
if not clean and os.path.exists(project_files_dir):
91+
if os.path.exists(project_files_dir):
9192
shutil.rmtree(project_files_dir, ignore_errors=True)
9293
os.rename(project_dir, project_files_dir)
9394

95+
#change yaml file to reference new project file location
96+
yaml_file = os.path.join(project_files_dir, 'projects.yaml')
97+
with open(yaml_file, 'r+') as f:
98+
proj_dict = yaml.load(f)
99+
proj_dict["projects"][test]["common"]["export_dir"] = project_files_dir
100+
with open(yaml_file, 'w+') as outf:
101+
outf.write(yaml.dump(proj_dict, default_flow_style=False))
102+
94103
def generate_and_build(self, tests, clean=False):
95104

96105
#build results

0 commit comments

Comments
 (0)