1.1.77 • Published 9 months ago

@markw65/monkeyc-optimizer v1.1.77

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

monkeyc-optimizer README

This package provides a set of utilities for working with Garmin Monkey-C projects.

Optimization and analysis

Its primary purpose is to serve as the optimization and analysis engine behind prettier-extension-monkeyc, but it's API can also be used to optimize code directly.

Font analysis

It also provides a tool to report information about the builtin fonts on a device. This can be used to compute layouts, or make decisions about whether a given string would fit in a given screen region at build time, rather than at runtime. More details

Release Notes

See Change Log

API

First you will need to install nodejs/npm. Note that you need node 16.17.1 or later, preferably 18.20.3 or later

Then you can install the package. From the directory where you want to use it:

npm install -D @markw65/monkeyc-optimizer

Then you need some javascript (or typescript) to invoke it. Here's a sample

import { buildOptimizedProject, getConfig } from "@markw65/monkeyc-optimizer";
import { optimizeProgram } from "@markw65/monkeyc-optimizer/sdk-util.js";
import * as path from "node:path";

const cwd = process.cwd();
const jungleFiles = path.resolve(cwd, process.argv[2]);
const workspace = path.dirname(jungleFiles);

getConfig({
  // These are largely the same options that can be passed to tasks in
  // @markw65/prettier-extension-monkeyc (see the descriptions there)
  // getConfig will read a number of options (such as developerKeyPath)
  // from the vscode user settings, and the project settings, but anything
  // passed in here will override those values.
  //
  // The root that output paths are relative to
  // Defaults to the current directory
  workspace,
  // Where to put the files built by MonkeyC.
  // Defaults to bin. Relative paths are relative to workspace
  buildDir: "bin",
  // Where to put the files generated by the source-to-source optimizer
  // Defaults to `${buildDir}/optimized`. Relative paths are relative to workspace
  outputPath: "bin/optimized",
  // Semi-colon separated list of jungle files
  jungleFiles,
  // If true, don't actually run the MonkeyC compiler, just return the
  // command to do so.
  returnCommand: false,
}).then((options) =>
  // Passing null instead of a device id will build an .iq file
  buildOptimizedProject("fr955", options)
    .then((result) => {
      // The return value includes:
      //
      // exe - the executable to run to build the generated code ('java')
      // args - the arguments to pass to exe
      // diagnostics - collection of diagnostics raised by monkeyc-optimizer
      // program - the program that was generated by monkeyc (or that would
      //           be generated, if returnCommand is true)
      // product - the device that was targeted.
      // hasTests - true if any functions marked by (:test) were found

      // If you passed `returnCommand: true` above, you would want
      // to execute (exe, args) here
      console.log(`Built: ${result.program}`);
      return result;
    })
    .then((result) =>
      optimizeProgram(
        // program to optimize
        result.program,
        options.developerKeyPath,
        // output program. default will insert ".opt" before the input's extension
        // so foo.prg => foo.opt.prg, and foo.iq => foo.opt.iq
        undefined,
        // A few of the BuildConfig options apply to the post build optimizer
        options
      )
    )
    .then(({ output }) => console.log(`Optimized: ${output}`))
);

If you save the above as optimize.mjs, you can then optimize a project via:

node optimize.mjs path-to-my-project-monkey.jungle
1.1.77

9 months ago

1.1.76

10 months ago

1.1.75

10 months ago

1.1.70

12 months ago

1.1.74

11 months ago

1.1.73

12 months ago

1.1.72

12 months ago

1.1.71

12 months ago

1.1.63

1 year ago

1.1.62

1 year ago

1.1.67

1 year ago

1.1.66

1 year ago

1.1.65

1 year ago

1.1.64

1 year ago

1.1.69

12 months ago

1.1.68

12 months ago

1.1.61

1 year ago

1.1.60

1 year ago

1.1.59

1 year ago

1.1.58

1 year ago

1.1.57

1 year ago

1.1.56

1 year ago

1.1.55

1 year ago

1.1.54

1 year ago

1.1.53

1 year ago

1.1.52

1 year ago

1.1.51

1 year ago

1.1.50

1 year ago

1.1.49

1 year ago

1.1.48

1 year ago

1.1.47

1 year ago

1.1.45

1 year ago

1.1.46

1 year ago

1.1.44

1 year ago

1.1.43

1 year ago

1.1.42

1 year ago

1.1.41

1 year ago

1.1.39

1 year ago

1.1.40

1 year ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.30

2 years ago

1.1.31

2 years ago

1.1.27

2 years ago

1.1.16

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.39

3 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.40

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.45

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.22

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.34

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.21

3 years ago

1.0.10

3 years ago

1.0.20

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago