diff options
| author | Dominic Sisneros <[email protected]> | 2020-04-01 11:55:35 -0600 |
|---|---|---|
| committer | Dominic Sisneros <[email protected]> | 2020-04-01 11:55:35 -0600 |
| commit | e3875ae8c5a9cd8ebef7fa4775698bf85d7c8eb9 (patch) | |
| tree | 43199871ab16f12be182bb6d06311f07b7cf4e8d /lib | |
| parent | 5acd802d2be19872b703d6c9876aa61a262c6c8c (diff) | |
| download | mruby-e3875ae8c5a9cd8ebef7fa4775698bf85d7c8eb9.tar.gz mruby-e3875ae8c5a9cd8ebef7fa4775698bf85d7c8eb9.zip | |
build when directories and files have spaces
Modified the build to quote filenames so that it builds when files have spaces
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mruby/build/command.rb | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 03d814800..3e8b3f57c 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -36,9 +36,14 @@ module MRuby private def _run(options, params={}) - return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command + + cmd_string = if NotFoundCommands.key?(@command) + command + ' ' + ( options % params ) + else + build.filename(command) + ' ' + ( options % params ) + end begin - sh build.filename(command) + ' ' + ( options % params ) + sh cmd_string rescue RuntimeError NotFoundCommands[@command] = true _run options, params @@ -58,9 +63,9 @@ module MRuby @source_exts = source_exts @include_paths = ["#{MRUBY_ROOT}/include"] @defines = %w() - @option_include_path = '-I%s' - @option_define = '-D%s' - @compile_options = '%{flags} -o %{outfile} -c %{infile}' + @option_include_path = %q[-I"%s"] + @option_define = %q[-D"%s"] + @compile_options = %q[%{flags} -o "%{outfile}" -c "%{infile}"] @cxx_invalid_flags = [] end @@ -184,9 +189,9 @@ module MRuby @flags_before_libraries, @flags_after_libraries = [], [] @libraries = [] @library_paths = [] - @option_library = '-l%s' - @option_library_path = '-L%s' - @link_options = "%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}" + @option_library = %q[-l"%s"] + @option_library_path = %q[-L"%s"] + @link_options = %Q[%{flags} -o "%{outfile}" %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}] end def all_flags(_library_paths=[], _flags=[]) @@ -217,7 +222,7 @@ module MRuby :libs => library_flags.join(' ') } else _run link_options, { :flags => all_flags(_library_paths, _flags), - :outfile => filename(outfile) , :objs => filename(objfiles).join(' '), + :outfile => filename(outfile) , :objs => filename(objfiles).map{|f| %Q["#{f}"]}.join(' '), :flags_before_libraries => [flags_before_libraries, _flags_before_libraries].flatten.join(' '), :flags_after_libraries => [flags_after_libraries, _flags_after_libraries].flatten.join(' '), :libs => library_flags.join(' ') } @@ -231,16 +236,16 @@ module MRuby def initialize(build) super @command = ENV['AR'] || 'ar' - @archive_options = 'rs %{outfile} %{objs}' + @archive_options = 'rs "%{outfile}" %{objs}' end def run(outfile, objfiles) mkdir_p File.dirname(outfile) _pp "AR", outfile.relative_path if MRUBY_BUILD_HOST_IS_CYGWIN - _run archive_options, { :outfile => cygwin_filename(outfile), :objs => cygwin_filename(objfiles).join(' ') } + _run archive_options, { :outfile => cygwin_filename(outfile), :objs => cygwin_filename(objfiles).map{|f| %Q["#{f}"]}.join(' ') } else - _run archive_options, { :outfile => filename(outfile), :objs => filename(objfiles).join(' ') } + _run archive_options, { :outfile => filename(outfile), :objs => filename(objfiles).map{|f| %Q["#{f}"]}.join(' ') } end end end @@ -251,7 +256,7 @@ module MRuby def initialize(build) super @command = 'bison' - @compile_options = '-o %{outfile} %{infile}' + @compile_options = %q[-o "%{outfile}" "%{infile}"] end def run(outfile, infile) @@ -267,7 +272,7 @@ module MRuby def initialize(build) super @command = 'gperf' - @compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}' + @compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"] end def run(outfile, infile) @@ -341,7 +346,7 @@ module MRuby infiles.each do |f| _pp "MRBC", f.relative_path, nil, :indent => 2 end - cmd = "#{filename @command} #{@compile_options % {:funcname => funcname}} #{filename(infiles).join(' ')}" + cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}] puts cmd if Rake.verbose IO.popen(cmd, 'r+') do |io| out.puts io.read |
