akcache 1.1.3 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61606c56e5669af26ac45d1570d7c03b9f7162fada8fa21f81b7d6e31cfd73c9
4
- data.tar.gz: 1a4f8d700c08f5f3a4c76b98859587a39fbf84a6a3f4e9d0f726c14b78506238
3
+ metadata.gz: 4369582924b54b8726037e8c644c6ae3cfab4df668c3123f5ae24f7ccf6ed6af
4
+ data.tar.gz: 9be701fddb92e20f9290d63c0ce2742bd1627b294619f448444774110a48c7eb
5
5
  SHA512:
6
- metadata.gz: c1bcf43339041a467e95482b9ed716d1422075aa1dd71340119df6f7aaf84046497de93501ca4740703887cf3e5d90f4f107d8860bdeb783a3aa422b077fc91e
7
- data.tar.gz: 75be160670313f6ed6f1add935ac70f1851e69ed0597e9ac3a69817c4b4bda6d3bf959d10bf80c5c8b52abd90990dadc850e2c8246d9532726bbe1a647a60f50
6
+ metadata.gz: 902da61b7bafde61bbf7e8665a67ca5515e2892314e0a49cc9cfcc09745be1f54566598c3695c346246b9f57c85bdad055585012fc91c2686284882b816e6fc3
7
+ data.tar.gz: 4731b53c0145a785e4ec796e21eb41323d3b7b373f6fe34cf080134ecd95f649902a05b0e440a008f180848863d41e4daa3709e912494cc5891d1801c1cb977b
data/bin/kcache CHANGED
@@ -10,11 +10,9 @@ if ARGV[0] == "xcodebuild" or ARGV[0] == "fastlane"
10
10
  manager.project_task_end
11
11
 
12
12
  elsif ARGV[0] == "inject"
13
-
14
13
  manager.set_prama_to_yaml
15
14
 
16
15
  elsif ARGV[0] == "copy"
17
-
18
16
  manager.copy_cache
19
17
 
20
18
  elsif ARGV[0] == "begin"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yusheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -32,24 +32,7 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - ".github/workflows/main.yml"
36
- - ".gitignore"
37
- - ".rubocop.yml"
38
- - ".vscode/launch.json"
39
- - CODE_OF_CONDUCT.md
40
- - Gemfile
41
- - Gemfile.lock
42
- - LICENSE.txt
43
- - README.md
44
- - Rakefile
45
- - bin/console
46
35
  - bin/kcache
47
- - bin/setup
48
- - kcache.gemspec
49
- - lib/kcache.rb
50
- - lib/kcache/README.md
51
- - lib/kcache/version.rb
52
- - lib/pod_plugin.rb
53
36
  homepage: https://github.com/yusheng00
54
37
  licenses:
55
38
  - MIT
@@ -72,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
55
  - !ruby/object:Gem::Version
73
56
  version: '0'
74
57
  requirements: []
75
- rubygems_version: 3.1.6
58
+ rubygems_version: 3.2.3
76
59
  signing_key:
77
60
  specification_version: 4
78
61
  summary: a cache tool
@@ -1,18 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: 2.6.3
14
- - name: Run the default task
15
- run: |
16
- gem install bundler -v 2.2.6
17
- bundle install
18
- bundle exec rake
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120
data/.vscode/launch.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "configurations": [
3
- {
4
- "type": "ruby-debug",
5
- "request": "launch",
6
- "name": "Launch File",
7
- "program": "${workspaceFolder}/${command:AskForProgramName}",
8
- "programArgs": [],
9
- "useBundler": false
10
- }
11
- ]
12
- }
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at yusheng@akulaku.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in kcache.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rubocop", "~> 1.7"
data/Gemfile.lock DELETED
@@ -1,55 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- akcache (1.0.2)
5
- xcodeproj (~> 1.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- CFPropertyList (3.0.4)
11
- rexml
12
- ast (2.4.2)
13
- atomos (0.1.3)
14
- claide (1.0.3)
15
- colored2 (3.1.2)
16
- nanaimo (0.3.0)
17
- parallel (1.20.1)
18
- parser (3.0.2.0)
19
- ast (~> 2.4.1)
20
- rainbow (3.0.0)
21
- rake (13.0.6)
22
- regexp_parser (2.1.1)
23
- rexml (3.2.5)
24
- rubocop (1.18.4)
25
- parallel (~> 1.10)
26
- parser (>= 3.0.0.0)
27
- rainbow (>= 2.2.2, < 4.0)
28
- regexp_parser (>= 1.8, < 3.0)
29
- rexml
30
- rubocop-ast (>= 1.8.0, < 2.0)
31
- ruby-progressbar (~> 1.7)
32
- unicode-display_width (>= 1.4.0, < 3.0)
33
- rubocop-ast (1.8.0)
34
- parser (>= 3.0.1.1)
35
- ruby-progressbar (1.11.0)
36
- unicode-display_width (2.0.0)
37
- xcodeproj (1.21.0)
38
- CFPropertyList (>= 2.3.3, < 4.0)
39
- atomos (~> 0.1.3)
40
- claide (>= 1.0.2, < 2.0)
41
- colored2 (~> 3.1)
42
- nanaimo (~> 0.3.0)
43
- rexml (~> 3.2.4)
44
-
45
- PLATFORMS
46
- universal-darwin-20
47
- universal-darwin-21
48
-
49
- DEPENDENCIES
50
- akcache!
51
- rake (~> 13.0)
52
- rubocop (~> 1.7)
53
-
54
- BUNDLED WITH
55
- 2.2.6
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021 yusheng
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,44 +0,0 @@
1
- # AKCache
2
-
3
-
4
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kcache`. To experiment with that code, run `bin/console` for an interactive prompt.
5
-
6
- TODO: Delete this and the text above, and describe your gem
7
-
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- ```ruby
13
- gem 'kcache'
14
- ```
15
-
16
- And then execute:
17
-
18
- $ bundle install
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install kcache
23
-
24
- ## Usage
25
-
26
- TODO: Write usage instructions here
27
-
28
- ## Development
29
-
30
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
-
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
-
34
- ## Contributing
35
-
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kcache. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/kcache/blob/master/CODE_OF_CONDUCT.md).
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
-
42
- ## Code of Conduct
43
-
44
- Everyone interacting in the Kcache project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kcache/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
5
-
6
- RuboCop::RakeTask.new
7
-
8
- task default: :rubocop
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "kcache"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/kcache.gemspec DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require_relative "lib/kcache/version"
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "akcache"
10
- spec.version = Kcache::VERSION
11
- spec.authors = ["yusheng"]
12
- spec.email = ["1433233832@qq.com"]
13
-
14
- spec.summary = "a cache tool"
15
- spec.description = "a cache tool that can reduce xcode archive time"
16
- spec.homepage = "https://github.com/yusheng00"
17
- spec.license = "MIT"
18
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
19
-
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = spec.homepage
22
- spec.metadata["changelog_uri"] = spec.homepage
23
-
24
- # Specify which files should be added to the gem when it is released.
25
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
28
- end
29
- spec.bindir = "bin"
30
- spec.executables = "kcache"
31
- spec.require_paths = ["lib"]
32
-
33
- # Uncomment to register a new dependency of your gem
34
- spec.add_dependency "xcodeproj", "~> 1.0"
35
-
36
- # For more information and examples about making a new gem, checkout our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
- end
data/lib/kcache/README.md DELETED
@@ -1,29 +0,0 @@
1
- # AKMall
2
-
3
- [![CI Status](https://img.shields.io/travis/pangyulei/AKMall.svg?style=flat)](https://travis-ci.org/pangyulei/AKMall)
4
- [![Version](https://img.shields.io/cocoapods/v/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
5
- [![License](https://img.shields.io/cocoapods/l/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
6
- [![Platform](https://img.shields.io/cocoapods/p/AKMall.svg?style=flat)](https://cocoapods.org/pods/AKMall)
7
-
8
- ## Example
9
-
10
- To run the example project, clone the repo, and run `pod install` from the Example directory first.
11
-
12
- ## Requirements
13
-
14
- ## Installation
15
-
16
- AKMall is available through [CocoaPods](https://cocoapods.org). To install
17
- it, simply add the following line to your Podfile:
18
-
19
- ```ruby
20
- pod 'AKMall'
21
- ```
22
-
23
- ## Author
24
-
25
- pangyulei, pangyulei@gmail.com
26
-
27
- ## License
28
-
29
- AKMall is available under the MIT license. See the LICENSE file for more info.
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kcache
4
- VERSION = "1.1.3"
5
- end
data/lib/kcache.rb DELETED
@@ -1,819 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "kcache/version"
4
- require 'yaml'
5
- require 'json/ext'
6
- require 'xcodeproj'
7
- require 'pathname'
8
- require "find"
9
- require 'set'
10
-
11
- #配置
12
-
13
- TARGET_CACHE_CONFIG = "target_cache_config.yml"
14
-
15
- CACHE_STATUS_MISS = "miss"
16
- CACHE_STATUS_READY = "ready"
17
- CACHE_STATUS_HIT = "hit"
18
-
19
- FILE_NAME_PRODUCT = "product.tar"
20
- FILE_NAME_CONTEXT = "context.yml"
21
- FILE_NAME_TARGET_CONTEXT = "target_context.yml"
22
-
23
- #Xcode编译相关常量
24
- MODULEMAP_FILE = "MODULEMAP_FILE"
25
- FULL_PRODUCT_NAME = "FULL_PRODUCT_NAME"
26
- CONFIGURATION_BUILD_DIR = "CONFIGURATION_BUILD_DIR"
27
- CONFIGURATION_TEMP_DIR = "CONFIGURATION_TEMP_DIR"
28
- TARGET_TEMP_DIR = "TARGET_TEMP_DIR"
29
- TARGET_BUILD_DIR = "TARGET_BUILD_DIR"
30
-
31
- PODS_XCFRAMEWORKS_BUILD_DIR = "PODS_XCFRAMEWORKS_BUILD_DIR"
32
- SYMROOT = "SYMROOT"
33
- SRCROOT = "SRCROOT"
34
- OBJROOT = "OBJROOT"
35
-
36
-
37
- #变量
38
- $target_build_configuration = "Release"
39
- $podfile_spec_checksums = nil
40
- $file_md5_hash = {}
41
- $exclude_target = []
42
-
43
- class CacheManager
44
-
45
- def get_cache_root
46
- return Dir.home + "/ysCache"
47
- end
48
-
49
- def get_content_without_pwd(content)
50
- content = content.gsub("#{Dir.pwd}/", "").gsub(/#{Dir.pwd}(\W|$)/, '\1')
51
- return content
52
- end
53
-
54
- def get_file_md5(file)
55
- if $file_md5_hash.has_key? file
56
- return $file_md5_hash[file]
57
- end
58
- md5 = Digest::MD5.hexdigest(File.read(file))
59
- $file_md5_hash[file] = md5
60
- return md5
61
- end
62
-
63
-
64
- def get_projects
65
- pods_project = Xcodeproj::Project.open("Pods/Pods.xcodeproj")
66
- super_project_paths = get_super_project(pods_project)
67
- super_projects = []
68
- super_project_paths.each do | path |
69
- next if path.end_with? "Pods/Pods.xcodeproj"
70
- project = Xcodeproj::Project.open(path)
71
- super_projects.push project
72
- end
73
- return (super_projects + [pods_project])
74
- end
75
-
76
- def get_super_project(project)
77
- wrapper_projects = project.files.select{|file|file.last_known_file_type=="wrapper.pb-project"}
78
- wrapper_project_paths = []
79
- wrapper_projects.each do | wrapper_project_file |
80
- wrapper_project_file_path = wrapper_project_file.real_path.to_s
81
- wrapper_project_paths.push wrapper_project_file_path
82
- end
83
- return wrapper_project_paths.uniq
84
- end
85
-
86
-
87
- def backup_project(project)
88
- command = "cp \"#{project.path}/project.pbxproj\" \"#{project.path}/ysTest_backup.pbxproj\""
89
- raise unless system command
90
- end
91
-
92
- def clean_temp_files
93
- # command = "rm -rf Pods/*.xcodeproj/ysTest_backup.pbxproj"
94
- # raise unless system command
95
-
96
- command = "rm -rf Pods/*.xcodeproj/*.#{FILE_NAME_TARGET_CONTEXT}"
97
- raise unless system command
98
- end
99
-
100
- def restore_project(project)
101
- if File.exist? "#{project.path}/ysTest_backup.pbxproj"
102
- command = "mv \"#{project.path}/ysTest_backup.pbxproj\" \"#{project.path}/project.pbxproj\""
103
- raise unless system command
104
- end
105
- end
106
-
107
-
108
- def can_cache_target(target)
109
- if target.product_type == "com.apple.product-type.bundle" or
110
- target.product_type == "com.apple.product-type.library.static" or
111
- target.product_type == "com.apple.product-type.framework"
112
- return true
113
- end
114
- return false
115
- end
116
-
117
- def get_target_dependency_files(target, intermediate_dir, product_dir, xcframeworks_build_dir, src_path)
118
- dependency_files = []
119
- Dir.glob("#{intermediate_dir}/**/*.d").each do | dependency_file |
120
- content = File.read(dependency_file)
121
- files = content.scan(/(?:\S(?:\\ )*)+/).flatten.uniq
122
- files = files - ["dependencies:", "\\", ":"]
123
- files.each do | file |
124
- file = file.gsub("\\ ", " ")
125
- if file.start_with? target.name
126
- file = src_path + "/" + file
127
- end
128
- unless File.exist? file
129
- puts "<ERROR> #{target.name} #{file} should exist in dependency file #{dependency_file}"
130
- return []
131
- end
132
-
133
- if file.start_with? intermediate_dir + "/" or
134
- file.start_with? product_dir + "/"
135
- next
136
- end
137
-
138
- if xcframeworks_build_dir and xcframeworks_build_dir.size > 0 and file.start_with? xcframeworks_build_dir + "/"
139
- next
140
- end
141
- dependency_files.push file
142
- end
143
- end
144
-
145
- return dependency_files.uniq
146
- end
147
-
148
-
149
- def get_target_source_files(target)
150
- files = []
151
- #获取所有可执行文件(.m .swift .cpp .mm)
152
- target.source_build_phase.files.each do | file |
153
- file_path = file.file_ref.real_path.to_s
154
- files.push file_path
155
- end
156
-
157
- #获取所有头文件(.h)
158
- target.headers_build_phase.files.each do | file |
159
- file_path = file.file_ref.real_path.to_s
160
- files.push file_path
161
- end
162
- #获取所有资源文件(.png,.strings .json .html)
163
- target.resources_build_phase.files.each do | file |
164
- file_path = file.file_ref.real_path.to_s
165
- files.push file_path
166
- end
167
- expand_files = []
168
- files.uniq.each do | file |
169
- next unless File.exist? file
170
- if File.file? file
171
- expand_files.push file
172
- else
173
- Find.find(file).each do | file_in_dir |
174
- if File.file? file_in_dir
175
- expand_files.push file_in_dir
176
- end
177
- end
178
- end
179
- end
180
- return expand_files.uniq
181
- end
182
-
183
-
184
- def generate_target_all_infomation(project, target, source_files)
185
-
186
- if $podfile_spec_checksums == nil and File.exist? "Podfile.lock"
187
- podfile_lock = YAML.load(File.read("Podfile.lock"))
188
- $podfile_spec_checksums = podfile_lock["SPEC CHECKSUMS"]
189
- end
190
-
191
- project_configuration = project.build_configurations.detect { | config | config.name == $target_build_configuration}
192
- project_configuration_content = project_configuration.pretty_print.to_yaml
193
-
194
- project_xcconfig = ""
195
- if project_configuration.base_configuration_reference
196
- config_file_path = project_configuration.base_configuration_reference.real_path
197
- if File.exist? config_file_path
198
- project_xcconfig = File.read(config_file_path).lines.reject{|line|line.include? "_SEARCH_PATHS"}.sort.join("")
199
- end
200
- end
201
-
202
- target_configuration = target.build_configurations.detect { | config | config.name == $target_build_configuration}
203
- target_configuration_content = target_configuration.pretty_print.to_yaml
204
-
205
- target_xcconfig = ""
206
- if target_configuration.base_configuration_reference
207
- config_file_path = target_configuration.base_configuration_reference.real_path
208
- if File.exist? config_file_path
209
- target_xcconfig = File.read(config_file_path).lines.reject{|line|line.include? "_SEARCH_PATHS"}.sort.join("")
210
- end
211
- end
212
-
213
-
214
- files_configuration = []
215
- build_phases = []
216
- build_phases.push target.source_build_phase if target.methods.include? :source_build_phase
217
- build_phases.push target.resources_build_phase if target.methods.include? :resources_build_phase
218
- build_phases.each do | build_phase |
219
- target.source_build_phase.files_references.each do | files_reference |
220
- files_reference.build_files.each do |build_file|
221
- if build_file.settings and build_file.settings.class == Hash
222
- files_configuration.push File.basename(build_file.file_ref.real_path.to_s) + "\n" + build_file.settings.to_yaml
223
- end
224
- end
225
- end
226
- end
227
- files_configuration = files_configuration.sort.uniq.join("\n")
228
-
229
-
230
- source_md5_list = []
231
- has_found_checksum = false
232
- split_parts = target.name.split("-")
233
- split_parts.each_with_index do | part, index |
234
- spec_name = split_parts[0..index].join("-")
235
- if $podfile_spec_checksums.has_key? spec_name
236
- source_md5_list.push "SPEC CHECKSUM : #{spec_name} #{$podfile_spec_checksums[spec_name]}"
237
- has_found_checksum = true
238
- end
239
- end
240
-
241
- if has_found_checksum
242
- if target.name.start_with? "AK" or target.name.start_with? "EUR"
243
-
244
- source_md5_list.push "Project : #{File.basename(project.path)}"
245
- source_md5_list.push "Project configuration : "
246
- source_md5_list.push project_configuration_content.strip
247
- source_md5_list.push "Project xcconfig : "
248
- source_md5_list.push project_xcconfig.strip
249
-
250
- source_md5_list.push "Target : #{target.name}, #{target.product_type}"
251
- source_md5_list.push "Target configuration : "
252
- source_md5_list.push target_configuration_content.strip
253
- source_md5_list.push "Target xcconfig : "
254
- source_md5_list.push target_xcconfig.strip
255
- source_md5_list.push "Files settings : "
256
- source_md5_list.push files_configuration.strip
257
-
258
- source_md5_list.push "Files MD5 : "
259
- source_files.uniq.sort.each do | file |
260
- path = get_content_without_pwd(file)
261
- if target.name == "AKULocalizedStrings" or target.name == "EURLocalizedStrings"
262
- if file.include? ".swift"
263
- source_md5_list.push path + " : " + get_file_md5(path)
264
- end
265
- else
266
- source_md5_list.push path + " : " + get_file_md5(path)
267
- end
268
- end
269
- else
270
- source_md5_list.push "Target configuration: #{$target_build_configuration}"
271
- end
272
-
273
- source_md5_content = source_md5_list.join("\n")
274
- return source_md5_content
275
-
276
- end
277
- end
278
-
279
-
280
-
281
- def get_target_cache(target, target_md5)
282
-
283
- dependency_start_time = Time.now
284
-
285
- target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
286
-
287
- hit_results = []
288
-
289
- target_cache_dirs.each do |target_cache_dir|
290
- unless File.exist? target_cache_dir + "/" + FILE_NAME_PRODUCT
291
- puts "<ERROR> #{target.name} target cache dir missed files: #{target_cache_dir}"
292
- next
293
- end
294
- unless File.exist? target_cache_dir + "/" + FILE_NAME_CONTEXT
295
- puts "<ERROR> #{target.name} target cache dir missed files: #{target_cache_dir}"
296
- next
297
- end
298
-
299
- target_context = YAML.load(File.read(target_cache_dir + "/" + FILE_NAME_CONTEXT))
300
-
301
- if target_context[:target_md5] != target_md5 or target_context[:product_md5] != get_file_md5(target_cache_dir + "/" + FILE_NAME_PRODUCT)
302
- command = "rm -rf \"#{target_cache_dir}\""
303
- raise unless system command
304
- puts "<ERROR> #{target.name} target md5 does not match: #{target_cache_dir}"
305
- end
306
-
307
- dependency_exit = true
308
-
309
- if target_context[:dependency_files_md5]
310
- target_context[:dependency_files_md5].each do | item |
311
- dependency_file = item[0]
312
- dependency_md5 = item[1]
313
- unless File.exist? dependency_file
314
- puts "<WARNING> #{target.name} dependency file miss: #{dependency_file}"
315
- dependency_exit = false
316
- break
317
- end
318
- unless get_file_md5(dependency_file) == dependency_md5
319
- puts "<WARNING> #{target.name} dependency file md5 does not match: #{dependency_file}"
320
- dependency_exit = false
321
- break
322
- end
323
- end
324
- end
325
-
326
- if dependency_exit
327
- hit_results.push target_cache_dir
328
- end
329
- end
330
-
331
- return hit_results
332
-
333
- end
334
-
335
- def set_prama_to_yaml
336
- target_name = ARGV[1]
337
- project_path = ARGV[2]
338
- if File.exist? "#{project_path}/#{target_name}.#{FILE_NAME_TARGET_CONTEXT}"
339
- target_context = YAML.load(File.read("#{project_path}/#{target_name}.#{FILE_NAME_TARGET_CONTEXT}"))
340
-
341
- [SYMROOT, OBJROOT, SRCROOT, CONFIGURATION_BUILD_DIR, CONFIGURATION_TEMP_DIR, TARGET_BUILD_DIR, TARGET_TEMP_DIR, PODS_XCFRAMEWORKS_BUILD_DIR, MODULEMAP_FILE, FULL_PRODUCT_NAME].sort.each do | key |
342
- if ENV[key]
343
- target_context[key] = ENV[key]
344
- end
345
- end
346
- target_context[:target_status] = CACHE_STATUS_READY
347
- File.write("#{project_path}/#{target_name}.#{FILE_NAME_TARGET_CONTEXT}", target_context.to_yaml)
348
- end
349
- end
350
-
351
- def inject_flag_action(project, target)
352
- command_exec = "\"#{$0}\""
353
- inject_phase = target.new_shell_script_build_phase("ys_inject_#{target.name}")
354
- inject_phase.shell_script = "#{command_exec} #{"inject"} #{target.name} \"#{project.path}\""
355
- inject_phase.show_env_vars_in_log = '1'
356
- end
357
-
358
- def inject_copy_action(project, target, target_context)
359
- target_cache_dir = target_context[:hit_target_cache_dir]
360
-
361
- target.build_phases.delete_if { | build_phase |
362
- build_phase.class == Xcodeproj::Project::Object::PBXHeadersBuildPhase or
363
- build_phase.class == Xcodeproj::Project::Object::PBXSourcesBuildPhase or
364
- build_phase.class == Xcodeproj::Project::Object::PBXResourcesBuildPhase
365
- }
366
-
367
- command_exec = "\"#{$0}\""
368
- inject_phase = target.new_shell_script_build_phase("ys_copy_#{target.name}")
369
- inject_phase.shell_script = "#{command_exec} #{"copy"} \"#{target_cache_dir}\""
370
- inject_phase.show_env_vars_in_log = '1'
371
- end
372
-
373
- def copy_cache
374
-
375
- puts "<INFO> #{Time.now.to_f.to_s}"
376
- start_time = Time.now
377
- target_cache_dir = ARGV[1]
378
- cache_product_path = target_cache_dir + "/#{FILE_NAME_PRODUCT}"
379
-
380
- [SYMROOT, CONFIGURATION_BUILD_DIR, CONFIGURATION_TEMP_DIR, OBJROOT, TARGET_BUILD_DIR, TARGET_TEMP_DIR, SRCROOT, FULL_PRODUCT_NAME].sort.each do | key |
381
- unless ENV.has_key? key and ENV[key] and ENV[key].size > 0
382
- raise "<INFO> #{$0} should have #{key}"
383
- break
384
- end
385
- end
386
-
387
- command = "mkdir -p \"#{ENV[CONFIGURATION_BUILD_DIR]}\" && cd \"#{File.dirname(ENV[CONFIGURATION_BUILD_DIR])}/\" && tar -xf \"#{cache_product_path}\""
388
- raise unless system command
389
-
390
- if ENV[CONFIGURATION_BUILD_DIR] != ENV[TARGET_BUILD_DIR]
391
-
392
- command = "rm -rf \"#{ENV[TARGET_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME]}\""
393
- raise unless system command
394
-
395
- command = "mkdir -p \"#{File.dirname(ENV[TARGET_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME])}\""
396
- raise unless system command
397
-
398
- command = "mv \"#{ENV[CONFIGURATION_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME]}\" \"#{ENV[TARGET_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME]}\""
399
- raise unless system command
400
-
401
- command = "/bin/ln -sfh \"#{ENV[TARGET_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME]}\" \"#{ENV[CONFIGURATION_BUILD_DIR]+"/"+ENV[FULL_PRODUCT_NAME]}\""
402
- raise unless system command
403
- end
404
-
405
- puts "<INFO> duration = #{((Time.now - start_time)*1000).to_i} ms in copy cache action"
406
- puts "<INFO> #{Time.now.to_f.to_s}"
407
- end
408
-
409
-
410
- def add_cache(target, target_info)
411
- target_md5 = target_info[:target_md5]
412
- product_dir = target_info[CONFIGURATION_BUILD_DIR]
413
- full_product_name = target_info[FULL_PRODUCT_NAME]
414
-
415
- Dir.glob("#{product_dir}/**/*.modulemap").each do | modulemap |
416
- modulemap_content = File.read(modulemap)
417
- if modulemap_content.include? File.dirname(modulemap) + "/"
418
- modulemap_content = modulemap_content.gsub(File.dirname(modulemap) + "/", "")
419
- File.write(modulemap, modulemap_content)
420
- end
421
- end
422
-
423
- unless full_product_name and full_product_name.size > 0 and File.exist? "#{product_dir}/#{full_product_name}"
424
- puts "<ERROR> #{target.name} #{product_dir}/#{full_product_name} should exist"
425
- return false
426
- end
427
-
428
- zip_start_time = Time.now
429
-
430
- command = "cd \"#{File.dirname(product_dir)}\" && tar -L -c -f #{target.name}.#{FILE_NAME_PRODUCT} #{File.basename(product_dir)}/#{full_product_name}"
431
- if target.product_type == "com.apple.product-type.library.static"
432
- command = "cd \"#{File.dirname(product_dir)}\" && tar --exclude=*.bundle --exclude=*.framework -L -c -f #{target.name}.#{FILE_NAME_PRODUCT} #{File.basename(product_dir)}"
433
- end
434
-
435
- unless system command
436
- puts "<INFO> #{command} should succeed"
437
- return false
438
- end
439
-
440
- already_target_cache_dirs = Dir.glob(get_cache_root + "/" + target.name + "-" + target_md5 + "-*")
441
- already_target_cache_dirs.each do |path|
442
- if File.exist? path
443
- raise unless system "rm -rf \"#{path}\""
444
- end
445
- end
446
-
447
- target_cache_dir = get_cache_root + "/" + target.name + "-" + target_md5 + "-" + (Time.now.to_f * 1000).to_i.to_s
448
- if File.exist? target_cache_dir
449
- puts "<INFO> #{target_cache_dir} should not exist"
450
- raise unless system "rm -rf \"#{target_cache_dir}\""
451
- return false
452
- end
453
-
454
- command = "mkdir -p \"#{target_cache_dir}\""
455
- unless system command
456
- puts "<INFO> #{command} should succeed"
457
- return false
458
- end
459
-
460
- cache_product_path = target_cache_dir + "/#{FILE_NAME_PRODUCT}"
461
- command = "mv \"#{File.dirname(product_dir)}/#{target.name}.#{FILE_NAME_PRODUCT}\" \"#{cache_product_path}\""
462
- unless system command
463
- puts "<INFO> #{command} should succeed"
464
- return false
465
- end
466
- unless File.exist? cache_product_path
467
- puts "<INFO> #{cache_product_path} should exist after mv"
468
- return false
469
- end
470
-
471
- target_info[:product_md5] = get_file_md5(cache_product_path)
472
- target_info[:build_product_dir] = target_info[CONFIGURATION_BUILD_DIR].gsub(target_info[SYMROOT] + "/", "")
473
- target_info[:build_intermediate_dir] = target_info[TARGET_TEMP_DIR].gsub(target_info[OBJROOT] + "/", "")
474
- if target_info[MODULEMAP_FILE]
475
- target_info[MODULEMAP_FILE] = get_content_without_pwd(target_info[MODULEMAP_FILE])
476
- end
477
-
478
- target_info = target_info.clone
479
- target_info.delete(:dependency_files)
480
- target_info.delete(:target_status)
481
- target_info.delete(:hit_target_cache_dir)
482
- target_info.delete(:target_md5_content)
483
- [SYMROOT, CONFIGURATION_BUILD_DIR, CONFIGURATION_TEMP_DIR, OBJROOT, TARGET_TEMP_DIR, TARGET_BUILD_DIR, PODS_XCFRAMEWORKS_BUILD_DIR, SRCROOT].each do | key |
484
- target_info.delete(key)
485
- end
486
-
487
- File.write(target_cache_dir + "/" + FILE_NAME_CONTEXT, target_info.to_yaml)
488
-
489
- return true
490
-
491
- end
492
-
493
- def get_custom_config_information
494
- if File.exist? "project_cache_config.yml"
495
- custom_config = YAML.load (File.read("project_cache_config.yml"))
496
- $exclude_target = custom_config[:exclude_targets]
497
- else
498
- source = {
499
- :description => nil,
500
- :dependency_check => true,
501
- :exclude_targets => ["target1", "target2"],
502
- }.to_yaml
503
-
504
- substitution_list = {
505
- /:description:/ => "# You can assign values to these parameters to achieve some custom functions\n",
506
- /:dependency_check:/ => "\n\n# Whether to check the dependencies of the target. For exzample: target A depends on target B. Under normal circumstances, target B is recompiled, then target A will be recompiled, but if the dependencies are not checked, target A will not be recompiled at this time\n:dependency_check:",
507
- /:exclude_targets:/ => "\n\n# the targets that will not participate in cache dependency detection\n:exclude_targets:",
508
- }
509
-
510
- substitution_list.each do |pattern, replacement|
511
- source.gsub!(pattern, replacement)
512
- end
513
- puts source
514
- File.write("project_cache_config.yml", source)
515
- end
516
-
517
- end
518
-
519
-
520
- def project_task_begin(argv)
521
-
522
- argv.each do |prama|
523
- if prama.include? "configuration"
524
- if prama.include? "Debug"
525
- $target_build_configuration = "Debug"
526
- elsif prama.include? "Release"
527
- $target_build_configuration = "Release"
528
- end
529
- end
530
- end
531
-
532
- projects = get_projects
533
- total_count = 0
534
- hit_count = 0
535
- miss_count = 0
536
- error_count = 0
537
- hit_target_md5_cache_set = Set.new
538
- miss_target_cache_set = Set.new
539
-
540
- get_custom_config_information
541
-
542
- pre_targets_info = {}
543
-
544
- projects.each do |project|
545
- restore_project(project)
546
- backup_project(project)
547
- end
548
-
549
- clean_temp_files
550
-
551
- projects = get_projects
552
-
553
- projects.each do |project|
554
- project.native_targets.each do |target|
555
- if can_cache_target(target)
556
- total_count = total_count + 1
557
- source_files = get_target_source_files(target)
558
- target_md5_content = generate_target_all_infomation(project, target, source_files)
559
- unless target_md5_content
560
- puts "<ERROR> target md5 content can not generate: #{target.name}"
561
- error_count = error_count + 1
562
- next
563
- end
564
-
565
- target_md5 = Digest::MD5.hexdigest(target_md5_content)
566
- hit_target_cache_dirs = get_target_cache(target, target_md5)
567
- target_info = {}
568
- target_info[:target_md5] = target_md5
569
-
570
- if hit_target_cache_dirs.count == 0
571
- puts "<INFO> #{target.name} #{target_md5} does not hit any cache"
572
- target_info[:target_status] = CACHE_STATUS_MISS
573
- inject_flag_action(project, target)
574
- miss_count = miss_count + 1
575
- File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
576
- else
577
- target_info[:hit_target_cache_dir] = hit_target_cache_dirs
578
- hit_target_md5_cache_set.add "#{target.name}-#{target_info[:target_md5]}"
579
- end
580
- pre_targets_info[target] = target_info
581
- end
582
- end
583
- end
584
-
585
- while true
586
- projects.each do |project|
587
- project.native_targets.each do |target|
588
- target_info = pre_targets_info[target]
589
- next unless target_info and target_info[:target_status] != CACHE_STATUS_MISS
590
- next unless target_info and target_info[:target_status] != CACHE_STATUS_HIT
591
- hit_target_cache_dirs = target_info[:hit_target_cache_dir]
592
- next unless hit_target_cache_dirs and hit_target_cache_dirs.count > 0
593
- target_md5 = target_info[:target_md5]
594
-
595
- target_really_hit_dir = ""
596
- target_really_miss = false
597
- hit_target_cache_dirs.each do |hit_target_cache_dir|
598
- all_dependency_target_exist = true
599
- target_really_miss = false
600
- hit_targets_info = YAML.load(File.read(hit_target_cache_dir + "/" + FILE_NAME_CONTEXT))
601
- if hit_targets_info[:dependency_targets_md5]
602
- hit_targets_info[:dependency_targets_md5].each do | item |
603
- dependency_target = item[0]
604
- dependency_target_md5 = item[1]
605
- if $exclude_target.include? dependency_target
606
- puts "<INFO> #{target.name} #{target_md5} hit cache, dependency target #{dependency_target}-#{dependency_target_md5} skip check"
607
- next
608
- end
609
-
610
- if miss_target_cache_set.include? "#{dependency_target}"
611
- puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
612
- target_really_miss = true
613
- all_dependency_target_exist = false
614
- break
615
- end
616
-
617
- unless hit_target_md5_cache_set.include? "#{dependency_target}-#{dependency_target_md5}"
618
- puts "<INFO> #{target.name} #{target_md5} hit cache, but dependency target #{dependency_target}-#{dependency_target_md5} does not hit"
619
- all_dependency_target_exist = false
620
- target_really_miss = true
621
- break
622
- end
623
- end
624
-
625
- if all_dependency_target_exist
626
- target_really_hit_dir = hit_target_cache_dir
627
- break
628
- end
629
-
630
- if target_really_miss
631
- break
632
- end
633
- end
634
- end
635
-
636
- if target_really_hit_dir.length > 0
637
- puts "<INFO> #{target.name} #{target_md5} hit cache"
638
- hit_count = hit_count + 1
639
- hit_target_info = YAML.load(File.read(target_really_hit_dir + "/" + FILE_NAME_CONTEXT))
640
- target_info = target_info.merge!(hit_target_info)
641
- target_info[:target_status] = CACHE_STATUS_HIT
642
- target_info[:hit_target_cache_dir] = target_really_hit_dir
643
- inject_copy_action(project, target, target_info)
644
- end
645
-
646
- if target_really_miss
647
- miss_count = miss_count + 1
648
- miss_target_cache_set.add "#{target.name}"
649
- hit_target_md5_cache_set.delete "#{target.name}-#{target_info[:target_md5]}"
650
- target_info[:target_status] = CACHE_STATUS_MISS
651
- target_info.delete(:hit_target_cache_dir)
652
- inject_flag_action(project, target)
653
- end
654
-
655
- File.write("#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}", target_info.to_yaml)
656
- end
657
- project.save
658
- end
659
- if total_count == hit_count + miss_count + error_count
660
- break
661
- else
662
- puts "<INFO> continue to find hit cache"
663
- end
664
- end
665
- puts "<INFO> total count: #{total_count}, hit count: #{hit_count}, miss_count: #{miss_count}, error_count: #{error_count}"
666
- end
667
-
668
-
669
- def project_task_end
670
-
671
- projects = get_projects
672
- post_targets_context = {}
673
- total_add_count = 0
674
-
675
- projects.each do |project|
676
- project.native_targets.each do | target |
677
- target_context_file = "#{project.path}/#{target.name}.#{FILE_NAME_TARGET_CONTEXT}"
678
- next unless File.exist? target_context_file
679
- if can_cache_target(target)
680
- target_info = YAML.load(File.read(target_context_file))
681
- if target_info[:target_status] == CACHE_STATUS_READY
682
- # 保证编译前后MD5不变
683
- source_files = get_target_source_files(target)
684
- target_md5_content = generate_target_all_infomation(project, target, source_files)
685
- target_md5 = Digest::MD5.hexdigest(target_md5_content)
686
- unless target_info[:target_md5] == target_md5
687
- puts "<ERROR> #{target.name} md5 should not be changed after build"
688
- next
689
- end
690
-
691
- target_info[:target_md5_content] = target_md5_content
692
-
693
- product_dir = target_info[CONFIGURATION_BUILD_DIR]
694
- intermediate_dir = target_info[TARGET_TEMP_DIR].to_s
695
- xcframeworks_build_dir = target_info[PODS_XCFRAMEWORKS_BUILD_DIR]
696
- src_path = target_info[SRCROOT]
697
-
698
- unless intermediate_dir.length > 0
699
- puts "<ERROR> #{target.name} should have intermediate_dir"
700
- next
701
- end
702
- dependency_files = get_target_dependency_files(target, intermediate_dir, product_dir, xcframeworks_build_dir, src_path)
703
- if source_files.size > 0 and dependency_files.size == 0 and target.product_type != "com.apple.product-type.bundle"
704
- puts "<ERROR> #{target.name} should have dependency files"
705
- next
706
- end
707
- target_info[:dependency_files] = dependency_files - source_files
708
-
709
- module_file_path = target_info[MODULEMAP_FILE]
710
-
711
- if src_path and src_path.size > 0 and module_file_path and module_file_path.size > 0
712
- if File.exist? Dir.pwd + "/" + get_content_without_pwd("#{src_path}/#{module_file_path}")
713
- target_info[MODULEMAP_FILE] = get_content_without_pwd("#{src_path}/#{module_file_path}")
714
- else
715
- puts "<ERROR> #{target.name} #{module_file_path} should be supported"
716
- next
717
- end
718
- end
719
- elsif target_info[:target_status] == CACHE_STATUS_HIT
720
- module_file_path = target_info[MODULEMAP_FILE]
721
- if module_file_path and module_file_path.size > 0
722
- if not File.exist? Dir.pwd + "/" + target_info[MODULEMAP_FILE]
723
- puts "<ERROR> #{target.name} #{module_file_path} should be supported"
724
- next
725
- end
726
- end
727
- end
728
- post_targets_context[target] = target_info
729
-
730
- end
731
- end
732
- end
733
-
734
- projects.each do |project|
735
- project.native_targets.each do | target |
736
- if post_targets_context.has_key? target
737
- target_info = post_targets_context[target]
738
- next unless target_info[:target_status] == CACHE_STATUS_READY
739
-
740
- dependency_targets_set = Set.new
741
- implicit_dependencies = []
742
-
743
- post_targets_context.each do | other_target, other_target_context |
744
- next if target == other_target
745
- next if target.product_type == "com.apple.product-type.bundle"
746
- next if other_target.product_type == "com.apple.product-type.bundle"
747
-
748
- configuration_build_dir = other_target_context[CONFIGURATION_BUILD_DIR]
749
- target_temp_dir = other_target_context[TARGET_TEMP_DIR]
750
- build_product_dir = other_target_context[:build_product_dir]
751
- build_intermediate_dir = other_target_context[:build_intermediate_dir]
752
-
753
- target_info[:dependency_files].each do | dependency |
754
- if configuration_build_dir and configuration_build_dir.size > 0 and dependency.start_with? configuration_build_dir + "/"
755
- dependency_targets_set.add other_target
756
- implicit_dependencies.push dependency
757
- end
758
-
759
- if target_temp_dir and target_temp_dir.size > 0 and dependency.start_with? target_temp_dir + "/"
760
- dependency_targets_set.add other_target
761
- implicit_dependencies.push dependency
762
- end
763
-
764
- if build_product_dir and build_product_dir.size > 0 and dependency.start_with? target_info[SYMROOT] + "/" + build_product_dir + "/"
765
- dependency_targets_set.add other_target
766
- implicit_dependencies.push dependency
767
- end
768
-
769
- if build_intermediate_dir and build_intermediate_dir.size > 0 and dependency.start_with? target_info[OBJROOT] + "/" + build_intermediate_dir + "/"
770
- dependency_targets_set.add other_target
771
- implicit_dependencies.push dependency
772
- end
773
-
774
- end
775
- target_info[:dependency_files] = target_info[:dependency_files] - implicit_dependencies
776
-
777
- end
778
- target_info[:dependency_files] = target_info[:dependency_files] - implicit_dependencies
779
-
780
- dependency_files_md5 = []
781
-
782
- should_cache = true
783
- if target_info and target_info[:dependency_files].size > 0
784
- target_info[:dependency_files].each do | file |
785
- if file.start_with? target_info[OBJROOT] + "/" or file.start_with? target_info[SYMROOT] + "/"
786
- puts "#{target.name} #{file} dependecy should not include build path"
787
- should_cache = false
788
- break
789
- end
790
- dependency_files_md5.push [get_content_without_pwd(file), get_file_md5(file)]
791
- end
792
- end
793
- next unless should_cache
794
-
795
- target_info[:dependency_files_md5] = dependency_files_md5.sort.uniq
796
- dependency_targets_md5 = dependency_targets_set.to_a.map { | target | [target.name, post_targets_context[target][:target_md5]]}
797
- target_info[:dependency_targets_md5] = dependency_targets_md5
798
-
799
- if add_cache(target, target_info)
800
- puts "<INFO> #{target} is being added to cache dir"
801
- total_add_count = total_add_count + 1
802
- target.build_phases.delete_if { |phase|
803
- phase.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase and phase.name.include? "ys_"
804
- }
805
- end
806
-
807
- end
808
- end
809
- restore_project(project)
810
- end
811
-
812
- puts "<INFO> total add cache count: #{total_add_count}"
813
- end
814
-
815
- end
816
-
817
-
818
-
819
-
data/lib/pod_plugin.rb DELETED
File without changes