Class: Pod::Command::JxedtCommand::Options

Inherits:
Pod::Command::JxedtCommand show all
Defined in:
lib/cocoapods-jxedt/command/options/options.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



18
19
20
21
22
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 18

def initialize(argv)
    @config = argv.flag?('config', false)
    @more_config = argv.flag?('more-config', false)
    super
end

Class Method Details

.optionsObject



12
13
14
15
16
17
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 12

def self.options
    [
        ['--config', '获取cocoapods-jxedt插件的基础配置'],
        ['--more-config', '获取cocoapods-jxedt插件的完整配置']
    ]
end

Instance Method Details

#log_section(message) ⇒ Object



108
109
110
111
112
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 108

def log_section(message)
    Pod::UI.puts "-----------------------------------------"
    Pod::UI.puts message
    Pod::UI.puts "-----------------------------------------"
end


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 45

def print_base_options_config
    config = <<CONFIG
use_frameworks! :linkage => :static
# use_modular_headers!

plugin 'cocoapods-jxedt'
options = {
    'all_binary': true, # 所有组件开启binary
    'keep_source_project': true, # 保留源码pod工程,所在目录`Pods-Source`
    'excluded_pods': [], # 排除binary的组件名称
    'framework_header_search_enabled': true, # 兼容头文件引用`#import "xxx.h"`
    'configurations': ['Release'], # 支持的configurations ['Release', 'Debug']
    'device_build_enabled': true, # 真机
    'simulator_build_enabled': false # 模拟器
}
cocoapods_jxedt_config(options)
CONFIG
    Pod::UI.puts config
end


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 65

def print_options_config
    dsl_config = Jxedt::Config::APPLICABLE_DSL_CONFIG
    git_config = Jxedt::Config::GIT_CACHE_CONFIG

    config = <<CONFIG
use_frameworks! :linkage => :static # 插件是支持使用library的,插件会把编译后的.a生成framework。如果你的工程不支持module,可以删掉或者注释掉这一行。不影响使用
# use_modular_headers!

plugin 'cocoapods-jxedt'

# 这里默认配置了大部分常用的配置参数,只需要简单修改就可以使用了
options = {
    'all_binary': true, # #{dsl_config[:all_binary]}
    'binary_dir': '../_Prebuild', # #{dsl_config[:binary_dir]}
    'binary_switch': true, # #{dsl_config[:binary_switch]}
    'prebuild_job': true, # #{dsl_config[:prebuild_job]}
    'keep_source_project': false, # #{dsl_config[:keep_source_project]}
    'excluded_pods': [], # #{dsl_config[:excluded_pods]}
    'framework_header_search_enabled': false, # #{dsl_config[:framework_header_search_enabled]}
    'configurations': ['Release'], # #{dsl_config[:configurations]}
    'xcframework': false, # #{dsl_config[:xcframework]}
    'clean_build': true, # #{dsl_config[:clean_build]}
    'device_build_enabled': true, # #{dsl_config[:device_build_enabled]}
    'simulator_build_enabled': false, # #{dsl_config[:simulator_build_enabled]}
    'disable_resource_compilable_pods': false, # #{dsl_config[:disable_resource_compilable_pods]}
    'build_args': { # 下面是默认的配置,如果没有改动可删除节点
        'default': ["ONLY_ACTIVE_ARCH=NO", "BUILD_LIBRARY_FOR_DISTRIBUTION=YES"],
        'device': ["ARCHS='arm64'"],
        'simulator': ["ARCHS='x86_64'"]
    },
    'git_cache': { # 如果不需要git缓存,直接删掉这个节点即可
        'repo': '', # #{git_config[:repo]}
        'branch': 'develop', # #{git_config[:branch]}
        'auto_fetch': true, # #{git_config[:auto_fetch]}
        'auto_push': false # #{git_config[:auto_push]}
    }
}
cocoapods_jxedt_config(options)
CONFIG

    Pod::UI.puts config
end

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 28

def run
    require 'cocoapods-jxedt/binary/config'

    return print_options_config if @more_config
    return print_base_options_config if @config

    require 'json'
    
    log_section "🌹 APPLICABLE_DSL_CONFIG"
    dsl_config = Jxedt::Config::APPLICABLE_DSL_CONFIG
    Pod::UI.puts JSON.pretty_generate(dsl_config)

    log_section "🌹 GIT_CACHE_CONFIG"
    git_config = Jxedt::Config::GIT_CACHE_CONFIG
    Pod::UI.puts JSON.pretty_generate(git_config)
end

#validate!Object



24
25
26
# File 'lib/cocoapods-jxedt/command/options/options.rb', line 24

def validate!
    super
end