Compare commits
2 Commits
master
...
precompile
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dc1280f68 | |||
| 355014def6 |
@ -33,6 +33,7 @@ module Rscons
|
|||||||
:Lex,
|
:Lex,
|
||||||
:Library,
|
:Library,
|
||||||
:Object,
|
:Object,
|
||||||
|
:Precompile,
|
||||||
:Preprocess,
|
:Preprocess,
|
||||||
:Program,
|
:Program,
|
||||||
:SharedLibrary,
|
:SharedLibrary,
|
||||||
@ -152,6 +153,7 @@ require_relative "rscons/builders/disassemble"
|
|||||||
require_relative "rscons/builders/lex"
|
require_relative "rscons/builders/lex"
|
||||||
require_relative "rscons/builders/library"
|
require_relative "rscons/builders/library"
|
||||||
require_relative "rscons/builders/object"
|
require_relative "rscons/builders/object"
|
||||||
|
require_relative "rscons/builders/precompile"
|
||||||
require_relative "rscons/builders/preprocess"
|
require_relative "rscons/builders/preprocess"
|
||||||
require_relative "rscons/builders/program"
|
require_relative "rscons/builders/program"
|
||||||
require_relative "rscons/builders/shared_library"
|
require_relative "rscons/builders/shared_library"
|
||||||
|
|||||||
29
lib/rscons/builders/precompile.rb
Normal file
29
lib/rscons/builders/precompile.rb
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
module Rscons
|
||||||
|
module Builders
|
||||||
|
# The Precompile builder generates .di interface files from .d source files
|
||||||
|
# for D.
|
||||||
|
class Precompile < Builder
|
||||||
|
|
||||||
|
# Run the builder to produce a build target.
|
||||||
|
def run(options)
|
||||||
|
if @command
|
||||||
|
finalize_command
|
||||||
|
else
|
||||||
|
if @sources.find {|s| s.end_with?(*@env.expand_varref("${DSUFFIX}", @vars))}
|
||||||
|
pcc = @env.expand_varref("${DC}")
|
||||||
|
if pcc =~ /ldc/
|
||||||
|
dpc_cmd = "${DPC_CMD:ldc}"
|
||||||
|
else
|
||||||
|
dpc_cmd = "${DPC_CMD:gdc}"
|
||||||
|
end
|
||||||
|
@vars["_TARGET"] = @target
|
||||||
|
@vars["_SOURCES"] = @sources
|
||||||
|
command = @env.build_command(dpc_cmd, @vars)
|
||||||
|
standard_command("Precompile <source>#{Util.short_format_paths(@sources)}<reset>", command)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -43,6 +43,8 @@ module Rscons
|
|||||||
"DFLAGS" => [],
|
"DFLAGS" => [],
|
||||||
"DISASM_CMD" => %w[${OBJDUMP} ${DISASM_FLAGS} ${_SOURCES}],
|
"DISASM_CMD" => %w[${OBJDUMP} ${DISASM_FLAGS} ${_SOURCES}],
|
||||||
"DISASM_FLAGS" => %w[--disassemble --source],
|
"DISASM_FLAGS" => %w[--disassemble --source],
|
||||||
|
"DPC_CMD:ldc" => %w[${DC} -H -Hf ${_TARGET} -o- ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
||||||
|
"DPC_CMD:gdc" => %w[${DC} -H -Hf ${_TARGET} -fsyntax-only ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
||||||
"DSUFFIX" => %w[.d],
|
"DSUFFIX" => %w[.d],
|
||||||
"D_IMPORT_PATH" => [],
|
"D_IMPORT_PATH" => [],
|
||||||
"INCPREFIX" => "-I",
|
"INCPREFIX" => "-I",
|
||||||
|
|||||||
@ -34,15 +34,7 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [Array<String>] Paths matching the specified pattern(s).
|
# @return [Array<String>] Paths matching the specified pattern(s).
|
||||||
def glob(*patterns)
|
def glob(*patterns)
|
||||||
require "pathname"
|
Util.glob(*patterns)
|
||||||
patterns.reduce([]) do |result, pattern|
|
|
||||||
if pattern.end_with?("/**")
|
|
||||||
pattern += "/"
|
|
||||||
end
|
|
||||||
result += Dir.glob(pattern).map do |path|
|
|
||||||
Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
|
|
||||||
end
|
|
||||||
end.sort
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Download a file.
|
# Download a file.
|
||||||
|
|||||||
@ -156,6 +156,33 @@ module Rscons
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return a list of paths matching the specified pattern(s).
|
||||||
|
#
|
||||||
|
# A pattern can contain a "/**" component to recurse through directories.
|
||||||
|
# If the pattern ends with "/**" then only the recursive list of
|
||||||
|
# directories will be returned.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# - "src/**": return all directories under "src", recursively (including
|
||||||
|
# "src" itself).
|
||||||
|
# - "src/**/*": return all files and directories recursively under the src
|
||||||
|
# directory.
|
||||||
|
# - "src/**/*.c": return all .c files recursively under the src directory.
|
||||||
|
# - "dir/*/": return all directories in dir, but no files.
|
||||||
|
#
|
||||||
|
# @return [Array<String>] Paths matching the specified pattern(s).
|
||||||
|
def glob(*patterns)
|
||||||
|
require "pathname"
|
||||||
|
patterns.reduce([]) do |result, pattern|
|
||||||
|
if pattern.end_with?("/**")
|
||||||
|
pattern += "/"
|
||||||
|
end
|
||||||
|
result += Dir.glob(pattern).map do |path|
|
||||||
|
Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
|
||||||
|
end
|
||||||
|
end.sort
|
||||||
|
end
|
||||||
|
|
||||||
# Make a relative path corresponding to a possibly absolute one.
|
# Make a relative path corresponding to a possibly absolute one.
|
||||||
#
|
#
|
||||||
# @param path [String]
|
# @param path [String]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user