Class: Ambient::DSL::MainScope

Inherits:
Object
  • Object
show all
Defined in:
lib/ambient/dsl/main_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ MainScope

Returns a new instance of MainScope.



6
7
8
# File 'lib/ambient/dsl/main_scope.rb', line 6

def initialize(application)
  @application = application
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



4
5
6
# File 'lib/ambient/dsl/main_scope.rb', line 4

def application
  @application
end

Instance Method Details

#base_ios_settings!(project_name, prefix: "", tests: false, ui_tests: false, swift: true, target: nil, test_target: nil, ui_test_target: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
# File 'lib/ambient/dsl/main_scope.rb', line 18

def base_ios_settings!(project_name, prefix: "", tests: false, ui_tests: false, swift: true, target: nil, test_target: nil, ui_test_target: nil)
  use_defaults_for_everything_not_specified_in_this_file!
  enable_default_warnings!

  target ||= "project_name"
  test_target ||= "#{project_name}Tests"
  ui_test_target ||= "#{project_name}UITests"
  tests = true if test_target
  ui_tests = true if ui_test_target

  option "ALWAYS_SEARCH_USER_PATHS", false
  option "CLANG_CXX_LANGUAGE_STANDARD", "gnu++0x"
  option "CLANG_CXX_LIBRARY", "libc++"
  option "CLANG_ENABLE_MODULES", true
  option "CLANG_ENABLE_OBJC_ARC", true

  option "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Developer"
  option "COPY_PHASE_STRIP", false

  option "ENABLE_STRICT_OBJC_MSGSEND", true
  option "GCC_C_LANGUAGE_STANDARD", "gnu99"
  option "GCC_NO_COMMON_BLOCKS", true
  option "SDKROOT", "iphoneos"
  option "IPHONEOS_DEPLOYMENT_TARGET", "9.0"

  scheme "Debug" do
    option "DEBUG_INFORMATION_FORMAT", "dwarf"
    option "ENABLE_TESTABILITY", true
    option "MTL_ENABLE_DEBUG_INFO", true
    option "ONLY_ACTIVE_ARCH", true
    option "GCC_DYNAMIC_NO_PIC", false
    option "GCC_OPTIMIZATION_LEVEL", "0"
    option "GCC_PREPROCESSOR_DEFINITIONS", ["DEBUG=1", "$(inherited)"]
    option "SWIFT_OPTIMIZATION_LEVEL", "-Onone" if swift
  end

  scheme "Release" do
    option "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"
    option "ENABLE_NS_ASSERTIONS", false
    option "MTL_ENABLE_DEBUG_INFO", false
    option "VALIDATE_PRODUCT", true
  end

  target project_name do
    option "INFOPLIST_FILE", "#{project_name}/Info.plist"
    option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}"
    option "ASSETCATALOG_COMPILER_APPICON_NAME", "AppIcon"
    option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks"
    option "PRODUCT_NAME", "$(TARGET_NAME)"
  end

  if tests
    target test_target do
      option "INFOPLIST_FILE", "#{project_name}Tests/Info.plist"
      option "BUNDLE_LOADER", "$(TEST_HOST)"
      option "TEST_HOST", "$(BUILT_PRODUCTS_DIR)/#{project_name}.app/#{project_name}"
      option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}Tests"
      option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
      option "PRODUCT_NAME", "$(TARGET_NAME)"
    end
  end

  if ui_tests
    target ui_test_target do
      option "INFOPLIST_FILE", "#{project_name}UITests/Info.plist"
      option "TEST_TARGET_NAME", "#{project_name}"
      option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}UITests"
      option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
      option "USES_XCTRUNNER", "YES"
      option "PRODUCT_NAME", "$(TARGET_NAME)"
    end
  end
end

#enable_default_warnings!Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/ambient/dsl/main_scope.rb', line 121

def enable_default_warnings!
  truthy = %w(CLANG_WARN_BOOL_CONVERSION
    CLANG_WARN_CONSTANT_CONVERSION
    CLANG_WARN_EMPTY_BODY
    CLANG_WARN_ENUM_CONVERSION
    CLANG_WARN_INT_CONVERSION
    CLANG_WARN_UNREACHABLE_CODE
    CLANG_WARN__DUPLICATE_METHOD_MATCH
    GCC_WARN_64_TO_32_BIT_CONVERSION
    GCC_WARN_UNDECLARED_SELECTOR
    GCC_WARN_UNUSED_FUNCTION
    GCC_WARN_UNUSED_VARIABLE)
  error = %w(CLANG_WARN_DIRECT_OBJC_ISA_USAGE
    CLANG_WARN_OBJC_ROOT_CLASS
    GCC_WARN_ABOUT_RETURN_TYPE)
  aggressive = %w(GCC_WARN_UNINITIALIZED_AUTOS)

  truthy.each { |w| option(w, true) }
  error.each { |w| option(w, "YES_ERROR") }
  aggressive.each { |w| option(w, "YES_AGGRESSIVE") }
end

#enable_extra_warnings_and_static_analyser!Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/ambient/dsl/main_scope.rb', line 92

def enable_extra_warnings_and_static_analyser!
  warnings = %w(GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED
    GCC_WARN_MISSING_PARENTHESES
    GCC_WARN_ABOUT_RETURN_TYPE
    GCC_WARN_SIGN_COMPARE
    GCC_WARN_CHECK_SWITCH_STATEMENTS
    GCC_WARN_UNUSED_FUNCTION
    GCC_WARN_UNUSED_LABEL
    GCC_WARN_UNUSED_VALUE
    GCC_WARN_UNUSED_VARIABLE
    GCC_WARN_SHADOW
    GCC_WARN_64_TO_32_BIT_CONVERSION
    GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS
    GCC_WARN_UNDECLARED_SELECTOR
    GCC_WARN_TYPECHECK_CALLS_TO_PRINTF
    GCC_WARN_UNINITIALIZED_AUTOS
    CLANG_WARN_INT_CONVERSION
    CLANG_WARN_ENUM_CONVERSION
    CLANG_WARN_CONSTANT_CONVERSION
    CLANG_WARN_BOOL_CONVERSION
    CLANG_WARN_EMPTY_BODY
    CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
    CLANG_WARN__DUPLICATE_METHOD_MATCH
    GCC_WARN_64_TO_32_BIT_CONVERSION
    RUN_CLANG_STATIC_ANALYZER
    GCC_TREAT_WARNINGS_AS_ERRORS)
  warnings.each { |w| option(w, true) }
end

#option(name, value) ⇒ Object



14
15
16
# File 'lib/ambient/dsl/main_scope.rb', line 14

def option(name, value)
  application.configure { set_option(name, value) }
end

#plist(path, &block) ⇒ Object



155
156
157
# File 'lib/ambient/dsl/main_scope.rb', line 155

def plist(path, &block)
  PlistScope.new(application, path).configure(&block)
end

#scheme(name, parent: nil, &block) ⇒ Object



151
152
153
# File 'lib/ambient/dsl/main_scope.rb', line 151

def scheme(name, parent: nil, &block)
  SchemeScope.new(application, nil, name, parent).configure(&block)
end

#target(name, &block) ⇒ Object



143
144
145
# File 'lib/ambient/dsl/main_scope.rb', line 143

def target(name, &block)
  TargetScope.new(application, name).configure(&block)
end

#use_defaults_for_everything_not_specified_in_this_file!Object



147
148
149
# File 'lib/ambient/dsl/main_scope.rb', line 147

def use_defaults_for_everything_not_specified_in_this_file!
  application.configure { @use_defaults = true }
end

#use_settings_from(filename) ⇒ Object



10
11
12
# File 'lib/ambient/dsl/main_scope.rb', line 10

def use_settings_from(filename)
  application.configure { run_ambientfile(filename) }
end