Skip to content

Commit e3f5a14

Browse files
committed
nits
1 parent 66fdd6e commit e3f5a14

File tree

7 files changed

+30
-24
lines changed

7 files changed

+30
-24
lines changed

.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ AlwaysBreakAfterReturnType: None
1010

1111
IndentWidth: 4
1212
DerivePointerAlignment: false
13+
14+
# Precise control over braces alignment
15+
BreakBeforeBraces: Custom
16+
BraceWrapping:
17+
AfterClass: true
18+
SplitEmptyFunction: false
19+
SplitEmptyRecord: false
1320
---

func/cpp/py_func.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
extern "C"
2-
{
1+
extern "C" {
32
#include "pyinit.h"
43
}
54

@@ -21,8 +20,7 @@ extern "C"
2120
* Returns the relevant Python entry function. We need to invoke different
2221
* functions depending on which Faasm function index we're dealing with.
2322
*/
24-
const char* getPythonFunctionName()
25-
{
23+
const char* getPythonFunctionName() {
2624
char* entryFunc = faasmGetPythonEntry();
2725

2826
if (strlen(entryFunc) == 0) {
@@ -36,8 +34,7 @@ const char* getPythonFunctionName()
3634
* Returns the working dir we need to be in to import the Python module
3735
* for the required function.
3836
*/
39-
const char* getPythonWorkingDir(const char* user, const char* funcName)
40-
{
37+
const char* getPythonWorkingDir(const char* user, const char* funcName) {
4138
auto workingDir = new char[60];
4239

4340
#ifdef __wasm__
@@ -53,8 +50,7 @@ const char* getPythonWorkingDir(const char* user, const char* funcName)
5350
* Returns the name of the python module to execute. If executing in wasm this
5451
* will be different to when executing natively.
5552
*/
56-
const char* getPythonModuleName(const char* funcName)
57-
{
53+
const char* getPythonModuleName(const char* funcName) {
5854
#ifdef __wasm__
5955
return "function";
6056
#else
@@ -65,8 +61,7 @@ const char* getPythonModuleName(const char* funcName)
6561
/**
6662
* Initialise CPython using a Faasm zygote to avoid doing so repeatedly
6763
*/
68-
FAASM_ZYGOTE()
69-
{
64+
FAASM_ZYGOTE() {
7065
Py_InitializeEx(0);
7166

7267
// 21/12/2022 - Numpy support is broken
@@ -95,8 +90,7 @@ FAASM_ZYGOTE()
9590
return 0;
9691
}
9792

98-
int main(int argc, char* argv[])
99-
{
93+
int main(int argc, char* argv[]) {
10094
// With this line uncommented, this file can be run as a normal executable
10195
// for testing setEmulatedMessageFromJson(R"({"user": "python", "function":
10296
// "py_func", "py_user": "python", "py_func": "lang_test", "py_entry":

func/cpp/pyinit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
fprintf(devNull, "%p", trunc##sfx); \
7575
fprintf(devNull, "%p", rint##sfx);
7676

77-
void setUpPyNumpy()
78-
{
77+
void setUpPyNumpy() {
7978
FILE* devNull = fopen("/dev/null", "w");
8079

8180
// Maths

func/cpp/pyinit.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
#define FAASM_PYTHON_H
33

44
#ifdef __cplusplus
5-
extern "C"
6-
{
5+
extern "C" {
76
#endif
87

9-
void setUpPyNumpy();
8+
void setUpPyNumpy();
109

1110
#ifdef __cplusplus
1211
}

tasks/cpython.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from copy import copy as deep_copy
22
from faasmctl.util.upload import upload_wasm
3-
from faasmtools.build import (
4-
build_config_cmd,
5-
get_faasm_build_env_dict
6-
)
3+
from faasmtools.build import build_config_cmd, get_faasm_build_env_dict
74
from faasmtools.compile_util import wasm_cmake, wasm_copy_upload
85
from faasmtools.env import LLVM_NATIVE_VERSION, WASM_DIR
96
from invoke import task
@@ -57,7 +54,9 @@
5754
LIB_DEST_DIR = join(FAASM_RUNTIME_ROOT, "lib")
5855

5956
LIBPYTHON_SRC_PATH = join(LIB_SRC_DIR, "libpython3.8.a")
60-
LIBPYTHON_DEST_PATH = join(ENV_VARS["FAASM_WASM_LIB_INSTALL_DIR"], "libpython3.8.a")
57+
LIBPYTHON_DEST_PATH = join(
58+
ENV_VARS["FAASM_WASM_LIB_INSTALL_DIR"], "libpython3.8.a"
59+
)
6160

6261
INCLUDE_SRC_DIR = join(CPYTHON_INSTALL_DIR, "include", "python3.8")
6362
INCLUDE_DEST_DIR = join(ENV_VARS["FAASM_WASM_HEADER_INSTALL_DIR"], "python3.8")
@@ -233,7 +232,14 @@ def func(ctx, clean=False, debug=False):
233232
wasm_file = join(func_build_dir, "{}.wasm".format(CPYTHON_FUNC_NAME))
234233

235234
# Build and install the wasm
236-
wasm_cmake(func_dir, func_build_dir, CPYTHON_FUNC_NAME, clean, debug, is_threads=True)
235+
wasm_cmake(
236+
func_dir,
237+
func_build_dir,
238+
CPYTHON_FUNC_NAME,
239+
clean,
240+
debug,
241+
is_threads=True,
242+
)
237243
wasm_copy_upload(CPYTHON_FUNC_USER, CPYTHON_FUNC_NAME, wasm_file)
238244

239245

tasks/format_code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def format(ctx, check=False):
5454
clang_cmd = [
5555
"clang-format-{}".format(LLVM_VERSION.split(".")[0]),
5656
"--dry-run --Werror" if check else "-i",
57+
"-style=file",
5758
" ".join(files_to_check),
5859
]
5960
clang_cmd = " ".join(clang_cmd)

0 commit comments

Comments
 (0)