Commit Graph

22 Commits

Author SHA1 Message Date
Dylan Baker 492d8e90ad templates: use common classes for remaining languages
These all break down into either a single file or a file + header. This
means a little more customization per class, but not too much.
2023-07-25 15:50:21 -04:00
Dylan Baker 5449d10f01 templates: use a common template for C# and Java
The only real differences between these generators is the file extension
and the templates themselves. We can uses a shared abstract class
with a few abstract properties to provide all of this to the same base
class. This results in less code duplication and easier maintanence.

I've made a few cleanups to the shared template:
- use `str.capitalize()` instead of `str.upper()[0] + str[1:]`
- use `open` as a context manager
- use f-strings
- put some duplicate calculations in the initializer
2023-07-25 15:50:21 -04:00
Dylan Baker 65a0cd127e templates: fix typo in function name `sameple` -> `sample` 2023-07-25 15:50:21 -04:00
Dylan Baker d0729bde02 templates: move initializer to base class
Every class implements the exact same initializer, simplify this by
putting it in the base class initializer
2023-07-25 15:50:21 -04:00
Dylan Baker 3fdc877e8a templates/samplefactory: move type checking only import to special block
Don't import things we don't actually need at runtime
2023-07-25 15:50:21 -04:00
Dylan Baker b0cd88ceae minit: use a Protocol for arguments
Which gives better type hinting. It also points out that we're changing
the type of sourcefiles. That's now fixed
2023-07-25 15:50:21 -04:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Zihua Wu 3a4aa109b4 Fix a typo in the CUDA template
The original version will output something like `xtakes no arguments`, and the modified version will correctly output `x takes no arguments`.
2022-11-17 10:25:29 -08:00
Eli Schwartz 3990dc6d64 flake8: fix indentation style 2022-01-27 10:48:01 -08:00
Alberto Fanjul 05e0712f59 Add vala template 2021-11-16 22:25:14 -05:00
Eli Schwartz 59d4f771d2
editorconfig: add setting to trim trailing whitespace
and clean up all outstanding issues

Skip 'test cases/common/141 special characters/meson.build' since it
intentionally uses trailing newlines.
2021-08-15 09:36:18 -04:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Daniel Mensinger 1b19822a2d
typing: Fix templates 2020-09-08 20:15:58 +02:00
Daniel Mensinger 86394132e7 cuda: Fix meson template (fixes #6869) 2020-04-01 20:38:49 +03:00
Jan Alexander Steffens (heftig) 03870de639 Fix meson_jar_template
It was generating an extra comma.

    The Meson build system
    Version: 0.54.0
    Source dir: /tmp/tmp34halxhe
    Build dir: /tmp/tmp34halxhe/build
    Build type: native build

    meson.build:6:15: ERROR: Expecting rparen got comma.
        'Foo.java',,
                   ^
    For a block that started at 5,3
    jar('tmp34halxhe',
       ^

    A full log can be found at /tmp/tmp34halxhe/build/meson-logs/meson-log.txt
    Using "tmp34halxhe" (name of current directory) as project name.
    Using "tmp34halxhe" (project name) as name of executable to build.
    Detected source files: Foo.java
    Detected language: java
    Generated meson.build file:

    project('tmp34halxhe', 'java',
      version : '0.1',
      default_options : ['warning_level=3'])

    jar('tmp34halxhe',
        'Foo.java',,
        main_class: tmp34halxhe,
        install : true)

It was also missing quotes around the main class name.

    The Meson build system
    Version: 0.54.0
    Source dir: /tmp/tmpjm5cg44a
    Build dir: /tmp/tmpjm5cg44a/build
    Build type: native build
    Project name: tmpjm5cg44a
    Project version: 0.1
    Java compiler for the host machine: javac (unknown 1.8.0)
    Host machine cpu family: x86_64
    Host machine cpu: x86_64

    meson.build:5:0: ERROR: Unknown variable "tmpjm5cg44a".

    A full log can be found at /tmp/tmpjm5cg44a/build/meson-logs/meson-log.txt
    Using "tmpjm5cg44a" (name of current directory) as project name.
    Using "tmpjm5cg44a" (project name) as name of executable to build.
    Detected source files: Foo.java
    Detected language: java
    Generated meson.build file:

    project('tmpjm5cg44a', 'java',
      version : '0.1',
      default_options : ['warning_level=3'])

    jar('tmpjm5cg44a',
        'Foo.java',
        main_class: tmpjm5cg44a,
        install : true)
2020-04-01 20:37:49 +03:00
Michael 02e7316d31 sample factory implementation 2020-03-19 22:44:59 +02:00
Michael 99202c9ccd add logic for Java jar project 2020-03-08 13:52:01 +02:00
Nirbheek Chauhan 7f1d78f304 tests: Ensure that executable and library are named differently
On Windows, the basename is used to determine the name of the PDB
file. So for a project called myproject, we will create myproject.dll
and myproject.exe, both of which will have myproject.pdb. This is
a file collision. Instead, append `_test`, similar to the C# template.

Fixes AllPlatformTest.test_templates on MSVC. This became a hard error
when we started listing PDBs in the implicit outputs list of ninja
targets.

Do the same for a test that was making the same mistake.
2020-02-22 06:49:34 +05:30
Michael 683cf46f32 add new templates 2020-02-02 17:16:03 -08:00
Jussi Pakkanen 6e7d5a0c61 Make D template work even if dub is not available. 2019-12-31 13:19:21 +02:00
Michael Hirsch, Ph.D bbe6db08e3 Minit templates modularization 2019-11-02 23:34:58 +02:00