Skip to content

Commit

Permalink
fix: build --no-codegen output file name error (#14239)
Browse files Browse the repository at this point in the history
  • Loading branch information
apainintheneck authored Feb 2, 2024
1 parent 3ba4291 commit 3def4de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ class Crystal::Command
allowed_formats = ["text", "json"])
compiler = new_compiler
compiler.progress_tracker = @progress_tracker
compiler.no_codegen = no_codegen
link_flags = [] of String
filenames = [] of String
has_stdin_filename = false
Expand Down Expand Up @@ -608,7 +609,7 @@ class Crystal::Command
output_filename = "#{::Path[first_filename].stem}#{output_extension}"

# Check if we'll overwrite the main source file
if !no_codegen && !run && first_filename == File.expand_path(output_filename)
if !compiler.no_codegen? && !run && first_filename == File.expand_path(output_filename)
error "compilation will overwrite source file '#{Crystal.relative_filename(first_filename)}', either change its extension to '.cr' or specify an output file with '-o'"
end
end
Expand All @@ -620,15 +621,15 @@ class Crystal::Command

error "maximum number of threads cannot be lower than 1" if compiler.n_threads < 1

if !no_codegen && !run && Dir.exists?(output_filename)
if !compiler.no_codegen? && !run && Dir.exists?(output_filename)
error "can't use `#{output_filename}` as output filename because it's a directory"
end

if run
emit_base_filename = ::Path[sources.first.filename].stem
end

combine_rpath = run && !no_codegen
combine_rpath = run && !compiler.no_codegen?
@config = CompilerConfig.new compiler, sources, output_filename, emit_base_filename,
arguments, specified_output, hierarchy_exp, cursor_location, output_format.not_nil!,
combine_rpath, includes, excludes, verbose, check, tallies
Expand Down

0 comments on commit 3def4de

Please sign in to comment.