[vala/wip/vapicheck: 3/4] WIP Direct parse and compile checking




commit c8560036c5ba9888cab703294cacaf2950a297fe
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Jan 29 18:30:39 2021 +0100

    WIP Direct parse and compile checking

 vapigen/Makefile.am        | 39 +++++++++++++++++++++++++--------------
 vapigen/valavapicheck.vala | 44 ++++++++++++++++++++++----------------------
 2 files changed, 47 insertions(+), 36 deletions(-)
---
diff --git a/vapigen/Makefile.am b/vapigen/Makefile.am
index cdeab3ffd..673fe448f 100644
--- a/vapigen/Makefile.am
+++ b/vapigen/Makefile.am
@@ -6,16 +6,6 @@ SUBDIRS = \
        vala-gen-introspect \
        $(NULL)
 
-AM_CPPFLAGS = \
-       -DG_LOG_DOMAIN=\"vapigen\" \
-       $(COVERAGE_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       -I$(top_srcdir)/gee \
-       -I$(top_srcdir)/ccode \
-       -I$(top_srcdir)/vala \
-       -I$(top_srcdir)/gobject-introspection \
-       $(NULL)
-
 bin_PROGRAMS = \
        vapigen \
        $(NULL)
@@ -64,13 +54,22 @@ vapicheck.vala.stamp: $(vapicheck_VALASOURCES)
                $(VALAFLAGS) \
                -C \
                --vapidir $(top_srcdir)/vapi \
-               --vapidir $(top_srcdir)/gee --pkg gee \
-               --vapidir $(top_srcdir)/vala --pkg vala \
-               --vapidir $(top_srcdir)/gobject-introspection --pkg gidl \
+               --vapidir $(top_srcdir)/vala --pkg libvala@PACKAGE_SUFFIX@ \
+               --vapidir $(top_srcdir)/ccode --pkg ccode \
+               --vapidir $(top_srcdir)/codegen --pkg codegen \
                --pkg config \
                $^
        @touch $@
 
+vapigen_CPPFLAGS = \
+       -DG_LOG_DOMAIN=\"vapigen\" \
+       $(COVERAGE_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       -I$(top_srcdir)/gee \
+       -I$(top_srcdir)/vala \
+       -I$(top_srcdir)/gobject-introspection \
+       $(NULL)
+
 vapigen_LDADD = \
        $(COVERAGE_LIBS) \
        $(GLIB_LIBS) \
@@ -78,11 +77,23 @@ vapigen_LDADD = \
        $(top_builddir)/gobject-introspection/libgidl.la \
        $(NULL)
 
+vapicheck_CPPFLAGS = \
+       -DG_LOG_DOMAIN=\"vapicheck\" \
+       $(COVERAGE_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       -I$(top_srcdir)/gee \
+       -I$(top_srcdir)/vala \
+       -I$(top_srcdir)/ccode \
+       -I$(top_srcdir)/vala \
+       -I$(top_srcdir)/codegen \
+       $(NULL)
+
 vapicheck_LDADD = \
        $(COVERAGE_LIBS) \
        $(GLIB_LIBS) \
        $(top_builddir)/vala/libvala@PACKAGE_SUFFIX@.la \
-       $(top_builddir)/gobject-introspection/libgidl.la \
+       $(top_builddir)/ccode/libvalaccode.la \
+       $(top_builddir)/codegen/libvalaccodegen.la \
        $(NULL)
 
 if ENABLE_UNVERSIONED
diff --git a/vapigen/valavapicheck.vala b/vapigen/valavapicheck.vala
index 45833d7c0..83b0fa396 100644
--- a/vapigen/valavapicheck.vala
+++ b/vapigen/valavapicheck.vala
@@ -390,6 +390,15 @@ class Vala.VapiCheck {
                        return quit ();
                }
 
+               var codegen = new Codegen ();
+               foreach (SourceFile file in context.get_source_files ()) {
+                       if (file.filename != source_filename) {
+                               continue;
+                       }
+                       codegen.run (context, file);
+                       break;
+               }
+
                if (fast_vapi_filename != null) {
                        var interface_writer = new CodeWriter (CodeWriterType.FAST);
                        interface_writer.write_file (context, fast_vapi_filename);
@@ -409,15 +418,6 @@ class Vala.VapiCheck {
                        }
                }
 
-               var codegen = new Codegen ();
-               foreach (SourceFile file in context.get_source_files ()) {
-                       if (file.filename != source_filename) {
-                               continue;
-                       }
-                       codegen.run (context, file);
-                       break;
-               }
-
                if (dump_tree != null) {
                        var code_writer = new CodeWriter (CodeWriterType.DUMP);
                        code_writer.write_file (context, dump_tree);
@@ -427,7 +427,7 @@ class Vala.VapiCheck {
                        return quit ();
                }
 
-               //context.codegen.emit (context);
+               context.codegen.emit (context);
 
                if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 
0)) {
                        return quit ();
@@ -532,14 +532,14 @@ class Vala.VapiCheck {
                }
                
                if (!ccode_only) {
-                       //var ccompiler = new CCodeCompiler ();
+                       var ccompiler = new CCodeCompiler ();
                        if (cc_command == null && Environment.get_variable ("CC") != null) {
                                cc_command = Environment.get_variable ("CC");
                        }
                        if (cc_options == null) {
-                               //ccompiler.compile (context, cc_command, new string[] { });
+                               ccompiler.compile (context, cc_command, new string[] { });
                        } else {
-                               //ccompiler.compile (context, cc_command, cc_options);
+                               ccompiler.compile (context, cc_command, cc_options);
                        }
                }
 
@@ -611,7 +611,7 @@ public class Codegen : Vala.CodeVisitor {
                b.add_statement (decl);
                block.add_statement (b);
 
-               b.check (context);
+               //b.check (context);
                current_block = b;
                element.accept_children (this);
        }
@@ -628,7 +628,7 @@ public class Codegen : Vala.CodeVisitor {
                b.add_statement (decl);
                block.add_statement (b);
 
-               b.check (context);
+               //b.check (context);
                current_block = b;
                element.accept_children (this);
        }
@@ -650,7 +650,7 @@ public class Codegen : Vala.CodeVisitor {
                b.add_statement (decl);
                block.add_statement (b);
 
-               b.check (context);
+               //b.check (context);
                current_block = b;
                element.accept_children (this);
        }
@@ -671,7 +671,7 @@ public class Codegen : Vala.CodeVisitor {
                }
 
                current_block.add_statement (b);
-               current_block.check (context);
+               //current_block.check (context);
        }
 
        public override void visit_property (Vala.Property element) {
@@ -711,7 +711,7 @@ public class Codegen : Vala.CodeVisitor {
 
                var stmt = new ExpressionStatement (mcall);
                b.add_statement (stmt);
-               b.check (context);
+               //b.check (context);
                block.add_statement (b);
        }
 
@@ -772,7 +772,7 @@ public class Codegen : Vala.CodeVisitor {
                        b.add_statement (new ExpressionStatement (mcall));
                }
 
-               b.check (context);
+               //b.check (context);
                block.add_statement (b);
        }
 
@@ -804,7 +804,7 @@ public class Codegen : Vala.CodeVisitor {
                append_arguments (b, mcall, parameters, ref i);
                b.add_statement (new ExpressionStatement (mcall));
 
-               b.check (context);
+               //b.check (context);
                block.add_statement (b);
        }
 
@@ -820,7 +820,7 @@ public class Codegen : Vala.CodeVisitor {
                var b = new Block ();
                var decl = new DeclarationStatement (new LocalVariable (new VarType (false), "v", 
get_member_access (element), element.source_reference));
                b.add_statement (decl);
-               b.check (context);
+               //b.check (context);
 
                var assert = new MethodCall (new MemberAccess (null, "assert"));
                assert.add_argument (new BinaryExpression (BinaryOperator.EQUALITY, new MemberAccess (null, 
"v"), get_member_access (element)));
@@ -837,7 +837,7 @@ public class Codegen : Vala.CodeVisitor {
                var b = new Block ();
                var decl = new DeclarationStatement (new LocalVariable (get_local_type 
(element.type_reference), "v", get_member_access (element), element.source_reference));
                b.add_statement (decl);
-               b.check (context);
+               //b.check (context);
 
                var assert = new MethodCall (new MemberAccess (null, "assert"));
                assert.add_argument (new BinaryExpression (BinaryOperator.EQUALITY, new MemberAccess (null, 
"v"), get_member_access (element)));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]