lib/build/rule.rb in build-1.1.1 vs lib/build/rule.rb in build-2.0.0
- old
+ new
@@ -17,12 +17,20 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
module Build
- # A rule is a function with a specific set of input and output parameters, which can match against a given set of specific inputs and outputs. For example, there might be several rules for compiling, but the specific rules depend on the language being compiled.
+ # A rule is a function with a specific set of input and output parameters, which can match against a given set of specific arguments. For example, there might be several rules for compiling, but the specific rules depend on the language being compiled.
class Rule
+ def self.build(name, &block)
+ rule = self.new(*name.split('.', 2))
+
+ rule.instance_eval(&block)
+
+ return rule.freeze
+ end
+
class Parameter
def initialize(direction, name, options = {}, &block)
@direction = direction
@name = name
@@ -116,9 +124,24 @@
# compile_cpp
attr :full_name
attr :primary_output
+
+ def freeze
+ return self if frozen?
+
+ @name.freeze
+ @full_name.freeze
+ @process_name.freeze
+ @type.freeze
+
+ @apply.freeze
+ @parameters.freeze
+ @primary_output.freeze
+
+ super
+ end
def input(name, options = {}, &block)
self << Parameter.new(:input, name, options, &block)
end