Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build --no-codegen output file name error #14239

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,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 @@ -596,7 +597,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 @@ -608,15 +609,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