summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.erl
Commit message (Collapse)AuthorAgeFilesLines
* Only lint app files when compilingFred Hebert2019-06-021-0/+1
| | | | | | | | This allows to reduce the number of noise to only checking deps' app files when they're built, rather than on every run. Since main apps and checkouts are still compiled every time, the linting takes place there and then with a higher frequency.
* Ensure the right deps are in pathFred Hebert2018-11-281-0/+1
| | | | | Compile time with parse transforms needs to have the deps first in scope before the plugins
* Fix load order for custom project buildersFred Hebert2018-11-281-1/+1
| | | | | | | | | Due to building dependencies with potential artifacts such as parse transforms or macros, project builder plugins should be included in the path, but _after_ deps are loaded. Doing otherwise means that if any of the dependencies is required at compile time, those of a plugin might get used first.
* Optimize path handlingFred Hebert2018-10-111-6/+6
| | | | | | | | | | | | | | | | | - Only set paths that need to be put as a priority - Clean up paths before leaving API mode The first point accounted for some performance cost, but the latter one explains the 40% overhead in test runs: since rebar3 calls rebar3 a lot with a bunch of fake apps, and that the new mechanism for path handling by default does not _remove_ paths, it just _orders_ them, we would end up in a situation where as the tests ran, more and more fake paths would get added to the VM. By the time the run was over, all path handling would take longer since more paths needed filtering every time. By resetting paths at the end of an API run, we prevent a given 'project' from polluting another one's runtime and performance once the API successfully returns.
* Fix a bug in compiler path handlingFred Hebert2018-10-111-1/+1
| | | | Also handle some formatting
* Abstracted path managementFred Hebert2018-10-111-20/+16
| | | | | | | | | | | | | | | | Move path management out of rebar_utils manual code path function handling (which we leave there for backwards compat), and centralize them to allow easier coordination of paths between plugins and deps. On top of path handling, do a check of loaded modules to only purge and reload those that actually need it done in order to prevent all kinds of weird interaction and accidental purge kills. It also allows the possible cohabitation of both at once, with a "in case of conflict pick X" as a policy Changing path handling in providers also highlighted a bunch of bugs in some tests and appears to fix some in other providers, specifically around plugins.
* throw builder error when returned from project build (#1909)Tristan Sloughter2018-10-101-2/+6
|
* compiler behaviour (#1893)Tristan Sloughter2018-10-051-4/+39
| | | | | | | | | | | | | | | | * add compile type for dynamic project compilation * new rebar_compiler abstraction for running multiple compilers rebar_compiler is a new behaviour that a plugin can implement to be called on any ues of the compile provider to compile source files and keep track of their dependencies. * fix check that modules in .app modules list are from src_dirs * use project_type to find module for building projects * allow plugins to add project builders and compilers
* add option to compiler provider to only build dependencies (#1888)Tristan Sloughter2018-09-191-7/+25
|
* Fix symlink/copying logic in compiler for privFred Hebert2018-04-271-1/+10
| | | | | Priv and include dirs need the virtual symlink in order to preserve hook functionality in some edge cases.
* Prevent copying or symlink non-existing src_dirsFred Hebert2018-04-271-1/+4
| | | | | | | | | | This would cause crashes on linux and force people to have a src_dirs config that is strictly matching what is on the file system rather than acting as a specification of those that are valid. To compare, if lib_dirs worked the same, then any repo that did not both have apps/ and lib/ would crash, as the spec mentions both options as valid.
* Fix compilation for custom resources dynamic vsnFred Hebert2017-11-221-1/+12
| | | | | | | | | | | | | | | | | | | | | | | The Erlang compiler runs based on a global state built from currently loaded libraries and the configured code path that is available. For this reason, the rebar3 compiler job unloads all plugin paths before calling the Erlang compiler. However, this causes a problem when an application uses a custom resource handler with a dynamic version in their .app.src file since the plugin that can be used to find the version has been unloaded. Fortunately, the compile phase that runs the version handling is distinct from the phase that uses the Erlang compiler. This patch fixes the problem by re-loading the plugins' paths in memory before generating the .app file, and before unloading them afterwards. It appears that unloading them is unnecessary because the hooks after that will re-load them, but it is likely better to play it safe with that global state and clean up after ourselves. It offers better protection for future changes. Fixes #1657
* Fix include paths in profile multiapp edge caseFred Hebert2017-10-231-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiling of OTP applications is done by first topographically sorting them according to their dependencies, deps-first. This allows all compilation to take place in order. In the current code, the same logic extends to top-level applications in an umbrella project. Unfortunately, there are cases where this is not going to be true: when an application has extra_src_dirs entries (or additional directories or files) to conditionally compile under some profiles, it may start depending on another top-level application dedicated to that profile for include files. However, such an app will never make it to production and neither will the compilation artifacts that create the dependency. Under that scenario, current rebar3 is unusable. This patch makes it so that the compilation provider instead changes the logic for top-level apps: rather than copying their directories one by one and compiling them in order, it: 1. copies all top-level apps to the build directory so the files are in their proper locations 2. adds the top-level apps to the path (after the global hooks have run, so the existing scope and env has not changed) 3. runs the compilation as usual. Fixes #1651
* Unicode support in all the placesFred Hebert2017-08-061-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is done through 3 main change groups: - replacing `~s` by `~ts` in format strings, so that strings that contain unicode are properly printed rather than crashing - adding the `unicode` argument to all function of the `re` module to ensure transformations on strings containing unicode data are valid instead of crashing (see issue #1302) - replacing `ec_cnv:to_binary/1` and `ec_cnv:to_list/1` with matching functions in `rebar_utils`. The last point has been done, rather than modifying and updating erlware commons, because binary and list conversions can be a contentious subject. For example, if what is being handled is actually bytes from a given binary stream, then forcing a byte-oriented interpretation of the data can corrupt it. As such, it does not appear safe to modify erlware commons' conversion functions since it may not be safe for all its users. Instead, rebar3 reimplements a subset of them (only converting atoms and chardata, ignoring numbers) with the explicit purpose of handling unicode string data. Tests were left as unchanged as possible. This may impact the ability to run rebar3's own suites in a unicode path, but respects a principle of least change for such a large patch.
* Include hook for app compilationZachary Hueras2016-02-091-4/+7
|
* Add secondary hook for rebar_prv_compileZachary Hueras2016-02-021-7/+11
| | | | | erlc_compile, for before/after compiling .erls to .beams, but before .app.src to .app
* warn if the directories `eunit' or `ct' show up in `src_dirs'alisdair sullivan2016-01-051-2/+17
| | | | | | | | if these directories actually exist they'll be added to the path ahead of the release/standard distribution directories and they'll break eunit and/or ct execution fixes #950
* allow ct suites to be specified at the root of a project (or root of app)alisdair sullivan2015-12-201-0/+4
| | | | | | | | previously rebar3 dropped suites declared at the root of the project (via `--suite=whatever_SUITE' probably) and warned. this was because the compiler would recursively copy and compile everything in the directory indicated by the test suite. this changes the copy mechanism to only copy erl source files and directories that end with `_SUITE_data' into the `extras' dir in `_build'
* refactor `rebar_erlc_compiler`alisdair sullivan2015-10-261-12/+107
| | | | | | | | | | | | | | | | | | | * modify compiler interface to work on either application objects or directories containing source files * compile all sources in `src_dirs` to the application `ebin` dir and all sources in `extra_src_dirs` to a directory mirroring it's position in the app's `_build` directory. for example, `apps/foo/more` would compile to `_build/default/lib/foo/more` for `extra_src_dirs` in the root of a project with multiple applications (so orphan directories that don't "belong" to an application) compile to `_build/default/extras/more` * copy directories specified in `extra_src_dirs` into the `_build` directory so tools like `ct` and `xref` that expect source to be in a particular location still work * clean compiled artifacts from all `extra_src_dirs` * alter `eunit`, `ct` and `cover` to work with the new directory structure * billions of new tests
* add bare compile provider, for starters for use by mixTristan Sloughter2015-09-141-1/+5
|
* support updating of per app info by hooksTristan Sloughter2015-09-061-8/+8
|
* more cleanupTristan Sloughter2015-08-311-9/+0
|
* update use of hooks and plugins with state in app_infoTristan Sloughter2015-08-311-13/+17
|
* remove state record from app_info recordTristan Sloughter2015-08-311-2/+2
|
* wip: move state into app_infoTristan Sloughter2015-08-311-8/+8
|
* Merge pull request #613 from tsloughter/plugins_fix_pathFred Hebert2015-07-161-1/+2
|\ | | | | keep plugins in path after compile provider run
| * keep plugins in path after compileprovider runTristan Sloughter2015-07-151-1/+2
| |
* | Revert "don't add `{extra_src_dirs, ["test"]}` to `test` profile"alisdair sullivan2015-07-121-1/+1
|/ | | | This reverts commit b06a6ecaddfc6fea16f3c24881fd41ac731ffa9e.
* ensure necessary directories exist to compile mibs filesTristan Sloughter2015-07-061-0/+13
|
* add config option artifactsTristan Sloughter2015-06-021-0/+13
|
* keep all_deps list in state created for building depsTristan Sloughter2015-05-301-4/+7
|
* Merge pull request #487 from ferd/fix-provider-barenessTristan Sloughter2015-05-301-1/+1
|\ | | | | fix bareness issues
| * fix bareness issuesFred Hebert2015-05-311-1/+1
| | | | | | | | | | | | - Crashes in providers lib when no providers in a namespace are bare - Making sure bareness matches semantics; i.e. a bare provider is visible, a non-bare provider is hidden.
* | store plugin providers in app_info's state for depsTristan Sloughter2015-05-281-1/+0
| |
* | fix for plugin installation and code pathsTristan Sloughter2015-05-271-0/+3
| |
* | move handling of undefined app state to functionTristan Sloughter2015-05-221-9/+1
|/
* run hooks when building pluginsTristan Sloughter2015-05-211-8/+7
|
* Merge pull request #443 from kovyl2404/singleapp-project-duplicated-hookFred Hebert2015-05-211-1/+1
|\ | | | | Run hooks for single application only once.
| * Properly reset hooks for single-app projectViacheslav V. Kovalev2015-05-211-1/+1
| |
* | don't add `{extra_src_dirs, ["test"]}` to `test` profilealisdair sullivan2015-05-201-1/+1
| | | | | | | | | | | | adding it results in ct test suites being compiled before they're properly copied so changes made to suites between runs are not reflected if a run fails before test dirs are copied
* | methods for retrieving `src_dirs` and `extra_src_dirs`alisdair sullivan2015-05-191-3/+1
|/ | | | | | note that now ALL `src_dirs` across included profiles are compiled. previously only the last included profile's `src_dirs` were used
* generalize the "test" special dir into an {extra_src_dirs, [...]} optionalisdair sullivan2015-05-161-2/+3
| | | | | | like `src_dirs`, `extra_src_dirs` are directories to be copied to the `_build` dir and compiled. unlike `src_dirs` they are not added to the .app specification
* real bootstrappingTristan Sloughter2015-04-221-2/+1
|
* track and cleanup code paths for different contextsTristan Sloughter2015-04-211-2/+9
|
* run project wide pre-compile hooks after deps have compiledTristan Sloughter2015-04-201-2/+3
|
* don't duplicate hooks for top level appTristan Sloughter2015-04-191-7/+4
|
* update project_apps and state before running post hooksTristan Sloughter2015-04-171-2/+4
|
* include applications list in compile sortTristan Sloughter2015-04-151-2/+3
|
* Merge pull request #320 from tsloughter/dep_pluginsFred Hebert2015-04-051-9/+13
|\ | | | | install dep plugins & run provider hooks the same as shell hooks (Rereopen 316)
| * swich clean and compile to use macro provider in hook runTristan Sloughter2015-04-041-4/+4
| |