From 65714bc8605f22c1dafcd911e1e399c606e74e98 Mon Sep 17 00:00:00 2001 From: Igor Makarov Date: Wed, 27 May 2020 10:14:36 +0300 Subject: [PATCH] fix inherit configuration logic (#212) --- lib/xcake/dsl/configuration/sugar.rb | 2 +- lib/xcake/dsl/project.rb | 2 +- lib/xcake/dsl/target.rb | 8 ++++++-- spec/dsl/target/sugar_spec.rb | 3 ++- spec/dsl/target_spec.rb | 9 ++++++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/xcake/dsl/configuration/sugar.rb b/lib/xcake/dsl/configuration/sugar.rb index 4525877d..db4212a9 100644 --- a/lib/xcake/dsl/configuration/sugar.rb +++ b/lib/xcake/dsl/configuration/sugar.rb @@ -17,7 +17,7 @@ class Configuration # # @example Using Supported Devices # - # Target.new do |t| + # Target.new(project) do |t| # t.all_configurations.each do |c| # c.supported_devices = :ipad_only # end diff --git a/lib/xcake/dsl/project.rb b/lib/xcake/dsl/project.rb index bfd22aaa..eaad3a2e 100644 --- a/lib/xcake/dsl/project.rb +++ b/lib/xcake/dsl/project.rb @@ -63,7 +63,7 @@ def initialize(name = 'Project') # the newly created target # def target(&block) - target = Target.new(&block) + target = Target.new(self, &block) targets << target target end diff --git a/lib/xcake/dsl/target.rb b/lib/xcake/dsl/target.rb index 43ecad94..3f8255b2 100644 --- a/lib/xcake/dsl/target.rb +++ b/lib/xcake/dsl/target.rb @@ -182,16 +182,19 @@ class Target # attr_accessor :schemes + # @param [Project] project + # the project the target belongs to. + # # @param [Proc] block # an optional block that configures the target through the DSL. # # @example Creating a Target. # - # Target.new do |t| + # Target.new(project) do |t| # t.name "test" # end # - def initialize + def initialize(project) @pinned_build_phases = [] @build_phases = [] @build_rules = [] @@ -200,6 +203,7 @@ def initialize @system_libraries = [] @target_dependencies = [] @schemes = [] + @project = project yield(self) if block_given? end diff --git a/spec/dsl/target/sugar_spec.rb b/spec/dsl/target/sugar_spec.rb index dc1a3999..8674c41d 100644 --- a/spec/dsl/target/sugar_spec.rb +++ b/spec/dsl/target/sugar_spec.rb @@ -3,7 +3,8 @@ module Xcake describe Target do before :each do - @target = Target.new + @project = Project.new + @target = Target.new(@project) @build_phase_name = 'Hello World' end diff --git a/spec/dsl/target_spec.rb b/spec/dsl/target_spec.rb index 35fb9464..805e41a4 100644 --- a/spec/dsl/target_spec.rb +++ b/spec/dsl/target_spec.rb @@ -3,7 +3,8 @@ module Xcake describe Target do before :each do - @target = Target.new + @project = Project.new + @target = Target.new(@project) @target.name = 'Test' end @@ -116,6 +117,12 @@ module Xcake expect(@target.default_release_settings).to eq(settings) end + it 'should inherit settings' do + @project.debug_configuration :Test + expect(@target.all_configurations.count).to eq(1) + expect(@target.all_configurations.first.name).to eq('Test') + end + it 'should initialize schemes' do expect(@target.schemes).not_to be(nil) end