Skip to content

Commit 6b3d841

Browse files
committed
Merge pull request #56 from 0xc0170/fix_generated_dir
Fix generated dir
2 parents e472a51 + 80cecbf commit 6b3d841

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

tools/export/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def online_build_url_resolver(url):
5555

5656

5757
def export(project_path, project_name, ide, target, destination='/tmp/',
58-
tempdir=None, clean=True, extra_symbols=None, zip=True, build_url_resolver=online_build_url_resolver):
58+
tempdir=None, clean=True, extra_symbols=None, zip=True, build_url_resolver=online_build_url_resolver, relative=False):
5959
# Convention: we are using capitals for toolchain and target names
6060
if target is not None:
6161
target = target.upper()
@@ -99,7 +99,7 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
9999
# target checked, export
100100
try:
101101
exporter = Exporter(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
102-
exporter.scan_and_copy_resources(project_path, tempdir)
102+
exporter.scan_and_copy_resources(project_path, tempdir, relative)
103103
exporter.generate()
104104
report['success'] = True
105105
except OldLibrariesException, e:

tools/export/exporters.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __scan_all(self, path):
111111

112112
return resources
113113

114-
def scan_and_copy_resources(self, prj_path, trg_path):
114+
def scan_and_copy_resources(self, prj_path, trg_path, relative=False):
115115
# Copy only the file for the required target and toolchain
116116
lib_builds = []
117117
for src in ['lib', 'src']:
@@ -136,9 +136,13 @@ def scan_and_copy_resources(self, prj_path, trg_path):
136136
fhandle = file(join(hgdir, 'keep.me'), 'a')
137137
fhandle.close()
138138

139-
# Final scan of the actual exported resources
140-
self.resources = self.toolchain.scan_resources(trg_path)
141-
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
139+
if not relative:
140+
# Final scan of the actual exported resources
141+
self.resources = self.toolchain.scan_resources(trg_path)
142+
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
143+
else:
144+
# use the prj_dir (source, not destination)
145+
self.resources = self.toolchain.scan_resources(prj_path)
142146
# Check the existence of a binary build of the mbed library for the desired target
143147
# This prevents exporting the mbed libraries from source
144148
# if not self.toolchain.mbed_libs:

tools/project.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
from shutil import move, rmtree
77
from optparse import OptionParser
8+
from os import path
89

910
from tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP
1011
from tools.paths import MBED_BASE, MBED_LIBRARIES
1112
from tools.export import export, setup_user_prj, EXPORTERS, mcu_ide_matrix
12-
from tools.utils import args_error
13+
from tools.utils import args_error, mkdir
1314
from tools.tests import TESTS, Test, TEST_MAP
1415
from tools.targets import TARGET_NAMES
1516
from tools.libraries import LIBRARIES
@@ -136,15 +137,19 @@
136137
zip = True
137138
clean = True
138139

140+
# source_dir = use relative paths, otherwise sources are copied
141+
sources_relative = True if options.source_dir else False
142+
139143
for mcu in mcus.split(','):
140144
# Program Number or name
141-
p, n, src = options.program, options.program_name, options.source_dir
145+
p, n, src, ide = options.program, options.program_name, options.source_dir, options.ide
142146

143147
if src is not None:
144148
# --source is used to generate IDE files to toolchain directly in the source tree and doesn't generate zip file
145149
project_dir = options.source_dir
146150
project_name = basename(project_dir)
147-
project_temp = project_dir
151+
project_temp = path.join(options.source_dir, 'projectfiles', ide)
152+
mkdir(project_temp)
148153
lib_symbols = []
149154
if options.macros:
150155
lib_symbols += options.macros
@@ -204,7 +209,7 @@
204209
setup_user_prj(project_dir, test.source_dir, test.dependencies)
205210

206211
# Export to selected toolchain
207-
tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir, project_temp, clean=clean, zip=zip, extra_symbols=lib_symbols)
212+
tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir, project_temp, clean=clean, zip=zip, extra_symbols=lib_symbols, relative=sources_relative)
208213
print tmp_path
209214
if report['success']:
210215
zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, ide, mcu))

0 commit comments

Comments
 (0)