baltix 0.1.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +136 -10
- data/Rakefile +8 -3
- data/baltix.gemspec +47 -29
- data/bin/console +4 -3
- data/data/alt-licenses/README.md +26 -0
- data/data/alt-licenses/licenses.json +2991 -0
- data/data/alt-rpm/README.md +21 -0
- data/data/alt-rpm/architectures.json +613 -0
- data/data/spdx/README.md +22 -0
- data/data/spdx/licenses.json +9287 -0
- data/docs/action-flow.md +42 -0
- data/docs/actor-integration.md +71 -0
- data/docs/alt-architectures.md +27 -0
- data/docs/cleanup-actors.md +14 -0
- data/docs/dependency-actions.md +22 -0
- data/docs/installation-actors.md +35 -0
- data/docs/pkglist.md +56 -0
- data/docs/plans/revision-003.md +328 -0
- data/docs/plans/revision-004.md +416 -0
- data/docs/plans/revision-005.md +431 -0
- data/docs/plans/revision-006.md +439 -0
- data/docs/plans/revision-007.md +441 -0
- data/docs/plans/revision-008.md +445 -0
- data/docs/plans/revision-009.md +450 -0
- data/docs/plans/revision-010.md +486 -0
- data/docs/plans/revision-011.md +500 -0
- data/docs/plans/revision-012.md +501 -0
- data/docs/plans/revision-013.md +501 -0
- data/docs/plans/revision-014.md +501 -0
- data/docs/plans/revision-015.md +502 -0
- data/docs/plans/revision-016.md +503 -0
- data/docs/plans/revision-017.md +504 -0
- data/docs/plans/revision-018.md +505 -0
- data/docs/plans/revision-019.md +510 -0
- data/docs/plans/revision-020.md +524 -0
- data/docs/plans/revision-021.md +542 -0
- data/docs/plans/revision-022.md +542 -0
- data/docs/plans/revision-023.md +545 -0
- data/docs/plans/revision-024.md +567 -0
- data/docs/plans/revision-025.md +583 -0
- data/docs/plans/revision-026.md +241 -0
- data/docs/plans/revision-027.md +305 -0
- data/docs/plans/revision-028.md +298 -0
- data/docs/plans/revision-029.md +288 -0
- data/docs/rpm-action-macros.md +52 -0
- data/docs/rpm-parts.md +53 -0
- data/docs/ruby-dependencies.md +217 -0
- data/docs/ruby-policy-2.1.md +28 -0
- data/docs/ruby-versioning.md +61 -0
- data/docs/space-format.md +58 -0
- data/exe/baltix +1 -0
- data/lib/baltix/action_flow/files.rb +49 -0
- data/lib/baltix/action_flow/inputs.rb +60 -0
- data/lib/baltix/action_flow/journal.rb +60 -0
- data/lib/baltix/action_flow/options.rb +60 -0
- data/lib/baltix/action_flow.rb +65 -0
- data/lib/baltix/actor/build/collect.rb +72 -0
- data/lib/baltix/actor/build/compile.rb +25 -0
- data/lib/baltix/actor/build/extconf.rb +14 -0
- data/lib/baltix/actor/build/make.rb +18 -0
- data/lib/baltix/actor/build/postprocess.rb +14 -0
- data/lib/baltix/actor/build/rake.rb +18 -0
- data/lib/baltix/actor/build/ronn.rb +55 -0
- data/lib/baltix/actor/build.rb +87 -0
- data/lib/baltix/actor/clean/remove.rb +45 -0
- data/lib/baltix/actor/clean.rb +37 -0
- data/lib/baltix/actor/config.rb +12 -0
- data/lib/baltix/actor/copy.rb +22 -7
- data/lib/baltix/actor/distclean.rb +20 -0
- data/lib/baltix/actor/doc/collect.rb +39 -0
- data/lib/baltix/actor/doc/generate.rb +47 -0
- data/lib/baltix/actor/doc/inputs.rb +25 -0
- data/lib/baltix/actor/doc.rb +70 -0
- data/lib/baltix/actor/gen.rb +19 -0
- data/lib/baltix/actor/install/data.rb +18 -0
- data/lib/baltix/actor/install/documentation.rb +48 -0
- data/lib/baltix/actor/install/executable.rb +27 -0
- data/lib/baltix/actor/install/extension.rb +44 -0
- data/lib/baltix/actor/install/headers.rb +10 -0
- data/lib/baltix/actor/install/library.rb +13 -0
- data/lib/baltix/actor/install/metadata.rb +21 -0
- data/lib/baltix/actor/install/paths.rb +73 -0
- data/lib/baltix/actor/install/plugin.rb +25 -0
- data/lib/baltix/actor/install/record.rb +48 -0
- data/lib/baltix/actor/install/shebang.rb +29 -0
- data/lib/baltix/actor/install/transfer.rb +64 -0
- data/lib/baltix/actor/install/trees.rb +34 -0
- data/lib/baltix/actor/install.rb +71 -0
- data/lib/baltix/actor/link.rb +15 -6
- data/lib/baltix/actor/make.rb +14 -0
- data/lib/baltix/actor/predeps/write.rb +51 -0
- data/lib/baltix/actor/predeps.rb +41 -0
- data/lib/baltix/actor/provides.rb +12 -0
- data/lib/baltix/actor/requires.rb +12 -0
- data/lib/baltix/actor/show.rb +26 -0
- data/lib/baltix/actor/spec.rb +6 -3
- data/lib/baltix/actor/test/record.rb +8 -0
- data/lib/baltix/actor/test/run.rb +30 -0
- data/lib/baltix/actor/test/select.rb +16 -0
- data/lib/baltix/actor/test.rb +41 -0
- data/lib/baltix/actor/touch.rb +14 -5
- data/lib/baltix/actor.rb +43 -26
- data/lib/baltix/cli/dependency_options.rb +63 -0
- data/lib/baltix/cli/options/action.rb +32 -0
- data/lib/baltix/cli/options.rb +280 -0
- data/lib/baltix/cli/output_options.rb +56 -0
- data/lib/baltix/cli/rake_tasks.rb +59 -0
- data/lib/baltix/cli/source_options.rb +52 -0
- data/lib/baltix/cli.rb +130 -116
- data/lib/baltix/concerns/command.rb +52 -0
- data/lib/baltix/concerns/configuration.rb +39 -0
- data/lib/baltix/concerns/dependency_output.rb +21 -0
- data/lib/baltix/concerns/extension_metadata.rb +44 -0
- data/lib/baltix/concerns/file_destination.rb +14 -0
- data/lib/baltix/concerns/inspection.rb +27 -0
- data/lib/baltix/concerns/parts.rb +16 -0
- data/lib/baltix/concerns/target_paths.rb +57 -0
- data/lib/baltix/concerns.rb +11 -0
- data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
- data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
- data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
- data/lib/baltix/deps/executables.rb +30 -0
- data/lib/baltix/deps/packages.rb +32 -0
- data/lib/baltix/deps.rb +103 -194
- data/lib/baltix/dsl/dependency_groups.rb +77 -0
- data/lib/baltix/dsl/dependency_sources.rb +100 -0
- data/lib/baltix/dsl/filtering.rb +26 -0
- data/lib/baltix/dsl/loading.rb +72 -0
- data/lib/baltix/dsl/merging.rb +74 -0
- data/lib/baltix/dsl/rendering.rb +54 -0
- data/lib/baltix/dsl/requirements.rb +77 -0
- data/lib/baltix/dsl/temporary_files.rb +36 -0
- data/lib/baltix/dsl.rb +66 -273
- data/lib/baltix/executable_dependencies/features.rb +53 -0
- data/lib/baltix/executable_dependencies/library.rb +21 -0
- data/lib/baltix/executable_dependencies/library_features.rb +34 -0
- data/lib/baltix/executable_dependencies/syntax.rb +102 -0
- data/lib/baltix/executable_dependencies.rb +102 -0
- data/lib/baltix/extensions/bones.rb +173 -0
- data/lib/baltix/extensions/echoe.rb +143 -0
- data/lib/baltix/extensions/hoe/metadata.rb +89 -0
- data/lib/baltix/extensions/hoe/options.rb +84 -0
- data/lib/baltix/extensions/hoe/readme.rb +29 -0
- data/lib/baltix/extensions/hoe.rb +146 -0
- data/lib/baltix/extensions/jeweler.rb +95 -0
- data/lib/baltix/extensions/levitate.rb +74 -0
- data/lib/baltix/extensions/olddoc.rb +42 -0
- data/lib/baltix/extensions.rb +340 -419
- data/lib/baltix/i18n.rb +22 -19
- data/lib/baltix/license/catalog/capture.rb +58 -0
- data/lib/baltix/license/catalog.rb +75 -0
- data/lib/baltix/license.rb +76 -0
- data/lib/baltix/loader/capture.rb +91 -0
- data/lib/baltix/loader/cmake.rb +6 -3
- data/lib/baltix/loader/evaluation.rb +49 -0
- data/lib/baltix/loader/extconf.rb +27 -0
- data/lib/baltix/loader/feature_loading.rb +54 -0
- data/lib/baltix/loader/git-version-gen.rb +36 -21
- data/lib/baltix/loader/mast/properties.rb +58 -0
- data/lib/baltix/loader/mast.rb +97 -109
- data/lib/baltix/loader/object_capture.rb +27 -0
- data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
- data/lib/baltix/loader/pom.rb +36 -16
- data/lib/baltix/loader/rookbook.rb +19 -14
- data/lib/baltix/loader/yaml.rb +9 -5
- data/lib/baltix/loader.rb +85 -132
- data/lib/baltix/log.rb +26 -27
- data/lib/baltix/rake/metadata_adapter.rb +30 -0
- data/lib/baltix/rake/task_context.rb +59 -0
- data/lib/baltix/rake/task_libraries.rb +73 -0
- data/lib/baltix/rake.rb +62 -12
- data/lib/baltix/source/base/dependencies.rb +81 -0
- data/lib/baltix/source/base/file_queries.rb +67 -0
- data/lib/baltix/source/base/file_tree.rb +70 -0
- data/lib/baltix/source/base/metadata.rb +140 -0
- data/lib/baltix/source/base/options.rb +71 -0
- data/lib/baltix/source/base/roots.rb +53 -0
- data/lib/baltix/source/base.rb +95 -377
- data/lib/baltix/source/fake.rb +89 -5
- data/lib/baltix/source/gem/delegation.rb +32 -0
- data/lib/baltix/source/gem/dependencies.rb +69 -0
- data/lib/baltix/source/gem/discovery.rb +72 -0
- data/lib/baltix/source/gem/file_trees.rb +114 -0
- data/lib/baltix/source/gem/forwarding.rb +12 -0
- data/lib/baltix/source/gem/metadata.rb +104 -0
- data/lib/baltix/source/gem/specification.rb +65 -0
- data/lib/baltix/source/gem.rb +65 -312
- data/lib/baltix/source/gemfile.rb +55 -5
- data/lib/baltix/source/rakefile.rb +12 -5
- data/lib/baltix/source.rb +36 -24
- data/lib/baltix/space/configuration.rb +54 -0
- data/lib/baltix/space/data/collections.rb +33 -0
- data/lib/baltix/space/data/gem_metadata.rb +79 -0
- data/lib/baltix/space/data/models.rb +20 -0
- data/lib/baltix/space/data/values.rb +72 -0
- data/lib/baltix/space/data.rb +53 -0
- data/lib/baltix/space/dependencies.rb +53 -0
- data/lib/baltix/space/filters.rb +96 -0
- data/lib/baltix/space/initialization.rb +124 -0
- data/lib/baltix/space/metadata.rb +130 -0
- data/lib/baltix/space/source_order.rb +43 -0
- data/lib/baltix/space/source_selection.rb +136 -0
- data/lib/baltix/space/source_status.rb +114 -0
- data/lib/baltix/space/spec.rb +3 -0
- data/lib/baltix/space.rb +87 -367
- data/lib/baltix/spec/rpm/aliases.rb +79 -0
- data/lib/baltix/spec/rpm/arch.rb +119 -0
- data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
- data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
- data/lib/baltix/spec/rpm/build_queries.rb +61 -0
- data/lib/baltix/spec/rpm/changelog.rb +115 -0
- data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
- data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
- data/lib/baltix/spec/rpm/deps.rb +113 -0
- data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
- data/lib/baltix/spec/rpm/env.rb +76 -0
- data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
- data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
- data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
- data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
- data/lib/baltix/spec/rpm/layout.rb +14 -0
- data/lib/baltix/spec/rpm/manpages.rb +71 -0
- data/lib/baltix/spec/rpm/metadata.rb +78 -0
- data/lib/baltix/spec/rpm/name/equality.rb +68 -0
- data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
- data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
- data/lib/baltix/spec/rpm/name.rb +77 -108
- data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
- data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
- data/lib/baltix/spec/rpm/parser/context.rb +50 -0
- data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
- data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
- data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
- data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
- data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
- data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
- data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
- data/lib/baltix/spec/rpm/parser/values.rb +85 -0
- data/lib/baltix/spec/rpm/parser.rb +124 -269
- data/lib/baltix/spec/rpm/part_files.rb +64 -0
- data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
- data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
- data/lib/baltix/spec/rpm/part_switches.rb +65 -0
- data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
- data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
- data/lib/baltix/spec/rpm/pkglist.rb +116 -0
- data/lib/baltix/spec/rpm/preparation.rb +73 -0
- data/lib/baltix/spec/rpm/rendering.rb +66 -0
- data/lib/baltix/spec/rpm/repository_application.rb +33 -0
- data/lib/baltix/spec/rpm/revision.rb +58 -0
- data/lib/baltix/spec/rpm/root_source.rb +48 -0
- data/lib/baltix/spec/rpm/scripts.rb +85 -0
- data/lib/baltix/spec/rpm/secondaries.rb +82 -0
- data/lib/baltix/spec/rpm/secondary.rb +117 -64
- data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
- data/lib/baltix/spec/rpm/section_document.rb +84 -0
- data/lib/baltix/spec/rpm/section_guards.rb +116 -0
- data/lib/baltix/spec/rpm/source_selection.rb +82 -0
- data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
- data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
- data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
- data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
- data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
- data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
- data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
- data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
- data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
- data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
- data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
- data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
- data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
- data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
- data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
- data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
- data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
- data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
- data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
- data/lib/baltix/spec/rpm/spec_core.rb +75 -527
- data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
- data/lib/baltix/spec/rpm.rb +253 -644
- data/lib/baltix/spec.rb +16 -14
- data/lib/baltix/target/gem.rb +61 -0
- data/lib/baltix/target/site.rb +40 -0
- data/lib/baltix/target.rb +16 -0
- data/lib/baltix/version.rb +3 -1
- data/lib/baltix.rb +77 -5
- data/locale/en_US.UTF-8.yaml +4 -1
- data/locale/ru_RU.UTF-8.yaml +7 -1
- data/rpm/baltix.env +4 -0
- data/rpm/baltix.prov +8 -0
- data/rpm/baltix.prov.files +6 -0
- data/rpm/baltix.req +8 -0
- data/rpm/baltix.req.files +6 -0
- data/rpm/macros.baltix +24 -0
- data/utils/rubocop/compact_block_braces.rb +39 -0
- data/utils/rubocop/spacing.rb +96 -0
- data/utils/update_alt_architectures.rb +57 -0
- data/utils/update_alt_licenses.rb +19 -0
- data/utils/update_spdx_licenses.rb +21 -0
- metadata +526 -17
- data/.github/workflows/ci.yml +0 -44
- data/.gitignore +0 -10
- data/TODO +0 -84
data/lib/baltix/dsl.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'bundler'
|
|
2
4
|
require 'fileutils'
|
|
3
5
|
require 'tempfile'
|
|
@@ -6,306 +8,97 @@ require 'baltix'
|
|
|
6
8
|
|
|
7
9
|
# DSL service for baltix.
|
|
8
10
|
class Baltix::DSL
|
|
9
|
-
# group
|
|
11
|
+
# default group = binary, devel, test
|
|
12
|
+
#
|
|
13
|
+
# group to kinds mapping
|
|
10
14
|
GROUP_MAPPING = {
|
|
11
|
-
default:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
default: %i[devel runtime binary test],
|
|
16
|
+
gemfile: %i[devel binary test],
|
|
17
|
+
integration: %i[devel test],
|
|
18
|
+
development: %i[devel test],
|
|
19
|
+
test: %i[test devel],
|
|
20
|
+
build: %i[build devel],
|
|
21
|
+
debug: %i[devel test],
|
|
22
|
+
runtime: %i[runtime test],
|
|
23
|
+
production: %i[binary runtime],
|
|
24
|
+
true => %i[runtime binary]
|
|
25
|
+
}.reduce(Hash.new(%i[devel test].freeze)) {|r, (k, v)| r.merge(k => v) }
|
|
26
|
+
|
|
27
|
+
PLATFORMS = {
|
|
28
|
+
ruby: true,
|
|
29
|
+
jruby: false,
|
|
30
|
+
mingw: false
|
|
31
|
+
}.freeze
|
|
32
|
+
|
|
33
|
+
DSL_CONT_EXCEPTIONS = %w[LoadError SyntaxError TypeError Bundler::GemNotFound Bundler::VersionConflict
|
|
34
|
+
Bundler::GemfileNotFound Bundler::VersionConflic Bundler::Dsl::DSLError Bundler::GemspecError
|
|
35
|
+
Errno::ENOENT Gem::InvalidSpecificationException].freeze
|
|
19
36
|
|
|
20
37
|
# attributes
|
|
21
38
|
attr_reader :source_file, :replace_list, :skip_list, :append_list, :spec
|
|
22
39
|
|
|
23
|
-
def
|
|
24
|
-
return @gemfiles if @gemfiles
|
|
25
|
-
|
|
26
|
-
gemfiles = dsl.instance_variable_get(:@gemfiles) || []
|
|
27
|
-
|
|
28
|
-
@gemfiles = gemfiles.map {|g| g.is_a?(Pathname) && g || Pathname.new(g) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def gemfile
|
|
32
|
-
gemfiles.first || original_gemfile || fake_gemfile_path
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def original_gemfile
|
|
36
|
-
@original_gemfile ||= is_source_gemfile && Pathname.new(source_file) || find_gemfile
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def is_source_gemfile
|
|
40
|
+
def is_source_gemfile?
|
|
40
41
|
source_file =~ /Gemfile$/i
|
|
41
42
|
end
|
|
43
|
+
alias is_source_gemfile is_source_gemfile?
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def
|
|
50
|
-
if
|
|
51
|
-
@
|
|
52
|
-
|
|
53
|
-
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", @fake_gemfile_path
|
|
54
|
-
@fake_gemfile.close
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
@fake_gemfile_path
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def fake_gemlock_path
|
|
61
|
-
if !@fake_gemlock && @fake_gemlock ||= Tempfile.create('Gemfile.lock')
|
|
62
|
-
@fake_gemlock_path = @fake_gemlock.path
|
|
63
|
-
|
|
64
|
-
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", @fake_gemlock_path
|
|
65
|
-
@fake_gemlock.close
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
@fake_gemlock_path
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def dsl
|
|
72
|
-
@dsl ||= (
|
|
73
|
-
begin
|
|
74
|
-
dsl =
|
|
75
|
-
Dir.chdir(File.dirname(source_file)) do
|
|
76
|
-
dsl = Bundler::Dsl.new
|
|
77
|
-
dsl.eval_gemfile(original_gemfile)
|
|
78
|
-
dsl
|
|
79
|
-
end
|
|
80
|
-
rescue LoadError,
|
|
81
|
-
TypeError,
|
|
82
|
-
Bundler::GemNotFound,
|
|
83
|
-
Bundler::GemfileNotFound,
|
|
84
|
-
Bundler::VersionConflict,
|
|
85
|
-
Bundler::Dsl::DSLError,
|
|
86
|
-
Errno::ENOENT,
|
|
87
|
-
::Gem::InvalidSpecificationException => e
|
|
88
|
-
|
|
89
|
-
dsl = Bundler::Dsl.new
|
|
90
|
-
dsl.instance_variable_set(:@gemfiles, [Pathname.new(fake_gemfile_path)])
|
|
91
|
-
dsl.to_definition(fake_gemlock_path, {})
|
|
92
|
-
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", nil
|
|
93
|
-
|
|
94
|
-
dsl
|
|
95
|
-
end)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def edsl
|
|
99
|
-
@edsl ||= (
|
|
100
|
-
begin
|
|
101
|
-
edsl = dsl.dup
|
|
102
|
-
edsl.dependencies = deps_but(dsl.dependencies)
|
|
103
|
-
edsl
|
|
104
|
-
end)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def definition
|
|
108
|
-
@definition ||=
|
|
109
|
-
Dir.mktmpdir do
|
|
110
|
-
FileUtils.touch("Gemfile")
|
|
111
|
-
|
|
112
|
-
edsl.to_definition("./Gemfile", {})
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def original_deps_for kinds_in = nil
|
|
117
|
-
groups = defined_groups_for(kinds_in)
|
|
118
|
-
|
|
119
|
-
original_deps.select do |dep|
|
|
120
|
-
(dep.groups & groups).any? &&
|
|
121
|
-
dep.should_include? # &&
|
|
122
|
-
# (dep.autorequire || [ true ]).all? { |r| r }
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def original_deps
|
|
127
|
-
@original_deps ||= definition.dependencies.map do |dep|
|
|
128
|
-
type = dep.groups.map {|g| GROUP_MAPPING[g]}.compact.uniq.sort.first || dep.type
|
|
129
|
-
dep.instance_variable_set(:@type, type)
|
|
130
|
-
valid = !dep.source.is_a?(Bundler::Source::Path)
|
|
131
|
-
|
|
132
|
-
valid && dep || nil
|
|
133
|
-
end.compact
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def gemspecs
|
|
137
|
-
spec ? [spec] : dsl.gemspecs
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def extracted_gemspec_deps
|
|
141
|
-
gemspecs.map { |gs| gs.dependencies }.flatten.uniq
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def extracted_gemspec_runtime_deps
|
|
145
|
-
gemspecs.map do |gs|
|
|
146
|
-
gs.dependencies.select {|dep|dep.runtime?}
|
|
147
|
-
end.flatten.uniq
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def runtime_deps kind = :gemspec
|
|
151
|
-
if kind == :gemspec
|
|
152
|
-
deps_but(extracted_gemspec_runtime_deps)
|
|
153
|
-
else
|
|
154
|
-
deps_but(original_deps_for(:runtime))
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def development_deps kind = :gemspec
|
|
159
|
-
deps_but(original_deps_for(:development))
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def defined_groups_for kinds_in = nil
|
|
163
|
-
no_groups =
|
|
164
|
-
[kinds_in].compact.flatten.map do |k|
|
|
165
|
-
GROUP_MAPPING.map do |(g, k_in)|
|
|
166
|
-
k_in != k && g || nil
|
|
167
|
-
end.compact
|
|
168
|
-
end.flatten
|
|
169
|
-
|
|
170
|
-
definition.groups - no_groups
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
class << self
|
|
174
|
-
def merge_dependencies *depses
|
|
175
|
-
depses.reduce({}) do |res, deps|
|
|
176
|
-
deps.reduce(res.dup) do |r, x|
|
|
177
|
-
r[x.name] =
|
|
178
|
-
if r[x.name]
|
|
179
|
-
req = r[x.name].requirement.merge(x.requirement)
|
|
180
|
-
|
|
181
|
-
r[x.name].class.new(x.name, req, "type" => r[x.name].type)
|
|
182
|
-
else
|
|
183
|
-
x
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
r
|
|
187
|
-
end
|
|
188
|
-
end.values
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def filter_dependencies type, *depses
|
|
192
|
-
depses.map { |deps| deps.select {|x|x.type == type }}
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def dependencies type = nil
|
|
197
|
-
if type
|
|
198
|
-
self.class.merge_dependencies(*self.class.filter_dependencies(type, definition.dependencies, spec.dependencies))
|
|
199
|
-
else
|
|
200
|
-
self.class.merge_dependencies(definition.dependencies, spec.dependencies)
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def deps
|
|
205
|
-
deps_but(original_deps) | gemspec_deps
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def gemspec_deps
|
|
209
|
-
gemspecs.map do |gs|
|
|
210
|
-
version = gs.version || Gem::Version.new(0)
|
|
211
|
-
Gem::Dependency.new(gs.name, Gem::Requirement.new(["= #{version}"]), :development)
|
|
45
|
+
# Merges another source's dependencies into this DSL and refreshes derived data.
|
|
46
|
+
# @param other_dsl [Baltix::DSL] the source whose dependencies are imported
|
|
47
|
+
# @return [Baltix::DSL] self, including the imported dependency requirements and groups
|
|
48
|
+
# If both sources read the same existing Gemfile, no merge is needed. Otherwise,
|
|
49
|
+
# including when neither source has a Gemfile, dependencies are retained as
|
|
50
|
+
# additional dependencies and cached dependency views are invalidated.
|
|
51
|
+
def merge_in other_dsl
|
|
52
|
+
if !original_gemfile || original_gemfile.to_s != other_dsl.original_gemfile.to_s
|
|
53
|
+
@additional_dependencies = self.class.merge_dependencies(additional_dependencies, other_dsl.all_dependencies)
|
|
54
|
+
@original_deps = @edsl = @definition = nil
|
|
212
55
|
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def deps_for kinds_in = nil
|
|
216
|
-
deps_but(original_deps_for(kinds_in)) | gemspec_deps
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def ruby
|
|
220
|
-
{ type: required_ruby, version: required_ruby_version }
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def rubygems
|
|
224
|
-
{ version: required_rubygems_version }
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
def valid?
|
|
228
|
-
gemfiles.any? {|g| g.eql?(original_gemfile) }
|
|
229
|
-
end
|
|
230
56
|
|
|
231
|
-
|
|
232
|
-
spec = self.spec.dup
|
|
233
|
-
deps_in = deps_but(extracted_gemspec_deps)
|
|
234
|
-
deps = spec.dependencies.map {|x| deps_in.find {|a| a.name == x.name }}.compact
|
|
235
|
-
spec.dependencies.replace(deps)
|
|
236
|
-
spec.to_ruby
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
def to_gemfile
|
|
240
|
-
deps_but(original_deps).group_by { |d| d.name }.map do |name, deps|
|
|
241
|
-
reqs = deps.map do |dep|
|
|
242
|
-
reqs = dep.requirement.requirements.map {|r| "'#{r[0]} #{r[1]}'" }.join(", ")
|
|
243
|
-
end.join(", ")
|
|
244
|
-
|
|
245
|
-
dep = deps.first
|
|
246
|
-
autoreq = dep.respond_to?(:autorequire) &&
|
|
247
|
-
dep.autorequire &&
|
|
248
|
-
"require: #{dep.autorequire.any? &&
|
|
249
|
-
"[" + dep.autorequire.map { |r| r.inspect }.join(', ') + "]" ||
|
|
250
|
-
"false"}" || nil
|
|
251
|
-
groups = dep.respond_to?(:groups) && dep.groups || []
|
|
252
|
-
g = groups - [ :default ]
|
|
253
|
-
group_list = g.any? && "group: %i(#{groups.join("\n")})" || nil
|
|
254
|
-
|
|
255
|
-
[ "gem '#{name}'", reqs, autoreq, group_list ].compact.join(', ')
|
|
256
|
-
end.join("\n")
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
def required_rubygems_version
|
|
260
|
-
">= 0"
|
|
57
|
+
self
|
|
261
58
|
end
|
|
262
59
|
|
|
263
|
-
def
|
|
264
|
-
@
|
|
60
|
+
def additional_dependencies
|
|
61
|
+
@additional_dependencies ||= []
|
|
265
62
|
end
|
|
266
63
|
|
|
267
|
-
def
|
|
268
|
-
@
|
|
64
|
+
def assign_dependencies deps
|
|
65
|
+
@additional_dependencies = additional_dependencies | deps
|
|
269
66
|
end
|
|
270
67
|
|
|
271
|
-
def
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if dep.is_a?(Array)
|
|
276
|
-
dep.reduce { |res, dep_in| res.merge(dep_in) }
|
|
277
|
-
else
|
|
278
|
-
dep
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
self
|
|
68
|
+
def to_h
|
|
69
|
+
{ 'source_file' => source_file, 'spec' => spec, 'replace_list' => replace_list,
|
|
70
|
+
'skip_list' => skip_list, 'append_list' => append_list, 'skip_platforms' => @skip_platforms,
|
|
71
|
+
'dependency_platforms' => @dependency_platforms, 'additional_dependencies' => additional_dependencies }
|
|
284
72
|
end
|
|
285
73
|
|
|
286
74
|
protected
|
|
287
75
|
|
|
288
|
-
def deps_but deps
|
|
289
|
-
deps.map do |dep|
|
|
290
|
-
next if skip_list.include?(dep.name)
|
|
291
|
-
|
|
292
|
-
new_req = replace_list.reduce(nil) do |s, (name, req)|
|
|
293
|
-
s || name == dep.name && req
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
new_req && Bundler::Dependency.new(dep.name, Gem::Requirement.new([new_req]), "type" => dep.type) || dep
|
|
297
|
-
end.compact | append_list
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
#
|
|
301
76
|
def initialize source_file, options = {}
|
|
302
|
-
# TODO source_file is null for Fake source
|
|
77
|
+
# TODO: source_file is null for Fake source
|
|
303
78
|
# raise unless source_file && File.file?(source_file)
|
|
304
79
|
|
|
305
80
|
@source_file = source_file
|
|
306
81
|
@spec = options[:spec]
|
|
82
|
+
@dependency_platforms = options[:dependency_platforms] || {}
|
|
83
|
+
@skip_platforms = options[:skip_platforms] || []
|
|
307
84
|
@replace_list = options[:replace_list] || {}
|
|
308
85
|
@skip_list = options[:skip_list] || []
|
|
309
86
|
@append_list = options[:append_list] || []
|
|
310
87
|
end
|
|
311
88
|
end
|
|
89
|
+
|
|
90
|
+
require 'baltix/dsl/loading'
|
|
91
|
+
|
|
92
|
+
require 'baltix/dsl/temporary_files'
|
|
93
|
+
|
|
94
|
+
require 'baltix/dsl/dependency_groups'
|
|
95
|
+
|
|
96
|
+
require 'baltix/dsl/dependency_sources'
|
|
97
|
+
|
|
98
|
+
require 'baltix/dsl/merging'
|
|
99
|
+
|
|
100
|
+
require 'baltix/dsl/requirements'
|
|
101
|
+
|
|
102
|
+
require 'baltix/dsl/rendering'
|
|
103
|
+
|
|
104
|
+
require 'baltix/dsl/filtering'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Maps literal features to local files and already declared installed gems.
|
|
4
|
+
class Baltix::ExecutableDependencies
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def local_feature method, feature, path
|
|
8
|
+
candidates =
|
|
9
|
+
if method == 'require_relative'
|
|
10
|
+
[File.expand_path(feature, File.dirname(path))]
|
|
11
|
+
else
|
|
12
|
+
@source.libdirs.map {|directory| File.join(@root, directory, feature) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
candidates.flat_map {|candidate| [candidate, "#{candidate}.rb"] }.find {|file| File.file?(file) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def append_external_feature feature
|
|
19
|
+
installed = installed_feature_names(feature)
|
|
20
|
+
names = declared_feature_names(feature) | installed
|
|
21
|
+
|
|
22
|
+
@selected.concat(@declarations.select {|dependency| names.include?(dependency.name) })
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def installed_feature_names feature
|
|
26
|
+
Gem::Specification.find_all.filter_map do |specification|
|
|
27
|
+
specification.name if declared_installed_feature?(specification, feature)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def declared_installed_feature? specification, feature
|
|
32
|
+
@declarations.any? {|dependency| dependency.name == specification.name } &&
|
|
33
|
+
specification.contains_requirable_file?(feature)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def declared_feature_names feature
|
|
37
|
+
@declarations.filter_map do |dependency|
|
|
38
|
+
dependency.name if feature_aliases(dependency).any? {|name| feature_matches_name?(feature, name) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def feature_aliases dependency
|
|
43
|
+
name = dependency.name
|
|
44
|
+
aliases = [name, name.tr('-', '_'), name.tr('-', '/')]
|
|
45
|
+
custom = dependency.respond_to?(:autorequire) ? Array(dependency.autorequire) : []
|
|
46
|
+
|
|
47
|
+
aliases + custom
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def feature_matches_name? feature, name
|
|
51
|
+
feature == name || feature.start_with?("#{name}/")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Traverses declared public library entry points without promoting entire Gemfile groups.
|
|
4
|
+
class Baltix::ExecutableDependencies
|
|
5
|
+
# Reads conventional public library entry points without assigning a whole
|
|
6
|
+
# Gemfile group to runtime. Undeclared features are not guessed as gem names.
|
|
7
|
+
def library_dependencies
|
|
8
|
+
names = library_entrypoint_names
|
|
9
|
+
installed = installed_library_files
|
|
10
|
+
|
|
11
|
+
@source.libdirs.each do |directory|
|
|
12
|
+
names.each do |name|
|
|
13
|
+
file = File.expand_path(File.join(@root, directory, name.end_with?('.rb') ? name : "#{name}.rb"))
|
|
14
|
+
|
|
15
|
+
visit(file) if installed.include?(file)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
selected_library_dependencies
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Selects installed Ruby library features and combines only their already declared gem requirements.
|
|
4
|
+
class Baltix::ExecutableDependencies
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def library_entrypoint_names
|
|
8
|
+
names = [@source.name, @source.name.tr('-', '_'), @source.name.tr('-', '/')]
|
|
9
|
+
|
|
10
|
+
names | Array(@source.spec.autorequire).grep(String)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def installed_library_files
|
|
14
|
+
@source.libtree.flat_map do |directory, files|
|
|
15
|
+
files.map {|file| File.expand_path(File.join(@root, directory, file)) }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def selected_library_dependencies
|
|
20
|
+
declared = @declarations.map(&:name) - [@source.name]
|
|
21
|
+
grouped = @selected.select {|dependency| declared.include?(dependency.name) }.group_by(&:name)
|
|
22
|
+
|
|
23
|
+
grouped.map {|_, dependencies| merged_library_dependency(dependencies) }.tap(&:sort!)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def merged_library_dependency dependencies
|
|
27
|
+
dependency = dependencies.first.dup
|
|
28
|
+
requirement = dependencies.map(&:requirement).reduce {|left, right| left.merge(right) }
|
|
29
|
+
|
|
30
|
+
dependency.instance_variable_set(:@requirement, requirement)
|
|
31
|
+
|
|
32
|
+
dependency
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Recognizes literal Ruby loads and LoadError-protected optional calls without evaluating code.
|
|
4
|
+
class Baltix::ExecutableDependencies
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def walk node, path
|
|
8
|
+
return unless node.is_a?(Array)
|
|
9
|
+
|
|
10
|
+
if optional_load_body?(node)
|
|
11
|
+
node.drop(2).each {|child| walk(child, path) }
|
|
12
|
+
elsif (call = load_call(node))
|
|
13
|
+
walk_load_call(call, path)
|
|
14
|
+
else
|
|
15
|
+
node.each {|child| walk(child, path) }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def optional_load_body? node
|
|
20
|
+
node.first == :bodystmt && rescues_load_error?(node[2])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def walk_load_call call, path
|
|
24
|
+
method, arguments = call
|
|
25
|
+
|
|
26
|
+
arguments = arguments[1] if arguments&.first == :arg_paren
|
|
27
|
+
|
|
28
|
+
return unless arguments&.first == :args_add_block
|
|
29
|
+
|
|
30
|
+
values = literal_arguments(arguments[1])
|
|
31
|
+
|
|
32
|
+
return warn_dynamic_load(method, path) unless values&.first
|
|
33
|
+
|
|
34
|
+
load_feature(method, values, path)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def literal_arguments arguments
|
|
38
|
+
return unless arguments.is_a?(Array) && arguments.all?(Array)
|
|
39
|
+
|
|
40
|
+
arguments.map {|argument| literal_string(argument) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def warn_dynamic_load method, path
|
|
44
|
+
@warnings << "#{path}: dynamic #{method} cannot be resolved statically"
|
|
45
|
+
|
|
46
|
+
nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def rescues_load_error? node
|
|
50
|
+
return false unless node.is_a?(Array) && node.first == :rescue
|
|
51
|
+
|
|
52
|
+
handled = node[1].to_a.flatten.include?('LoadError') && !reraises?(node[3])
|
|
53
|
+
|
|
54
|
+
handled || rescues_load_error?(node[4])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def reraises? node
|
|
58
|
+
return false unless node.is_a?(Array)
|
|
59
|
+
return true if node.first == :retry
|
|
60
|
+
|
|
61
|
+
call = RAISE_CALL_NODES.include?(node.first) && node.dig(1, 1) == 'raise'
|
|
62
|
+
|
|
63
|
+
call || node.any? {|child| reraises?(child) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def load_call node
|
|
67
|
+
method, arguments =
|
|
68
|
+
case node.first
|
|
69
|
+
when :command then [node[1][1], node[2]]
|
|
70
|
+
when :method_add_arg then target_load_call(node[1], node[2])
|
|
71
|
+
when :command_call then [node[3][1], node[4]] if kernel?(node[1])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
[method, arguments] if LOAD_METHODS.include?(method)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def target_load_call target, arguments
|
|
78
|
+
if target.first == :fcall
|
|
79
|
+
[target[1][1], arguments]
|
|
80
|
+
elsif target.first == :call && kernel?(target[1])
|
|
81
|
+
[target[3][1], arguments]
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def kernel? node
|
|
86
|
+
node.first == :var_ref && node.dig(1, 0) == :@const && node.dig(1, 1) == 'Kernel'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def literal_string node
|
|
90
|
+
return unless node.is_a?(Array) && node.first == :string_literal
|
|
91
|
+
|
|
92
|
+
content = node[1]
|
|
93
|
+
|
|
94
|
+
return unless literal_string_content?(content)
|
|
95
|
+
|
|
96
|
+
content.drop(1).map! {|part| part[1] }.join
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def literal_string_content? content
|
|
100
|
+
content&.first == :string_content && content.drop(1).all? {|part| part.first == :@tstring_content }
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ripper'
|
|
4
|
+
require 'baltix'
|
|
5
|
+
|
|
6
|
+
# Resolves literal Ruby loads against this source's declarations and files.
|
|
7
|
+
# Source code is parsed, never executed. Development scripts outside exetree are
|
|
8
|
+
# not entry points. Requirements remain those of the current source metadata.
|
|
9
|
+
class Baltix::ExecutableDependencies
|
|
10
|
+
LOAD_METHODS = %w[require require_relative gem].freeze
|
|
11
|
+
RAISE_CALL_NODES = %i[vcall fcall command].freeze
|
|
12
|
+
|
|
13
|
+
attr_reader :warnings
|
|
14
|
+
|
|
15
|
+
def initialize source
|
|
16
|
+
@source = source
|
|
17
|
+
@root = File.directory?(source.rootdir) ? File.realpath(source.rootdir) : File.expand_path(source.rootdir)
|
|
18
|
+
@declarations = source.dsl.all_dependencies
|
|
19
|
+
@warnings = []
|
|
20
|
+
@visited = {}
|
|
21
|
+
@selected = []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def dependencies
|
|
25
|
+
unless File.directory?(@root)
|
|
26
|
+
@warnings << "#{@root}: executable sources unavailable; only explicit dependencies can be retained"
|
|
27
|
+
return []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@source.exetree.each do |directory, files|
|
|
31
|
+
files.each {|file| visit(File.join(@root, directory, file)) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Baltix::DSL.merge_dependencies(@selected).sort
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def visit path
|
|
40
|
+
return unless File.file?(path)
|
|
41
|
+
|
|
42
|
+
path = File.realpath(path)
|
|
43
|
+
|
|
44
|
+
return unless path.start_with?(@root + File::SEPARATOR)
|
|
45
|
+
return if @visited[path]
|
|
46
|
+
|
|
47
|
+
@visited[path] = true
|
|
48
|
+
|
|
49
|
+
parse_executable(path)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def parse_executable path
|
|
53
|
+
text = File.read(path)
|
|
54
|
+
|
|
55
|
+
return if text.start_with?('#!') && !text.lines.first.include?('ruby')
|
|
56
|
+
|
|
57
|
+
syntax = Ripper.sexp(text)
|
|
58
|
+
|
|
59
|
+
if syntax
|
|
60
|
+
walk(syntax, path)
|
|
61
|
+
else
|
|
62
|
+
@warnings << "#{path}: cannot parse Ruby executable dependency code"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def load_feature method, values, path
|
|
67
|
+
return load_gem(values) if method == 'gem'
|
|
68
|
+
|
|
69
|
+
feature = values.first
|
|
70
|
+
local = local_feature(method, feature, path)
|
|
71
|
+
|
|
72
|
+
return visit(local) if local
|
|
73
|
+
return if method == 'require_relative'
|
|
74
|
+
|
|
75
|
+
append_external_feature(feature)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def load_gem values
|
|
79
|
+
declaration = @declarations.find {|dependency| dependency.name == values.first }
|
|
80
|
+
requirement = explicit_gem_requirement(values)
|
|
81
|
+
|
|
82
|
+
return unless declaration || requirement
|
|
83
|
+
|
|
84
|
+
@selected << (declaration && requirement ? declaration.merge(requirement) : declaration || requirement)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def explicit_gem_requirement values
|
|
88
|
+
return unless values.all?
|
|
89
|
+
|
|
90
|
+
bounds = values.drop(1)
|
|
91
|
+
|
|
92
|
+
Gem::Dependency.new(values.first, bounds.empty? ? '>= 0' : bounds)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
require 'baltix/executable_dependencies/syntax'
|
|
97
|
+
|
|
98
|
+
require 'baltix/executable_dependencies/features'
|
|
99
|
+
|
|
100
|
+
require 'baltix/executable_dependencies/library'
|
|
101
|
+
|
|
102
|
+
require 'baltix/executable_dependencies/library_features'
|