Permalink
Browse files

More fixes for building 1.9 readline C-ext.

  • Loading branch information...
1 parent 0405396 commit 4ef646f87a014a573f3134a413678140c63b1fb0 @brixen brixen committed Nov 6, 2011
View
28 configure
@@ -855,20 +855,10 @@ int main() { return tgetnum(""); }
end
if @features["C-readline"] and
- if has_function("readline", ["stdio.h", "stdlib.h", "readline/readline.h"])
- @defines << "HAS_READLINE"
- elsif has_function("readline", ["stdio.h", "stdlib.h", "editline/readline.h"])
- @defines << "HAS_EDITLINE"
- end
-
- if has_function("readline", ["stdio.h", "stdlib.h", "readline/history.h"])
- @defines << "HAS_READLINE_HISTORY"
- end
- end
-
- if @features["ruby-readline"] or
- !@defines.include?("HAS_READLINE")
- !@defines.include?("HAS_EDITLINE")
+ (has_function("readline", ["stdio.h", "stdlib.h", "readline/readline.h"]) or
+ has_function("readline", ["stdio.h", "stdlib.h", "editline/readline.h"]))
+ @rb_readline = false
+ elsif @features["ruby-readline"]
@rb_readline = true
end
@@ -1134,16 +1124,6 @@ end
#endif
EOC
- if @defines.include?("HAS_READLINE")
- f.puts "#define HAVE_READLINE_READLINE_H 1"
- elsif @defines.include?("HAS_EDITLINE")
- f.puts "#define HAVE_READLINE_EDITLINE_H 1"
- end
-
- if @defines.include?("HAS_READLINE_HISTORY")
- f.puts "#define HAVE_READLINE_HISTORY_H 1"
- end
-
if @windows
f.puts "#define RBX_WINDOWS 1"
end
View
3 lib/19/readline/.gitignore
@@ -0,0 +1,3 @@
+ext/mkmf.log
+ext/Makefile
+ext/extconf.h
View
29 lib/19/readline/ext/Rakefile
@@ -1,29 +0,0 @@
-require 'rake/loaders/makefile'
-
-# Setup project files
-project_files = common_headers + headers + sources + objects
-
-add_rbx_capi
-
-if ENV["READLINE_DIR"]
- add_include_dir ENV["READLINE_DIR"]
- add_link_dir "#{ENV["READLINE_DIR"]}/lib"
-else
- add_include_dir "/usr/include"
-end
-
-add_shared_lib "readline"
-if lib = Rubinius::BUILD_CONFIG[:curses]
- add_shared_lib lib
-end
-
-readline = "readline.#{$DLEXT}"
-
-file readline => project_files
-
-graph_dependencies sources
-
-import dependency_file
-
-desc "Build Readline extension"
-task :build => readline
View
87 lib/19/readline/ext/extconf.rb
@@ -0,0 +1,87 @@
+require "mkmf"
+
+$readline_headers = ["stdio.h"]
+
+def have_readline_header(header)
+ if have_header(header)
+ $readline_headers.push(header)
+ return true
+ else
+ return false
+ end
+end
+
+def have_readline_var(var)
+ return have_var(var, $readline_headers)
+end
+
+def have_readline_func(func)
+ return have_func(func, $readline_headers)
+end
+
+def have_readline_macro(macro)
+ return have_macro(macro, $readline_headers)
+end
+
+dir_config('curses')
+dir_config('ncurses')
+dir_config('termcap')
+dir_config("readline")
+enable_libedit = enable_config("libedit")
+have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
+have_library("ncurses", "tgetnum") ||
+ have_library("termcap", "tgetnum") ||
+ have_library("curses", "tgetnum")
+
+if enable_libedit
+ unless (have_readline_header("editline/readline.h") ||
+ have_readline_header("readline/readline.h")) &&
+ have_library("edit", "readline")
+ exit
+ end
+else
+ unless ((have_readline_header("readline/readline.h") &&
+ have_readline_header("readline/history.h")) &&
+ (have_library("readline", "readline") ||
+ have_library("edit", "readline"))) ||
+ (have_readline_header("editline/readline.h") &&
+ have_library("edit", "readline"))
+ exit
+ end
+end
+
+have_readline_func("rl_getc_function")
+have_readline_func("rl_filename_completion_function")
+have_readline_func("rl_username_completion_function")
+have_readline_func("rl_completion_matches")
+have_readline_func("rl_refresh_line")
+have_readline_var("rl_deprep_term_function")
+have_readline_var("rl_completion_append_character")
+have_readline_var("rl_basic_word_break_characters")
+have_readline_var("rl_completer_word_break_characters")
+have_readline_var("rl_basic_quote_characters")
+have_readline_var("rl_completer_quote_characters")
+have_readline_var("rl_filename_quote_characters")
+have_readline_var("rl_attempted_completion_over")
+have_readline_var("rl_library_version")
+have_readline_var("rl_editing_mode")
+have_readline_var("rl_line_buffer")
+have_readline_var("rl_point")
+# workaround for native windows.
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_event_hook")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_sigwinch")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_signals")
+have_readline_func("rl_cleanup_after_signal")
+have_readline_func("rl_clear_signals")
+have_readline_func("rl_set_screen_size")
+have_readline_func("rl_get_screen_size")
+have_readline_func("rl_vi_editing_mode")
+have_readline_func("rl_emacs_editing_mode")
+have_readline_func("replace_history_entry")
+have_readline_func("remove_history")
+have_readline_func("clear_history")
+have_readline_macro("RL_PROMPT_START_IGNORE")
+have_readline_macro("RL_PROMPT_END_IGNORE")
+
+create_header
+create_makefile("readline")
View
4 lib/19/readline/ext/readline.c
@@ -126,7 +126,7 @@ readline_getc(FILE *input)
VALUE c;
if (!readline_instream) return rl_getc(input);
GetOpenFile(readline_instream, ifp);
- if (rl_instream != ifp->stdio_file) return rl_getc(input);
+ if (rl_instream != rb_io_stdio_file(ifp)) return rl_getc(input);
c = rb_funcall(readline_instream, id_getbyte, 0, 0);
if (NIL_P(c)) return EOF;
return NUM2CHR(c);
@@ -1167,11 +1167,13 @@ hist_to_s(VALUE self)
return rb_str_new_cstr("HISTORY");
}
+#ifdef HAVE_READLINE_HISTORY_H
static int
history_get_offset_history_base(int offset)
{
return history_base + offset;
}
+#endif
static int
history_get_offset_0(int offset)
View
6 rakelib/extensions.rake
@@ -51,6 +51,8 @@ def build_extconf(name, opts)
ENV["CFLAGS"] = "-I#{include18_dir} -I#{include19_dir}"
end
+ ENV["RBXOPT"] = opts[:env] if opts.key? :env
+
unless opts[:deps] and opts[:deps].all? { |n| File.exists? n }
sh("#{rbx_build} extconf.rb #{redirect}", &fail_block)
end
@@ -122,7 +124,9 @@ compile_ext "nkf"
if BUILD_CONFIG[:defines].include? "HAS_READLINE"
compile_ext "readline", :dir => "lib/18/readline/ext"
- compile_ext "readline", :dir => "lib/19/readline/ext"
+ compile_ext "readline", :dir => "lib/19/readline/ext",
+ :deps => ["Makefile", "extconf.rb"],
+ :env => "-X19"
end
# rbx must be able to run to build these because they use

0 comments on commit 4ef646f

Please sign in to comment.