-
Notifications
You must be signed in to change notification settings - Fork 47
/
gccx86canadianfix.cc
108 lines (105 loc) · 3.55 KB
/
gccx86canadianfix.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include<fast_io.h>
#include<fast_io_device.h>
#include<string_view>
#include<algorithm>
#include<functional>
using namespace fast_io::io;
int main(int argc,char **argv)
{
if(argc<2)
{
if(argc==0)
{
return 1;
}
perr("Usage:",fast_io::mnp::os_c_str(*argv)," <gcc source directory>\n");
return 1;
}
using namespace ::std::string_view_literals;
constexpr
::std::u8string_view vw(u8R"abc(case $GCC,$host_os in
yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
library_names_spec='$libname.dll.a'
# DLL is installed to $(libdir)/../bin by postinstall_cmds
postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname~
chmod a+x \$dldir/$dlname~
if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
fi'
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
dlpath=$dir/\$dldll~
$RM \$dlpath'
shlibpath_overrides_runpath=yes)abc"sv);
constexpr
::std::u8string_view newvw(u8R"abc(case $GCC,$host_os in
yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
library_names_spec='$libname.dll.a'
# DLL is installed to $(libdir)/../bin by postinstall_cmds
# If user builds GCC with mulitlibs enabled, it should just install on $(libdir)
# not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones.
if test ${multilib} = yes; then
postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
$install_prog $dir/$dlname $destdir/$dlname~
chmod a+x $destdir/$dlname~
if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
eval '\''$striplib $destdir/$dlname'\'' || exit \$?;
fi'
else
postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname~
chmod a+x \$dldir/$dlname~
if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
fi'
fi
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
dlpath=$dir/\$dldll~
$RM \$dlpath'
shlibpath_overrides_runpath=yes)abc"sv);
::std::boyer_moore_horspool_searcher searcher(reinterpret_cast<char const*>(vw.data()),
reinterpret_cast<char const*>(vw.data())+vw.size());
fast_io::dir_file df(fast_io::mnp::os_c_str(argv[1]));
for(auto ent : recursive(at(df)))
{
if(type(ent)!=fast_io::file_type::regular)
{
continue;
}
std::u8string_view fnm_view(u8filename(ent));
if(fnm_view==u8"configure"sv||fnm_view==u8"libtool.m4"sv)
{
{
fast_io::native_file_loader loader(drt(ent));
auto bg{loader.data()};
auto ed{loader.data()+loader.size()};
auto it{std::search(bg,ed,searcher)};
if(it==ed)
{
continue;
}
}
fast_io::allocation_file_loader loader(drt(ent));
fast_io::obuf_file obf(drt(ent));
for(auto it{loader.data()},ed{it+loader.size()};;)
{
auto retit{std::search(it,ed,searcher)};
write(obf,it,retit);
if(retit==ed)
{
break;
}
write(obf,newvw.cbegin(),newvw.cend());
it=retit+vw.size();
}
}
}
}