Class: Pindo::Command::Android::Autobuild

Inherits:
Pindo::Command::Android show all
Includes:
Appselect
Defined in:
lib/pindo/command/android/autobuild.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Appselect

#all_deploy_bundle_name, #all_dev_bundle_name, #all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundle_name, #get_selected_deploy_bundleid, #get_selected_dev_bundle_name, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app

Methods inherited from Pindo::Command

command_name, #initialize_options, run

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from HelpValidator

#validate!

Constructor Details

#initialize(argv) ⇒ Autobuild

Returns a new instance of Autobuild.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/pindo/command/android/autobuild.rb', line 112

def initialize(argv)
  @options = initialize_options(argv)

  @args_release_flag = @options[:release] || false
  @args_conf = @options[:conf]
  @args_bundle_name = @options[:bundle_name]  # 从 @options 获取,确保能被缓存

  # send、media 或 bind 都依赖 upload:如果指定了任一参数,自动启用 upload
  @args_upload_flag = @options[:send] || @options[:bind] || @options[:media] || @options[:upload]

  # media 任务是独立的,不依赖任何其他任务,但是为输入命令参数更加简单,如果有--bind和--send, 则默认认为一定会有--media参数
  @args_media_flag = @options[:send] || @options[:bind] || @options[:media] || false

  # send 都依赖 bind:如果指定了任一参数,自动启用 bind
  @args_bind_flag = @options[:send] || @options[:bind] || false

  @args_send_flag = @options[:send]

  # Unity 参数
  @args_skip_lib = @options[:skiplib] || false
  @args_skip_yoo = @options[:skipyoo] || false

  # Task 参数
  @args_multi_flag = @options[:multi] || false

  # Git 参数
  @args_release_branch = @options[:release_branch] || 'master'
  @args_ver_inc = Pindo::Options::GitOptions.parse_version_increase_type(@options[:ver_inc])
  @args_tag_type = Pindo::Options::GitOptions.parse_create_tag_type(@options[:tag_type])
  @args_tag_pre = @options[:tag_pre] || 'v'
  # 解析 --git-commit 参数(不设置默认值,以便区分用户是否指定了参数)
  @args_git_commit = Pindo::Options::GitOptions.parse_git_commit_type(@options[:git_commit])

  super
  @additional_args = argv.remainder!
end

Class Method Details

.option_itemsObject

定义此命令使用的参数项



97
98
99
100
101
102
103
104
105
106
# File 'lib/pindo/command/android/autobuild.rb', line 97

def self.option_items
  @option_items ||= Pindo::Options::OptionGroup.merge(
    Pindo::Options::BuildOptions.select(:bundle_name, :release, :skipclean, :skipvalidate, :injectsigning),
    Pindo::Options::JPSOptions.select(:conf, :upload, :media, :bind, :send),
    Pindo::Options::UnityOptions.select(:skiplib, :skipyoo),
    Pindo::Options::UnityOptions.select_with_defaults(skipmacro: true),
    Pindo::Options::TaskOptions.select(:multi),
    Pindo::Options::GitOptions.all
  )
end

.optionsObject



108
109
110
# File 'lib/pindo/command/android/autobuild.rb', line 108

def self.options
  option_items.map(&:to_claide_option).concat(super)
end

.use_cache?Boolean

启用缓存机制

Returns:

  • (Boolean)


29
30
31
# File 'lib/pindo/command/android/autobuild.rb', line 29

def self.use_cache?
  true  # 此命令启用缓存
end

Instance Method Details

#runObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/pindo/command/android/autobuild.rb', line 149

def run
  pindo_project_dir = Dir.pwd

  begin
    # 加载 JPS 配置(缓存 project_name,并通过映射表解析 bundle_id)
    Pindo::BuildHelper.share_instance.load_jps_build_config(pindo_project_dir, conf: @args_conf)

    # 解析 bundle_name(优先级:命令行参数 > JPSBuildConfig映射 > 交互选择)
    resolve_bundle_name!

    # 准备配置
    config = prepare_android_config(pindo_project_dir)

    # 创建并执行任务
    tasks = make_build_task(config)

    # 添加到任务管理器并执行
    task_manager = Pindo::TaskSystem::TaskManager.instance
    task_manager.clear_all
    tasks.each { |task| task_manager.add_task(task) }

    # 执行任务(根据 --multi 参数决定模式)
    if @args_multi_flag
      task_manager.start(mode: :concurrent, max_workers: 3)
    else
      task_manager.start
    end

    system "open #{pindo_project_dir}"
  ensure
    Pindo::Options::GlobalOptionsState.instance.clear
  end
end