Compare commits
No commits in common. "023af39a222359b9999d31aca2158d4d32c5518e" and "8a7f556520409d9684bc55707158afd9fd628d8c" have entirely different histories.
023af39a22
...
8a7f556520
@ -67,9 +67,6 @@ if (${IS_GNU} OR ${IS_CLANG})
|
|||||||
include(FindOpenMP)
|
include(FindOpenMP)
|
||||||
if (OpenMP_CXX_FOUND)
|
if (OpenMP_CXX_FOUND)
|
||||||
set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
|
||||||
if (ANDROID)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-openmp")
|
|
||||||
endif()
|
|
||||||
add_definitions(-D_GLIBCXX_PARALLEL)
|
add_definitions(-D_GLIBCXX_PARALLEL)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -81,15 +78,7 @@ if (${IS_GNU} OR ${IS_CLANG})
|
|||||||
else()
|
else()
|
||||||
set(IS_HOST_NOT_ANDROID 0)
|
set(IS_HOST_NOT_ANDROID 0)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "--closure 1 --closure-args=\"--compilation_level SIMPLE\" -lnodefs.js -lembind -sDYNAMIC_EXECUTION=0 -sFORCE_FILESYSTEM=1 -sWASM=0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=${IS_HOST_NOT_ANDROID} -sMALLOC='emmalloc' -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 -sSTACK_SIZE=8MB -sALLOW_MEMORY_GROWTH=1 -Wno-pthreads-mem-growth -sMEMORY_GROWTH_GEOMETRIC_STEP=0 -sDECLARE_ASM_MODULE_EXPORTS=1 ${CMAKE_EXE_LINKER_FLAGS}")
|
set(CMAKE_EXE_LINKER_FLAGS "--closure 1 --closure-args=\"--compilation_level SIMPLE\" -lnodefs.js -lembind -sDYNAMIC_EXECUTION=0 -sFORCE_FILESYSTEM=1 -sWASM=0 --memory-init-file 0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=${IS_HOST_NOT_ANDROID} -sMALLOC='emmalloc' -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sSTRICT=1 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 -sSTACK_SIZE=8MB -sALLOW_MEMORY_GROWTH=1 -Wno-pthreads-mem-growth -sMEMORY_GROWTH_GEOMETRIC_STEP=0 -sDECLARE_ASM_MODULE_EXPORTS=1 -sDEMANGLE_SUPPORT=1 ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.58)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sSTRICT=1")
|
|
||||||
endif ()
|
|
||||||
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.54)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sDEMANGLE_SUPPORT=1")
|
|
||||||
elseif (EMSCRIPTEN_VERSION VERSION_LESS 3.1.55)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --memory-init-file 0")
|
|
||||||
endif()
|
|
||||||
if (CMAKE_USE_PTHREADS_INIT)
|
if (CMAKE_USE_PTHREADS_INIT)
|
||||||
set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}") # Emscripten requires the -pthread flag
|
set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}") # Emscripten requires the -pthread flag
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-sPROXY_TO_PTHREAD=0 -sPTHREAD_POOL_SIZE=3 ${CMAKE_EXE_LINKER_FLAGS}") # See https://github.com/emscripten-core/emscripten/issues/16706
|
set(CMAKE_EXE_LINKER_FLAGS "-sPROXY_TO_PTHREAD=0 -sPTHREAD_POOL_SIZE=3 ${CMAKE_EXE_LINKER_FLAGS}") # See https://github.com/emscripten-core/emscripten/issues/16706
|
||||||
@ -213,16 +202,13 @@ if (EMSCRIPTEN)
|
|||||||
set(NODE_PACKAGE_PROGRAM "${NPM_PRESENT}")
|
set(NODE_PACKAGE_PROGRAM "${NPM_PRESENT}")
|
||||||
endif()
|
endif()
|
||||||
if (DEFINED NODE_PACKAGE_PROGRAM)
|
if (DEFINED NODE_PACKAGE_PROGRAM)
|
||||||
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.58)
|
|
||||||
set(YAO_ASSETS "\n \"assets\": \"../${EXENAME}.worker.js\",")
|
|
||||||
endif()
|
|
||||||
configure_file("resources/package.json" "processed/package.json" @ONLY)
|
configure_file("resources/package.json" "processed/package.json" @ONLY)
|
||||||
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/processed/package.json" DESTINATION ".")
|
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/processed/package.json" DESTINATION ".")
|
||||||
file(COPY "resources/.npmrc" DESTINATION ".")
|
file(COPY "resources/.npmrc" DESTINATION ".")
|
||||||
add_custom_target(yao_pkg COMMAND ${NODE_PACKAGE_PROGRAM} install)
|
add_custom_target(vercel_pkg COMMAND ${NODE_PACKAGE_PROGRAM} install)
|
||||||
add_dependencies(yao_pkg ${EXENAME})
|
add_dependencies(vercel_pkg ${EXENAME})
|
||||||
# Warning: https://github.com/sbingner/ldid has to be on the PATH, before packaging, for the arm64 macOS executable to work
|
# Warning: https://github.com/sbingner/ldid has to be on the PATH, before packaging, for the arm64 macOS executable to work
|
||||||
add_custom_command(TARGET yao_pkg POST_BUILD COMMAND node_modules/.bin/pkg --config processed/package.json -C Brotli $<TARGET_FILE:${EXENAME}> --no-bytecode --public-packages "\"*\"" --public --output "${EXENAME}-mac" VERBATIM)
|
add_custom_command(TARGET vercel_pkg POST_BUILD COMMAND node_modules/.bin/pkg --config processed/package.json -C Brotli $<TARGET_FILE:${EXENAME}> --no-bytecode --public-packages "\"*\"" --public --output "${EXENAME}-mac" VERBATIM)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
@ -3,19 +3,18 @@ def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disa
|
|||||||
boolean use_yarn_or_npm() { return fileExists('/usr/bin/yarn') || fileExists('/usr/bin/npm') }
|
boolean use_yarn_or_npm() { return fileExists('/usr/bin/yarn') || fileExists('/usr/bin/npm') }
|
||||||
|
|
||||||
/* Required Plugins:
|
/* Required Plugins:
|
||||||
- CMake 3.21 or higher
|
- CMake
|
||||||
- Sidebar Link
|
- Sidebar Link
|
||||||
- Workspace Cleanup
|
- Workspace Cleanup
|
||||||
Required Compilers:
|
Required Compilers:
|
||||||
- Musl cross-compiling toolchains (archives ending in "-cross" from https://musl.cc/#binaries) for x86_64, i686, armel, armhf, aarch64 and riscv64, unzipped into /usr/, along with soft links from /usr/bin/ to the binaries
|
- Musl cross-compiling toolchains (archives ending in "-cross" from https://musl.cc/#binaries) for x86_64, i686, armel, armhf, aarch64 and riscv64, unzipped into /usr/, along with soft links from /usr/bin/ to the binaries
|
||||||
- Emscripten Clang (https://github.com/emscripten-core/emsdk; the 3.1.30 version is known to work) in /usr/share/
|
- Emscripten Clang (https://github.com/emscripten-core/emsdk; the 3.1.30 version is known to work) in /usr/share/
|
||||||
- MinGW32 G++/Clang (https://github.com/mstorsjo/llvm-mingw) for x86_64, i686, armhf and aarch64, (unzip the content of the folder in the tar.xz file) in /usr/, along with soft links from /usr/bin/ to the binaries
|
- MinGW32 G++/Clang (https://github.com/mstorsjo/llvm-mingw) for x86_64, i686, armhf and aarch64, (unzip the content of the folder in the tar.xz file) in /usr/, along with soft links from /usr/bin/ to the binaries
|
||||||
- Android NDK Clang (https://ci.android.com/builds/submitted/10493228/linux/latest/android-ndk-10493228-linux-x86_64.zip) unzipped as /usr/android-ndk
|
|
||||||
Optional Tools:
|
Optional Tools:
|
||||||
- Ninja
|
- Ninja
|
||||||
- UPX (d61edc9 or higher)
|
- UPX (d61edc9 or higher)
|
||||||
- NPM/Yarn to enable Yao PKG (https://github.com/yao-pkg/pkg)
|
- Vercel PKG (https://github.com/vercel/pkg)
|
||||||
- LDID (https://github.com/ProcursusTeam/ldid or https://github.com/sbingner/ldid)
|
- LDID (https://github.com/sbingner/ldid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
@ -40,7 +39,7 @@ pipeline {
|
|||||||
name 'TARGET'
|
name 'TARGET'
|
||||||
values(
|
values(
|
||||||
'x86_64-linux-musl (RPM=x86_64, DEB=amd64)',
|
'x86_64-linux-musl (RPM=x86_64, DEB=amd64)',
|
||||||
'i686-linux-musl (RPM=i686, DEB=i386)',
|
'i686-linux-musl (RPM=i386, DEB=i386)',
|
||||||
'armel-linux-musleabi (RPM=armv4l, DEB=armel)',
|
'armel-linux-musleabi (RPM=armv4l, DEB=armel)',
|
||||||
'armv7l-linux-musleabihf (RPM=armv7hl, DEB=armhf)',
|
'armv7l-linux-musleabihf (RPM=armv7hl, DEB=armhf)',
|
||||||
'aarch64-linux-musl (RPM=aarch64, DEB=arm64)',
|
'aarch64-linux-musl (RPM=aarch64, DEB=arm64)',
|
||||||
@ -49,10 +48,6 @@ pipeline {
|
|||||||
'i686-w64-mingw32 (RPM=i386, DEB=i386)',
|
'i686-w64-mingw32 (RPM=i386, DEB=i386)',
|
||||||
'armv7-w64-mingw32 (RPM=armv7hl, DEB=armhf)',
|
'armv7-w64-mingw32 (RPM=armv7hl, DEB=armhf)',
|
||||||
'aarch64-w64-mingw32 (RPM=aarch64, DEB=arm64)',
|
'aarch64-w64-mingw32 (RPM=aarch64, DEB=arm64)',
|
||||||
'x86_64-linux-android21 (RPM=x86_64, DEB=amd64) -> x86_64',
|
|
||||||
'i686-linux-android21 (RPM=i686, DEB=i386) -> x86',
|
|
||||||
'armv7a-linux-android21 (RPM=armv7, DEB=armhf) -> armeabi-v7a',
|
|
||||||
'aarch64-linux-android21 (RPM=aarch64, DEB=arm64) -> arm64-v8a',
|
|
||||||
'/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
|
'/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -65,15 +60,16 @@ pipeline {
|
|||||||
final String path = use_toolchain ? "${TARGET}" : "${TARGET}".substring(0, "${TARGET}".indexOf(' ('))
|
final String path = use_toolchain ? "${TARGET}" : "${TARGET}".substring(0, "${TARGET}".indexOf(' ('))
|
||||||
final String rpmArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('(RPM=') + 5, "${TARGET}".indexOf(','))
|
final String rpmArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('(RPM=') + 5, "${TARGET}".indexOf(','))
|
||||||
final String debArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('DEB=') + 4, "${TARGET}".indexOf(')'))
|
final String debArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('DEB=') + 4, "${TARGET}".indexOf(')'))
|
||||||
final String system_name = path.contains('mingw') ? 'Windows' : (path.contains('android') ? 'Android' : sh(returnStdout: true, script: 'uname -s').trim())
|
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
|
||||||
final String linker = "/usr/bin/${path}-ld"
|
final String linker = "/usr/bin/${path}-ld"
|
||||||
final boolean not_packer_compatible = path.contains('riscv') || ((path.contains('aarch64') || path.contains('arm')) && path.contains('mingw'))
|
final boolean not_packer_compatible = path.contains('riscv') || ((path.contains('aarch64') || path.contains('arm')) && path.contains('mingw'))
|
||||||
final String build_directory = "cmake-build-${use_toolchain ? path.substring(path.lastIndexOf('/') + 1, path.length() - 6) : path}".toLowerCase()
|
final String build_directory = "cmake-build-${use_toolchain ? path.substring(path.lastIndexOf('/') + 1, path.length() - 6) : path}".toLowerCase()
|
||||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||||
|
// Note: CMake 3.20 or higher is needed
|
||||||
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
||||||
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCXX_TARGET=\"${use_toolchain ? 'noarch' : debArch}\" -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ ${system_name == 'Android' ? "-DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_CXX_FLAGS=-static-openmp -DCMAKE_ANDROID_NDK=/usr/android-ndk -DCMAKE_ANDROID_ARCH_ABI=${"${TARGET}".substring("${TARGET}".indexOf(' -> ') + 4)}" : "-DCMAKE_SYSTEM_PROCESSOR=${path.substring(0, path.indexOf('-'))}"} -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON${path.endsWith('armv7-w64-mingw32') ? ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=NO' : ''}",
|
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCXX_TARGET=\"${use_toolchain ? 'noarch' : debArch}\" -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCMAKE_SYSTEM_PROCESSOR=\"${path.substring(0, path.indexOf('-'))}\" -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON${path.endsWith('armv7-w64-mingw32') ? ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=NO' : ''}",
|
||||||
generator: cmake_generator()
|
generator: cmake_generator()
|
||||||
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'yao_pkg'}", installation: 'Latest'
|
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'vercel_pkg'}", installation: 'Latest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
"name": "@EXENAME@",
|
"name": "@EXENAME@",
|
||||||
"bin": "@EXENAME@.js",
|
"bin": "@EXENAME@.js",
|
||||||
"license": "@CPACK_RPM_PACKAGE_LICENSE@",
|
"license": "@CPACK_RPM_PACKAGE_LICENSE@",
|
||||||
"devDependencies": { "@yao-pkg/pkg": "^5.9.0" },
|
"devDependencies": { "pkg": "^5.8.0" },
|
||||||
"pkg": {@YAO_ASSETS@
|
"pkg": {
|
||||||
|
"assets": "../@EXENAME@.worker.js",
|
||||||
"targets": [
|
"targets": [
|
||||||
"latest-macos-x64",
|
"latest-macos-x64",
|
||||||
"latest-macos-arm64"
|
"latest-macos-arm64"
|
||||||
|
@ -81,5 +81,10 @@ vector<tok> lex(const string_view& in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Test
|
||||||
|
for (const auto& it : resVal) {
|
||||||
|
cout << it << ' ' << it.toktype << '\n';
|
||||||
|
}
|
||||||
|
*/
|
||||||
return resVal;
|
return resVal;
|
||||||
}
|
}
|
10
src/main.cpp
10
src/main.cpp
@ -52,22 +52,22 @@ int main(int argc, char* argv[]) {
|
|||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
if (not parallel) omp_set_num_threads(1);
|
if (not parallel) omp_set_num_threads(1);
|
||||||
#endif
|
#endif
|
||||||
filesystem::path file_path;
|
optional<filesystem::path> file_path;
|
||||||
if (not text_provided) file_path = mount(currentArgument);
|
if (not text_provided) file_path = mount(currentArgument);
|
||||||
Units.insert_or_assign(currentArgument, async(not parallel ? launch::deferred : launch::async, [&, currentArgument, file_path, index = Units.size() + 1]() {
|
Units.insert_or_assign(currentArgument, async(not parallel ? launch::deferred : launch::async, [&, currentArgument, file_path, index = Units.size() + 1]() {
|
||||||
unit_result resultingPair;
|
unit_result resultingPair;
|
||||||
try {
|
try {
|
||||||
resultingPair.first = Target::forName(target, newLines)->transpileWithTree(
|
resultingPair.first = Target::forName(target, newLines)->transpileWithTree(
|
||||||
parseString(text_provided ? string(currentArgument) + '\n' : getFileContent(file_path.string(/* NOTE: This string is expected to finish with a line ending */)))
|
parseString(text_provided ? string(currentArgument) + '\n' : getFileContent(file_path->string(/* NOTE: This string is expected to finish with a line ending */)))
|
||||||
);
|
);
|
||||||
if (!text_provided or output_directory.has_value())
|
if (!text_provided or output_directory.has_value())
|
||||||
outputFileContent(
|
outputFileContent(
|
||||||
(not output_directory.has_value() ? filesystem::path(file_path)
|
(not output_directory.has_value() ? filesystem::path(file_path.value())
|
||||||
: output_directory->append(
|
: output_directory->append(
|
||||||
(not text_provided) ? file_path.filename().string() : to_string(index))
|
(not text_provided) ? file_path->filename().string() : to_string(index))
|
||||||
).replace_extension(target).string(), resultingPair.first);
|
).replace_extension(target).string(), resultingPair.first);
|
||||||
} catch (const Yerbacon::Exception& error) {
|
} catch (const Yerbacon::Exception& error) {
|
||||||
resultingPair.first = not text_provided ? file_path.filename().string() : string();
|
resultingPair.first = file_path.has_value() ? file_path->filename().string() : string();
|
||||||
resultingPair.second.emplace(error);
|
resultingPair.second.emplace(error);
|
||||||
}
|
}
|
||||||
return resultingPair;
|
return resultingPair;
|
||||||
|
Loading…
Reference in New Issue
Block a user