Skip to content

Commit 535a430

Browse files
authored
Merge pull request #14 from zfi/master
Version 1.0.0
2 parents 525d5cb + a8d1448 commit 535a430

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,6 @@ pip-log.txt
220220

221221
#Mr Developer
222222
.mr.developer.cfg
223+
/CloudCompiler-Pkg.tar.gz
224+
/build
225+
/deploy-test

cloudcompiler.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
from SpinCompiler import SpinCompiler
88
from PropCCompiler import PropCCompiler
9+
import base64
910

1011
__author__ = 'Michel'
1112

13+
version = "1.0.0"
1214
app = Flask(__name__)
1315

1416

@@ -110,10 +112,10 @@ def multiple_c(action):
110112

111113

112114
def handle_c(action, source_files, app_filename):
113-
# format data
115+
# format to upper case to make string compares easier
114116
action = action.upper()
115117

116-
# check data
118+
# Verify that we have received a valid action (COMPILE, BIN, EEPROM)
117119
if action not in actions:
118120
failure_data = {
119121
"success": False,
@@ -129,6 +131,8 @@ def handle_c(action, source_files, app_filename):
129131
"message": "missing-main-filename"
130132
}
131133
return Response(json.dumps(failure_data), 200, mimetype="application/json")
134+
135+
# Is the application file name is in the list of files
132136
if app_filename not in source_files:
133137
failure_data = {
134138
"success": False,
@@ -137,6 +141,24 @@ def handle_c(action, source_files, app_filename):
137141
}
138142
return Response(json.dumps(failure_data), 400, mimetype="application/json")
139143

144+
# --------------------------------------------------------------
145+
# Custom hook to trap the S3 Scribbler demo/initialization block
146+
# Look for a specific string in the source file (single.c)
147+
# --------------------------------------------------------------
148+
if '#pragma load_default_scribbler_binary' in source_files['single.c']:
149+
out = "Loading S3 Demo App..."
150+
data = {
151+
"success": True,
152+
"compiler-output": out,
153+
"compiler-error": ''
154+
}
155+
156+
if action != "COMPILE":
157+
data['binary'] = s3_load_init_binary()
158+
data['extension'] = 'elf'
159+
160+
return Response(json.dumps(data), 200, mimetype="application/json")
161+
140162
# call compiler and prepare return data
141163
(success, base64binary, extension, out, err) = compilers["PROP-C"].compile(action, source_files, app_filename)
142164

@@ -148,12 +170,22 @@ def handle_c(action, source_files, app_filename):
148170
"compiler-output": out,
149171
"compiler-error": err
150172
}
173+
151174
if action != "COMPILE" and success:
152175
data['binary'] = base64binary
153176
data['extension'] = extension
177+
154178
return Response(json.dumps(data), 200, mimetype="application/json")
155179

156180

181+
def s3_load_init_binary():
182+
with open('scribbler_default.binary', 'rb') as f:
183+
encoded = base64.b64encode(f.read())
184+
185+
f.close()
186+
return encoded
187+
188+
157189
# --------------------------------------- Defaults and compiler initialization --------------------------------
158190
defaults = {
159191
'c-compiler': '/opt/parallax/bin/propeller-elf-gcc',
@@ -163,6 +195,7 @@ def handle_c(action, source_files, app_filename):
163195
}
164196

165197
configfile = expanduser("~/cloudcompiler.properties")
198+
166199
if isfile(configfile):
167200
configs = ConfigParser(defaults)
168201
configs.readfp(FakeSecHead(open(configfile)))
@@ -196,7 +229,7 @@ def handle_c(action, source_files, app_filename):
196229

197230
# ----------------------------------------------- Development server -------------------------------------------
198231
if __name__ == '__main__':
199-
app.debug = True
232+
app.debug = False
200233
app.run(host='0.0.0.0')
201234

202235

scribbler_default.binary

29.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)