Skip to content
This repository
Browse code

[LocalPod] Sandbox header files.

  • Loading branch information...
commit 337ef587623d5e99e425d033fdacae6e15e216a5 1 parent 1f5c7f4
Fabio Pelosin authored
7  lib/cocoapods/local_pod.rb
@@ -312,6 +312,7 @@ def all_specs_public_header_files
312 312
     # @return [void] Copies the pods headers to the sandbox.
313 313
     #
314 314
     def link_headers
  315
+      @sandbox.add_header_search_path(headers_sandbox)
315 316
       header_mappings.each do |namespaced_path, files|
316 317
         @sandbox.add_header_files(namespaced_path, files)
317 318
       end
@@ -367,13 +368,17 @@ def header_mappings
367 368
         paths = paths - headers_excluded_from_search_paths
368 369
         paths.each do |from|
369 370
           from_relative = from.relative_path_from(root)
370  
-          to = spec.header_dir + spec.copy_header_mapping(from_relative)
  371
+          to = headers_sandbox + (spec.header_dir) + spec.copy_header_mapping(from_relative)
371 372
           (mappings[to.dirname] ||= []) << from
372 373
         end
373 374
       end
374 375
       mappings
375 376
     end
376 377
 
  378
+    def headers_sandbox
  379
+      @headers_sandbox ||= Pathname.new(top_specification.name)
  380
+    end
  381
+
377 382
     # @return [<Pathname>] The relative path of the headers that should not be
378 383
     # included in the linker search paths.
379 384
     #
10  lib/cocoapods/sandbox.rb
@@ -42,6 +42,16 @@ def header_search_paths
42 42
       @header_search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
43 43
     end
44 44
 
  45
+    # Adds an header search path to the sandbox.
  46
+    #
  47
+    # @param path [Pathname] The path tho add.
  48
+    #
  49
+    # @return [void]
  50
+    #
  51
+    def add_header_search_path(path)
  52
+      @header_search_paths << Pathname.new(HEADERS_DIR) + path
  53
+    end
  54
+
45 55
     def prepare_for_install
46 56
       headers_root.rmtree if headers_root.exist?
47 57
     end
37  lib/cocoapods/specification.rb
@@ -192,9 +192,6 @@ def available_platforms
192 192
     top_attr_accessor :license,             lambda { |l| ( l.kind_of? String ) ? { :type => l } : l }
193 193
     top_attr_accessor :version,             lambda { |v| Version.new(v) }
194 194
     top_attr_accessor :authors,             lambda { |a| parse_authors(a) }
195  
-    top_attr_accessor :header_mappings_dir, lambda { |file| Pathname.new(file) } # If not provided the headers files are flattened
196  
-    top_attr_accessor :prefix_header_file,  lambda { |file| Pathname.new(file) }
197  
-    top_attr_accessor :prefix_header_contents
198 195
 
199 196
     top_attr_reader   :description,         lambda {|instance, ivar| ivar || instance.summary }
200 197
     top_attr_writer   :description
@@ -212,6 +209,13 @@ def self.parse_authors(*names_and_email_addresses)
212 209
 
213 210
     ### Attributes **with** multiple platform support
214 211
 
  212
+    # @todo allow for subspecs
  213
+    #
  214
+    top_attr_accessor :header_mappings_dir, lambda { |file| Pathname.new(file) } # If not provided the headers files are flattened
  215
+    top_attr_accessor :prefix_header_file,  lambda { |file| Pathname.new(file) }
  216
+    top_attr_accessor :prefix_header_contents
  217
+
  218
+
215 219
     pltf_chained_attr_accessor  :source_files,                lambda {|value, current| pattern_list(value) }
216 220
     pltf_chained_attr_accessor  :resources,                   lambda {|value, current| pattern_list(value) }
217 221
     pltf_chained_attr_accessor  :preserve_paths,              lambda {|value, current| pattern_list(value) } # Paths that should not be cleaned
@@ -224,17 +228,28 @@ def self.parse_authors(*names_and_email_addresses)
224 228
     alias_method :framework=,     :frameworks=
225 229
     alias_method :library=,       :libraries=
226 230
 
227  
-    # @return The directory to namespace the headers.
  231
+    # @!method header_dir=
228 232
     #
229  
-    # It defaults to the name of the top level specification.
  233
+    # @abstract The directory where to name space the headers files of
  234
+    #   the specification.
230 235
     #
231  
-    platform_attr_writer :header_dir, lambda { |dir,_| Pathname.new(dir) }
  236
+    # @param [String] The headers directory.
  237
+    #
  238
+    platform_attr_writer :header_dir, lambda { |dir, _| Pathname.new(dir) }
232 239
 
  240
+    # @abstract (see #header_dir=)
  241
+    #
  242
+    # @return [Pathname] The headers directory.
  243
+    #
  244
+    # @note If no value is provided it returns an empty {Pathname}.
  245
+    #
233 246
     def header_dir
234  
-      @header_dir[active_platform] || pod_destroot_name
  247
+      @header_dir[active_platform] || (@parent.header_dir if @parent) || Pathname.new('')
235 248
     end
236 249
 
237  
-    platform_attr_writer        :xcconfig,                     lambda {|value, current| current.tap { |c| c.merge!(value) } }
  250
+    # @!method xcconfig=
  251
+    #
  252
+    platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } }
238 253
 
239 254
     def xcconfig
240 255
       raw_xconfig.dup.
@@ -357,12 +372,6 @@ def pod_destroot
357 372
       end
358 373
     end
359 374
 
360  
-    def pod_destroot_name
361  
-      if root = pod_destroot
362  
-        root.basename
363  
-      end
364  
-    end
365  
-
366 375
     def self.pattern_list(patterns)
367 376
       if patterns.is_a?(Array) && (!defined?(Rake) || !patterns.is_a?(Rake::FileList))
368 377
         patterns

0 notes on commit 337ef58

Please sign in to comment.
Something went wrong with that request. Please try again.