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 =
{
  format: %w[-Wformat -Wformat-security -Werror=format-security],
  stackprotector: %w[-fstack-protector-strong],
  fortify: %w[-O2 -D_FORTIFY_SOURCE=2],
  pic: '-fPIC',
  strictoverflow: '-fno-strict-overflow',
  relro: '-zrelro',
  bindnow: '-zbindnow'
}.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



94
95
96
97
98
# File 'lib/pkgforge/components/deps.rb', line 94

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



51
52
53
54
55
# File 'lib/pkgforge/components/cflags.rb', line 51

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



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

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

#name(value) ⇒ Object



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

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

#org(value) ⇒ Object



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

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

#package(params) ⇒ Object



66
67
68
69
# File 'lib/pkgforge/components/package.rb', line 66

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



101
102
103
104
# File 'lib/pkgforge/components/deps.rb', line 101

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

#remove_pkgconfig_files(value = true) ⇒ Object



107
108
109
110
# File 'lib/pkgforge/components/deps.rb', line 107

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

#source(params) ⇒ Object



51
52
53
54
# File 'lib/pkgforge/components/source.rb', line 51

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

#test(&block) ⇒ Object



72
73
74
75
# File 'lib/pkgforge/components/test.rb', line 72

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