Mxx_ru 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #--
2
2
  # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
3
  # Copyright (c) 2004-2006, JSC Intervale
4
- # Copyright (c) 2006, The Mxx_ru Project
4
+ # Copyright (c) 2006-2008, The Mxx_ru Project
5
5
  # All rights reserved.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without modification,
@@ -83,6 +83,33 @@ module MxxRu
83
83
  return TargetState.new( state )
84
84
  end
85
85
 
86
+ # Checks collection of statuses.
87
+ #
88
+ # Returns true if at least one of statuses have value REBUILT or ABSENT.
89
+ #
90
+ # Typical usage is:
91
+ # subprojects_status = build_subprojects
92
+ # self_files_status = build_self_files
93
+ #
94
+ # if TargetState.rebuilding_needed?(
95
+ # subprojects_status, self_files_status )
96
+ # do_rebuild
97
+ # end
98
+ #
99
+ # Since v.1.4.4
100
+ #
101
+ def TargetState.rebuilding_needed?( *statuses )
102
+ nil != statuses.find { |s| EXISTS != s.state }
103
+ end
104
+
105
+ # Creates and returns objects of state ABSENT
106
+ #
107
+ # Since v.1.4.4
108
+ #
109
+ def TargetState.make_absent
110
+ TargetState.new( ABSENT )
111
+ end
112
+
86
113
  end # Class TargetState
87
114
 
88
115
  # For compatibility with previous versions.
@@ -1103,17 +1103,22 @@ module MxxRu
1103
1103
  objs_state,
1104
1104
  res_state )
1105
1105
 
1106
+ rebuilding_needed = TargetState.rebuilding_needed?(
1107
+ required_prjs_state,
1108
+ objs_state,
1109
+ res_state )
1110
+
1106
1111
  state = nil
1107
1112
  toolset = MxxRu::Cpp::toolset
1108
1113
  if nil == target_type
1109
1114
  raise MxxRu::UnsupportedTargetTypeEx.new(
1110
1115
  self.class.name, "nil" )
1111
1116
  elsif target_type.name == LibTargetType::TYPE
1112
- state = toolset.make_lib( self )
1117
+ state = toolset.make_lib( self, rebuilding_needed )
1113
1118
  elsif target_type.name == DllTargetType::TYPE
1114
- state = toolset.make_dll( self )
1119
+ state = toolset.make_dll( self, rebuilding_needed )
1115
1120
  elsif target_type.name == ExeTargetType::TYPE
1116
- state = toolset.make_exe( self )
1121
+ state = toolset.make_exe( self, rebuilding_needed )
1117
1122
  else
1118
1123
  raise MxxRu::UnsupportedTargetTypeEx.new(
1119
1124
  self.class.name, target_type.name )
@@ -428,9 +428,8 @@ module MxxRu
428
428
  cpp_objs.each { |o| target.obj_file( o.name ) }
429
429
 
430
430
  # Also informing if some object files were rebuilt.
431
- state = TargetState::EXISTS
432
- state = TargetState::REBUILT if ( c_objs_to_build.size() ||
433
- cpp_objs_to_build.size() )
431
+ state = (c_objs_to_build.empty? && cpp_objs_to_build.empty?) ?
432
+ TargetState::EXISTS : TargetState::REBUILT
434
433
 
435
434
  return TargetState.new( state )
436
435
  end
@@ -505,7 +504,11 @@ module MxxRu
505
504
  # Perform static library build.
506
505
  # Target parameter should be an object of a class, inherited from
507
506
  # MxxRu::Cpp::Target.
508
- def make_lib( target )
507
+ #
508
+ # If force_rebuilding is true then library will be rebuilt whitout
509
+ # checking its dependecies.
510
+ #
511
+ def make_lib( target, force_rebuilding = false )
509
512
  # Creating result file name. Also determining in which folder
510
513
  # lib should be. The name of that folder should be included in
511
514
  # libraries search paths of given target.
@@ -514,8 +517,8 @@ module MxxRu
514
517
  # Determining target status.
515
518
  lib_file = lib_info.full_name
516
519
 
517
- lib_state = MxxRu::TargetState::detect(
518
- lib_file, target.mxx_obj_files )
520
+ lib_state = force_rebuilding ? MxxRu::TargetState.make_absent :
521
+ MxxRu::TargetState::detect( lib_file, target.mxx_obj_files )
519
522
  if MxxRu::TargetState::EXISTS != lib_state.state
520
523
  # File should be rebuilt.
521
524
  cmd_lines = make_lib_command_lines(
@@ -582,24 +585,26 @@ module MxxRu
582
585
  # Perform dynamic library build.
583
586
  # Target parameter should be an object of a class, inherited from
584
587
  # MxxRu::Cpp::Target.
585
- def make_dll( target )
588
+ #
589
+ # If force_rebuilding is true then DLL will be rebuilt whitout
590
+ # checking its dependecies.
591
+ #
592
+ def make_dll( target, force_rebuilding = false )
586
593
  # Creating result file name.
587
594
  dll_info = make_dll_name( target.mxx_target_name, target )
588
-
589
- # Creating dependencies list.
590
- all_depend_files = create_executable_depend_list( target )
591
-
592
- # This values will be required later during a calculation of
593
- # dependencies of that DLL.
594
- link_lists = prepare_linker_lists( target )
595
-
596
595
  dll_file = dll_info.full_name
597
596
 
598
- dll_state = MxxRu::TargetState::detect(
599
- dll_file, all_depend_files )
597
+ dll_state = if force_rebuilding
598
+ MxxRu::TargetState.make_absent
599
+ else
600
+ MxxRu::TargetState::detect(
601
+ dll_file,
602
+ create_executable_depend_list( target ) )
603
+ end
604
+
600
605
  if MxxRu::TargetState::EXISTS != dll_state.state
601
606
  # Target should be rebuilt.
602
-
607
+ link_lists = prepare_linker_lists( target )
603
608
  cmd_lines = make_dll_command_lines(
604
609
  dll_file, dll_info, link_lists, target )
605
610
 
@@ -655,17 +660,23 @@ module MxxRu
655
660
  # Perform executable file build.
656
661
  # Target parameter should be an object of a class, inherited from
657
662
  # MxxRu::Cpp::Target.
658
- def make_exe( target )
663
+ #
664
+ # If force_rebuilding is true then EXE will be rebuilt whitout
665
+ # checking its dependecies.
666
+ #
667
+ def make_exe( target, force_rebuilding = false )
659
668
  # Creating result file name.
660
669
  exe_info = make_exe_name( target.mxx_target_name, target )
661
-
662
- # Creating dependencies list.
663
- all_depend_files = create_executable_depend_list( target )
664
-
665
670
  exe_file = exe_info.full_name
666
671
 
667
- exe_state = MxxRu::TargetState::detect(
668
- exe_file, all_depend_files )
672
+ exe_state = if force_rebuilding
673
+ MxxRu::TargetState.make_absent
674
+ else
675
+ MxxRu::TargetState::detect(
676
+ exe_file,
677
+ create_executable_depend_list( target ) )
678
+ end
679
+
669
680
  if MxxRu::TargetState::EXISTS != exe_state.state
670
681
  # Target should be rebuilt.
671
682
 
@@ -34,5 +34,5 @@
34
34
  #
35
35
  # puts 'Mxx_ru version is: ' + MXX_RU_VERSION
36
36
  #
37
- MXX_RU_VERSION = '1.4.3'
37
+ MXX_RU_VERSION = '1.4.4'
38
38
 
@@ -0,0 +1,3 @@
1
+ #include <cstdio>
2
+
3
+ void A() { std::printf( "A2\n" ); }
@@ -0,0 +1,8 @@
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::lib_target {
4
+ target 'a'
5
+
6
+ cpp_source 'a.cpp'
7
+ }
8
+
@@ -0,0 +1,6 @@
1
+ #include <cstdio>
2
+
3
+ void B() {
4
+ std::printf( "B\n" );
5
+ }
6
+
@@ -0,0 +1,10 @@
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::lib_target {
4
+ target 'b'
5
+
6
+ required_prj 'a.rb'
7
+
8
+ cpp_source 'b.cpp'
9
+ }
10
+
@@ -0,0 +1,10 @@
1
+ void A();
2
+ void B();
3
+
4
+ int main() {
5
+ A();
6
+ B();
7
+
8
+ return 0;
9
+ }
10
+
@@ -0,0 +1,12 @@
1
+ require 'mxx_ru/cpp'
2
+
3
+ MxxRu::Cpp::exe_target {
4
+ target 'checker'
5
+
6
+ MxxRu::enable_show_brief
7
+
8
+ required_prj 'b.rb'
9
+
10
+ cpp_source 'checker.cpp'
11
+ }
12
+
@@ -0,0 +1,11 @@
1
+ require 'mxx_ru/cpp'
2
+ require 'mxx_ru/textfile_unittest'
3
+
4
+ MxxRu::setup_target( MxxRu::TextfileUnittestTarget.new(
5
+ 'first.ut.rb',
6
+ 'checker.rb' ) {
7
+
8
+ launch ' > out/first.txt',
9
+ [ pair( 'out/first.txt', 'etalon/first.txt' ) ]
10
+ })
11
+
@@ -0,0 +1,11 @@
1
+ require 'mxx_ru/cpp'
2
+ require 'mxx_ru/textfile_unittest'
3
+
4
+ MxxRu::setup_target( MxxRu::TextfileUnittestTarget.new(
5
+ 'second.ut.rb',
6
+ 'checker.rb' ) {
7
+
8
+ launch ' > out/second.txt',
9
+ [ pair( 'out/second.txt', 'etalon/second.txt' ) ]
10
+ })
11
+
@@ -0,0 +1,47 @@
1
+ require 'test/unit'
2
+
3
+ require File.dirname( __FILE__ ) + '/../../test_with_compilation'
4
+
5
+ class TC_NormalBuild < Test::Unit::TestCase
6
+ include TestWithCompilation
7
+
8
+ test_path 'tests/cpp/lib_from_lib_dependecies'
9
+
10
+ FIRST = 'first.ut.rb'
11
+ SECOND = 'second.ut.rb'
12
+
13
+ test_case :first_and_second_builds do
14
+ write_first_content
15
+ clean FIRST
16
+ clean SECOND
17
+ build FIRST
18
+
19
+ puts "sleeping for several seconds..."
20
+ sleep( 2 )
21
+ write_second_content
22
+ build SECOND
23
+
24
+ clean FIRST, SECOND
25
+ end
26
+
27
+ def write_first_content
28
+ File.open( 'a.cpp', 'w' ) do |file|
29
+ file << <<EOS
30
+ #include <cstdio>
31
+
32
+ void A() { std::printf( "A\\n" ); }
33
+ EOS
34
+ end
35
+ end
36
+
37
+ def write_second_content
38
+ File.open( 'a.cpp', 'w' ) do |file|
39
+ file << <<EOS
40
+ #include <cstdio>
41
+
42
+ void A() { std::printf( "A2\\n" ); }
43
+ EOS
44
+ end
45
+ end
46
+ end
47
+
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
- require_gem 'RuCodeGen'
2
+ gem 'RuCodeGen'
3
+
4
+ require 'rucodegen'
3
5
 
4
6
  cpp_value_incapsulator :host_config_t do |c|
5
7
  c.decl_file :script_relative => "h/host_config.impl.hpp"
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
- require_gem 'RuCodeGen'
2
+ gem 'RuCodeGen'
3
+
4
+ require 'rucodegen'
3
5
 
4
6
  cpp_value_incapsulator :conn_params_t do |c|
5
7
  c.decl_file :script_relative => "h/conn_params.impl.hpp"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Mxx_ru
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Mxx_ru Project
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-26 00:00:00 +03:00
12
+ date: 2008-04-03 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -72,7 +72,24 @@ files:
72
72
  - tests/cpp/custom_target_prefix
73
73
  - tests/cpp/custom_target_prefix/dll.cpp
74
74
  - tests/cpp/custom_target_prefix/dll.rb
75
+ - tests/cpp/custom_target_prefix/o
75
76
  - tests/cpp/custom_target_prefix/tc_custom_target_prefix.rb
77
+ - tests/cpp/lib_from_lib_dependecies
78
+ - tests/cpp/lib_from_lib_dependecies/a.cpp
79
+ - tests/cpp/lib_from_lib_dependecies/a.rb
80
+ - tests/cpp/lib_from_lib_dependecies/b.cpp
81
+ - tests/cpp/lib_from_lib_dependecies/b.rb
82
+ - tests/cpp/lib_from_lib_dependecies/checker.cpp
83
+ - tests/cpp/lib_from_lib_dependecies/checker.rb
84
+ - tests/cpp/lib_from_lib_dependecies/etalon
85
+ - tests/cpp/lib_from_lib_dependecies/etalon/first.txt
86
+ - tests/cpp/lib_from_lib_dependecies/etalon/second.txt
87
+ - tests/cpp/lib_from_lib_dependecies/first.ut.rb
88
+ - tests/cpp/lib_from_lib_dependecies/o
89
+ - tests/cpp/lib_from_lib_dependecies/o/main.obj
90
+ - tests/cpp/lib_from_lib_dependecies/out
91
+ - tests/cpp/lib_from_lib_dependecies/second.ut.rb
92
+ - tests/cpp/lib_from_lib_dependecies/tc_checker.rb
76
93
  - tests/cpp/mswin_res_dll
77
94
  - tests/cpp/mswin_res_dll/build.rb
78
95
  - tests/cpp/mswin_res_dll/dll.cpp