1
+ use std:: collections:: HashSet ;
1
2
use std:: env;
2
3
3
4
fn make_builder ( ) -> cc:: Build {
@@ -226,18 +227,60 @@ fn compile_clp() {
226
227
}
227
228
228
229
const CGL_SRC_PATH : & str = "vendor/Cgl/Cgl/src" ;
229
- const CGL_SRCS : [ & str ; 5 ] = [
230
+ const CGL_SRCS : [ & str ; 34 ] = [
230
231
"CglCutGenerator.cpp" ,
231
232
"CglMessage.cpp" ,
232
233
"CglParam.cpp" ,
233
234
"CglStored.cpp" ,
234
235
"CglTreeInfo.cpp" ,
236
+ "CglAllDifferent/CglAllDifferent.cpp" ,
237
+ "CglClique/CglClique.cpp" ,
238
+ "CglClique/CglCliqueHelper.cpp" ,
239
+ "CglDuplicateRow/CglDuplicateRow.cpp" ,
240
+ "CglFlowCover/CglFlowCover.cpp" ,
241
+ "CglGMI/CglGMI.cpp" ,
242
+ "CglGMI/CglGMIParam.cpp" ,
243
+ "CglGomory/CglGomory.cpp" ,
244
+ "CglKnapsackCover/CglKnapsackCover.cpp" ,
245
+ "CglLandP/CglLandP.cpp" ,
246
+ "CglLandP/CglLandPMessages.cpp" ,
247
+ "CglLandP/CglLandPSimplex.cpp" ,
248
+ "CglLandP/CglLandPTabRow.cpp" ,
249
+ "CglLandP/CglLandPUtils.cpp" ,
250
+ "CglLandP/CglLandPValidator.cpp" ,
251
+ "CglMixedIntegerRounding/CglMixedIntegerRounding.cpp" ,
252
+ "CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp" ,
253
+ "CglOddHole/CglOddHole.cpp" ,
254
+ "CglPreProcess/CglPreProcess.cpp" ,
255
+ "CglProbing/CglProbing.cpp" ,
256
+ "CglRedSplit/CglRedSplit.cpp" ,
257
+ "CglRedSplit/CglRedSplitParam.cpp" ,
258
+ "CglRedSplit2/CglRedSplit2.cpp" ,
259
+ "CglRedSplit2/CglRedSplit2Param.cpp" ,
260
+ "CglResidualCapacity/CglResidualCapacity.cpp" ,
261
+ "CglSimpleRounding/CglSimpleRounding.cpp" ,
262
+ "CglTwomir/CglTwomir.cpp" ,
263
+ "CglZeroHalf/CglZeroHalf.cpp" ,
264
+ "CglZeroHalf/Cgl012cut.cpp" ,
235
265
] ;
236
266
237
- fn compile_cgl ( ) -> Vec < String > {
238
- let mut builder = make_builder ( ) ;
267
+ /// Returns the include directories for Cgl.
268
+ fn cgl_include_dirs ( ) -> Vec < String > {
269
+ let mut include_dirs: HashSet < String > = HashSet :: new ( ) ;
270
+
271
+ include_dirs. insert ( CGL_SRC_PATH . to_string ( ) ) ;
272
+ for src in CGL_SRCS . iter ( ) {
273
+ let split: Vec < _ > = src. split ( "/" ) . collect ( ) ;
274
+ if split. len ( ) == 2 {
275
+ include_dirs. insert ( format ! ( "{}/{}" , CGL_SRC_PATH , split[ 0 ] ) ) ;
276
+ }
277
+ }
239
278
240
- let mut extra_include_dirs = vec ! [ ] ;
279
+ include_dirs. into_iter ( ) . collect ( )
280
+ }
281
+
282
+ fn compile_cgl ( ) {
283
+ let mut builder = make_builder ( ) ;
241
284
242
285
builder
243
286
. include ( COIN_UTILS_PATH )
@@ -250,134 +293,8 @@ fn compile_cgl() -> Vec<String> {
250
293
builder. file ( format ! ( "{}/{}" , CGL_SRC_PATH , src) ) ;
251
294
}
252
295
253
- {
254
- let pth = format ! ( "{}/CglAllDifferent" , CGL_SRC_PATH ) ;
255
- builder. file ( format ! ( "{}/CglAllDifferent.cpp" , pth) ) ;
256
- extra_include_dirs. push ( pth) ;
257
- }
258
-
259
- {
260
- let pth = format ! ( "{}/CglClique" , CGL_SRC_PATH ) ;
261
- builder. file ( format ! ( "{}/CglClique.cpp" , pth) ) ;
262
- builder. file ( format ! ( "{}/CglCliqueHelper.cpp" , pth) ) ;
263
- extra_include_dirs. push ( pth) ;
264
- }
265
-
266
- {
267
- let pth = format ! ( "{}/CglDuplicateRow" , CGL_SRC_PATH ) ;
268
- builder. file ( format ! ( "{}/CglDuplicateRow.cpp" , pth) ) ;
269
- extra_include_dirs. push ( pth) ;
270
- }
271
-
272
- {
273
- let pth = format ! ( "{}/CglFlowCover" , CGL_SRC_PATH ) ;
274
- builder. file ( format ! ( "{}/CglFlowCover.cpp" , pth) ) ;
275
- extra_include_dirs. push ( pth) ;
276
- }
277
-
278
- {
279
- let pth = format ! ( "{}/CglGMI" , CGL_SRC_PATH ) ;
280
- builder. file ( format ! ( "{}/CglGMI.cpp" , pth) ) ;
281
- builder. file ( format ! ( "{}/CglGMIParam.cpp" , pth) ) ;
282
- extra_include_dirs. push ( pth) ;
283
- }
284
-
285
- {
286
- let pth = format ! ( "{}/CglGomory" , CGL_SRC_PATH ) ;
287
- builder. file ( format ! ( "{}/CglGomory.cpp" , pth) ) ;
288
- extra_include_dirs. push ( pth) ;
289
- }
290
-
291
- {
292
- let pth = format ! ( "{}/CglKnapsackCover" , CGL_SRC_PATH ) ;
293
- builder. file ( format ! ( "{}/CglKnapsackCover.cpp" , pth) ) ;
294
- extra_include_dirs. push ( pth) ;
295
- }
296
-
297
- {
298
- let pth = format ! ( "{}/CglLandP" , CGL_SRC_PATH ) ;
299
- builder. file ( format ! ( "{}/CglLandP.cpp" , pth) ) ;
300
- builder. file ( format ! ( "{}/CglLandPMessages.cpp" , pth) ) ;
301
- builder. file ( format ! ( "{}/CglLandPSimplex.cpp" , pth) ) ;
302
- builder. file ( format ! ( "{}/CglLandPTabRow.cpp" , pth) ) ;
303
- builder. file ( format ! ( "{}/CglLandPUtils.cpp" , pth) ) ;
304
- builder. file ( format ! ( "{}/CglLandPValidator.cpp" , pth) ) ;
305
- extra_include_dirs. push ( pth) ;
306
- }
307
-
308
- {
309
- let pth = format ! ( "{}/CglMixedIntegerRounding" , CGL_SRC_PATH ) ;
310
- builder. file ( format ! ( "{}/CglMixedIntegerRounding.cpp" , pth) ) ;
311
- extra_include_dirs. push ( pth) ;
312
- }
313
-
314
- {
315
- let pth = format ! ( "{}/CglMixedIntegerRounding2" , CGL_SRC_PATH ) ;
316
- builder. file ( format ! ( "{}/CglMixedIntegerRounding2.cpp" , pth) ) ;
317
- extra_include_dirs. push ( pth) ;
318
- }
319
-
320
- {
321
- let pth = format ! ( "{}/CglOddHole" , CGL_SRC_PATH ) ;
322
- builder. file ( format ! ( "{}/CglOddHole.cpp" , pth) ) ;
323
- extra_include_dirs. push ( pth) ;
324
- }
325
-
326
- {
327
- let pth = format ! ( "{}/CglPreProcess" , CGL_SRC_PATH ) ;
328
- builder. file ( format ! ( "{}/CglPreProcess.cpp" , pth) ) ;
329
- extra_include_dirs. push ( pth) ;
330
- }
331
-
332
- {
333
- let pth = format ! ( "{}/CglProbing" , CGL_SRC_PATH ) ;
334
- builder. file ( format ! ( "{}/CglProbing.cpp" , pth) ) ;
335
- extra_include_dirs. push ( pth) ;
336
- }
337
-
338
- {
339
- let pth = format ! ( "{}/CglRedSplit" , CGL_SRC_PATH ) ;
340
- builder. file ( format ! ( "{}/CglRedSplit.cpp" , pth) ) ;
341
- builder. file ( format ! ( "{}/CglRedSplitParam.cpp" , pth) ) ;
342
- extra_include_dirs. push ( pth) ;
343
- }
344
-
345
- {
346
- let pth = format ! ( "{}/CglRedSplit2" , CGL_SRC_PATH ) ;
347
- builder. file ( format ! ( "{}/CglRedSplit2.cpp" , pth) ) ;
348
- builder. file ( format ! ( "{}/CglRedSplit2Param.cpp" , pth) ) ;
349
- extra_include_dirs. push ( pth) ;
350
- }
351
-
352
- {
353
- let pth = format ! ( "{}/CglResidualCapacity" , CGL_SRC_PATH ) ;
354
- builder. file ( format ! ( "{}/CglResidualCapacity.cpp" , pth) ) ;
355
- extra_include_dirs. push ( pth) ;
356
- }
357
-
358
- {
359
- let pth = format ! ( "{}/CglSimpleRounding" , CGL_SRC_PATH ) ;
360
- builder. file ( format ! ( "{}/CglSimpleRounding.cpp" , pth) ) ;
361
- extra_include_dirs. push ( pth) ;
362
- }
363
-
364
- {
365
- let pth = format ! ( "{}/CglTwomir" , CGL_SRC_PATH ) ;
366
- builder. file ( format ! ( "{}/CglTwomir.cpp" , pth) ) ;
367
- extra_include_dirs. push ( pth) ;
368
- }
369
-
370
- {
371
- let pth = format ! ( "{}/CglZeroHalf" , CGL_SRC_PATH ) ;
372
- builder. file ( format ! ( "{}/CglZeroHalf.cpp" , pth) ) ;
373
- builder. file ( format ! ( "{}/Cgl012cut.cpp" , pth) ) ;
374
- extra_include_dirs. push ( pth) ;
375
- }
376
-
377
- builder. includes ( & extra_include_dirs) ;
296
+ builder. includes ( cgl_include_dirs ( ) ) ;
378
297
builder. compile ( "Cgl" ) ;
379
-
380
- extra_include_dirs
381
298
}
382
299
383
300
const CBC_SRC_PATH : & str = "vendor/Cbc/Cbc/src" ;
@@ -462,18 +379,17 @@ const CBC_SRCS: [&str; 75] = [
462
379
"CbcTreeLocal.cpp" ,
463
380
] ;
464
381
465
- fn compile_cbc ( cgl_include_dirs : & [ String ] ) {
382
+ fn compile_cbc ( ) {
466
383
let mut builder = make_builder ( ) ;
467
384
468
385
builder
469
386
. include ( COIN_UTILS_PATH )
470
387
. include ( OSI_SRC_PATH )
471
388
. include ( CLP_SRC_PATH )
472
389
. include ( CLP_OSI_SRC_PATH )
473
- . include ( CGL_SRC_PATH )
474
390
. include ( CBC_SRC_PATH ) ;
475
391
476
- builder. includes ( cgl_include_dirs) ;
392
+ builder. includes ( cgl_include_dirs ( ) ) ;
477
393
478
394
for src in CBC_SRCS . iter ( ) {
479
395
builder. file ( format ! ( "{}/{}" , CBC_SRC_PATH , src) ) ;
@@ -484,9 +400,9 @@ fn compile_cbc(cgl_include_dirs: &[String]) {
484
400
}
485
401
486
402
fn main ( ) {
487
- compile_coin_utils ( ) ;
488
- compile_clp ( ) ;
403
+ compile_cbc ( ) ;
404
+ compile_cgl ( ) ;
489
405
compile_osi ( ) ;
490
- let cgl_include_dirs = compile_cgl ( ) ;
491
- compile_cbc ( & cgl_include_dirs ) ;
406
+ compile_clp ( ) ;
407
+ compile_coin_utils ( ) ;
492
408
}
0 commit comments