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

[TargetEnvironmentHeader] Refine implementation

parent fdd6195f
......@@ -38,29 +38,29 @@ module Pod
#
STATISTICS_CACHE_FILE = CACHE_ROOT + 'statistics.yml'
autoload :Command, 'cocoapods/command'
autoload :Executable, 'cocoapods/executable'
autoload :ExternalSources, 'cocoapods/external_sources'
autoload :Installer, 'cocoapods/installer'
autoload :SourcesManager, 'cocoapods/sources_manager'
autoload :Library, 'cocoapods/library'
autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver'
autoload :Sandbox, 'cocoapods/sandbox'
autoload :UI, 'cocoapods/user_interface'
autoload :Validator, 'cocoapods/validator'
autoload :Command, 'cocoapods/command'
autoload :Executable, 'cocoapods/executable'
autoload :ExternalSources, 'cocoapods/external_sources'
autoload :Installer, 'cocoapods/installer'
autoload :SourcesManager, 'cocoapods/sources_manager'
autoload :Library, 'cocoapods/library'
autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver'
autoload :Sandbox, 'cocoapods/sandbox'
autoload :UI, 'cocoapods/user_interface'
autoload :Validator, 'cocoapods/validator'
module Generator
autoload :Acknowledgements, 'cocoapods/generator/acknowledgements'
autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :Documentation, 'cocoapods/generator/documentation'
autoload :DummySource, 'cocoapods/generator/dummy_source'
autoload :Markdown, 'cocoapods/generator/acknowledgements/markdown'
autoload :Plist, 'cocoapods/generator/acknowledgements/plist'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetHeader, 'cocoapods/generator/target_header'
autoload :XCConfig, 'cocoapods/generator/xcconfig'
autoload :Acknowledgements, 'cocoapods/generator/acknowledgements'
autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :Documentation, 'cocoapods/generator/documentation'
autoload :DummySource, 'cocoapods/generator/dummy_source'
autoload :Markdown, 'cocoapods/generator/acknowledgements/markdown'
autoload :Plist, 'cocoapods/generator/acknowledgements/plist'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :XCConfig, 'cocoapods/generator/xcconfig'
end
module Hooks
......
......@@ -21,7 +21,7 @@ module Pod
# // Non CocoaPods code
# #endif
#
class TargetHeader
class TargetEnvironmentHeader
# @return [Array<LocalPod>] the specifications installed for the target.
#
......@@ -51,9 +51,9 @@ module Pod
source.puts
source.puts
specs.each do |spec|
spec_name = spec.name.gsub(/[^\w]/,'_')
spec_name = safe_spec_name(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?
source.puts "#define COCOAPODS_VERSION_MAJOR_#{spec_name} #{spec.version.major}"
source.puts "#define COCOAPODS_VERSION_MINOR_#{spec_name} #{spec.version.minor}"
......@@ -71,6 +71,16 @@ module Pod
#-----------------------------------------------------------------------#
private
# !@group Private Helpers
def safe_spec_name(spec_name)
spec_name.gsub(/[^\w]/,'_')
end
#-----------------------------------------------------------------------#
end
end
end
......@@ -35,7 +35,7 @@ module Pod
create_suport_files_group
create_xcconfig_file
create_target_environement_header
create_target_environment_header
create_prefix_header
create_bridge_support_file
create_copy_resources_script
......@@ -158,10 +158,10 @@ module Pod
# Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod.
#
def create_target_environement_header
def create_target_environment_header
path = library.target_environment_header_path
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)
add_file_to_support_group(path)
end
......
......@@ -7,14 +7,14 @@
// JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE
#define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning,
// so we were not able to define version macros.
// Please contact the author.
// Version: 1.5pre.
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,19 +7,19 @@
// PodTest
#define COCOAPODS_POD_AVAILABLE_PodTest TRUE
#define COCOAPODS_POD_AVAILABLE_PodTest
#define COCOAPODS_VERSION_MAJOR_PodTest 1
#define COCOAPODS_VERSION_MINOR_PodTest 0
#define COCOAPODS_VERSION_PATCH_PodTest 0
// 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_MINOR_PodTest_subspec_1 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0
// 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_MINOR_PodTest_subspec_2 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,14 +7,14 @@
// JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE
#define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning,
// so we were not able to define version macros.
// Please contact the author.
// Version: 1.5pre.
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// JSONKit
#define COCOAPODS_POD_AVAILABLE_JSONKit TRUE
#define COCOAPODS_POD_AVAILABLE_JSONKit
// This library does not follow semantic-versioning,
// so we were not able to define version macros.
// Please contact the author.
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
......@@ -7,7 +7,7 @@
// 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_MINOR_PodTest_subspec_2 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_2 0
......
......@@ -7,7 +7,7 @@
// 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_MINOR_PodTest_subspec_1 0
#define COCOAPODS_VERSION_PATCH_PodTest_subspec_1 0
......
......@@ -7,7 +7,7 @@
// Reachability
#define COCOAPODS_POD_AVAILABLE_Reachability TRUE
#define COCOAPODS_POD_AVAILABLE_Reachability
#define COCOAPODS_VERSION_MAJOR_Reachability 3
#define COCOAPODS_VERSION_MINOR_Reachability 1
#define COCOAPODS_VERSION_PATCH_Reachability 0
......
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::TargetHeader do
describe Pod::Generator::TargetEnvironmentHeader do
before do
specification = fixture_spec('banana-lib/BananaLib.podspec')
@gen = Pod::Generator::TargetHeader.new([specification])
@gen = Pod::Generator::TargetEnvironmentHeader.new([specification])
end
it "generates a header files which include macro definitions for installed Pods" do
......@@ -20,12 +20,17 @@ describe Pod::Generator::TargetHeader do
// BananaLib
#define COCOAPODS_POD_AVAILABLE_BananaLib TRUE
#define COCOAPODS_POD_AVAILABLE_BananaLib
#define COCOAPODS_VERSION_MAJOR_BananaLib 1
#define COCOAPODS_VERSION_MINOR_BananaLib 0
#define COCOAPODS_VERSION_PATCH_BananaLib 0
EOS
end
it "handles specifications with special characters" do
name = @gen.send(:safe_spec_name, 'AppleCoreAudioUtilityClasses@thehtb')
name.should == 'AppleCoreAudioUtilityClasses_thehtb'
end
end
......@@ -151,7 +151,7 @@ module Pod
@installer.install!
file = config.sandbox.root + 'Pods-environment.h'
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_MINOR_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