@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 SuperStormer
Copyright (c) 2020 SuperStormer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -2,17 +2,25 @@
Compiles C code to Mindustry logic. Still in beta, so compiled output may not be fully optimized.
# Installation
`pip install git+https://github.com/SuperStormer/c2logic`
# Usage
`python3 -m c2logic filename -O optimization_level`
Run the command line tool using:
`c2logic filename -O optimization_level`
where `filename` is a string and `optimization_level` is an integer.
When developing your script, you can include `c2logic/builtins.h` located in the python include directory(location depends on system, mine is at `~/.local/include/python3.8/`)
See [examples](./examples) for API sample usage.
# Documentation
See `include/mindustry.h` for API definitions.
See `include/builtins.h` for API definitions.
# Unsupported Features
@ -1,4 +1,5 @@
-I ./include
-I/home/larry/.local/include/python3.8/
-Wall
-Wextra
-Wno-main-return-type
-Wno-incompatible-library-redeclaration
@ -1,4 +1,4 @@
#include "../include/mindustry.h"
#include "c2logic/builtins.h"
/*expected output:
5678
0246
@ -0,0 +1,15 @@
extern struct MindustryObject message1;
double factorial(int x) {
int ret = 1;
for (int i = 2; i <= x; i++) {
ret *= x;
}
return ret;
void main(void) {
printd(factorial(4));
print("\n");
printd(factorial(5));
printflush(message1);
extern struct MindustryObject swarmer1;
extern struct MindustryObject conveyor1;
double x = rand(20), y = rand(20);
@ -12,6 +12,7 @@ setuptools.setup(
author="SuperStormer",
url="https://github.com/SuperStormer/c2logic",
project_urls={"Source Code": "https://github.com/SuperStormer/c2logic"},
entry_points={"console_scripts": ["c2logic=c2logic:main"]},
headers=["include/builtins.h"],
entry_points={"console_scripts": ["c2logic=c2logic.compiler:main"]},
install_requires=["pycparser~=2.20"]
)