mirror of
https://github.com/pocketpy/pocketpy
synced 2026-03-02 19:30:17 +00:00
Compare commits
1 Commits
47fca05936
...
3f12f9f601
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f12f9f601 |
@ -80,14 +80,7 @@ for entry in os.listdir(ROOT):
|
|||||||
headers[f'{entry}/{file}'] = Header(f'{entry}/{file}')
|
headers[f'{entry}/{file}'] = Header(f'{entry}/{file}')
|
||||||
|
|
||||||
def merge_c_files():
|
def merge_c_files():
|
||||||
c_files = [
|
c_files = [COPYRIGHT, '\n', '#include "pocketpy.h"', '\n']
|
||||||
COPYRIGHT,
|
|
||||||
'\n',
|
|
||||||
'#define PK_IS_AMALGAMATED_C',
|
|
||||||
'\n',
|
|
||||||
'#include "pocketpy.h"',
|
|
||||||
'\n'
|
|
||||||
]
|
|
||||||
|
|
||||||
# merge internal headers
|
# merge internal headers
|
||||||
internal_h = []
|
internal_h = []
|
||||||
@ -130,12 +123,7 @@ def merge_c_files():
|
|||||||
return ''.join(c_files)
|
return ''.join(c_files)
|
||||||
|
|
||||||
def merge_h_files():
|
def merge_h_files():
|
||||||
h_files = [
|
h_files = [COPYRIGHT, '#pragma once']
|
||||||
COPYRIGHT,
|
|
||||||
'#pragma once',
|
|
||||||
'\n',
|
|
||||||
'#define PK_IS_PUBLIC_INCLUDE',
|
|
||||||
]
|
|
||||||
|
|
||||||
def _replace(m):
|
def _replace(m):
|
||||||
path = m.group(1)
|
path = m.group(1)
|
||||||
@ -160,15 +148,9 @@ write_file('amalgamated/pocketpy.h', merge_h_files())
|
|||||||
|
|
||||||
shutil.copy("src2/main.c", "amalgamated/main.c")
|
shutil.copy("src2/main.c", "amalgamated/main.c")
|
||||||
|
|
||||||
def checked_sh(cmd):
|
|
||||||
ok = os.system(cmd)
|
|
||||||
assert ok == 0, f"command failed: {cmd}"
|
|
||||||
|
|
||||||
if sys.platform in ['linux', 'darwin']:
|
if sys.platform in ['linux', 'darwin']:
|
||||||
common_flags = "-O1 --std=c11 -lm -ldl -lpthread -Iamalgamated"
|
ok = os.system("gcc -o main amalgamated/pocketpy.c amalgamated/main.c -O1 --std=c11 -lm -ldl -lpthread")
|
||||||
checked_sh(f"gcc -o main amalgamated/pocketpy.c src2/example.c {common_flags}")
|
if ok == 0:
|
||||||
checked_sh("./main && rm -f ./main")
|
print("Test build success!")
|
||||||
checked_sh(f"gcc -o main amalgamated/pocketpy.c amalgamated/main.c {common_flags}")
|
|
||||||
|
|
||||||
|
|
||||||
print("amalgamated/pocketpy.h")
|
print("amalgamated/pocketpy.h")
|
||||||
|
|||||||
@ -28,7 +28,6 @@ typedef double py_f64;
|
|||||||
/// A generic destructor function.
|
/// A generic destructor function.
|
||||||
typedef void (*py_Dtor)(void*);
|
typedef void (*py_Dtor)(void*);
|
||||||
|
|
||||||
#ifndef PK_IS_AMALGAMATED_C
|
|
||||||
#ifdef PK_IS_PUBLIC_INCLUDE
|
#ifdef PK_IS_PUBLIC_INCLUDE
|
||||||
typedef struct py_TValue {
|
typedef struct py_TValue {
|
||||||
py_Type type;
|
py_Type type;
|
||||||
@ -41,7 +40,6 @@ typedef struct py_TValue {
|
|||||||
};
|
};
|
||||||
} py_TValue;
|
} py_TValue;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/// A string view type. It is helpful for passing strings which are not null-terminated.
|
/// A string view type. It is helpful for passing strings which are not null-terminated.
|
||||||
typedef struct c11_sv {
|
typedef struct c11_sv {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user