diff --git a/tools/export/gnuarmeclipse/.cproject.tmpl b/tools/export/gnuarmeclipse/.cproject.tmpl
index 7146db0eda..7c80fc3ab0 100644
--- a/tools/export/gnuarmeclipse/.cproject.tmpl
+++ b/tools/export/gnuarmeclipse/.cproject.tmpl
@@ -153,7 +153,7 @@
-
+
{% if options['as']['usepreprocessor'] %}
@@ -537,7 +537,7 @@
-
+
{% if options['as']['usepreprocessor'] %}
diff --git a/tools/export/gnuarmeclipse/__init__.py b/tools/export/gnuarmeclipse/__init__.py
index 42ade5f9c4..00f9ef4b4c 100644
--- a/tools/export/gnuarmeclipse/__init__.py
+++ b/tools/export/gnuarmeclipse/__init__.py
@@ -22,11 +22,12 @@ the GNU ARM Eclipse plug-ins.
Author: Liviu Ionescu
"""
from tools.export.exporters import Exporter
-from os.path import splitext, basename, relpath, dirname
+from os.path import splitext, basename, relpath, dirname, exists
from random import randint
import os
import copy
import tempfile
+import shutil
from subprocess import call, Popen, PIPE
# import logging
@@ -188,6 +189,7 @@ class GNUARMEclipse(Exporter):
# expected context values is not defined.
self.gen_file('gnuarmeclipse/.project.tmpl', ctx, '.project')
self.gen_file('gnuarmeclipse/.cproject.tmpl', ctx, '.cproject')
+ self.gen_file('gnuarmeclipse/makefile.targets.tmpl', ctx, 'makefile.targets')
print 'Done.'
@@ -228,16 +230,38 @@ class GNUARMEclipse(Exporter):
'--launcher.suppressErrors',
'-nosplash',
'-application org.eclipse.cdt.managedbuilder.core.headlessbuild',
- '-data', tmp_folder,
- '-import', os.getcwd(),
- '-cleanBuild', 'all',
+ '-data', relpath(tmp_folder, os.getcwd()),
+ '-import', '.',
+ '-cleanBuild', 'all'
]
- ret_code = subprocess.call(cmd)
+ p = Popen(' '.join(cmd), stdout=PIPE, stderr=PIPE)
+ out, err = p.communicate()
+ ret_code = p.returncode
+
+ stdout_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n"
+ err_string = "=" * 10 + "STDERR" + "=" * 10 + "\n"
+ err_string += err
+
+
+ ret_string = "SUCCESS\n"
+ if ret_code != 0:
+ ret_string += "FAILURE\n"
+
+ print "%s\nSee %s for STDOUT\n%s\n%s" % (stdout_string, log_name, err_string, ret_string)
+
+ if log_name:
+ # Write the output to the log file
+ with open(log_name, 'w+') as f:
+ f.write(stdout_string)
+ f.write(out)
+ f.write(err_string)
+ f.write(ret_string)
# Cleanup the exported and built files
if cleanup:
- os.remove(log_name)
+ if exists(log_name):
+ os.remove(log_name)
os.remove('.project')
os.remove('.cproject')
if exists('Debug'):
diff --git a/tools/export/gnuarmeclipse/makefile.targets.tmpl b/tools/export/gnuarmeclipse/makefile.targets.tmpl
new file mode 100644
index 0000000000..ad8400a32d
--- /dev/null
+++ b/tools/export/gnuarmeclipse/makefile.targets.tmpl
@@ -0,0 +1,8 @@
+define \n
+
+
+endef
+
+mbedclean:
+ $(foreach TO_BE_CLEANED,$(CC_DEPS)$(C++_DEPS)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) {{name}}.elf,$(RM) $(TO_BE_CLEANED)${\n})
+ -@echo ' '
\ No newline at end of file