Skip to content

Commit

Permalink
build: fix github action
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiaosiyuan0 committed Feb 11, 2023
1 parent bb705d7 commit 7bc4f69
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 17 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ jobs:
platform: x64

- name: Setup Cmake
uses: aminya/install-cmake@master
with:
cmake: 3.25.1
ninja: 1.11.1
uses: lukka/get-cmake@latest

- name: Checkout code
uses: actions/checkout@v2

- name: Test
run: |
mkdir build && cd build
cmake .. --fresh -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja tests && ctest --test-dir tests --output-on-failure
shell: bash
- name: Run Tests
uses: lukka/run-cmake@v10
with:
configurePreset: "default"
buildPreset: "run-tests"
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"BIGNUM",
"bjson",
"bugprone",
"buildsystems",
"BYTECODE",
"Casefolded",
"Casemapped",
Expand Down
63 changes: 63 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"description": "Default build using Ninja generator",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_INSTALLED_DIR}/scripts/buildsystems/vcpkg.cmake"
},
"environment": {},
"vendor": {}
},
{
"name": "qjs:debugger",
"description": "Compile qjs with debugger support",
"inherits": "default",
"cacheVariables": {
"QJS_CONFIG_DEBUGGER": "y"
}
}
],
"buildPresets": [
{
"name": "qjs:debugger",
"description": "Run qjs with debugger support",
"configurePreset": "qjs:debugger",
"targets": [
"qjs"
]
},
{
"name": "run-tests",
"configurePreset": "default",
"targets": [
"run-tests"
]
},
{
"name": "run-microbench",
"configurePreset": "default",
"targets": [
"microbench"
],
"configuration": "Release"
},
{
"name": "run-test262",
"configurePreset": "default",
"targets": [
"run-test262-test2"
],
"configuration": "Release"
}
]
}
2 changes: 1 addition & 1 deletion qjs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_compile_definitions(qjs PRIVATE CONFIG_VERSION="${CONFIG_VERSION}")
# generated by the qjsc
add_dependencies(qjs qjsc)

set(QJSC "${PROJECT_BINARY_DIR}/qjsc/qjsc")
set(QJSC "$<TARGET_FILE:qjsc>")

add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/repl.c"
Expand Down
4 changes: 2 additions & 2 deletions qjs/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void
/* only handle %p and %zd */
if (*fmt == 'p') {
uint8_t *ptr = (uint8_t *)va_arg(ap, void *);
if (ptr == nullptr) {
if (ptr == NULL) {
printf("NULL");
} else {
printf("H%+06lld.%zd",
Expand Down Expand Up @@ -203,7 +203,7 @@ static void *js_trace_malloc(JSMallocState *s, size_t size) {
assert(size != 0);

if (unlikely(s->malloc_size + size > s->malloc_limit))
return nullptr;
return NULL;
ptr = malloc(size);
js_trace_malloc_printf(s, "A %zd -> %p\n", size, ptr);
if (ptr) {
Expand Down
11 changes: 9 additions & 2 deletions qjsc/qjsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,16 @@ static void output_object_code(JSContext *ctx, FILE *fo, JSValueConst obj,

namelist_add(&cname_list, c_name, NULL, load_only);

fprintf(fo, "extern const uint32_t %s_size = %u;\n\n", c_name,
fprintf(fo, "\n#ifdef __cplusplus\n /* extern \"C\" { */\n"
" #define EXTERN_CONST extern const\n"
"#else\n"
" #define EXTERN_CONST const\n"
"#endif\n\n");

fprintf(fo, "EXTERN_CONST uint32_t %s_size = %u;\n\n", c_name,
(unsigned int)out_buf_len);
fprintf(fo, "EXTERN_CONST uint8_t %s[%u] = {\n", c_name,
(unsigned int)out_buf_len);
fprintf(fo, "extern const uint8_t %s[%u] = {\n", c_name, (unsigned int)out_buf_len);
dump_hex(fo, out_buf, out_buf_len);
fprintf(fo, "};\n\n");

Expand Down
8 changes: 7 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ target_link_options(tests PRIVATE -shared -undefined dynamic_lookup)

add_dependencies(tests qjs examples)

set(QJS "${PROJECT_BINARY_DIR}/qjs/qjs")
add_custom_target(
run-tests
COMMAND ctest
DEPENDS tests
JOB_POOL console)

set(QJS "$<TARGET_FILE:qjs>")

macro(qjs_test)
add_test(
Expand Down
2 changes: 1 addition & 1 deletion tests/run-test262/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_compile_definitions(run-test262

add_dependencies(run-test262 quickjs)

set(RUN_TEST262 "${PROJECT_BINARY_DIR}/tests/run-test262/run-test262")
set(RUN_TEST262 "$<TARGET_FILE:run-test262>")

add_custom_target(
run-test262-test2-default
Expand Down

0 comments on commit 7bc4f69

Please sign in to comment.