Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use QuickJS-ng #427

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
[submodule "deps/libffi"]
path = deps/libffi
url = https://github.com/libffi/libffi
[submodule "deps/quickjs"]
path = deps/quickjs
url = https://github.com/quickjs-ng/quickjs.git
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ endif()
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
message(STATUS "Building with ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} on ${CMAKE_SYSTEM}")

set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_C_STANDARD 11)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -funsigned-char")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-bounds -Wno-format-truncation -Wno-unused-variable -Wno-unused-but-set-variable")
endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0 -fno-omit-frame-pointer")

message(STATUS "C flags: ${CMAKE_C_FLAGS}")
message(STATUS "C Debug flags: ${CMAKE_C_FLAGS_DEBUG}")
message(STATUS "C Release flags: ${CMAKE_C_FLAGS_RELEASE}")

set(CMAKE_VERBOSE_MAKEFILE TRUE)

set(TJS__VERSION_MAJOR 23)
set(TJS__VERSION_MINOR 10)
set(TJS__VERSION_PATCH 0)
Expand Down Expand Up @@ -89,7 +100,7 @@ add_executable(tjs
src/bundles/c/core/core.c
src/bundles/c/core/polyfills.c
src/bundles/c/core/run-main.c
../deps/quickjs/src/cutils.c
../deps/quickjs/cutils.c
)

if(NOT MINGW)
Expand Down Expand Up @@ -149,7 +160,7 @@ if (BUILD_WITH_ASAN)
target_link_options(tjs PRIVATE -fsanitize=address)
endif()

add_executable(qjsc EXCLUDE_FROM_ALL
add_executable(tjsc EXCLUDE_FROM_ALL
src/qjsc.c
)
target_link_libraries(qjsc qjs m)
target_link_libraries(tjsc qjs m)
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
BUILD_DIR=build
BUILDTYPE?=MinSizeRel
BUILDTYPE?=Release
JOBS?=$(shell getconf _NPROCESSORS_ONLN)

QJSC=$(BUILD_DIR)/qjsc
QJSC=$(BUILD_DIR)/tjsc
STDLIB_MODULES=$(wildcard src/js/stdlib/*.js)

all: build

build: $(BUILD_DIR)/Makefile
cmake --build $(BUILD_DIR) -j $(JOBS)

$(BUILD_DIR)/qjsc: $(BUILD_DIR)/Makefile
cmake --build $(BUILD_DIR) --target qjsc -j $(JOBS)
$(QJSC): $(BUILD_DIR)/Makefile
cmake --build $(BUILD_DIR) --target tjsc -j $(JOBS)

src/bundles/js/core/polyfills.js: src/js/polyfills/*.js
npx esbuild src/js/polyfills/index.js \
Expand All @@ -25,7 +25,7 @@ src/bundles/js/core/polyfills.js: src/js/polyfills/*.js

src/bundles/c/core/polyfills.c: $(QJSC) src/bundles/js/core/polyfills.js
@mkdir -p $(basename $(dir $@))
$(BUILD_DIR)/qjsc -m \
$(QJSC) -m \
-o $@ \
-n "polyfills.js" \
-p tjs__ \
Expand All @@ -44,7 +44,7 @@ src/bundles/js/core/core.js: src/js/core/*.js

src/bundles/c/core/core.c: $(QJSC) src/bundles/js/core/core.js
@mkdir -p $(basename $(dir $@))
$(BUILD_DIR)/qjsc -m \
$(QJSC) -m \
-o $@ \
-n "core.js" \
-p tjs__ \
Expand All @@ -63,7 +63,7 @@ src/bundles/js/core/run-main.js: src/js/run-main/*.js

src/bundles/c/core/run-main.c: $(QJSC) src/bundles/js/core/run-main.js
@mkdir -p $(basename $(dir $@))
$(BUILD_DIR)/qjsc -m \
$(QJSC) -m \
-o $@ \
-n "run-main.js" \
-p tjs__ \
Expand All @@ -73,7 +73,7 @@ core: src/bundles/c/core/polyfills.c src/bundles/c/core/core.c src/bundles/c/cor

src/bundles/c/stdlib/%.c: $(QJSC) src/bundles/js/stdlib/%.js
@mkdir -p $(basename $(dir $@))
$(BUILD_DIR)/qjsc -m \
$(QJSC) -m \
-o $@ \
-n "tjs:$(basename $(notdir $@))" \
-p tjs__ \
Expand All @@ -90,7 +90,7 @@ src/bundles/js/stdlib/%.js: src/js/stdlib/*.js src/js/stdlib/ffi/*.js

src/bundles/c/stdlib/%.c: $(QJSC) src/bundles/js/stdlib/%.js
@mkdir -p $(basename $(dir $@))
$(BUILD_DIR)/qjsc -m \
$(QJSC) -m \
-o $@ \
-n "tjs:$(basename $(notdir $@))" \
-p tjs__ \
Expand Down
1 change: 1 addition & 0 deletions deps/quickjs
Submodule quickjs added at 0dc99e
54 changes: 0 additions & 54 deletions deps/quickjs/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion deps/quickjs/VERSION

This file was deleted.

Loading