Develop and Download Open Source Software

Browse CVS Repository

Contents of /exerb/exerbtk/ext/extconf.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Thu Jan 29 00:41:36 2004 UTC (20 years, 2 months ago) by yuya
Branch: MAIN
CVS Tags: snapshot20040204, release002, HEAD
Changes since 1.2: +35 -2 lines
* インポートテーブルの書き換え処理を追加

1
2 #==============================================================================#
3 # $Id: extconf.rb,v 1.2 2004/01/22 21:14:11 yuya Exp $
4 #==============================================================================#
5
6 require 'fileutils'
7
8 #==============================================================================#
9
10 INFILE = 'etklib.in'
11 OUTFILE = 'etklib.so'
12
13 #==============================================================================#
14
15 case RUBY_PLATFORM
16 when 'i386-mswin32'
17 # copy the file.
18 FileUtils.cp(INFILE, OUTFILE)
19 when 'i386-cygwin'
20 # replace filename of ruby's dynamic-library in the import table.
21 sec = 0x00000210 # Raw address of [.rdata] section
22 bin = File.open(INFILE, 'rb') { |file| file.read }
23 name = bin[sec + 0x00000000, 8]
24 size = bin[sec + 0x00000010, 4].unpack('L')[0]
25 addr = bin[sec + 0x00000014, 4].unpack('L')[0]
26
27 raise('invalid section name') unless name == ".rdata\0\0"
28
29 bin[addr, size] = bin[addr, size].sub(/msvcrt-ruby18.dll\0/, "cygruby18.dll\0\0\0\0\0")
30
31 File.open(OUTFILE, 'wb') { |file| file.write(bin) }
32 else
33 raise("[#{RUBY_PLATFORM}] which is your platform is not supported.")
34 end
35
36 #==============================================================================#
37
38 File.open('Makefile', 'w') { |file|
39 file.puts('all: etklib.so')
40 file.puts('etklib.so:')
41 }
42
43 #==============================================================================#
44 #==============================================================================#

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26