|
292 | 292 | # Compound commands
|
293 | 293 |
|
294 | 294 | (defn out-path
|
295 |
| - "Take a source file path and convert it to an output path." |
| 295 | + "Take a source file path and convert it to an output path with no intermediate directories." |
296 | 296 | [path to-ext &opt sep]
|
297 | 297 | (default sep "/")
|
298 | 298 | (def flatpath
|
|
305 | 305 | "Compile a number of source files, and return the
|
306 | 306 | generated objects files, as well as a boolean if any cpp
|
307 | 307 | source files were found."
|
308 |
| - [sources cmds-into] |
| 308 | + [sources cmds-into ext] |
309 | 309 | (def objects @[])
|
310 | 310 | (var has-cpp false)
|
311 | 311 | (each source sources
|
312 |
| - (def o (out-path source ".o")) |
| 312 | + (def o (out-path source ext)) |
313 | 313 | (def source-type (classify-source source))
|
314 | 314 | (case source-type
|
315 | 315 | :o
|
|
331 | 331 | "Compile and link a shared C/C++ library. Return an array of commands."
|
332 | 332 | [to & sources]
|
333 | 333 | (def res @[])
|
334 |
| - (def [has-cpp objects] (compile-many sources res)) |
| 334 | + (def [has-cpp objects] (compile-many sources res ".shared.o")) |
335 | 335 | (array/push
|
336 | 336 | res
|
337 | 337 | (if has-cpp
|
|
342 | 342 | "Compile and link an executable C/C++ program. Return an array of commands."
|
343 | 343 | [to & sources]
|
344 | 344 | (def res @[])
|
345 |
| - (def [has-cpp objects] (compile-many sources res)) |
| 345 | + (def [has-cpp objects] (compile-many sources res ".executable.o")) |
346 | 346 | (array/push
|
347 | 347 | res
|
348 | 348 | (if has-cpp
|
|
353 | 353 | "Compile and create a static archive. Return an array of commands."
|
354 | 354 | [to & sources]
|
355 | 355 | (def res @[])
|
356 |
| - (def [_ objects] (compile-many sources res)) |
| 356 | + (def [_ objects] (compile-many sources res ".static.o")) |
357 | 357 | (array/push res (make-archive objects to)))
|
358 | 358 |
|
359 | 359 | ###
|
|
436 | 436 | nil)
|
437 | 437 |
|
438 | 438 | (defn- msvc-opt
|
439 |
| - [] |
| 439 | + [to] |
| 440 | + (def pdb-name (string to ".pdb")) |
440 | 441 | (case (build-type)
|
441 |
| - :debug ["/Od" "/Zi" "/MDd"] |
| 442 | + :debug ["/Od" "/Zi" "/MDd" (string "/Fd" pdb-name)] |
442 | 443 | ["/O2" "/MD"]))
|
443 | 444 | (defn- msvc-defines []
|
444 | 445 | (def res @[])
|
|
485 | 486 | (defn msvc-compile-c
|
486 | 487 | "Compile a C source file with MSVC to an object file. Return the command arguments."
|
487 | 488 | [from to]
|
488 |
| - (exec [(cl.exe) "/c" (msvc-cstd) "/utf-8" "/nologo" ;(cflags) ;(msvc-compile-paths) ;(msvc-opt) ;(msvc-defines) |
| 489 | + (exec [(cl.exe) "/c" (msvc-cstd) "/utf-8" "/nologo" ;(cflags) ;(msvc-compile-paths) ;(msvc-opt to) ;(msvc-defines) |
489 | 490 | from (string "/Fo" to)]
|
490 | 491 | [from] [to] (string "compiling " from "...")))
|
491 | 492 |
|
492 | 493 | (defn msvc-compile-c++
|
493 | 494 | "Compile a C++ source file with MSVC to an object file. Return the command arguments."
|
494 | 495 | [from to]
|
495 |
| - (exec [(cl.exe) "/c" (msvc-c++std) "/utf-8" "/nologo" "/EHsc" ;(c++flags) ;(msvc-compile-paths) ;(msvc-opt) ;(msvc-defines) |
| 496 | + (exec [(cl.exe) "/c" (msvc-c++std) "/utf-8" "/nologo" "/EHsc" ;(c++flags) ;(msvc-compile-paths) ;(msvc-opt to) ;(msvc-defines) |
496 | 497 | from (string "/Fo" to)]
|
497 | 498 | [from] [to] (string "compiling " from "...")))
|
498 | 499 |
|
|
520 | 521 | "Compile a number of source files, and return the
|
521 | 522 | generated objects files, as well as a boolean if any cpp
|
522 | 523 | source files were found."
|
523 |
| - [sources cmds-into] |
| 524 | + [sources cmds-into ext] |
524 | 525 | (def objects @[])
|
525 | 526 | (each source sources
|
526 |
| - (def o (out-path source ".o" "\\")) |
| 527 | + (def o (out-path source ext "\\")) |
527 | 528 | (def source-type (classify-source source))
|
528 | 529 | (case source-type
|
529 | 530 | :o
|
|
544 | 545 | "Compile and link a shared C/C++ library. Return an array of commands."
|
545 | 546 | [to & sources]
|
546 | 547 | (def res @[])
|
547 |
| - (def objects (msvc-compile-many sources res)) |
| 548 | + (def objects (msvc-compile-many sources res ".shared.o")) |
548 | 549 | (array/push
|
549 | 550 | res
|
550 | 551 | (msvc-link-shared objects to)))
|
|
553 | 554 | "Compile and link an executable C/C++ program. Return an array of commands."
|
554 | 555 | [to & sources]
|
555 | 556 | (def res @[])
|
556 |
| - (def objects (msvc-compile-many sources res)) |
| 557 | + (def objects (msvc-compile-many sources res ".executable.o")) |
557 | 558 | (array/push
|
558 | 559 | res
|
559 | 560 | (msvc-link-executable objects to)))
|
|
562 | 563 | "Compile and create a static archive. Return an array of commands."
|
563 | 564 | [to & sources]
|
564 | 565 | (def res @[])
|
565 |
| - (def objects (msvc-compile-many sources res)) |
| 566 | + (def objects (msvc-compile-many sources res ".static.o")) |
566 | 567 | (array/push res (msvc-make-archive objects to)))
|
567 | 568 |
|
568 | 569 | ###
|
|
0 commit comments