├── .editorconfig ├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md └── get_quickjs.cmake.in /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = tab 6 | indent_size = 4 7 | tab_width = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Kosaki Mezumona 2 | # This cmake script is distributed under the MIT License. 3 | # See LICENSE for more details. 4 | cmake_minimum_required(VERSION 3.1) 5 | project(quickjs) 6 | 7 | set(quickjs_version 2020-01-19) 8 | set(quickjs_url https://bellard.org/quickjs/quickjs-${quickjs_version}.tar.xz) 9 | set(quickjs_sha1 a33a7abb4471d566da39df90d0b688d120a8a2c4) 10 | set(quickjs_extras_url https://bellard.org/quickjs/quickjs-extras-${quickjs_version}.tar.xz) 11 | set(quickjs_extras_sha1 ae35cebc11f64e9c8bc97c53832607b0fe33953c) 12 | set(quickjs_extract_dir ${CMAKE_CURRENT_BINARY_DIR}/sources) 13 | set(quickjs_sources_root ${quickjs_extract_dir}/quickjs-${quickjs_version}) 14 | set(quickjs_sources 15 | ${quickjs_sources_root}/quickjs.h 16 | ${quickjs_sources_root}/quickjs-libc.h 17 | ${quickjs_sources_root}/quickjs.c 18 | ${quickjs_sources_root}/libregexp.c 19 | ${quickjs_sources_root}/libunicode.c 20 | ${quickjs_sources_root}/libbf.c 21 | ${quickjs_sources_root}/cutils.c 22 | ${quickjs_sources_root}/quickjs-libc.c 23 | ) 24 | 25 | set(get_quickjs_cmake_in ${CMAKE_CURRENT_LIST_DIR}/get_quickjs.cmake.in) 26 | set(get_quickjs_cmake ${CMAKE_CURRENT_BINARY_DIR}/get_quickjs.cmake) 27 | configure_file( 28 | ${get_quickjs_cmake_in} 29 | ${get_quickjs_cmake} 30 | @ONLY 31 | ) 32 | add_custom_command( 33 | OUTPUT 34 | ${quickjs_sources} 35 | DEPENDS 36 | ${get_quickjs_cmake} 37 | COMMENT 38 | Get quickjs sources. 39 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/get_quickjs.cmake 40 | ) 41 | 42 | add_library(${PROJECT_NAME} 43 | ${quickjs_sources} 44 | ) 45 | target_compile_definitions(${PROJECT_NAME} 46 | PRIVATE 47 | CONFIG_VERSION="${quickjs_version}" 48 | ) 49 | target_include_directories(${PROJECT_NAME} 50 | PUBLIC 51 | ${quickjs_sources_root} 52 | ) 53 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Thanks for your visiting. 3 | Sorry for my poor English but I wrote without anxiety. 4 | 5 | # Style guides 6 | * Write in clear English. 7 | 8 | # Reporting a bug 9 | * Search issues on GitHub to check the bug was not already reported. 10 | * If you are unable to find it, open a new issue. 11 | * Please write title and description clearly. 12 | 13 | # Putting your debug patch 14 | * Search pull requests on GitHub to check the patch was not already submitted. 15 | * Create a new pull request on GitHub. 16 | * Write description to clear your opinion and solution. 17 | 18 | # Suggesting enhancement 19 | * Search on GitHub issues to check the suggestion was not already exists. 20 | * Create a new issue on GitHub. 21 | * Write why this enhancement is useful. 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mezumona Kosaki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unofficial QuickJS CMake scripts 2 | [QuickJS](https://bellard.org/quickjs/) is a JavaScript interpreter. 3 | This repository contains scripts to build QuickJS on CMake system. 4 | 5 | # Usage 6 | You must put "CMakeLists.txt" and "get_quickjs.cmake.in" on same cmake directory. 7 | If you embed in your application, use "add_subdirectory()" 8 | and add "quickjs" dependency to your project using "target_link_libraries()". 9 | 10 | # Contributing 11 | Welcome. 12 | See [CONTRIBUTING.md](CONTRIBUTING.md) for more details. 13 | 14 | # License 15 | This cmake scripts are distributed under the MIT License. 16 | See [LICENSE](LICENSE) for more details. 17 | 18 | # Copyright 19 | Copyright (c) 2020 Kosaki Mezumona 20 | -------------------------------------------------------------------------------- /get_quickjs.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Kosaki Mezumona 2 | # This cmake script is distributed under the MIT License. 3 | # See LICENSE for more details. 4 | cmake_minimum_required(VERSION 3.2) 5 | set(quickjs_url @quickjs_url@) 6 | set(quickjs_sha1 @quickjs_sha1@) 7 | set(quickjs_extras_url @quickjs_extras_url@) 8 | set(quickjs_extras_sha1 @quickjs_extras_sha1@) 9 | set(quickjs_extract_dir @quickjs_extract_dir@) 10 | set(quickjs_sources @quickjs_sources@) 11 | 12 | set(must_extract FALSE) 13 | set(quickjs_tar @CMAKE_CURRENT_BINARY_DIR@/quickjs.tar.xz) 14 | set(quickjs_extras_tar @CMAKE_CURRENT_BINARY_DIR@/quickjs-extra.tar.xz) 15 | 16 | if(NOT EXISTS ${quickjs_tar}) 17 | file(DOWNLOAD 18 | ${quickjs_url} 19 | ${quickjs_tar} 20 | EXPECTED_HASH SHA1=${quickjs_sha1} 21 | ) 22 | set(must_extract TRUE) 23 | endif() 24 | 25 | if(NOT EXISTS ${quickjs_extras_tar}) 26 | file(DOWNLOAD 27 | ${quickjs_extras_url} 28 | ${quickjs_extras_tar} 29 | EXPECTED_HASH SHA1=${quickjs_extras_sha1} 30 | ) 31 | set(must_extract TRUE) 32 | endif() 33 | 34 | foreach(source IN LISTS quickjs_sources) 35 | if (NOT EXISTS ${source}) 36 | set(must_extract TRUE) 37 | break() 38 | endif() 39 | endforeach() 40 | 41 | 42 | if (must_extract) 43 | execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${quickjs_extract_dir}) 44 | execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${quickjs_extract_dir}) 45 | execute_process( 46 | COMMAND ${CMAKE_COMMAND} -E tar xJ ${quickjs_tar} 47 | WORKING_DIRECTORY ${quickjs_extract_dir} 48 | ) 49 | execute_process( 50 | COMMAND ${CMAKE_COMMAND} -E tar xJ ${quickjs_extras_tar} 51 | WORKING_DIRECTORY ${quickjs_extract_dir} 52 | ) 53 | endif() 54 | --------------------------------------------------------------------------------