Class: PkgForge::DSL::Forge

Inherits:
Base
  • Object
show all
Defined in:
lib/pkgforge/components/deps.rb,
lib/pkgforge/base.rb,
lib/pkgforge/components/dirs.rb,
lib/pkgforge/components/test.rb,
lib/pkgforge/components/build.rb,
lib/pkgforge/components/patch.rb,
lib/pkgforge/components/cflags.rb,
lib/pkgforge/components/source.rb,
lib/pkgforge/components/upload.rb,
lib/pkgforge/components/package.rb,
lib/pkgforge/components/metadata.rb,
lib/pkgforge/components/configure.rb

Overview

Add configure flag options to Forge DSL

Constant Summary collapse

ALL_HARDEN_OPTS =
{
  controlflow: %w[-fcf-protection],
  format: %w[-Wformat -Wformat-security -Werror=format-security],
  fortify: %w[-D_FORTIFY_SOURCE=2],
  implicit: %w[-Werror=implicit-function-declaration],
  lazybinding: %w[-Wl,-z,now],
  optimize: %w[-O2],
  pic: %w[-fPIC -shared],
  pie: %w[-fpie -Wl,-pie],
  relro: %w[-Wl,-z,relro],
  stackclash: %w[-fstack-clash-protection],
  stackprotector: %w[-fstack-protector-strong],
  strictoverflow: %w[-fno-strict-overflow],
  underlinking: %w[-Wl,-z,defs],
  warnings: %w[-Wall]
}.freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PkgForge::Base

Instance Method Details

#build(&block) ⇒ Object



29
30
31
32
# File 'lib/pkgforge/components/build.rb', line 29

def build(&block)
  @forge.build_block = block
  nil
end

#cflags(value = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/pkgforge/components/cflags.rb', line 23

def cflags(value = nil)
  default = '-I%<dep>s/usr/include -L%<dep>s/usr/lib'
  value ||= @forge.deps.map { |x, _| format(default, dep: dep(x)).split }
  @forge.cflags += value.flatten
  nil
end

#configure_flags(value) ⇒ Object



18
19
20
21
# File 'lib/pkgforge/components/configure.rb', line 18

def configure_flags(value)
  @forge.configure_flags = value
  nil
end

#dep(dep_name) ⇒ Object



36
37
38
# File 'lib/pkgforge/components/dirs.rb', line 36

def dep(dep_name)
  @forge.dep(dep_name)
end

#deps(value) ⇒ Object



98
99
100
101
102
# File 'lib/pkgforge/components/deps.rb', line 98

def deps(value)
  value = value.map { |k, v| [k, v.is_a?(Hash) ? v : { version: v }] }
  @forge.deps = Hash[value]
  nil
end

#endpoint(value) ⇒ Object



57
58
59
60
# File 'lib/pkgforge/components/upload.rb', line 57

def endpoint(value)
  @forge.endpoint = value
  nil
end

#harden(list = []) ⇒ Object



60
61
62
63
64
# File 'lib/pkgforge/components/cflags.rb', line 60

def harden(list = [])
  harden_opts = ALL_HARDEN_OPTS.reject { |k, _| list.include? k.to_s }
  @forge.cflags += harden_opts.values.flatten
  nil
end

#libs(value = nil) ⇒ Object



31
32
33
34
35
36
# File 'lib/pkgforge/components/cflags.rb', line 31

def libs(value = nil)
  value ||= @forge.deps.keys
  value.map! { |x| '-l' + x.to_s }
  @forge.libs += value
  nil
end

#licenses(files) ⇒ Object Also known as: license



55
56
57
58
59
# File 'lib/pkgforge/components/metadata.rb', line 55

def licenses(files)
  files = [files] unless files.is_a? Array
  @forge.licenses = files
  nil
end

#name(value) ⇒ Object



43
44
45
46
# File 'lib/pkgforge/components/metadata.rb', line 43

def name(value)
  @forge.name = value
  nil
end

#org(value) ⇒ Object



49
50
51
52
# File 'lib/pkgforge/components/metadata.rb', line 49

def org(value)
  @forge.org = value
  nil
end

#package(params) ⇒ Object



71
72
73
74
# File 'lib/pkgforge/components/package.rb', line 71

def package(params)
  @forge.package = params
  nil
end

#patch(file) ⇒ Object



31
32
33
34
# File 'lib/pkgforge/components/patch.rb', line 31

def patch(file)
  @forge.patches << file
  nil
end

#remove_linker_archives(value = true) ⇒ Object



105
106
107
108
# File 'lib/pkgforge/components/deps.rb', line 105

def remove_linker_archives(value = true)
  @forge.remove_linker_archives = value
  nil
end

#remove_pkgconfig_files(value = true) ⇒ Object



111
112
113
114
# File 'lib/pkgforge/components/deps.rb', line 111

def remove_pkgconfig_files(value = true)
  @forge.remove_pkgconfig_files = value
  nil
end

#source(params) ⇒ Object



55
56
57
58
# File 'lib/pkgforge/components/source.rb', line 55

def source(params)
  @forge.source = params
  nil
end

#test(&block) ⇒ Object



70
71
72
73
# File 'lib/pkgforge/components/test.rb', line 70

def test(&block)
  @forge.test_block = block
  nil
end