Module: RakeOE

Includes:
Rake::DSL
Defined in:
lib/rakeoe/defaults.rb,
lib/rakeoe.rb,
lib/rakeoe/app.rb,
lib/rakeoe/lib.rb,
lib/rakeoe/config.rb,
lib/rakeoe/version.rb,
lib/rakeoe/toolchain.rb,
lib/rakeoe/binary_base.rb,
lib/rakeoe/qt_settings.rb,
lib/rakeoe/prj_file_cache.rb,
lib/rakeoe/test_framework.rb,
lib/rakeoe/key_value_reader.rb

Overview

TODO Write Test cases for class

Defined Under Namespace

Classes: App, BinaryBase, Config, Default, KeyValueReader, Lib, PrjFileCache, QtSettings, TestFramework, Toolchain

Constant Summary collapse

VERSION =
'0.0.10'
DEFAULT_SUFFIXES =

A list of default file extensions used for the project. This has to match the format as described for RakeOE::Config.suffixes

{
  :as_sources => %w[.S .s],
  :c_sources => %w[.c],
  :c_headers => %w[.h],
  :cplus_sources => %w[.cpp .cxx .C .cc],
  :cplus_headers => %w[.h .hpp .hxx .hh],
  :moc_header => '.h',
  :moc_source => '.cpp'
}
DEFAULT_DIRS =

A list of default directories used for the project

{
  :apps => %w[src/app],
  :libs => %w[src/lib src/3rdparty],
  :build => 'build',
  :deploy => 'deploy'
}
DEFAULT_RELEASE =

Default release mode used for the project if no such parameter given via Rakefile

'dbg'
DEFAULT_TEST_FW =

Default test framework used for linking test case binaries

''
DEFAULT_OPTIMIZATION_DBG =

Default optimization levels used for compiling binaries

'-O0'
DEFAULT_OPTIMIZATION_RELEASE =
'-O3'
DEFAULT_LANGUAGE_STD_C =

Default language standards

'-std=gnu99'
DEFAULT_LANGUAGE_STD_CPP =
'-std=c++03'
DEFAULT_SW_VERSION =

Default software version string

'unversioned'

Instance Method Summary collapse

Instance Method Details

#init(config) ⇒ RakeOE::Toolchain

Initialize RakeOE project. Reads & parses all prj.rake files of given config.

Parameters:

  • config (RakeOE::Config)

    Configuration as provided by project Rakefile

Returns:



26
27
28
29
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/rakeoe.rb', line 26

def init(config)

  RakeOE::PrjFileCache.set_defaults(RakeOE::Default.prj_settings)
  RakeOE::PrjFileCache.sweep_recursive(config.directories[:apps] + config.directories[:libs])

  toolchain = RakeOE::Toolchain.new(config)
  RakeOE::PrjFileCache.join_regex_keys_for!(toolchain.target)
  #
  # Top level tasks
  #
  %w[lib app].each do |type|
    namespace type do
      # Introduce type:all
      #
      # All libs/apps will make themselves dependent on this task, so whenever you call
      #   'rake lib:all' or 'rake app:all'
      # all libs/apps will thus be generated automatically
      desc "Create all #{type}s"
      task :all

      case type
      when 'lib'
        RakeOE::PrjFileCache.for_each('LIB') do |name, settings|
          RakeOE::Lib.new(name, settings, toolchain).create
        end

        RakeOE::PrjFileCache.for_each('SOLIB') do |name, settings|
          RakeOE::Lib.new(name, settings, toolchain).create
        end

      when 'app'
        RakeOE::PrjFileCache.for_each('APP') do |name, settings|
          RakeOE::App.new(name, settings, toolchain).create
        end
      else
        raise "No such type #{type} supported"
      end

      # Introduce type:test:all
      #
      # All tests in lib/app will make themselves dependent on this task, so whenever you call
      #   'rake lib:test:all'
      # all available library tests will be generated automatically before execution
      namespace 'test' do
        desc "Run all #{type} tests"
        task :all

        desc "Run all #{type} tests and create junit xml output"
        task :junit
      end
    end
  end

  desc 'Deploys apps and dynamic objects to deploy_dir/bin, deploy_dir/lib'
  task :deploy, [:deploy_dir] => :all do |t, args|
    args.with_defaults(:deploy_dir => config.directories[:deploy])
    puts "Copy binaries from #{toolchain.build_dir} => #{args.deploy_dir}"
    begin
      FileUtils.mkdir_p("#{args.deploy_dir}/bin")
      FileUtils.mkdir_p("#{args.deploy_dir}/lib")
    rescue
      raise
    end

    # deploy binaries
    Dir.glob("#{toolchain.build_dir}/apps/*").each do |file|
      next if file.end_with?('.bin')
      FileUtils.cp(file, "#{args.deploy_dir}/bin/#{File.basename(file)}") if File.executable?(file)
    end
    # deploy dynamic libraries
    Dir.glob("#{toolchain.build_dir}/libs/*.so").each do |file|
      next if file.end_with?('.bin')
      FileUtils.cp(file, "#{args.deploy_dir}/lib/")
    end
  end

  desc 'Dump configuration & toolchain variables'
  task :dump do
    puts
    config.dump
    puts
    toolchain.dump
    puts
  end

  task :all => %w[lib:all app:all]
  task :test => %w[lib:test:all app:test:all]
  task :test_build => %w[lib:test:build app:test:build]
  task :junit => %w[lib:test:junit app:test:junit]
  task :default => :all

  # kind of mrproper/realclean
  CLOBBER.include('*.tmp', "#{config.directories[:build]}/*")

  toolchain
end