Commit 661ab69b authored by Fabio Pelosin's avatar Fabio Pelosin

[TargetEnvironmentHeader] Refine implementation

parent fdd6195f
...@@ -59,7 +59,7 @@ module Pod ...@@ -59,7 +59,7 @@ module Pod
autoload :Markdown, 'cocoapods/generator/acknowledgements/markdown' autoload :Markdown, 'cocoapods/generator/acknowledgements/markdown'
autoload :Plist, 'cocoapods/generator/acknowledgements/plist' autoload :Plist, 'cocoapods/generator/acknowledgements/plist'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header' autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetHeader, 'cocoapods/generator/target_header' autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :XCConfig, 'cocoapods/generator/xcconfig' autoload :XCConfig, 'cocoapods/generator/xcconfig'
end end
......
...@@ -21,7 +21,7 @@ module Pod ...@@ -21,7 +21,7 @@ module Pod
# // Non CocoaPods code # // Non CocoaPods code
# #endif # #endif
# #
class TargetHeader class TargetEnvironmentHeader
# @return [Array<LocalPod>] the specifications installed for the target. # @return [Array<LocalPod>] the specifications installed for the target.
# #
...@@ -51,9 +51,9 @@ module Pod ...@@ -51,9 +51,9 @@ module Pod
source.puts source.puts
source.puts source.puts
specs.each do |spec| specs.each do |spec|
spec_name = spec.name.gsub(/[^\w]/,'_') spec_name = safe_spec_name(spec.name)
source.puts "// #{spec.name}" source.puts "// #{spec.name}"
source.puts "#define COCOAPODS_POD_AVAILABLE_#{spec_name} TRUE" source.puts "#define COCOAPODS_POD_AVAILABLE_#{spec_name}"
if spec.version.semantic? if spec.version.semantic?
source.puts "#define COCOAPODS_VERSION_MAJOR_#{spec_name} #{spec.version.major}" source.puts "#define COCOAPODS_VERSION_MAJOR_#{spec_name} #{spec.version.major}"
source.puts "#define COCOAPODS_VERSION_MINOR_#{spec_name} #{spec.version.minor}" source.puts "#define COCOAPODS_VERSION_MINOR_#{spec_name} #{spec.version.minor}"
...@@ -71,6 +71,16 @@ module Pod ...@@ -71,6 +71,16 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private
# !@group Private Helpers
def safe_spec_name(spec_name)
spec_name.gsub(/[^\w]/,'_')
end
#-----------------------------------------------------------------------#
end end
end end
end end
...@@ -35,7 +35,7 @@ module Pod ...@@ -35,7 +35,7 @@ module Pod
create_suport_files_group create_suport_files_group
create_xcconfig_file create_xcconfig_file
create_target_environement_header create_target_environment_header
create_prefix_header create_prefix_header
create_bridge_support_file create_bridge_support_file
create_copy_resources_script create_copy_resources_script
...@@ -158,10 +158,10 @@ module Pod ...@@ -158,10 +158,10 @@ module Pod
# Generates a header which allows to inspect at compile time the installed # Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod. # pods and the installed specifications of a pod.
# #
def create_target_environement_header def create_target_environment_header
path = library.target_environment_header_path path = library.target_environment_header_path
UI.message "- Generating target environment header at #{UI.path(path)}" do UI.message "- Generating target environment header at #{UI.path(path)}" do
generator = Generator::TargetHeader.new(library.specs) generator = Generator::TargetEnvironmentHeader.new(library.specs)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
// JSONKit // JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE #define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning, // This library does not follow semantic-versioning,
// so we were not able to define version macros. // so we were not able to define version macros.
// Please contact the author. // Please contact the author.
// Version: 1.5pre. // Version: 1.5pre.
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
// PodTest // PodTest
#define COCOAPODS_POD_AVAILABLE_PodTest TRUE #define COCOAPODS_POD_AVAILABLE_PodTest
#define COCOAPODS_VERSION_MAJOR_PodTest 1 #define COCOAPODS_VERSION_MAJOR_PodTest 1
#define COCOAPODS_VERSION_MINOR_PodTest 0 #define COCOAPODS_VERSION_MINOR_PodTest 0
#define COCOAPODS_VERSION_PATCH_PodTest 0 #define COCOAPODS_VERSION_PATCH_PodTest 0
// PodTest/subspec_1 // PodTest/subspec_1
#define COCOAPODS_POD_AVAILABLE_PodTest_subspec_1 TRUE #define COCOAPODS_POD_AVAILABLE_PodTest_subspec_1
#define COCOAPODS_VERSION_MAJOR_PodTest_subspec_1 1 #define COCOAPODS_VERSION_MAJOR_PodTest_subspec_1 1
#define COCOAPODS_VERSION_MINOR_PodTest_subspec_1 0 #define COCOAPODS_VERSION_MINOR_PodTest_subspec_1 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0 #define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0
// PodTest/subspec_2 // PodTest/subspec_2
#define COCOAPODS_POD_AVAILABLE_PodTest_subspec_2 TRUE #define COCOAPODS_POD_AVAILABLE_PodTest_subspec_2
#define COCOAPODS_VERSION_MAJOR_PodTest_subspec_2 1 #define COCOAPODS_VERSION_MAJOR_PodTest_subspec_2 1
#define COCOAPODS_VERSION_MINOR_PodTest_subspec_2 0 #define COCOAPODS_VERSION_MINOR_PodTest_subspec_2 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0 #define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
// JSONKit // JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE #define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning, // This library does not follow semantic-versioning,
// so we were not able to define version macros. // so we were not able to define version macros.
// Please contact the author. // Please contact the author.
// Version: 1.5pre. // Version: 1.5pre.
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// JSONKit // JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE #define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning, // This library does not follow semantic-versioning,
// so we were not able to define version macros. // so we were not able to define version macros.
// Please contact the author. // Please contact the author.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// PodTest/subspec_2 // PodTest/subspec_2
#define COCOAPODS_POD_AVAILABLE_PodTest_subspec_2 TRUE #define COCOAPODS_POD_AVAILABLE_PodTest_subspec_2
#define COCOAPODS_VERSION_MAJOR_PodTest_subspec_2 1 #define COCOAPODS_VERSION_MAJOR_PodTest_subspec_2 1
#define COCOAPODS_VERSION_MINOR_PodTest_subspec_2 0 #define COCOAPODS_VERSION_MINOR_PodTest_subspec_2 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0 #define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// PodTest/subspec_1 // PodTest/subspec_1
#define COCOAPODS_POD_AVAILABLE_PodTest_subspec_1 TRUE #define COCOAPODS_POD_AVAILABLE_PodTest_subspec_1
#define COCOAPODS_VERSION_MAJOR_PodTest_subspec_1 1 #define COCOAPODS_VERSION_MAJOR_PodTest_subspec_1 1
#define COCOAPODS_VERSION_MINOR_PodTest_subspec_1 0 #define COCOAPODS_VERSION_MINOR_PodTest_subspec_1 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0 #define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Reachability // Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE #define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3 #define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1 #define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0 #define COCOAPODS_VERSION_PATCH_Reachability 0
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::TargetHeader do describe Pod::Generator::TargetEnvironmentHeader do
before do before do
specification = fixture_spec('banana-lib/BananaLib.podspec') specification = fixture_spec('banana-lib/BananaLib.podspec')
@gen = Pod::Generator::TargetHeader.new([specification]) @gen = Pod::Generator::TargetEnvironmentHeader.new([specification])
end end
it "generates a header files which include macro definitions for installed Pods" do it "generates a header files which include macro definitions for installed Pods" do
...@@ -20,12 +20,17 @@ describe Pod::Generator::TargetHeader do ...@@ -20,12 +20,17 @@ describe Pod::Generator::TargetHeader do
// BananaLib // BananaLib
#define COCOAPODS_POD_AVAILABLE_BananaLib TRUE #define COCOAPODS_POD_AVAILABLE_BananaLib
#define COCOAPODS_VERSION_MAJOR_BananaLib 1 #define COCOAPODS_VERSION_MAJOR_BananaLib 1
#define COCOAPODS_VERSION_MINOR_BananaLib 0 #define COCOAPODS_VERSION_MINOR_BananaLib 0
#define COCOAPODS_VERSION_PATCH_BananaLib 0 #define COCOAPODS_VERSION_PATCH_BananaLib 0
EOS EOS
end end
it "handles specifications with special characters" do
name = @gen.send(:safe_spec_name, 'AppleCoreAudioUtilityClasses@thehtb')
name.should == 'AppleCoreAudioUtilityClasses_thehtb'
end
end end
...@@ -151,7 +151,7 @@ module Pod ...@@ -151,7 +151,7 @@ module Pod
@installer.install! @installer.install!
file = config.sandbox.root + 'Pods-environment.h' file = config.sandbox.root + 'Pods-environment.h'
contents = file.read contents = file.read
contents.should.include?('#define COCOAPODS_POD_AVAILABLE_BananaLib TRUE') contents.should.include?('#define COCOAPODS_POD_AVAILABLE_BananaLib')
contents.should.include?('#define COCOAPODS_VERSION_MAJOR_BananaLib 1') contents.should.include?('#define COCOAPODS_VERSION_MAJOR_BananaLib 1')
contents.should.include?('#define COCOAPODS_VERSION_MINOR_BananaLib 0') contents.should.include?('#define COCOAPODS_VERSION_MINOR_BananaLib 0')
contents.should.include?('#define COCOAPODS_VERSION_PATCH_BananaLib 0') contents.should.include?('#define COCOAPODS_VERSION_PATCH_BananaLib 0')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment