Skip to content

Loading…

Mkmf with space #185

Closed
wants to merge 4 commits into from

4 participants

@nobu
Ruby Programming Language member

No description provided.

nobu added some commits
@nobu nobu mkmf.rb: unexpand macros
* lib/mkmf.rb: unexpand macros.
132909c
@nobu nobu mkmf.rb: directory timestamp
* lib/mkmf.rb (create_makefile): use timestamp file dependencies for
  directories.
cacb90b
@nobu nobu mkmf.rb: library path quote
* lib/mkmf.rb (LIBPATHFLAG): no needs to escape library path here.
7997ef6
@nobu nobu mkmf.rb: unspace
* lib/mkmf.rb (String#unspace): unescape with backslashes.  normal
  makes need to escape spaces with backslashes.  nmake is not the
  case.
1357c65
@sodabrew

Hi, could you add some more explanation / description of this patch? It looks like this is to escape the paths in the mkmf makefiles. We've gotten a related bug report in mysql2 about a path with parentheses. It'd be great if you could handle that scenario as well. Hope it gets merged, thank you!

@luislavena
Ruby Programming Language member

This is no longer relevant as an alternate solution has been merged already.

@zzak
Ruby Programming Language member

@luislavena So can we close this then? Can you link to the associated revision or redmine ticket?

@zzak
Ruby Programming Language member

@luislavena Nevermind, I found it.

Closing this, please refer to Bug #7036 in redmine

@zzak zzak closed this
@sodabrew

Awesome, thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 21, 2012
  1. @nobu

    mkmf.rb: unexpand macros

    nobu committed
    * lib/mkmf.rb: unexpand macros.
  2. @nobu

    mkmf.rb: directory timestamp

    nobu committed
    * lib/mkmf.rb (create_makefile): use timestamp file dependencies for
      directories.
  3. @nobu

    mkmf.rb: library path quote

    nobu committed
    * lib/mkmf.rb (LIBPATHFLAG): no needs to escape library path here.
  4. @nobu

    mkmf.rb: unspace

    nobu committed
    * lib/mkmf.rb (String#unspace): unescape with backslashes.  normal
      makes need to escape spaces with backslashes.  nmake is not the
      case.
Showing with 17 additions and 11 deletions.
  1. +17 −11 lib/mkmf.rb
View
28 lib/mkmf.rb
@@ -12,6 +12,11 @@ def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
end
+ # Escape whitespaces for Makefile.
+ def unspace
+ gsub(/\s/, '\\\\\\&')
+ end
+
# Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
@@ -196,10 +201,11 @@ def map_dir(dir, map = nil)
$extmk = path[0, topdir.size+1] == topdir+"/"
$extmk &&= %r"\A(?:ext|enc|tool|test(?:/.+)?)\z" =~ File.dirname(path[topdir.size+1..-1])
$extmk &&= true
- if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
+ if not $extmk and File.exist?(RbConfig::CONFIG["rubyhdrdir"] + "/ruby/ruby.h")
+ $hdrdir = CONFIG["rubyhdrdir"]
$topdir = $hdrdir
$top_srcdir = $hdrdir
- $arch_hdrdir = $hdrdir + "/$(arch)"
+ $arch_hdrdir = "$(hdrdir)/$(arch)"
elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h")
$topdir ||= RbConfig::CONFIG["topdir"]
$arch_hdrdir = "$(extout)/include/$(arch)"
@@ -1722,7 +1728,7 @@ def mkintpath(path)
end
unless defined?(mkintpath)
def mkintpath(path)
- path
+ path.unspace
end
end
@@ -1750,9 +1756,9 @@ def configuration(srcdir)
#### Start of system configuration section. ####
#{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
-srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}.quote}
-topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote}
-hdrdir = #{mkintpath(CONFIG["hdrdir"]).quote}
+srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}}
+topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir)}
+hdrdir = #{mkintpath(CONFIG["hdrdir"])}
arch_hdrdir = #{$arch_hdrdir.quote}
VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
}
@@ -1764,7 +1770,7 @@ def configuration(srcdir)
end
CONFIG.each do |key, var|
next unless /prefix$/ =~ key
- mk << "#{key} = #{with_destdir(var)}\n"
+ mk << "#{key} = #{with_destdir(var).unspace}\n"
end
CONFIG.each do |key, var|
next if /^abs_/ =~ key
@@ -2126,14 +2132,14 @@ def create_makefile(target, srcprefix = nil)
if target
f = "$(DLLIB)"
dest = "#{dir}/#{f}"
- mfile.puts dest
if $extout
+ mfile.puts dest
mfile.print "clean-so::\n"
mfile.print "\t-$(Q)$(RM) #{fseprepl[dest]}\n"
mfile.print "\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n"
else
- mfile.print "#{dest}: #{f}\n\t-$(Q)$(MAKEDIRS) $(@D#{sep})\n"
- mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} $(@D#{sep})\n"
+ mfile.print "#{f} #{timestamp_file(dir)}\n"
+ mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} #{dir}\n"
if defined?($installed_list)
mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
end
@@ -2398,7 +2404,7 @@ def mkmf_failed(path)
"$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
"$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
end
- LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
+ LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L%s'
RPATHFLAG = config_string('RPATHFLAG') || ''
LIBARG = config_string('LIBARG') || '-l%s'
MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main(void) {return 0;}'
Something went wrong with that request. Please try again.