Closed bulislaw closed 6 years ago
your cp
command is mising a destination.
I executed the copy correctly (the main.c and some headers are in the sources). Now also fixed in bug report.
Hi, guys,
google gives me the link, some solutions to this issu?
Thanks
make all Building file: tools/data/rpc/class.cpp Invoking: Cross ARM GNU C++ Compiler arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction- tools/data/rpc/class.cpp:1:11: error: expected unqualified-id before '{' token class Rpc{{name}} : public RPC { ^ tools/data/rpc/class.cpp:1:17: error: expected ';' after class definition class Rpc{{name}} : public RPC { ^ tools/data/rpc/class.cpp:1:19: error: expected unqualified-id before ':' token class Rpc{{name}} : public RPC { ^ make: *** tools/data/rpc/subdir.mk:20: tools/data/rpc/class.o] Error 1
18:20:05 Build Finished (took 26s.247ms)
Huh. the tools directory contains an mbedignore with a *
in it. That file should not be included.
so, should i delete this tools folder?
The fact that the files are being included is a bug.
I can reproduce this behaviour for OS2. For OS5, the tools folder is excluded (by the gnuarmeclipse plugin?). For OS2 projects, the folder is in '.temp' and this folder is not shown in the project tree. But the CDT scanner finds this folder and the cpp source file. So this genrates the error.
Manual fix: Exclude the .tools subdir from the resources in the eclipse project settings: Resource/Resources Filters , Add Filter
This creates an entry in the .project file for excluding this folder.
@JojoS62 I'll look into how the exclude search is failing WRT mbed 2. You are correct that the tools folder should be excluded from builds.
I have tried to create a PR with the modified template file, but the PR contains all my commits for other stuff. So I need to read first more about the git stuff. Anyway, you should see my modification in the closed PR. But maybe @ilg-ul has also another way for configuring exclusions in his plugin?
@theotherjimmy found something more: there is a dictionary excluded_folders for this purpose. It is the same for mbed2 and 5 in https://github.com/ARMmbed/mbed-os/blob/master/tools/export/gnuarmeclipse/__init__.py#L468
# print 'excludings'
self.excluded_folders = ['BUILD']
self.recurse_excludings(self.source_tree)
Yep. (that's a list, not a dict, BTW).
I was suggesting that recursive_excludings
should add .temp
to that list.
@JojoS62 I convert the tools folder of mbed OS to a release by applying a smallish patch, so most things should be the same.
yes, I agree its better than modifying the template.
diff --git a/tools/build_api.py b/tools/build_api.py
index c9e288dae..bbc1e0ae7 100644
--- a/tools/build_api.py
+++ b/tools/build_api.py
@@ -34,12 +34,13 @@ from tools.paths import MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,\
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL, MBED_CONFIG_FILE,\
MBED_LIBRARIES_DRIVERS, MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,\
BUILD_DIR
-from tools.targets import TARGET_NAMES, TARGET_MAP
+from tools.targets import TARGET_NAMES, TARGET_MAP, set_targets_json_location
from tools.libraries import Library
-from tools.toolchains import TOOLCHAIN_CLASSES
+from tools.toolchains import TOOLCHAIN_CLASSES, mbedToolchain
from jinja2 import FileSystemLoader
from jinja2.environment import Environment
from tools.config import Config
+from tools.build_profiles import find_build_profile, get_toolchain_profile, find_targets_json
RELEASE_VERSIONS = ['2', '5']
@@ -487,6 +488,45 @@ def build_project(src_paths, build_path, target, toolchain_name,
rmtree(build_path)
mkdir(build_path)
+ ###################################
+ # mbed Classic/2.0/libary support #
+
+ # Find build system profile
+ profile = None
+ targets_json = None
+ for path in src_paths:
+ profile = find_build_profile(path) or profile
+ if profile:
+ targets_json = join(dirname(abspath(__file__)), 'legacy_targets.json')
+ else:
+ targets_json = find_targets_json(path) or targets_json
+
+ # Apply targets.json to active targets
+ if targets_json:
+ if verbose:
+ print("Using targets from %s" % targets_json)
+ set_targets_json_location(targets_json)
+
+ # Apply profile to toolchains
+ if profile:
+ def init_hook(self):
+ profile_data = get_toolchain_profile(self.name, profile)
+ if not profile_data:
+ return
+ if verbose:
+ self.info("Using toolchain %s profile %s" % (self.name, profile))
+
+ for k,v in profile_data.items():
+ if self.flags.has_key(k):
+ self.flags[k] = v
+ else:
+ setattr(self, k, v)
+
+ mbedToolchain.init = init_hook
+
+ # mbed Classic/2.0/libary support #
+ ###################################
+
toolchain = prepare_toolchain(
src_paths, build_path, target, toolchain_name, macros=macros,
clean=clean, jobs=jobs, notify=notify, silent=silent, verbose=verbose,
diff --git a/tools/config/__init__.py b/tools/config/__init__.py
index e6d888fda..80fb5005e 100644
--- a/tools/config/__init__.py
+++ b/tools/config/__init__.py
@@ -846,11 +846,6 @@ class Config(object):
self.cumulative_overrides['features']\
.update_target(self.target)
- for feature in self.target.features:
- if feature not in self.__allowed_features:
- raise ConfigException(
- "Feature '%s' is not a supported features" % feature)
-
return self.target.features
def validate_config(self):
diff --git a/targets/targets.json b/tools/latest_targets.json
similarity index 100%
rename from targets/targets.json
rename to tools/latest_targets.json
diff --git a/tools/legacy_targets.json b/tools/legacy_targets.json
new file mode 100644
[SNIP]
diff --git a/tools/project.py b/tools/project.py
index f9da97498..e540bec1a 100644
--- a/tools/project.py
+++ b/tools/project.py
@@ -15,12 +15,14 @@ from tools.settings import BUILD_DIR
from tools.export import EXPORTERS, mcu_ide_matrix, mcu_ide_list, export_project, get_exporter_toolchain
from tools.tests import TESTS, TEST_MAP
from tools.tests import test_known, test_name_known, Test
-from tools.targets import TARGET_NAMES
+from tools.targets import TARGET_NAMES, set_targets_json_location
from tools.utils import argparse_filestring_type, argparse_profile_filestring_type, argparse_many, args_error
from tools.utils import argparse_force_lowercase_type
from tools.utils import argparse_force_uppercase_type
from tools.utils import print_large_string
from tools.options import extract_profile, list_profiles, extract_mcus
+from tools.build_profiles import find_targets_json, find_build_profile, get_toolchain_profile
+from tools.toolchains import mbedToolchain
def setup_project(ide, target, program=None, source_dir=None, build=None, export_path=None):
"""Generate a name, if not provided, and find dependencies
@@ -89,6 +91,45 @@ def export(target, ide, build=None, src=None, macros=None, project_id=None,
zip_name = name+".zip" if zip_proj else None
+ ###################################
+ # mbed Classic/2.0/libary support #
+
+ # Find build system profile
+ profile = None
+ targets_json = None
+ for path in src:
+ profile = find_build_profile(path) or profile
+ if profile:
+ targets_json = join(dirname(dirname(abspath(__file__))), 'legacy_targets.json')
+ else:
+ targets_json = find_targets_json(path) or targets_json
+
+ # Apply targets.json to active targets
+ if targets_json:
+ if not silent:
+ print("Using targets from %s" % targets_json)
+ set_targets_json_location(targets_json)
+
+ # Apply profile to toolchains
+ if profile:
+ def init_hook(self):
+ profile_data = get_toolchain_profile(self.name, profile)
+ if not profile_data:
+ return
+ if not silent:
+ self.info("Using toolchain %s profile %s" % (self.name, profile))
+
+ for k,v in profile_data.items():
+ if self.flags.has_key(k):
+ self.flags[k] = v
+ else:
+ setattr(self, k, v)
+
+ mbedToolchain.init = init_hook
+
+ # mbed Classic/2.0/libary support #
+ ###################################
+
return export_project(src, project_dir, target, ide, name=name,
macros=macros, libraries_paths=lib, zip_proj=zip_name,
build_profile=build_profile, silent=silent,
diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py
index 9d0217423..1789feb54 100644
--- a/tools/targets/__init__.py
+++ b/tools/targets/__init__.py
@@ -120,7 +120,7 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
# Default location of the 'targets.json' file
__targets_json_location_default = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), '..', '..', 'targets', 'targets.json')
+ os.path.dirname(os.path.abspath(__file__)), '..', 'latest_targets.json')
# Current/new location of the 'targets.json' file
__targets_json_location = None
That's the diff (with a few new files removed).
I'm going to look real quick to see if the .temp folder is being missed for some silly reason.
I'm not sure I understand the use case.
generally the exporter should run in a fresh folder, where there are no other folders generated by other exporters, or temporary folders from other builds. otherwise the python code used by the exporter will pick up files which are not actually needed and I could not find a rule to ignore them.
and also I'm confused by the way you want to use the exporter, i.e. to run various make commands on the result. the exporter generates managed projects, which you open with Eclipse and build inside Eclipse.
Actually, We are just debugging using the exporter, as you describe, for mbed 2 projects. In mbed 2 projects, the tools folder is located at .temp/tools
and that appears to be indexed by GNU ARM Eclipse after export.
you can patch the exporter to exclude .temp
, if needed.
@ilg-ul I'm pretty sure that the mbed build system does not include the .temp
dir, so your exclusion mechanism should pick up on this and add an exclude rule for it. I'm going to look into it to see if there is a bug in one of the steps leading up to export or in the exporter.
feel free to add any exclusions as you think necessary.
from my understanding:
This is why I like the zip option where only the necessary sources are picked and added to the zip. Eclipse can import this as well and many operations work much faster because it has not to analyse the large target tree. A zipped mbed2 library base is about 2 MB, the complete mbed2 library repo is already about 1,2 GB. Using the sources when exporting from mbed-os5 is also fine, but compilation takes much longer (there is always a reason for build-all). So for the exporter it would be fine to have both options: --library for using the precompiled lib and --zip for creating a single target extract. When possible with the VCS information included.
1): found that: the 'C/C++ Projects' view has a menu with a 'filter' entry, there is '.*' selected and the '.temp' is just hidden but still visible for the CDT scanner. The 'excluded_folders' in the GUI are in the project settings:
@JojoS62 We could add a -z/--zip
command line option, in addition to fixing the normal mbed 2 export.
This is why I like the zip option where only the necessary sources are picked and added to the zip.
Sounds like a feature request to me. This would have another advantage: you could generate the same thing that the online tools do by just passing -z/--zip
@ilg-ul It sounds like we need to add the exclusion rule .*
for parody with the build system, or drop the skipping of .
prefixed files from the exclude generator.
@JojoS62 @ilg-ul It looks like the following diff does what we want with no discernible performance impact:
diff --git i/tools/export/gnuarmeclipse/__init__.py w/tools/export/gnuarmeclipse/__init__.py
index d6de69f4b..28123caaa 100644
--- i/tools/export/gnuarmeclipse/__init__.py
+++ w/tools/export/gnuarmeclipse/__init__.py
@@ -437,14 +437,6 @@ class GNUARMEclipse(Exporter):
# to accomodate Windows weirdness.
parts = root.split(os.sep)
- # Ignore paths that include parts starting with dot.
- skip = False
- for part in parts:
- if part.startswith('.'):
- skip = True
- break
- if skip:
- continue
# Further process only leaf paths, (that do not have
# sub-folders).
I have a .git
and .settings
folder in my project, and it looks like they are being added to the exclude list:
before
Create a GNU ARM Eclipse C++ managed project
Project name: mbed-os-example-fat-filesystem
Target: K64F
Toolchain: GCC_ARM
Source folders: 42, with 73 exclusions
after
Create a GNU ARM Eclipse C++ managed project
Project name: mbed-os-example-fat-filesystem
Target: K64F
Toolchain: GCC_ARM
Source folders: 42, with 75 exclusions
Yes. I hope this has no impact on the git plugin, I can test this later.
They are in the exclude list and this is ok because there is no c code for the project, but the git plugin should still see these directories.
@JojoS62 I'm a bit confused. Are you saying that the .git
and .settings
folders contains no C code? or that the project contains no C code?
I'm testing with an mbed 2 project, and it's not excluding .temp
:(
my suggestion is to explicitly ignore .git
and .settings
, I guess Eclipse does not parse them for source code anyway and you might save a few cycles on each export.
I'm guessing you mean to add it to the array of static ignores on this line:
self.excluded_folders = ['BUILD']
I don't particularly like that. It seems brittle. If I add more dot-files with C code in them we will have to continue adding more entries to the static ignores.
I'm trying to make the exclude generating code generate those excludes dynamically so that we remove a whole class of potential incompatibilities between this exporter and mbed compile
I don't see why this is brittle, processing .git
by the exporter is a definite waste of time, since Eclipse does not parse it anyway. each extra file processed by the exporter adds a new node in the internal tree, and the .git
folder has lots of files.
@ilg-ul The difference in processing time seems to be on the order of ~10ms.
I have a much less brittle proposal: have the Resource object track directories that were ignored during the resource scan. This should not add a significant overhead, and it would be very useful for these exporters.
@ilg-ul @JojoS62 The patch that has the resource scan do our work for us looks good. It drops ~100ms off the export time for gnuarmeclipse for mbed-os exports, and does not affect mbed compile
times.
I have no idea what your proposal mean.
whatever you think, processing .git
in the exporter is pointless, regardless how much processing time it adds.
It seems brittle. If I add more dot-files with C code in them we will have to continue adding more entries to the static ignores
frankly, I have no idea where this concern came from.
we are talking here about removing the code to filter out the dot folders. that code was added there mainly for .git
and .settings
(and possibly the .DS_Store) . without that code, the unwanted folders were explicitly added to .cproject
as exclusions; probably this is not harmfull, but it is definitely not usual or needed.
and I think you do not have to add any static ignore for those two folders.
I don't mind what solution you use, but I would prefer not to generate silly .cproject
files.
@ilg-ul My proposed solution is to modify scan_resources
to collect directories that it ignored while scanning. Then, in the exporters, simply use this list instead of repeating the scan. Alternatively, see PR #4783.
It seems brittle. If I add more dot-files with C code in them we will have to continue adding more entries to the static ignores
frankly, I have no idea where this concern came from.
The mbed 2 projects include the tools within a directory called .temp
. The tools, for whatever reason, contain a template file with a .c
extension. Including this file breaks builds. We need to ignore this directory.
I'd also rather solve this once and for all. But agreed, who, in their right mind, would add a directory starting with .
and have .c
or similar files in it!
I'm not familiar with the detailed logic behind your code, but, as I said, as long as it does not generate unwanted exclusions in .cproject
, it should be fine.
Yeah. That's fine. It generates all of the exclusions used by mbed compile
by collecting the directory removals at their source.
TL;DR/Don't care: The exclusions are now exactly the same as mbed compile
.
@theotherjimmy I don't konw ecactly how your solution looks like but it sounds good. I could also reproduce that not skipping the '.*' directrories does not work. Another thought: it would be nice if the directory names for the tools in mbed2 and 5 would be the same. But I think thats history and more difficult to get.
About the zip option: When I force 'zip_file = True' (in project.py main()), a project.zip is created in the root of the project. This can be imported in eclipse and it works. The zipfiles also doesn't have the .temp problem because it is not included. Just 2 MB with the pure single target project. This is also the behaviour for the exporters before the big mbed5 rework.
Another thought: it would be nice if the directory names for the tools in mbed2 and 5 would be the same. But I think thats history and more difficult to get.
Yeah, that ship has sailed.
When I force 'zip_file = True' (in project.py main()), a project.zip is created in the root of the project.
This is exactly what the website produces as well, if it succeeds.
I thinks this thread boils down to a bug and a feature request:
.temp
directory was not being ignored (fix in #4783)-z/--zip
option.I'll get to the second feature request tomorrow.
Great! And I learned more important things in this puzzle :-)
just one more thing (bug?):
This is exactly what the website produces as well, if it succeeds.
I got also an error with creating the zipfile, a file not found error for toos/export/.mbed. There I thought I had deleted it accidently, but I cannot see it in the repo: https://developer.mbed.org/users/mbed_official/code/mbed-sdk-tools/file/399953da035d/export
Either this is not needed or missing in the export dir, maybe this is a reason for the export error on the website?
Oh, that was a miss-copy. Let me get that for you.
Naw, the website uses the tools from a patched version of the mbed OS release from github. That's not the export problem on the website. I have tracked the website export problem down. We're verifying now and going to get it deployed ASAP.
I pushed the .mbed
file up for you. Sorry about that.
ARM Internal Ref: MBOTRIAGE-366
Description
Bug
Target EFM32GG_STJ3700
Toolchain: GCC_ARM
I'm trying to export some tests as a mbed OS application to debug them in eclipse:
The build works using mbed cli but fails using eclipse:
@theotherjimmy