Compare commits
10 Commits
8a7f556520
...
023af39a22
Author | SHA1 | Date |
---|---|---|
Username404-59 | 023af39a22 | |
Username404-59 | d4c854d8ef | |
Username404-59 | 1f319e9697 | |
Username404-59 | 3d97955d41 | |
Username404-59 | 5d43854e6d | |
Username404-59 | 8f92674387 | |
Username404 | 7a4549dafb | |
Username404 | 7d5abdf9b5 | |
Username404 | 2b22029e77 | |
Username404 | 1a9b549f9b |
|
@ -67,6 +67,9 @@ if (${IS_GNU} OR ${IS_CLANG})
|
|||
include(FindOpenMP)
|
||||
if (OpenMP_CXX_FOUND)
|
||||
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)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -78,7 +81,15 @@ if (${IS_GNU} OR ${IS_CLANG})
|
|||
else()
|
||||
set(IS_HOST_NOT_ANDROID 0)
|
||||
endif()
|
||||
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}")
|
||||
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}")
|
||||
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)
|
||||
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
|
||||
|
@ -202,13 +213,16 @@ if (EMSCRIPTEN)
|
|||
set(NODE_PACKAGE_PROGRAM "${NPM_PRESENT}")
|
||||
endif()
|
||||
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)
|
||||
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/processed/package.json" DESTINATION ".")
|
||||
file(COPY "resources/.npmrc" DESTINATION ".")
|
||||
add_custom_target(vercel_pkg COMMAND ${NODE_PACKAGE_PROGRAM} install)
|
||||
add_dependencies(vercel_pkg ${EXENAME})
|
||||
add_custom_target(yao_pkg COMMAND ${NODE_PACKAGE_PROGRAM} install)
|
||||
add_dependencies(yao_pkg ${EXENAME})
|
||||
# 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 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)
|
||||
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)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -3,18 +3,19 @@ def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disa
|
|||
boolean use_yarn_or_npm() { return fileExists('/usr/bin/yarn') || fileExists('/usr/bin/npm') }
|
||||
|
||||
/* Required Plugins:
|
||||
- CMake
|
||||
- CMake 3.21 or higher
|
||||
- Sidebar Link
|
||||
- Workspace Cleanup
|
||||
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
|
||||
- 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
|
||||
- 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:
|
||||
- Ninja
|
||||
- UPX (d61edc9 or higher)
|
||||
- Vercel PKG (https://github.com/vercel/pkg)
|
||||
- LDID (https://github.com/sbingner/ldid)
|
||||
- NPM/Yarn to enable Yao PKG (https://github.com/yao-pkg/pkg)
|
||||
- LDID (https://github.com/ProcursusTeam/ldid or https://github.com/sbingner/ldid)
|
||||
*/
|
||||
|
||||
pipeline {
|
||||
|
@ -39,7 +40,7 @@ pipeline {
|
|||
name 'TARGET'
|
||||
values(
|
||||
'x86_64-linux-musl (RPM=x86_64, DEB=amd64)',
|
||||
'i686-linux-musl (RPM=i386, DEB=i386)',
|
||||
'i686-linux-musl (RPM=i686, DEB=i386)',
|
||||
'armel-linux-musleabi (RPM=armv4l, DEB=armel)',
|
||||
'armv7l-linux-musleabihf (RPM=armv7hl, DEB=armhf)',
|
||||
'aarch64-linux-musl (RPM=aarch64, DEB=arm64)',
|
||||
|
@ -48,6 +49,10 @@ pipeline {
|
|||
'i686-w64-mingw32 (RPM=i386, DEB=i386)',
|
||||
'armv7-w64-mingw32 (RPM=armv7hl, DEB=armhf)',
|
||||
'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'
|
||||
)
|
||||
}
|
||||
|
@ -60,16 +65,15 @@ pipeline {
|
|||
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 debArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('DEB=') + 4, "${TARGET}".indexOf(')'))
|
||||
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
|
||||
final String system_name = path.contains('mingw') ? 'Windows' : (path.contains('android') ? 'Android' : sh(returnStdout: true, script: 'uname -s').trim())
|
||||
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 String build_directory = "cmake-build-${use_toolchain ? path.substring(path.lastIndexOf('/') + 1, path.length() - 6) : path}".toLowerCase()
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
// Note: CMake 3.20 or higher is needed
|
||||
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_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' : ''}",
|
||||
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' : ''}",
|
||||
generator: cmake_generator()
|
||||
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'vercel_pkg'}", installation: 'Latest'
|
||||
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'yao_pkg'}", installation: 'Latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
"name": "@EXENAME@",
|
||||
"bin": "@EXENAME@.js",
|
||||
"license": "@CPACK_RPM_PACKAGE_LICENSE@",
|
||||
"devDependencies": { "pkg": "^5.8.0" },
|
||||
"pkg": {
|
||||
"assets": "../@EXENAME@.worker.js",
|
||||
"devDependencies": { "@yao-pkg/pkg": "^5.9.0" },
|
||||
"pkg": {@YAO_ASSETS@
|
||||
"targets": [
|
||||
"latest-macos-x64",
|
||||
"latest-macos-arm64"
|
||||
|
|
|
@ -81,10 +81,5 @@ vector<tok> lex(const string_view& in)
|
|||
}
|
||||
}
|
||||
}
|
||||
/* Test
|
||||
for (const auto& it : resVal) {
|
||||
cout << it << ' ' << it.toktype << '\n';
|
||||
}
|
||||
*/
|
||||
return resVal;
|
||||
}
|
10
src/main.cpp
10
src/main.cpp
|
@ -52,22 +52,22 @@ int main(int argc, char* argv[]) {
|
|||
#ifdef _OPENMP
|
||||
if (not parallel) omp_set_num_threads(1);
|
||||
#endif
|
||||
optional<filesystem::path> file_path;
|
||||
filesystem::path file_path;
|
||||
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]() {
|
||||
unit_result resultingPair;
|
||||
try {
|
||||
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())
|
||||
outputFileContent(
|
||||
(not output_directory.has_value() ? filesystem::path(file_path.value())
|
||||
(not output_directory.has_value() ? filesystem::path(file_path)
|
||||
: 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);
|
||||
} catch (const Yerbacon::Exception& error) {
|
||||
resultingPair.first = file_path.has_value() ? file_path->filename().string() : string();
|
||||
resultingPair.first = not text_provided ? file_path.filename().string() : string();
|
||||
resultingPair.second.emplace(error);
|
||||
}
|
||||
return resultingPair;
|
||||
|
|
Loading…
Reference in New Issue