This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Just extraction #818
Open
davidhyman
wants to merge
56
commits into
master
Choose a base branch
from
just_extraction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Just extraction #818
Changes from 48 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
c71736a
output folder WiP
thegecko 37a8d3a
gitignore idea
davidhyman 79d208f
common path manipulation tools
davidhyman b36dcb7
use the generator rather than assertions
davidhyman 97b8d0f
unused variables
davidhyman e6ed1f6
relative paths for CMakeLists
davidhyman 1826a31
protect paths code from argparser Namespace missing keys
davidhyman abfeeb2
tidy up installAndBuild
davidhyman 403d6aa
explicit flag for performing a full export (?)
davidhyman e5e503c
print debug traceback on exception
davidhyman d317d59
'export mode' added (but broken)
davidhyman 78fbe0b
works for very simple examples.
davidhyman 75792e9
successfully builds `ble` + `deps`
davidhyman 56c3f9b
stop using args namespaces (some more)
davidhyman 0fdbef4
use unittest assertions properly, update for ym->modules
davidhyman 8bb65d6
update docs
davidhyman 7cc282f
toolchain path, build cli clarification
davidhyman 3ce22b2
debugging circle using print statements. great.
davidhyman 0f3e277
in toolchain, force a string replace on toolchain include files
davidhyman f5fbca1
...
davidhyman afc8202
toolchain with absolute paths?
davidhyman fa11631
Revert "toolchain with absolute paths?"
davidhyman e9d0423
add a dockerfile for testing
davidhyman 7309123
Templated replacement for yotta header files
davidhyman a4e1722
yotta self reference
davidhyman b494095
test_debug relpath
davidhyman fae3e20
tweak template comments
davidhyman f4098b2
dockerfile updates
davidhyman 4f18ae3
Fixes test_testCustomCMake
davidhyman a394342
unicode is bad for the environment
davidhyman baecb75
tweaks for dev docker
davidhyman f4530a8
clarify depend_subdirs
davidhyman efb829f
fix add_own_subdirs
davidhyman d90625c
improve tempfile handling
davidhyman 066b164
add a test for export behaviour
davidhyman 71d683d
python3 print statement
davidhyman ce7e458
inconsistent docs
davidhyman 4da9861
remove paths & dockerfile for this branch
davidhyman c235600
circleci: give tox more time
davidhyman 398dbb0
fix for noop test for relative/non-relative paths
davidhyman 2942916
re-add `ym` as a default for backwards-compatibility
davidhyman 28e046e
timeouts on test export subprocess commands
davidhyman 9b61e1a
speculative grep fix
davidhyman ba14037
fix test_test_subcommand
davidhyman bed35b8
remove the subprocess32 stuff
davidhyman 0557159
oops, need that bit
davidhyman da8f188
unused imports
davidhyman b87ac7f
drop tox timeout
thegecko a5bed51
revert references to ym
davidhyman 0313a51
tweak export helpstring
davidhyman 6784962
Merge branch 'master' into just_extraction
caff88d
Add a couple of references to `export` in the docs
davidhyman e42079f
'vendor_modules' -> 'modules' + black->white list
davidhyman 09cc9a3
i) tidy up after exporting ii) builddir for export closer to top level
davidhyman e1f1399
Fix for extraneous quotes
e5e112f
update from master (0.18.4) - cryptography install fixes
davidhyman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ dist | |
git-access-testing | ||
github-access-testing | ||
*~ | ||
*.idea | ||
.tox | ||
*nosetests.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,8 @@ info: generate for target: x86-osx-native 0.0.7 at /path/to/helloyotta/yotta_tar | |
-- Configuring done | ||
-- Generating done | ||
-- Build files have been written to: /path/to/helloyotta/build/x86-osx-native | ||
[1/3] Building C object ym/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o | ||
FAILED: /usr/bin/cc -I/path/to/helloyotta -I/path/to/helloyotta/yotta_modules/simplelog -I/path/to/helloyotta/yotta_modules/simplelog/source -O2 -g -DNDEBUG -include "/path/to/helloyotta/build/x86-osx-native/yotta_config.h" -MMD -MT ym/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o -MF ym/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o.d -o ym/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o -c /path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c | ||
[1/3] Building C object modules/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o | ||
FAILED: /usr/bin/cc -I/path/to/helloyotta -I/path/to/helloyotta/yotta_modules/simplelog -I/path/to/helloyotta/yotta_modules/simplelog/source -O2 -g -DNDEBUG -include "/path/to/helloyotta/build/x86-osx-native/yotta_config.h" -MMD -MT modules/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o -MF modules/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o.d -o modules/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o -c /path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c | ||
/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c:25:50: error: expected ';' after expression | ||
printf("%s %s\n", prefixForLevel(level), msg) // deliberately missing semicolon | ||
^ | ||
|
@@ -64,14 +64,14 @@ error: command ['ninja'] failed | |
Here we can see that the file that was being built when the error occurred was: | ||
|
||
``` | ||
[1/3] Building C object ym/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o | ||
[1/3] Building C object modules/simplelog/source/CMakeFiles/simplelog.dir/path/to/helloyotta/yotta_modules/simplelog/source/simplelog.c.o | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
``` | ||
|
||
This is a path relative to the build directory, the `ym` directory is the | ||
This is a path relative to the build directory, the `modules` directory is the | ||
subdirectory where dependencies are built, and is always followed immediately | ||
by a dependency name (if there were no `ym/` at the start of the path then the | ||
by a dependency name (if there were no `modules/` at the start of the path then the | ||
object would belong to the top-level module/app being built). So from | ||
`/ym/simplelog/...` we can tell that the failed file is in the `simplelog` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
`/modules/simplelog/...` we can tell that the failed file is in the `simplelog` | ||
dependency. | ||
|
||
This is also visible from the source file where the error is reported: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# standard library modules, , , | ||
import os | ||
import logging | ||
import shutil | ||
|
||
|
||
# validate, , validate things, internal | ||
|
@@ -16,6 +17,11 @@ | |
from yotta.lib import cmakegen | ||
# Target, , represents an installed target, internal | ||
from yotta.lib import target | ||
# settings, , load and save settings, internal | ||
from yotta.lib import settings | ||
# paths | ||
from yotta.lib import paths | ||
from yotta.lib import fsutils | ||
# install, , install subcommand, internal | ||
from yotta import install | ||
# --config option, , , internal | ||
|
@@ -27,6 +33,13 @@ def addOptions(parser, add_build_targets=True): | |
action='store_true', default=False, | ||
help='Only generate CMakeLists, don\'t run CMake or build' | ||
) | ||
parser.add_argument('-x', '--export', dest='export', | ||
default=False, const=True, nargs='?', | ||
help=( | ||
'Export mode. If flag is set, generates builds without reference to Yotta.' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'[optional] Specify an output path to receive the clean build' | ||
) | ||
) | ||
parser.add_argument('-r', '--release-build', dest='release_build', action='store_true', default=True) | ||
parser.add_argument('-d', '--debug-build', dest='release_build', action='store_false', default=True) | ||
# the target class adds its own build-system specific options. In the | ||
|
@@ -56,16 +69,36 @@ def installAndBuild(args, following_args): | |
If status: is nonzero there was some sort of error. Other properties | ||
are optional, and may not be set if that step was not attempted. | ||
''' | ||
build_status = generate_status = install_status = 0 | ||
|
||
if not hasattr(args, 'build_targets'): | ||
vars(args)['build_targets'] = [] | ||
build_status = 0 | ||
generate_status = 0 | ||
error = None | ||
args_dict = vars(args) | ||
export_mode_or_path = args_dict.get('export') | ||
|
||
if export_mode_or_path: | ||
logging.info('this build will be configured for exporting') | ||
new_modules = settings.getProperty('build', 'vendor_modules_directory') or 'vendor_modules' | ||
new_targets = settings.getProperty('build', 'vendor_targets_directory') or 'vendor_targets' | ||
new_build_modules = settings.getProperty('build', 'built_modules_directory') or 'modules' | ||
# to save downloading the cached files, copy the old cache | ||
try: | ||
if not os.path.exists(new_modules): | ||
shutil.copytree(paths.Modules_Folder, new_modules) | ||
shutil.copytree(paths.Targets_Folder, new_targets) | ||
except Exception as e: | ||
logging.error(e) | ||
logging.error('failed to use existing cache; rebuilding') | ||
|
||
paths.Modules_Folder = new_modules | ||
paths.Targets_Folder = new_targets | ||
paths.BUILT_MODULES_DIR = new_build_modules | ||
|
||
args_dict.setdefault('build_targets', []) | ||
|
||
if 'test' in args.build_targets: | ||
logging.error('Cannot build "test". Use "yotta test" to run tests.') | ||
return {'status':1} | ||
|
||
cwd = os.getcwd() | ||
c = validate.currentDirectoryModule() | ||
if not c: | ||
return {'status':1} | ||
|
@@ -82,26 +115,26 @@ def installAndBuild(args, following_args): | |
|
||
# run the install command before building, we need to add some options the | ||
# install command expects to be present to do this: | ||
vars(args)['component'] = None | ||
vars(args)['act_globally'] = False | ||
args_dict['component'] = None | ||
args_dict['act_globally'] = False | ||
if not hasattr(args, 'install_test_deps'): | ||
if 'all_tests' in args.build_targets: | ||
vars(args)['install_test_deps'] = 'all' | ||
args_dict['install_test_deps'] = 'all' | ||
elif not len(args.build_targets): | ||
vars(args)['install_test_deps'] = 'own' | ||
args_dict['install_test_deps'] = 'own' | ||
else: | ||
# If the named build targets include tests from other modules, we | ||
# need to install the deps for those modules. To do this we need to | ||
# be able to tell which module a library belongs to, which is not | ||
# straightforward (especially if there is custom cmake involved). | ||
# That's why this is 'all', and not 'none'. | ||
vars(args)['install_test_deps'] = 'all' | ||
args_dict['install_test_deps'] = 'all' | ||
|
||
# install may exit non-zero for non-fatal errors (such as incompatible | ||
# version specs), which it will display | ||
install_status = install.execCommand(args, []) | ||
|
||
builddir = os.path.join(cwd, 'build', target.getName()) | ||
builddir = os.path.join(os.getcwd(), paths.DEFAULT_BUILD_DIR, target.getName()) | ||
|
||
all_deps = c.getDependenciesRecursive( | ||
target = target, | ||
|
@@ -125,7 +158,7 @@ def installAndBuild(args, following_args): | |
logging.debug("config done, merged config: %s", config['merged_config_json']) | ||
|
||
script_environment = { | ||
'YOTTA_MERGED_CONFIG_FILE': config['merged_config_json'] | ||
'YOTTA_MERGED_CONFIG_FILE': str(config['merged_config_json']) | ||
} | ||
# run pre-generate scripts for all components: | ||
runScriptWithModules(c, all_deps.values(), 'preGenerate', script_environment) | ||
|
@@ -139,7 +172,34 @@ def installAndBuild(args, following_args): | |
# run pre-build scripts for all components: | ||
runScriptWithModules(c, all_deps.values(), 'preBuild', script_environment) | ||
|
||
if (not hasattr(args, 'generate_only')) or (not args.generate_only): | ||
if export_mode_or_path and export_mode_or_path is not True: | ||
# these export exclusions apply at any level of the directory structure | ||
excludes = { | ||
'.module.json', | ||
'.yotta.json', | ||
'.yotta_origin.json', | ||
'module.json', | ||
'target.json', | ||
'yotta_modules', | ||
'yotta_targets' | ||
} | ||
export_to = os.path.abspath(export_mode_or_path) | ||
logging.info('exporting unbuilt project source and dependencies to %s', export_to) | ||
check = os.path.join(export_to, 'source') # this might be insufficient, or indeed misleading. | ||
if os.path.exists(export_to) and os.listdir(export_to) and not os.path.exists(check): | ||
# as the export can be any path we do a sanity check before calling 'rmRf' | ||
raise Exception( | ||
'Aborting export: directory is not empty and does not look like a previous export' | ||
' (expecting: %s)' | ||
% (check) | ||
) | ||
fsutils.rmRf(export_to) | ||
shutil.copytree(src='.', dst=export_to, ignore=lambda a, b: excludes) | ||
|
||
if args_dict.get('generate_only'): | ||
logging.info('skipping build step') | ||
else: | ||
# build in the current directory | ||
error = target.build( | ||
builddir, c, args, release_build=args.release_build, | ||
build_args=following_args, targets=args.build_targets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,3 @@ def execCommand(args, following_args): | |
return 1 | ||
|
||
fsutils.rmRf(os.path.join(c.path, 'build')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should still say
ym
notmodules