dep_selector 1.0.0.alpha.0 → 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5a48552c27513a71e2f314a0cfa5a5c7481f2de
4
- data.tar.gz: cd35c4124a5fba219a2d52741869a96782a77a8d
3
+ metadata.gz: eedf57363ca865a2274f202af0d5c2744d107f0e
4
+ data.tar.gz: 8b0012e3789d25b4ebca6abdadf95937ab8a7f2f
5
5
  SHA512:
6
- metadata.gz: 5e37053fb8f2176d4f367f483e16990269b2dab226a09b9e6708a4f9643027cc025b00ac0e2c8546482e0f31d07bca35afde31d2d476d82ed7bedc58ae9bb98c
7
- data.tar.gz: 882206dd0d935fa751af3132c9114fa67fce40a42167e6ffee4545518962c4fe031dc0b95cab69f8379ace674a90ad3006b3af89b7e66383470e7ec63bbb2f61
6
+ metadata.gz: cd94581cafdd7dc198c84fe25cf21eb5de8112d4f24ed767ef326ddc996d1e61f1bc68eda06f11ed9a872855328c95822e890a0eb0208a55d08052d1fd9c76a6
7
+ data.tar.gz: a2e9623c53220191aedcbb01ba33a3efe27f1ee5cb7728634172fe7c60393ffa49fdd9905dbd00706e14cf4dd4adff248f9855314e0879ae3ce952528470d1e2
@@ -17,43 +17,45 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- #
21
- # GECODE needs to be built with
22
- # ./configure --with-architectures=i386,x86_64
23
- # to work properly here.
24
- require 'mkmf'
25
-
26
- # $CFLAGS << "-g"
27
-
28
- gecode_installed =
29
- # Gecode documentation notes:
30
- # "Some linkers require the list of libraries to be sorted such that
31
- # libraries appear before all libraries they depend on."
32
- # http://www.gecode.org/doc-latest/MPG.pdf
33
- #
34
- # This appears to be true of the version of mingw that ships with Ruby 1.9.3.
35
- # The correct order of `-l` flags according to the docs is:
36
- #
37
- # 1. -lgecodeflatzinc
38
- # 2. -lgecodedriver
39
- # 3. -lgecodegist
40
- # 4. -lgecodesearch,
41
- # 5. -lgecodeminimodel
42
- # 6. -lgecodeset
43
- # 7. -lgecodefloat
44
- # 8. -lgecodeint
45
- # 9. -lgecodekernel
46
- # 10. -lgecodesupport
20
+ # Ruby that supports C extensions. Our library isn't an extension, but we piggyback on ruby's C extension build system
21
+ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
47
22
  #
48
- # Ruby `mkmf` will add `-l` flags in the _REVERSE_ order that they appear here.
49
- have_library('gecodesupport') &&
50
- have_library('gecodekernel') &&
51
- have_library('gecodeint') &&
52
- have_library('gecodeminimodel') &&
53
- have_library('gecodesearch')
54
-
55
- unless gecode_installed
56
- STDERR.puts <<EOS
23
+ # GECODE needs to be built with
24
+ # ./configure --with-architectures=i386,x86_64
25
+ # to work properly here.
26
+ require 'mkmf'
27
+
28
+ # $CFLAGS << "-g"
29
+
30
+ gecode_installed =
31
+ # Gecode documentation notes:
32
+ # "Some linkers require the list of libraries to be sorted such that
33
+ # libraries appear before all libraries they depend on."
34
+ # http://www.gecode.org/doc-latest/MPG.pdf
35
+ #
36
+ # This appears to be true of the version of mingw that ships with Ruby 1.9.3.
37
+ # The correct order of `-l` flags according to the docs is:
38
+ #
39
+ # 1. -lgecodeflatzinc
40
+ # 2. -lgecodedriver
41
+ # 3. -lgecodegist
42
+ # 4. -lgecodesearch,
43
+ # 5. -lgecodeminimodel
44
+ # 6. -lgecodeset
45
+ # 7. -lgecodefloat
46
+ # 8. -lgecodeint
47
+ # 9. -lgecodekernel
48
+ # 10. -lgecodesupport
49
+ #
50
+ # Ruby `mkmf` will add `-l` flags in the _REVERSE_ order that they appear here.
51
+ have_library('gecodesupport') &&
52
+ have_library('gecodekernel') &&
53
+ have_library('gecodeint') &&
54
+ have_library('gecodeminimodel') &&
55
+ have_library('gecodesearch')
56
+
57
+ unless gecode_installed
58
+ STDERR.puts <<EOS
57
59
  =========================================================================================
58
60
  Gecode >3.5 must be installed (http://www.gecode.org/).
59
61
 
@@ -72,7 +74,128 @@ For convenience, we have built Gecode for Debian/Ubuntu (<release> is lucid or m
72
74
  Other distributions can build from source.
73
75
  =========================================================================================
74
76
  EOS
75
- raise "Gecode not installed"
76
- end
77
+ raise "Gecode not installed"
78
+ end
79
+
80
+ create_makefile('dep_gecode')
81
+ else # JRUBY
82
+
83
+ require 'rbconfig'
84
+ require 'ffi/platform'
85
+
86
+ cflags = ENV['CFLAGS']
87
+ cppflags = ENV['CPPFLAGS']
88
+ cxxflags = ENV['CXXFLAGS']
89
+ ldflags = ENV['LDFLAGS']
90
+ cc = ENV['CC']
91
+ cxx = ENV['CXX']
92
+
93
+ ldsharedxx = RbConfig::MAKEFILE_CONFIG["LDSHAREDXX"]
94
+
95
+ # use the CC that ruby was compiled with by default
96
+ cc ||= RbConfig::MAKEFILE_CONFIG['CC']
97
+ cxx ||= RbConfig::MAKEFILE_CONFIG["CXX"]
98
+ cppflags ||= RbConfig::MAKEFILE_CONFIG["CPPFLAGS"]
99
+ cxxflags ||= RbConfig::MAKEFILE_CONFIG["CXXFLAGS"]
100
+ cflags ||= ""
101
+ ldflags ||= ""
102
+
103
+ # then ultimately default back to gcc
104
+ cc ||= "gcc"
105
+ cxx ||= "g++"
106
+
107
+ # JRuby reports that the compiler is "CC" no matter what, so we can't detect
108
+ # if we're using anything other than gcc/llvm. Therefore we just assume
109
+ # that's the compiler we're on.
110
+ cflags << "-Wno-error=shorten-64-to-32 -pipe"
111
+ cflags << " -O3" unless cflags =~ /-O\d/
112
+ cflags << " -Wall -fPIC"
113
+ cppflags << " -O3" unless cppflags =~ /-O\d/
114
+ cppflags << " -fno-common -fPIC"
115
+ cxxflags << " -O3" unless cppflags =~ /-O\d/
116
+ cxxflags << " -fno-common -fPIC"
117
+
118
+ ENV['CFLAGS'] = cflags
119
+ ENV['LDFLAGS'] = ldflags
120
+ ENV['CC'] = cc
121
+ ENV['CXX'] = cxx
122
+ ENV["CPPFLAGS"] = cppflags
123
+ ENV["CXXFLAGS"] = cxxflags
124
+
125
+ dlext = FFI::Platform::LIBSUFFIX
126
+
127
+ headers = "$(srcdir)/dep_selector_to_gecode.h $(srcdir)/dep_selector_to_gecode_interface.h"
128
+
129
+ install = RbConfig::MAKEFILE_CONFIG["INSTALL"]
77
130
 
78
- create_makefile('dep_gecode')
131
+ File.open("Makefile", "w") do |mf|
132
+ mf.puts(<<-EOH)
133
+ # Makefile for building dep_gecode
134
+
135
+ # V=0 quiet, V=1 verbose. other values don't work.
136
+ V = 1
137
+ Q1 = $(V:1=)
138
+ Q = $(Q1:0=@)
139
+ ECHO1 = $(V:1=@:)
140
+ ECHO = $(ECHO1:0=@echo)
141
+
142
+ srcdir = .
143
+
144
+ CFLAGS = #{ENV['CFLAGS']}
145
+ LDFLAGS = #{ENV['LDFLAGS']}
146
+ CPPFLAGS = #{ENV['CPPFLAGS']}
147
+ CXXFLAGS = #{ENV['CXXFLAGS']}
148
+ INCFLAGS = -I.
149
+ LDSHAREDXX = #{ldsharedxx}
150
+
151
+ empty =
152
+ OUTFLAG = -o $(empty)
153
+ COUTFLAG = -o $(empty)
154
+ CC = #{ENV['CC']}
155
+ CXX = #{ENV["CXX"]}
156
+ TARGET = dep_gecode
157
+ TARGET_NAME = dep_gecode
158
+ DLLIB = $(TARGET).#{dlext}
159
+ LIBS = -lgecodesearch -lgecodeminimodel -lgecodeint -lgecodekernel -lgecodesupport
160
+ CLEANLIBS = $(DLLIB)
161
+ OBJS = dep_selector_to_gecode.o dep_selector_to_gecode_interface.o
162
+ CLEANOBJS = *.o *.bak
163
+ HDRS = #{headers}
164
+
165
+ INSTALL = #{install}
166
+ INSTALL_PROG = $(INSTALL) -m 0755
167
+ INSTALL_DATA = $(INSTALL) -m 644
168
+
169
+ all:\t$(DLLIB)
170
+
171
+ install:
172
+
173
+ clean:
174
+ \t$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
175
+
176
+
177
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
178
+
179
+ .cc.o:
180
+ $(ECHO) compiling $(<)
181
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
182
+
183
+ .cxx.o:
184
+ $(ECHO) compiling $(<)
185
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
186
+
187
+ .cpp.o:
188
+ $(ECHO) compiling $(<)
189
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
190
+
191
+ $(DLLIB): $(OBJS) Makefile
192
+ $(ECHO) linking shared-object $(DLLIB)
193
+ -$(Q)$(RM) $(@)
194
+ $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
195
+ $(Q) test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' -f $@
196
+
197
+ $(OBJS): $(HDRS)
198
+
199
+ EOH
200
+ end
201
+ end
@@ -0,0 +1,83 @@
1
+ #
2
+ # Author:: Daniel DeLeo (<dan@getchef.com>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'ffi'
20
+
21
+ module Dep_gecode
22
+
23
+ extend FFI::Library
24
+
25
+ lib_dir = File.expand_path("../../", __FILE__)
26
+ lib_dir_path = Dir["#{lib_dir}/dep_gecode.*"].first
27
+
28
+ ext_dir = File.expand_path("../../../ext/dep_gecode/", __FILE__)
29
+ ext_dir_path = Dir["#{ext_dir}/dep_gecode.*"].first
30
+
31
+ path = lib_dir_path || ext_dir_path
32
+
33
+ ffi_lib path
34
+
35
+ # VersionProblem * VersionProblemCreate(int packageCount, bool dumpStats,
36
+ # bool debug, const char * log_id);
37
+ attach_function :VersionProblemCreate, [:int, :bool, :bool, :string], :pointer
38
+
39
+ # void VersionProblemDestroy(VersionProblem * vp);
40
+ attach_function :VersionProblemDestroy, [:pointer], :void
41
+
42
+ # int AddPackage(VersionProblem *problem, int min, int max, int currentVersion);
43
+ attach_function :AddPackage, [:pointer, :int, :int, :int], :int
44
+
45
+ # int VersionProblemSize(VersionProblem *p);
46
+ attach_function :VersionProblemSize, [:pointer], :int
47
+
48
+ # void MarkPackagePreferredToBeAtLatest(VersionProblem *problem, int packageId, int weight);
49
+ attach_function :MarkPackagePreferredToBeAtLatest, [:pointer, :int, :int], :void
50
+
51
+ # void MarkPackageRequired(VersionProblem *problem, int packageId);
52
+ attach_function :MarkPackageRequired, [:pointer, :int], :void
53
+
54
+ # void AddVersionConstraint(VersionProblem *problem, int packageId, int version,
55
+ # int dependentPackageId, int minDependentVersion, int maxDependentVersion);
56
+ attach_function :AddVersionConstraint, [:pointer, :int, :int, :int, :int, :int], :void
57
+
58
+ # VersionProblem * Solve(VersionProblem * problem);
59
+ attach_function :Solve, [:pointer], :pointer
60
+
61
+ # int GetDisabledVariableCount(VersionProblem *problem);
62
+ attach_function :GetDisabledVariableCount, [:pointer], :int
63
+
64
+ # int GetPackageVersion(VersionProblem *problem, int packageId);
65
+ attach_function :GetPackageVersion, [:pointer, :int], :int
66
+
67
+ # void MarkPackageSuspicious(VersionProblem *problem, int packageId);
68
+ attach_function :MarkPackageSuspicious, [:pointer, :int], :void
69
+
70
+ # bool GetPackageDisabledState(VersionProblem *problem, int packageId);
71
+ attach_function :GetPackageDisabledState, [:pointer, :int], :bool
72
+
73
+ # int VersionProblemPackageCount(VersionProblem *p);
74
+ attach_function :VersionProblemPackageCount, [:pointer], :int
75
+
76
+ # int GetPackageMax(VersionProblem *problem, int packageId);
77
+ attach_function :GetPackageMax, [:pointer, :int], :int
78
+
79
+ # int GetPackageMin(VersionProblem *problem, int packageId);
80
+ attach_function :GetPackageMin, [:pointer, :int], :int
81
+ end
82
+
83
+
@@ -1,3 +1,3 @@
1
1
  module DepSelector
2
- VERSION = "1.0.0.alpha.0"
2
+ VERSION = "1.0.0.alpha.1"
3
3
  end
@@ -77,10 +77,26 @@ module DepSelector
77
77
  packages.keys.sort.map{|name| packages[name].to_s(incl_densely_packed_versions)}.join("\n")
78
78
  end
79
79
 
80
- # TODO [cw,2010/11/23]: this is a simple but inefficient impl. Do
81
- # it for realz.
80
+ # Does a mostly deep copy of this graph, creating new Package,
81
+ # PackageVersion, and Dependency objects in the copy graph. Version and
82
+ # VersionConstraint objects are re-used from the existing graph.
82
83
  def clone
83
- Marshal.load(Marshal.dump(self))
84
+ copy = self.class.new
85
+ @packages.each do |name, package|
86
+ copy_package = copy.package(name)
87
+
88
+ package.versions.each do |package_version|
89
+ copy_pkg_version = copy_package.add_version(package_version.version)
90
+ package_version.dependencies.each do |pkg_vers_dep|
91
+ dep_pkg_name = pkg_vers_dep.package.name
92
+ copy_dependency = DepSelector::Dependency.new(copy.package(dep_pkg_name), pkg_vers_dep.constraint)
93
+ copy_pkg_version.dependencies << copy_dependency
94
+ end
95
+ end
96
+ end
97
+ copy
84
98
  end
99
+
100
+
85
101
  end
86
102
  end
@@ -18,18 +18,9 @@
18
18
  #
19
19
 
20
20
  require 'securerandom'
21
+ require 'dep_selector/dep_gecode'
21
22
  require 'dep_selector/exceptions'
22
23
 
23
- begin
24
- require "dep_gecode"
25
- rescue LoadError
26
- warn("Unable to find shared object `dep_gecode' in load path")
27
- path = File.expand_path("../../../ext/dep_gecode", __FILE__)
28
- warn("Adding ext directory `#{path}' to load path to find development extensions.")
29
- $:.unshift(path)
30
- require "dep_gecode"
31
- end
32
-
33
24
  module DepSelector
34
25
 
35
26
  @dump_statistics = false
@@ -43,6 +34,7 @@ module DepSelector
43
34
  end
44
35
 
45
36
  class GecodeWrapper
37
+
46
38
  attr_reader :gecode_problem
47
39
  attr_reader :debug_logs_on
48
40
  DontCareConstraint = -1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dep_selector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.0
4
+ version: 1.0.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Walters
@@ -9,36 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-02 00:00:00.000000000 Z
12
+ date: 2014-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: ffi
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: '2.14'
20
+ version: '1.9'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
21
35
  type: :development
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
39
  - - ~>
26
40
  - !ruby/object:Gem::Version
27
- version: '2.14'
41
+ version: '10.0'
28
42
  - !ruby/object:Gem::Dependency
29
- name: rake-compiler
43
+ name: rspec
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - ~>
33
47
  - !ruby/object:Gem::Version
34
- version: 0.9.2
48
+ version: '2.14'
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - ~>
40
54
  - !ruby/object:Gem::Version
41
- version: 0.9.2
55
+ version: '2.14'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: solve
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +77,7 @@ extensions:
63
77
  extra_rdoc_files: []
64
78
  files:
65
79
  - lib/dep_selector/densely_packed_set.rb
80
+ - lib/dep_selector/dep_gecode.rb
66
81
  - lib/dep_selector/dep_selector_version.rb
67
82
  - lib/dep_selector/dependency.rb
68
83
  - lib/dep_selector/dependency_graph.rb
@@ -78,13 +93,11 @@ files:
78
93
  - lib/dep_selector/version_constraint.rb
79
94
  - lib/dep_selector.rb
80
95
  - ext/dep_gecode/dep_selector_swig.i
81
- - ext/dep_gecode/dep_selector_swig_wrap.cxx
82
96
  - ext/dep_gecode/dep_selector_to_gecode.h
83
97
  - ext/dep_gecode/dep_selector_to_gecode_interface.h
84
98
  - ext/dep_gecode/dep_selector_to_gecode.cpp
85
99
  - ext/dep_gecode/dep_selector_to_gecode_interface.cpp
86
100
  - ext/dep_gecode/extconf.rb
87
- - ext/dep_gecode/lib/dep_selector_to_gecode.rb
88
101
  homepage: http://github.com/opscode/dep-selector
89
102
  licenses:
90
103
  - Apache v2