mirror of
https://github.com/zhigang1992/synx.git
synced 2026-01-12 17:52:53 +08:00
incorporate some output for the user
This commit is contained in:
@@ -5,6 +5,9 @@ require "synxronize/pbx_group"
|
||||
require "synxronize/abstract_object"
|
||||
require "synxronize/pbx_native_target"
|
||||
require "synxronize/pbx_variant_group"
|
||||
require "synxronize/tabber"
|
||||
|
||||
require "colored"
|
||||
|
||||
module Synxronize
|
||||
end
|
||||
|
||||
@@ -18,9 +18,21 @@ module Xcodeproj
|
||||
self.path = real_path.relative_path_from((project.work_pathname_to_pathname(group.work_pathname))).to_s
|
||||
end
|
||||
change_build_settings_reference
|
||||
|
||||
output
|
||||
else
|
||||
Synxronize::Tabber.puts "skipped #{basename}".red
|
||||
end
|
||||
end
|
||||
|
||||
def output
|
||||
build_settings_ammended = "(build settings ammended: #{@setting_keys_changed.join(", ")})" if @setting_keys_changed.count > 0
|
||||
removed_from_groups = "(had multiple parent groups, removed from groups: #{@removed_from_groups.join(", ")})" if @removed_from_groups.count > 0
|
||||
str_output = "#{basename} #{build_settings_ammended} #{removed_from_groups}"
|
||||
str_output = str_output.yellow if removed_from_groups || build_settings_ammended
|
||||
Synxronize::Tabber.puts str_output
|
||||
end
|
||||
|
||||
def should_sync?
|
||||
# Don't sync files that don't exist or are Apple/Build stuff
|
||||
real_path.exist? && !(real_path.to_s =~ /^\$\{(SDKROOT|DEVELOPER_DIR|BUILT_PRODUCTS_DIR)\}/)
|
||||
@@ -34,15 +46,27 @@ module Xcodeproj
|
||||
private :should_move?
|
||||
|
||||
def ensure_internal_consistency(group)
|
||||
@removed_from_groups = []
|
||||
if referring_groups.count > 1
|
||||
# Files should only have one referring group -- this is an internal consistency issue if there is more than 1.
|
||||
# Just remove all referring groups but the one we're syncing with
|
||||
referring_groups.each { |rg| rg.remove_reference(self) unless rg == group }
|
||||
|
||||
referring_groups.each do |rg|
|
||||
unless rg == group
|
||||
rg.remove_reference(self) unless rg == group
|
||||
@removed_from_groups << rg.hierarchy_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Duplicates for some reason?
|
||||
@removed_from_groups.uniq!
|
||||
end
|
||||
|
||||
# Fixes things like pch, info.plist references being changed
|
||||
def change_build_settings_reference
|
||||
@setting_keys_changed = []
|
||||
return unless basename =~ /\.(pch|plist)$/
|
||||
|
||||
project.targets.each do |t|
|
||||
@@ -51,10 +75,13 @@ module Xcodeproj
|
||||
setting_value = bs[setting_key]
|
||||
if setting_value == real_path.relative_path_from(project.root_pathname).to_s
|
||||
bs[setting_key] = hierarchy_path[1..-1]
|
||||
@setting_keys_changed << setting_key
|
||||
end
|
||||
end if bs
|
||||
end
|
||||
end
|
||||
|
||||
@setting_keys_changed.uniq!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,10 +7,15 @@ module Xcodeproj
|
||||
|
||||
def sync
|
||||
unless excluded_from_sync?
|
||||
Synxronize::Tabber.puts "#{basename}/".green
|
||||
Synxronize::Tabber.increase
|
||||
|
||||
work_pathname.mkpath
|
||||
files.each { |pbx_file| pbx_file.sync(self) }
|
||||
all_groups.each { |group| group.sync }
|
||||
sync_path
|
||||
|
||||
Synxronize::Tabber.decrease
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,13 +25,18 @@ module Xcodeproj
|
||||
|
||||
def move_entries_not_in_xcodeproj
|
||||
unless excluded_from_sync?
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.puts "#{basename}/".green
|
||||
Dir[real_path.to_s + "/*"].each do |entry|
|
||||
entry_pathname = real_path + entry
|
||||
unless has_entry?(entry_pathname)
|
||||
FileUtils.mv(entry_pathname.realpath, work_pathname.to_s)
|
||||
|
||||
puts_unused_file(entry_pathname)
|
||||
end
|
||||
end
|
||||
all_groups.each(&:move_entries_not_in_xcodeproj)
|
||||
Synxronize::Tabber.decrease
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,6 +62,17 @@ module Xcodeproj
|
||||
end
|
||||
private :variant_groups
|
||||
|
||||
def puts_unused_file(file_pathname)
|
||||
source_file_extensions = %W(.h .m .mm .c)
|
||||
|
||||
output = file_pathname.basename.to_s
|
||||
if source_file_extensions.include?(file_pathname.extname)
|
||||
output = "#{output} (source file that is not included in Xcode project)".yellow
|
||||
end
|
||||
|
||||
Synxronize::Tabber.puts output
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,9 +19,14 @@ module Synxronize
|
||||
end
|
||||
|
||||
def sync
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.puts "Syncing files that are included in Xcode project...".bold.white
|
||||
main_group.all_groups.each(&:sync)
|
||||
puts "\n\n"
|
||||
Synxronize::Tabber.puts "Syncing files that are not included in Xcode project..".bold.white
|
||||
main_group.all_groups.each(&:move_entries_not_in_xcodeproj)
|
||||
transplant_work_project
|
||||
Synxronize::Tabber.decrease
|
||||
save
|
||||
end
|
||||
|
||||
|
||||
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
|
||||
spec.add_development_dependency "pry"
|
||||
|
||||
spec.add_dependency "clamp"
|
||||
spec.add_dependency "colored"
|
||||
spec.add_dependency "xcodeproj"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user