Skip to content

Commit

Permalink
Compiler: only offer --cross-compile and --target flags when the …
Browse files Browse the repository at this point in the history
…command is `build`
  • Loading branch information
Ary Borenszweig committed Dec 31, 2014
1 parent 8039530 commit 60c3089
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module Crystal::Command
end

private def self.run_command(options)
config = create_compiler "run", options
config = create_compiler "run", options, run: true
if config.specified_output
config.compile
return
Expand Down Expand Up @@ -226,7 +226,7 @@ module Crystal::Command
end
end

private def self.create_compiler(command, options, no_build = false)
private def self.create_compiler(command, options, no_build = false, run = false)
compiler = Compiler.new
link_flags = [] of String
opt_filenames = nil
Expand All @@ -238,8 +238,10 @@ module Crystal::Command
opts.banner = "Usage: crystal #{command} [options] [programfile] [--] [arguments]\n\nOptions:"

unless no_build
opts.on("--cross-compile flags", "cross-compile") do |cross_compile|
compiler.cross_compile_flags = cross_compile
unless run
opts.on("--cross-compile flags", "cross-compile") do |cross_compile|
compiler.cross_compile_flags = cross_compile
end
end
opts.on("-d", "--debug", "Add symbolic debug info") do
compiler.debug = true
Expand Down Expand Up @@ -287,8 +289,10 @@ module Crystal::Command
opts.on("--threads ", "Maximum number of threads to use") do |n_threads|
compiler.n_threads = n_threads.to_i
end
opts.on("--target TRIPLE", "Target triple") do |triple|
compiler.target_triple = triple
unless run
opts.on("--target TRIPLE", "Target triple") do |triple|
compiler.target_triple = triple
end
end
opts.on("--verbose", "Display executed commands") do
compiler.verbose = true
Expand Down

0 comments on commit 60c3089

Please sign in to comment.