Class: Xcake::BuildRule

Inherits:
Object
  • Object
show all
Defined in:
lib/xcake/dsl/build_rule.rb

Overview

This class is used to describe a build rule for a Xcode project; This forms part of the DSL and is usually stored in files named ‘Cakefile`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ BuildRule

Returns a new instance of BuildRule.

Examples:

Creating a Build Rule.


BuildRule.new do |p|
  p.name "test"
end

Parameters:

  • block (Proc)

    an optional block that configures the build rule through the DSL.

Yields:

  • (_self)

Yield Parameters:



45
46
47
48
49
50
# File 'lib/xcake/dsl/build_rule.rb', line 45

def initialize
  @output_files = []
  @output_files_compiler_flags = []

  yield(self) if block_given?
end

Instance Attribute Details

#file_typeString

Returns the type of the files that should be processed by this rule.

Examples:

`pattern.proxy`.

Returns:

  • (String)

    the type of the files that should be processed by this rule.



17
18
19
# File 'lib/xcake/dsl/build_rule.rb', line 17

def file_type
  @file_type
end

#nameString

Returns the name of the rule.

Returns:

  • (String)

    the name of the rule.



9
10
11
# File 'lib/xcake/dsl/build_rule.rb', line 9

def name
  @name
end

#output_filesObjectList<PBXFileReference>

Returns the file references for the output files.

Returns:

  • (ObjectList<PBXFileReference>)

    the file references for the output files.



22
23
24
# File 'lib/xcake/dsl/build_rule.rb', line 22

def output_files
  @output_files
end

#output_files_compiler_flagsObjectList<String>

Returns the compiler flags used when creating the respective output files.

Returns:

  • (ObjectList<String>)

    the compiler flags used when creating the respective output files.



27
28
29
# File 'lib/xcake/dsl/build_rule.rb', line 27

def output_files_compiler_flags
  @output_files_compiler_flags
end

#scriptString

Note:

This attribute is present if the ##compiler_spec is ‘com.apple.compilers.proxy.script`

Returns the content of the script to use for the build rule.

Returns:

  • (String)

    the content of the script to use for the build rule.



34
35
36
# File 'lib/xcake/dsl/build_rule.rb', line 34

def script
  @script
end

Instance Method Details

#configure_native_build_rule(native_build_rule, _context) ⇒ Object

This method is called when generating the build rules subclasses should implement this to handle the configuration of the build phase



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xcake/dsl/build_rule.rb', line 56

def configure_native_build_rule(native_build_rule, _context)
  native_build_rule.name = name
  native_build_rule.compiler_spec = 'com.apple.compilers.proxy.script'
  native_build_rule.file_type = file_type
  native_build_rule.script = script.strip_heredoc
  if output_files_compiler_flags.empty?
    output_files.each do |file|
      native_build_rule.add_output_file(file)
    end
  else
    output_files.zip(output_files_compiler_flags).each do |file, flag|
      native_build_rule.add_output_file(file, flag)
    end
  end
end

#to_sObject



72
73
74
# File 'lib/xcake/dsl/build_rule.rb', line 72

def to_s
  "BuildRule<#{name}>"
end