mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 09:00:54 +00:00
idk what i did
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@446 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#!/usr/bin/env perl
|
||||
# $Id$
|
||||
|
||||
my @cfiles = ();
|
||||
my @cxxfiles = ();
|
||||
my @cfiles = ();
|
||||
|
||||
sub scan {
|
||||
opendir(DIR, $_[0]);
|
||||
my @files = readdir(DIR);
|
||||
foreach my $f (@files) {
|
||||
if ($f =~ /^vulkan\.cc?$/) {
|
||||
if ($f =~ /^vulkan\.c$/) {
|
||||
next;
|
||||
}
|
||||
if ($f =~ /\.c$/) {
|
||||
push(@cfiles, $_[0] . "/" . $f);
|
||||
}
|
||||
elsif ($f =~ /\.cc$/) {
|
||||
push(@cxxfiles, $_[0] . "/" . $f);
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
@@ -25,19 +21,7 @@ sub cobjs {
|
||||
my $r = "";
|
||||
foreach my $f (@cfiles) {
|
||||
my $b = $f;
|
||||
$b =~ s/\.cc?$/.obj/;
|
||||
$b =~ s/\//$_[0]/g;
|
||||
|
||||
$r = $r . " " . $_[1] . $b;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
sub cxxobjs {
|
||||
my $r = "";
|
||||
foreach my $f (@cxxfiles) {
|
||||
my $b = $f;
|
||||
$b =~ s/\.cc?$/.obj/;
|
||||
$b =~ s/\.c$/.obj/;
|
||||
$b =~ s/\//$_[0]/g;
|
||||
|
||||
$r = $r . " " . $_[1] . $b;
|
||||
@@ -49,29 +33,25 @@ sub generate {
|
||||
my ($output, $type) = @_;
|
||||
|
||||
my $cc = "";
|
||||
my $cxx = "";
|
||||
my $link = "";
|
||||
|
||||
my $suffix = 1;
|
||||
my $symbolic = "";
|
||||
my $dir = "\\";
|
||||
my $del = "del /f /q";
|
||||
my $out = "";
|
||||
my $dllout = "";
|
||||
my $def = "";
|
||||
my $inc = "";
|
||||
my $dll = "";
|
||||
my $prefobj = "";
|
||||
my $needlibs = "";
|
||||
my $lib = "";
|
||||
my $c_dllout = "";
|
||||
my $cxx_dllout = "";
|
||||
my $c_dllafter = "";
|
||||
my $cxx_dllafter = "";
|
||||
my $suffix = 1;
|
||||
my $symbolic = "";
|
||||
my $dir = "\\";
|
||||
my $del = "del /f /q";
|
||||
my $out = "";
|
||||
my $dllout = "";
|
||||
my $def = "";
|
||||
my $inc = "";
|
||||
my $dll = "";
|
||||
my $prefobj = "";
|
||||
my $needlibs = "";
|
||||
my $lib = "";
|
||||
my $c_dllout = "";
|
||||
my $c_dllafter = "";
|
||||
|
||||
if ($type eq "Borland") {
|
||||
$cc = "bcc32 -c";
|
||||
$cxx = "bcc32 -c -P";
|
||||
$link = "bcc32";
|
||||
$out = "-o";
|
||||
$dllout = "-e";
|
||||
@@ -80,12 +60,10 @@ sub generate {
|
||||
$dll = "-tWD";
|
||||
$lib = "-l";
|
||||
|
||||
$c_dllafter = "implib src${dir}Mw.lib src${dir}Mw.dll";
|
||||
$cxx_dllafter = "implib oosrc${dir}MwOO.lib oosrc${dir}MwOO.dll";
|
||||
$c_dllafter = "implib src${dir}Mw.lib src${dir}Mw.dll";
|
||||
}
|
||||
elsif ($type eq "MSVC") {
|
||||
$cc = "cl /TC /c /nologo";
|
||||
$cxx = "cl /TP /c /nologo";
|
||||
$link = "link /nologo";
|
||||
$out = "/Fo";
|
||||
$dllout = "/OUT:";
|
||||
@@ -95,7 +73,6 @@ sub generate {
|
||||
}
|
||||
elsif ($type eq "Watcom") {
|
||||
$cc = "wcc386 -bt=nt -q";
|
||||
$cxx = "wpp386 -bt=nt -q";
|
||||
$link = "wlink option quiet";
|
||||
$out = "-fo=";
|
||||
$dllout = "name ";
|
||||
@@ -110,42 +87,38 @@ sub generate {
|
||||
$del = "%erase";
|
||||
$prefobj = "file ";
|
||||
$needlibs = "${lib}clib3r.lib";
|
||||
$c_dllout = "option implib=src${dir}Mw.lib";
|
||||
$cxx_dllout = "option implib=oosrc${dir}MwOO.lib";
|
||||
$c_dllout = "option implib=src${dir}Mw.lib";
|
||||
}
|
||||
|
||||
open(OUT, ">", $output);
|
||||
print(OUT "# \$Id\$\n");
|
||||
print(OUT "CC = $cc\n");
|
||||
print(OUT "CXX = $cxx\n");
|
||||
print(OUT "LD = $link\n");
|
||||
print(OUT "\n");
|
||||
print(OUT
|
||||
"CFLAGS = ${inc}include ${def}_MILSKO ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD\n"
|
||||
);
|
||||
print(OUT "CXXFLAGS = ${inc}include\n");
|
||||
print(OUT "LDFLAGS = $dll");
|
||||
print(OUT "\n");
|
||||
|
||||
if ($suffix) {
|
||||
print(OUT ".SUFFIXES: .obj .c .cc\n");
|
||||
print(OUT ".SUFFIXES: .obj .c\n");
|
||||
}
|
||||
print(OUT "all: src${dir}Mw.dll oosrc${dir}MwOO.dll\n");
|
||||
print(OUT "all: src${dir}Mw.dll\n");
|
||||
print(OUT "clean: $symbolic\n");
|
||||
foreach my $f (@cfiles) {
|
||||
my $b = $f;
|
||||
$b =~ s/\.cc?$/.obj/;
|
||||
$b =~ s/\.c$/.obj/;
|
||||
$b =~ s/\//$dir/g;
|
||||
print(OUT " $del $b\n");
|
||||
}
|
||||
foreach my $f (@cxxfiles) {
|
||||
my $b = $f;
|
||||
$b =~ s/\.cc?$/.obj/;
|
||||
$b =~ s/\.c$/.obj/;
|
||||
$b =~ s/\//$dir/g;
|
||||
print(OUT " $del $b\n");
|
||||
}
|
||||
print(OUT " $del src${dir}Mw.dll\n");
|
||||
print(OUT " $del oosrc${dir}MwOO.dll\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "src${dir}Mw.dll: " . cobjs($dir) . "\n");
|
||||
print( OUT " \$(LD) \$(LDFLAGS) $c_dllout $dllout\$@ "
|
||||
@@ -153,33 +126,19 @@ sub generate {
|
||||
. " $needlibs ${lib}opengl32.lib ${lib}gdi32.lib ${lib}user32.lib\n");
|
||||
print(OUT " $c_dllafter\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "oosrc${dir}MwOO.dll: " . cxxobjs($dir) . "\n");
|
||||
print( OUT " \$(LD) \$(LDFLAGS) $cxx_dllout $dllout\$@ "
|
||||
. cxxobjs($dir, $prefobj)
|
||||
. " $needlibs ${lib}src${dir}Mw.lib\n");
|
||||
print(OUT " $cxx_dllafter\n");
|
||||
print(OUT "\n");
|
||||
|
||||
if ($suffix) {
|
||||
print(OUT ".c.obj:\n");
|
||||
print(OUT " \$(CC) \$(CFLAGS) ${out}\$@ \$<\n");
|
||||
print(OUT ".cc.obj:\n");
|
||||
print(OUT " \$(CXX) \$(CXXFLAGS) ${out}\$@ \$<\n");
|
||||
}
|
||||
else {
|
||||
print(OUT "\n");
|
||||
foreach my $f (@cfiles) {
|
||||
my $o = $f;
|
||||
$o =~ s/\.cc?$/.obj/;
|
||||
$o =~ s/\.c$/.obj/;
|
||||
print(OUT "$o: $f\n");
|
||||
print(OUT " \$(CC) \$(CFLAGS) ${out}\$@ \$<\n");
|
||||
}
|
||||
foreach my $f (@cxxfiles) {
|
||||
my $o = $f;
|
||||
$o =~ s/\.cc?$/.obj/;
|
||||
print(OUT "$o: $f\n");
|
||||
print(OUT " \$(CXX) \$(CXXFLAGS) ${out}\$@ \$<\n");
|
||||
}
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
@@ -191,9 +150,6 @@ scan("src/cursor");
|
||||
scan("src/widget");
|
||||
push(@cfiles, "src/backend/gdi.c");
|
||||
|
||||
scan("oosrc");
|
||||
scan("oosrc/widget");
|
||||
|
||||
generate("BorMakefile", "Borland");
|
||||
generate("NTMakefile", "MSVC");
|
||||
generate("WatMakefile", "Watcom");
|
||||
|
||||
328
tools/genoo.pl
328
tools/genoo.pl
@@ -1,328 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# $Id$
|
||||
|
||||
my $objs = "";
|
||||
|
||||
my $decl = "";
|
||||
my @calls = ();
|
||||
my %ints = ();
|
||||
my %texts = ();
|
||||
my %voids = ();
|
||||
open(IN, "<", "include/Mw/StringDefs.h");
|
||||
while (my $hl = <IN>) {
|
||||
$hl =~ s/\r?\n$//;
|
||||
if ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"C(.+)"$/) {
|
||||
my $name = "On" . uc(substr($2, 0, 1)) . substr($2, 1);
|
||||
my @c = ($1, $name);
|
||||
|
||||
$decl = $decl . " virtual void " . $name . "(void*){};\n";
|
||||
|
||||
push(@calls, [@c]);
|
||||
}
|
||||
elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"I(.+)"$/) {
|
||||
$ints{$1} = uc(substr($2, 0, 1)) . substr($2, 1);
|
||||
}
|
||||
elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"S(.+)"$/) {
|
||||
$texts{$1} = uc(substr($2, 0, 1)) . substr($2, 1);
|
||||
}
|
||||
elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"V(.+)"$/) {
|
||||
$voids{$1} = uc(substr($2, 0, 1)) . substr($2, 1);
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
|
||||
opendir(DIR, "include/Mw/Widget");
|
||||
my @files = readdir(DIR);
|
||||
foreach my $f (@files) {
|
||||
if ($f eq '.' || $f eq '..') {
|
||||
next;
|
||||
}
|
||||
|
||||
$f =~ /^(.+)\.h$/;
|
||||
|
||||
my $name = $1;
|
||||
my @props = ();
|
||||
my @methods = ();
|
||||
my @omethods = ();
|
||||
my @comments = ();
|
||||
my @names = ();
|
||||
my @args = ();
|
||||
|
||||
open(IN, "include/Mw/Widget/$f");
|
||||
while (my $l = <IN>) {
|
||||
$l =~ s/\r?\n$//g;
|
||||
|
||||
if ($l =~ /%prop[ \t]+(.+)$/) {
|
||||
@props = split(/[ \t]+/, $1);
|
||||
}
|
||||
elsif ($l =~
|
||||
/^(?:MWDECL|MwInline)[ \t]+(.+)[ \t]+Mw${name}([^ \t]+)[ \t]*\([^,\)]+(?:,(.*))?\)(?:;|[ \t]+\{)(?: \/\*(.+))?$/
|
||||
)
|
||||
{
|
||||
my $arg = $3;
|
||||
my $ret = $1;
|
||||
my $nam = $2;
|
||||
my $com = $4;
|
||||
|
||||
$arg =~ s/^[ \t]+//;
|
||||
$arg =~ s/[ \t]+$//;
|
||||
|
||||
if (!$arg) {
|
||||
$arg = "void";
|
||||
}
|
||||
|
||||
push(@methods, "$ret $nam($arg)");
|
||||
push(@omethods, "$ret MwOO::${name}::$nam($arg)");
|
||||
push(@names, $nam);
|
||||
push(@comments, $com);
|
||||
|
||||
my @al = split(/[ \t]*,[ \t]*/, $arg);
|
||||
my $i = 0;
|
||||
foreach my $dummy (@al) {
|
||||
$al[$i] =~ s/^.+[ \t]+([^ \t]+)$/\1/g;
|
||||
$i++;
|
||||
}
|
||||
|
||||
push(@args, join(", ", @al));
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
|
||||
push(@props, "MwNbackground");
|
||||
push(@props, "MwNforeground");
|
||||
|
||||
open(OUT, ">", "include/MwOO/Widget/$f");
|
||||
print(OUT "/* \$Id\$ */\n");
|
||||
print(OUT "#ifndef __MWOO_WIDGET_" . uc($name) . "_H__\n");
|
||||
print(OUT "#define __MWOO_WIDGET_" . uc($name) . "_H__\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "#include <MwOO/Base.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "namespace MwOO {\n");
|
||||
print(OUT " class ${name} : public MwOO::Base {\n");
|
||||
print(OUT " public:\n");
|
||||
print(OUT
|
||||
" ${name}(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);\n"
|
||||
);
|
||||
|
||||
foreach my $m (@methods) {
|
||||
if ($m =~ /^MwWidget[ \t]+/) {
|
||||
my $l = $m;
|
||||
$l =~ s/^MwWidget([ \t]+)/MwOO::Base\1/g;
|
||||
print(OUT " $l;\n");
|
||||
}
|
||||
else {
|
||||
print(OUT " $m;\n");
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $prop (@props) {
|
||||
my $type = "";
|
||||
my %hash = ();
|
||||
if (defined($ints{$prop})) {
|
||||
$type = "int";
|
||||
%hash = %ints;
|
||||
}
|
||||
elsif (defined($texts{$prop})) {
|
||||
$type = "const char*";
|
||||
%hash = %texts;
|
||||
}
|
||||
elsif (defined($voids{$prop})) {
|
||||
$type = "void*";
|
||||
%hash = %voids;
|
||||
}
|
||||
if (length($type) > 0) {
|
||||
print(OUT " void Set" . $hash{$prop} . "($type value);\n");
|
||||
print(OUT " $type Get" . $hash{$prop} . "(void);\n");
|
||||
}
|
||||
}
|
||||
print(OUT " };\n");
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "#endif\n");
|
||||
close(OUT);
|
||||
|
||||
open(OUT, ">", "oosrc/widget/" . lc($name) . ".cc");
|
||||
print(OUT "/* \$Id\$ */\n");
|
||||
print(OUT "#include <MwOO/Widget/$name.h>\n");
|
||||
print(OUT "#include <Mw/Widget/$name.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT
|
||||
"MwOO::${name}::${name}(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(Mw${name}Class, widget_name, parent, x, y, w, h){\n"
|
||||
);
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
|
||||
my $i = 0;
|
||||
foreach my $m (@omethods) {
|
||||
my $end = "";
|
||||
my $suffix = "";
|
||||
if ($m =~ /^MwWidget[ \t]+/) {
|
||||
my $l = $m;
|
||||
$l =~ s/^MwWidget([ \t]+)/MwOO::Base\1/;
|
||||
print(OUT "$l\{\n");
|
||||
}
|
||||
else {
|
||||
print(OUT "$m\{\n");
|
||||
}
|
||||
if ($args[$i] =~ /\.\.\./) {
|
||||
print(OUT " va_list va;\n");
|
||||
}
|
||||
if (!($m =~ /^void[ \t]+/)) {
|
||||
my $rettype = $m;
|
||||
$rettype =~ s/^MwWidget([ \t]+)/MwOO::Base\1/;
|
||||
$rettype =~ s/ MwOO::.+\)$//;
|
||||
print(OUT " $rettype ret;\n");
|
||||
}
|
||||
if ($args[$i] =~ /\.\.\./) {
|
||||
my $p = $comments[$i];
|
||||
$p =~ /VA_HINT:([^ ]+)/;
|
||||
print(OUT " va_start(va, $1);\n");
|
||||
$suffix = "Va";
|
||||
}
|
||||
if ($m =~ /^void[ \t]+/) {
|
||||
print(OUT " Mw${name}$suffix" . $names[$i]);
|
||||
}
|
||||
elsif ($m =~ /^MwWidget[ \t]+/) {
|
||||
print(OUT " ret = MwOO::Base(Mw${name}$suffix" . $names[$i]);
|
||||
$end = ")";
|
||||
}
|
||||
else {
|
||||
print(OUT " ret = Mw${name}$suffix" . $names[$i]);
|
||||
}
|
||||
if ($args[$i] eq "void") {
|
||||
print(OUT "(this->widget)$end;\n");
|
||||
}
|
||||
else {
|
||||
my $p = $args[$i];
|
||||
$p =~ s/\.\.\./va/;
|
||||
print(OUT "(this->widget, " . $p . ")$end;\n");
|
||||
}
|
||||
if ($args[$i] =~ /\.\.\./) {
|
||||
print(OUT " va_end(va);\n");
|
||||
}
|
||||
if (!($m =~ /^void[ \t]+/)) {
|
||||
print(OUT " return ret;\n");
|
||||
}
|
||||
print(OUT "}\n\n");
|
||||
$i++;
|
||||
}
|
||||
foreach my $prop (@props) {
|
||||
my $type = "";
|
||||
my $typename = "";
|
||||
my %hash = ();
|
||||
if (defined($ints{$prop})) {
|
||||
$type = "int";
|
||||
$typename = "Integer";
|
||||
%hash = %ints;
|
||||
}
|
||||
elsif (defined($texts{$prop})) {
|
||||
$type = "const char*";
|
||||
$typename = "Text";
|
||||
%hash = %texts;
|
||||
}
|
||||
elsif (defined($voids{$prop})) {
|
||||
$type = "void*";
|
||||
$typename = "Void";
|
||||
%hash = %voids;
|
||||
}
|
||||
if (length($type) > 0) {
|
||||
print( OUT "void MwOO::${name}::Set"
|
||||
. $hash{$prop}
|
||||
. "($type value){\n");
|
||||
print(OUT " MwSet$typename(this->widget, $prop, value);\n");
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "$type MwOO::${name}::Get" . $hash{$prop} . "(void){\n");
|
||||
print(OUT " return MwGet$typename(this->widget, $prop);\n");
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
}
|
||||
}
|
||||
close(OUT);
|
||||
|
||||
if (!($name eq 'Vulkan' || $name eq 'OpenGL')) {
|
||||
$objs = $objs . " oosrc/widget/" . lc($name) . ".o";
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
|
||||
open(OUT, ">", "oosrc/deps.mk");
|
||||
print(OUT "# \$Id\$\n");
|
||||
print(OUT "OOL_OBJS +=$objs\n");
|
||||
close(OUT);
|
||||
|
||||
my $base_h = "";
|
||||
my $skip = 0;
|
||||
|
||||
open(IN, "<", "include/MwOO/Base.h");
|
||||
while (my $l = <IN>) {
|
||||
$l =~ s/\r?\n$//;
|
||||
if ($l =~ /BEGIN AUTOGENERATE/) {
|
||||
$base_h = $base_h . "/* BEGIN AUTOGENERATE */\n";
|
||||
$skip = 1;
|
||||
$base_h = $base_h . $decl . "\n";
|
||||
}
|
||||
elsif ($l =~ /END AUTOGENERATE/) {
|
||||
$base_h = $base_h . "/* END AUTOGENERATE */\n";
|
||||
$skip = 0;
|
||||
}
|
||||
elsif (!$skip) {
|
||||
$base_h = $base_h . $l . "\n";
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
|
||||
open(OUT, ">", "include/MwOO/Base.h");
|
||||
print(OUT "$base_h");
|
||||
close(OUT);
|
||||
|
||||
my $base_c = "";
|
||||
my $skip = 0;
|
||||
|
||||
open(IN, "<", "oosrc/base.cc");
|
||||
while (my $l = <IN>) {
|
||||
$l =~ s/\r?\n$//;
|
||||
if ($l =~ /BEGIN AUTOGENERATE/) {
|
||||
$base_c = $base_c . "/* BEGIN AUTOGENERATE */\n";
|
||||
$skip = 1;
|
||||
|
||||
foreach my $call (@calls) {
|
||||
my @c = @{$call};
|
||||
$base_c =
|
||||
$base_c
|
||||
. "static void __"
|
||||
. $c[1]
|
||||
. "(MwWidget widget, void* user, void* call){\n";
|
||||
$base_c = $base_c . " MwOO::Base* c = (MwOO::Base*)user;\n";
|
||||
$base_c = $base_c . " (void)widget;";
|
||||
$base_c = $base_c . " c->" . $c[1] . "(call);\n";
|
||||
$base_c = $base_c . "}\n";
|
||||
}
|
||||
$base_c = $base_c . "\n";
|
||||
|
||||
$base_c = $base_c . "void MwOO::Base::SetHandler(void){\n";
|
||||
foreach my $call (@calls) {
|
||||
my @c = @{$call};
|
||||
$base_c =
|
||||
$base_c
|
||||
. " MwAddUserHandler(this->widget, "
|
||||
. $c[0] . ", __"
|
||||
. $c[1]
|
||||
. ", this);\n";
|
||||
}
|
||||
$base_c = $base_c . "}\n";
|
||||
}
|
||||
elsif ($l =~ /END AUTOGENERATE/) {
|
||||
$base_c = $base_c . "/* END AUTOGENERATE */\n";
|
||||
$skip = 0;
|
||||
}
|
||||
elsif (!$skip) {
|
||||
$base_c = $base_c . $l . "\n";
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
|
||||
open(OUT, ">", "oosrc/base.cc");
|
||||
print(OUT "$base_c");
|
||||
close(OUT);
|
||||
@@ -6,6 +6,5 @@ if which gmake >/dev/null 2>&1; then
|
||||
fi
|
||||
./tools/doc.pl
|
||||
./tools/icon.sh
|
||||
./tools/genoo.pl
|
||||
./tools/genmk.pl
|
||||
$MAKE format
|
||||
|
||||
Reference in New Issue
Block a user