Check-in all generated C files

Closes: https://github.com/quickjs-ng/quickjs/issues/262
This commit is contained in:
Saúl Ibarra Corretgé 2024-02-12 15:45:42 +01:00
parent 7ded62c536
commit 7f928d289f
8 changed files with 27 additions and 51 deletions

View file

@ -15,6 +15,15 @@ on:
- master - master
jobs: jobs:
codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build
run: |
make codegen
- name: Check if the git repository is clean
run: $(exit $(git status --porcelain --untracked-files=no | head -255 | wc -l)) || (echo "Dirty git tree"; git diff; exit 1)
linux: linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

View file

@ -5,9 +5,6 @@ project(quickjs LANGUAGES C)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(GNUInstallDirs) include(GNUInstallDirs)
# TODO:
# - Support cross-compilation
set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
@ -183,19 +180,10 @@ target_link_libraries(qjsc ${qjs_libs})
# QuickJS CLI # QuickJS CLI
# #
add_custom_command(
OUTPUT repl.c
COMMAND qjsc -o ./repl.c -m ${CMAKE_CURRENT_SOURCE_DIR}/repl.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile repl.js to bytecode"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/repl.js
)
add_executable(qjs_exe add_executable(qjs_exe
gen/repl.c
qjs.c qjs.c
quickjs-libc.c quickjs-libc.c
${CMAKE_CURRENT_BINARY_DIR}/repl.c
) )
set_target_properties(qjs_exe PROPERTIES set_target_properties(qjs_exe PROPERTIES
OUTPUT_NAME "qjs" OUTPUT_NAME "qjs"
@ -236,16 +224,8 @@ add_executable(unicode_gen EXCLUDE_FROM_ALL
) )
target_compile_definitions(unicode_gen PRIVATE ${qjs_defines}) target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
add_custom_command(
OUTPUT function_source.c
COMMAND qjsc -e -o function_source.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
DEPENDS qjsc ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile function_source.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
)
add_executable(function_source add_executable(function_source
${CMAKE_CURRENT_BINARY_DIR}/function_source.c gen/function_source.c
quickjs-libc.c quickjs-libc.c
) )
target_include_directories(function_source PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(function_source PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
@ -256,32 +236,16 @@ target_link_libraries(function_source ${qjs_libs})
# #
if(BUILD_EXAMPLES AND NOT WIN32) if(BUILD_EXAMPLES AND NOT WIN32)
add_custom_command(
OUTPUT hello.c
COMMAND qjsc -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile hello.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
)
add_executable(hello add_executable(hello
${CMAKE_CURRENT_BINARY_DIR}/hello.c gen/hello.c
quickjs-libc.c quickjs-libc.c
) )
target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(hello PRIVATE ${qjs_defines}) target_compile_definitions(hello PRIVATE ${qjs_defines})
target_link_libraries(hello ${qjs_libs}) target_link_libraries(hello ${qjs_libs})
add_custom_command(
OUTPUT hello_module.c
COMMAND qjsc -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile hello_module.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
)
add_executable(hello_module add_executable(hello_module
${CMAKE_CURRENT_BINARY_DIR}/hello_module.c gen/hello_module.c
quickjs-libc.c quickjs-libc.c
) )
target_include_directories(hello_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(hello_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
@ -320,17 +284,9 @@ if(BUILD_EXAMPLES AND NOT WIN32)
endif() endif()
endif() endif()
add_custom_command(
OUTPUT test_fib.c
COMMAND qjsc -e -o test_fib.c -M ${CMAKE_CURRENT_SOURCE_DIR}/examples/fib.so,fib -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/test_fib.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile test_fib.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/test_fib.js
)
add_executable(test_fib add_executable(test_fib
${CMAKE_CURRENT_BINARY_DIR}/test_fib.c
examples/fib.c examples/fib.c
gen/test_fib.c
quickjs-libc.c quickjs-libc.c
) )
target_include_directories(test_fib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(test_fib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

View file

@ -28,6 +28,7 @@ BUILD_DIR=build
BUILD_TYPE?=Release BUILD_TYPE?=Release
QJS=$(BUILD_DIR)/qjs QJS=$(BUILD_DIR)/qjs
QJSC=$(BUILD_DIR)/qjsc
RUN262=$(BUILD_DIR)/run-test262 RUN262=$(BUILD_DIR)/run-test262
JOBS?=$(shell getconf _NPROCESSORS_ONLN) JOBS?=$(shell getconf _NPROCESSORS_ONLN)
@ -49,12 +50,22 @@ $(BUILD_DIR):
$(QJS): $(BUILD_DIR) $(QJS): $(BUILD_DIR)
cmake --build $(BUILD_DIR) -j $(JOBS) cmake --build $(BUILD_DIR) -j $(JOBS)
install: $(QJS) $(QJSC): $(BUILD_DIR)
cmake --build $(BUILD_DIR) --target qjsc -j $(JOBS)
install: $(QJS) $(QJSC)
cmake --build $(BUILD_DIR) --target install cmake --build $(BUILD_DIR) --target install
clean: clean:
cmake --build $(BUILD_DIR) --target clean cmake --build $(BUILD_DIR) --target clean
codegen: $(QJSC)
$(QJSC) -o gen/repl.c -m repl.js
$(QJSC) -e -o gen/function_source.c tests/function_source.js
$(QJSC) -e -o gen/hello.c examples/hello.js
$(QJSC) -e -o gen/hello_module.c -m examples/hello_module.js
$(QJSC) -e -o gen/test_fib.c -M examples/fib.so,fib -m examples/test_fib.js
debug: debug:
BUILD_TYPE=Debug $(MAKE) BUILD_TYPE=Debug $(MAKE)
@ -92,4 +103,4 @@ unicode_gen: $(BUILD_DIR)
libunicode-table.h: unicode_gen libunicode-table.h: unicode_gen
$(BUILD_DIR)/unicode_gen unicode $@ $(BUILD_DIR)/unicode_gen unicode $@
.PHONY: all debug install clean distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) .PHONY: all debug install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC)

BIN
gen/function_source.c Normal file

Binary file not shown.

BIN
gen/hello.c Normal file

Binary file not shown.

BIN
gen/hello_module.c Normal file

Binary file not shown.

BIN
gen/repl.c Normal file

Binary file not shown.

BIN
gen/test_fib.c Normal file

Binary file not shown.