Class: ExternalProject

Inherits:
Buildable show all
Defined in:
lib/makeconf/externalproject.rb

Overview

An external project is typically a third-party library dependency that does not use makeconf for it’s build system.

Instance Attribute Summary collapse

Attributes inherited from Buildable

#buildable, #cflags, #distributable, #enable, #id, #installable, #ldadd, #localdep, #output, #output_type, #project, #rpath, #sources, #sysdep, #topdir

Instance Method Summary collapse

Methods inherited from Buildable

#binary?, #expand_sources, #finalize, #library?, #library_type, #makedepends, #objects

Constructor Details

#initialize(options) ⇒ ExternalProject

Returns a new instance of ExternalProject.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/makeconf/externalproject.rb', line 11

def initialize(options)
  # KLUDGE - parent constructor will barf unless we delete our 
  #       custom options
  @uri = options[:uri]
  options.delete :uri
  @configure = options[:configure]  # options passed to ./configure 
  options.delete :configure
  @configure = './configure' if @configure.nil?
  @patch = options[:patch]
  options.delete :patch
  @patch = [] if @patch.nil?

  super(options)

  @installable = false
  @distributable = false
end

Instance Attribute Details

#patchObject

Returns the value of attribute patch.



9
10
11
# File 'lib/makeconf/externalproject.rb', line 9

def patch
  @patch
end

#uriObject

Returns the value of attribute uri.



9
10
11
# File 'lib/makeconf/externalproject.rb', line 9

def uri
  @uri
end

Instance Method Details

#buildObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/makeconf/externalproject.rb', line 68

def build
   makefile = Makefile.new
   return makefile unless @buildable
   makefile.add_dependency('all', "#{@id}-build-stamp")
   makefile.add_target("#{@id}-build-stamp", [], 
           [
           "cd #{@id} && make",
           "touch #{@id}-build-stamp",
           ])
   makefile.add_rule('check', [ "cd #{@id} && make check" ])
   makefile.add_rule('clean', Platform.rm("#{@id}-build-stamp"))
   makefile
end

#configureObject

Examine the operating environment and set configuration options



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
# File 'lib/makeconf/externalproject.rb', line 30

def configure
  printf "checking for external project #{@id}... "
  if File.exists?(@id)
     puts "yes"
  else
    puts "no"
    download

    # Apply patches
    @patch.each do |p|
      system "cd #{@id} && patch -p0 -N < ../#{p}" \
          or throw "failed to apply patch: ../#{p}"
    end
  end

  # KLUDGE: passthrough certain options
  passthru = []
  Makeconf.original_argv.each do |x|
    passthru.push x if x =~ /^--(host|with-ndk|with-sdk)/
  end
  @configure += ' ' + passthru.join(' ') unless passthru.empty?

  # FIXME: this works, but autotools differ widely across host systems.
  #        make this an optional step that can be done
  #
  # Regenerate the Autotools files
  #if File.exists?(@id + '/configure.ac')
  #      system "cd #{@id} && autoreconf -fvi" \
  #          or throw "autoreconf failed"
  #    end

  # Run the autoconf-style ./configure script
  puts "*** Configuring #{@id} using #{@configure}"
  system "cd #{@id} && #{@configure}" \
      or throw "Unable to configure #{@id}"
  puts "*** Done"
end