Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 1 | # Copyright 2013, Big Switch Networks, Inc. |
| 2 | # |
| 3 | # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with |
| 4 | # the following special exception: |
| 5 | # |
| 6 | # LOXI Exception |
| 7 | # |
| 8 | # As a special exception to the terms of the EPL, you may distribute libraries |
| 9 | # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided |
| 10 | # that copyright and licensing notices generated by LoxiGen are not altered or removed |
| 11 | # from the LoxiGen Libraries and the notice provided below is (i) included in |
| 12 | # the LoxiGen Libraries, if distributed in source code form and (ii) included in any |
| 13 | # documentation for the LoxiGen Libraries, if distributed in binary form. |
| 14 | # |
| 15 | # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler." |
| 16 | # |
| 17 | # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain |
| 18 | # a copy of the EPL at: |
| 19 | # |
| 20 | # http://www.eclipse.org/legal/epl-v10.html |
| 21 | # |
| 22 | # Unless required by applicable law or agreed to in writing, software |
| 23 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 24 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 25 | # EPL for the specific language governing permissions and limitations |
| 26 | # under the EPL. |
| 27 | |
| 28 | """ |
| 29 | @brief C language specific LOXI generating configuration |
| 30 | |
| 31 | This language specific file defines a dictionary 'targets' that |
| 32 | defines the generated files and the functions used to generate them. |
| 33 | """ |
| 34 | |
| 35 | import os |
Andreas Wundsam | 76db006 | 2013-11-15 13:34:41 -0800 | [diff] [blame] | 36 | import c_gen.of_g_legacy as of_g |
| 37 | import c_gen.build_of_g as build_of_g |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 38 | import c_gen.c_code_gen as c_code_gen |
| 39 | import c_gen.c_test_gen as c_test_gen |
| 40 | import c_gen.c_dump_gen as c_dump_gen |
| 41 | import c_gen.c_show_gen as c_show_gen |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 42 | import c_gen.util |
Rich Lane | bdd8e29 | 2013-12-06 17:37:39 -0800 | [diff] [blame] | 43 | import c_gen.codegen |
Rich Lane | da5446f | 2013-11-10 17:21:48 -0800 | [diff] [blame] | 44 | import loxi_utils.loxi_utils as loxi_utils |
Andreas Wundsam | 76db006 | 2013-11-15 13:34:41 -0800 | [diff] [blame] | 45 | import template_utils |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 46 | |
| 47 | def static(out, name): |
| 48 | c_gen.util.render_template(out, os.path.basename(name)) |
| 49 | |
| 50 | targets = { |
| 51 | # LOCI headers |
| 52 | 'loci/inc/loci/loci.h': c_code_gen.top_h_gen, |
| 53 | 'loci/inc/loci/loci_idents.h': c_code_gen.identifiers_gen, |
| 54 | 'loci/inc/loci/loci_base.h': c_code_gen.base_h_gen, |
| 55 | 'loci/inc/loci/of_match.h': c_code_gen.match_h_gen, |
| 56 | 'loci/inc/loci/loci_doc.h': c_code_gen.gen_accessor_doc, |
| 57 | 'loci/inc/loci/loci_obj_dump.h': c_dump_gen.gen_obj_dump_h, |
| 58 | 'loci/inc/loci/loci_obj_show.h': c_show_gen.gen_obj_show_h, |
Rich Lane | cc32767 | 2014-04-10 13:37:35 -0700 | [diff] [blame] | 59 | 'loci/inc/loci/loci_validator.h': static, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 60 | |
| 61 | # Static LOCI headers |
| 62 | 'loci/inc/loci/bsn_ext.h': static, |
| 63 | 'loci/inc/loci/loci_dox.h': static, |
| 64 | 'loci/inc/loci/loci_dump.h': static, |
| 65 | 'loci/inc/loci/loci_show.h': static, |
| 66 | 'loci/inc/loci/of_buffer.h': static, |
| 67 | 'loci/inc/loci/of_doc.h': static, |
| 68 | 'loci/inc/loci/of_message.h': static, |
| 69 | 'loci/inc/loci/of_object.h': static, |
| 70 | 'loci/inc/loci/of_utils.h': static, |
| 71 | 'loci/inc/loci/of_wire_buf.h': static, |
| 72 | |
| 73 | # LOCI code |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 74 | 'loci/src/of_match.c': c_code_gen.match_c_gen, |
| 75 | 'loci/src/loci_obj_dump.c': c_dump_gen.gen_obj_dump_c, |
| 76 | 'loci/src/loci_obj_show.c': c_show_gen.gen_obj_show_c, |
Rich Lane | cc32767 | 2014-04-10 13:37:35 -0700 | [diff] [blame] | 77 | 'loci/src/loci_validator.c': static, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 78 | |
| 79 | # Static LOCI code |
| 80 | 'loci/src/loci_int.h': static, |
| 81 | 'loci/src/loci_log.c': static, |
| 82 | 'loci/src/loci_log.h': static, |
| 83 | 'loci/src/of_object.c': static, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 84 | 'loci/src/of_utils.c': static, |
| 85 | 'loci/src/of_wire_buf.c': static, |
| 86 | |
| 87 | # Static LOCI documentation |
| 88 | 'loci/README': static, |
| 89 | 'loci/Doxyfile': static, |
| 90 | |
| 91 | # locitest code |
| 92 | 'locitest/inc/locitest/of_dup.h': c_test_gen.dup_h_gen, |
| 93 | 'locitest/inc/locitest/test_common.h': c_test_gen.gen_common_test_header, |
| 94 | 'locitest/src/of_dup.c': c_test_gen.dup_c_gen, |
| 95 | 'locitest/src/test_common.c': c_test_gen.gen_common_test, |
| 96 | 'locitest/src/test_list.c': c_test_gen.gen_list_test, |
| 97 | 'locitest/src/test_match.c': c_test_gen.gen_match_test, |
| 98 | 'locitest/src/test_msg.c': c_test_gen.gen_msg_test, |
| 99 | 'locitest/src/test_scalar_acc.c': c_test_gen.gen_message_scalar_test, |
| 100 | 'locitest/src/test_uni_acc.c': c_test_gen.gen_unified_accessor_tests, |
Rich Lane | ccae031 | 2013-07-21 23:34:13 -0700 | [diff] [blame] | 101 | 'locitest/src/test_data.c': c_test_gen.gen_datafiles_tests, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 102 | |
| 103 | # Static locitest code |
| 104 | 'locitest/inc/locitest/unittest.h': static, |
| 105 | 'locitest/src/test_ext.c': static, |
| 106 | 'locitest/src/test_list_limits.c': static, |
| 107 | 'locitest/src/test_match_utils.c': static, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 108 | 'locitest/src/test_utils.c': static, |
| 109 | 'locitest/src/test_validator.c': static, |
Rich Lane | 99c29c3 | 2013-05-29 17:09:21 -0700 | [diff] [blame] | 110 | 'locitest/src/main.c': static, |
Rich Lane | 9ff6d16 | 2013-07-21 23:32:27 -0700 | [diff] [blame] | 111 | 'locitest/Makefile': static, |
Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 112 | } |
Rich Lane | da5446f | 2013-11-10 17:21:48 -0800 | [diff] [blame] | 113 | |
Andreas Wundsam | 76db006 | 2013-11-15 13:34:41 -0800 | [diff] [blame] | 114 | def generate(install_dir): |
| 115 | build_of_g.initialize_versions() |
| 116 | build_of_g.build_ordered_classes() |
| 117 | build_of_g.populate_type_maps() |
| 118 | build_of_g.analyze_input() |
| 119 | build_of_g.unify_input() |
| 120 | build_of_g.order_and_assign_object_ids() |
Rich Lane | da5446f | 2013-11-10 17:21:48 -0800 | [diff] [blame] | 121 | for (name, fn) in targets.items(): |
Andreas Wundsam | 76db006 | 2013-11-15 13:34:41 -0800 | [diff] [blame] | 122 | with template_utils.open_output(install_dir, name) as outfile: |
Rich Lane | da5446f | 2013-11-10 17:21:48 -0800 | [diff] [blame] | 123 | fn(outfile, os.path.basename(name)) |
Rich Lane | ce2e464 | 2013-12-15 12:05:45 -0800 | [diff] [blame] | 124 | c_gen.codegen.generate_classes(install_dir) |
Rich Lane | 573d2b2 | 2013-12-15 13:31:27 -0800 | [diff] [blame] | 125 | c_gen.codegen.generate_header_classes(install_dir) |
Rich Lane | def2e51 | 2013-12-15 15:54:02 -0800 | [diff] [blame] | 126 | c_gen.codegen.generate_classes_header(install_dir) |
Rich Lane | 8c4c23f | 2013-12-15 13:22:13 -0800 | [diff] [blame] | 127 | c_gen.codegen.generate_lists(install_dir) |
Rich Lane | 8a82273 | 2013-12-15 14:06:32 -0800 | [diff] [blame] | 128 | c_gen.codegen.generate_strings(install_dir) |
Rich Lane | cce961d | 2013-12-15 14:20:42 -0800 | [diff] [blame] | 129 | c_gen.codegen.generate_init_map(install_dir) |
Rich Lane | c0e20ff | 2013-12-15 23:40:31 -0800 | [diff] [blame] | 130 | c_gen.codegen.generate_type_maps(install_dir) |
Rich Lane | dc46fe2 | 2014-04-03 15:10:38 -0700 | [diff] [blame] | 131 | c_gen.codegen.generate_class_metadata(install_dir) |