diff --git a/.gitignore b/.gitignore index f6f7db4b..6bc64446 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build**/ upstream**/ **/dist/ +**/cmake-build**/ # build cache files **/*.idx diff --git a/tooling/CMakeLists.txt b/tooling/CMakeLists.txt new file mode 100644 index 00000000..fc05eb87 --- /dev/null +++ b/tooling/CMakeLists.txt @@ -0,0 +1,30 @@ +# set minimum cmake version +cmake_minimum_required(VERSION 3.26) + +# set project name +project(wasmtools) + +# set c++ standard +set(CMAKE_CXX_STANDARD 20) + +# set output directory +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/wasm-utils) + +file(GLOB WASM_UTILS_SRC ${CMAKE_SOURCE_DIR}/wasm-utils/*.cpp) +file(GLOB WASM_UTILS_HEADERS ${CMAKE_SOURCE_DIR}/wasm-utils/*.hpp) +file(GLOB WASM_TRANSFORM_SRC ${CMAKE_SOURCE_DIR}/wasm-transform/*.cpp) +file(GLOB WASM_PACKAGE_SRC ${CMAKE_SOURCE_DIR}/wasm-package/*.cpp) + +include_directories(${CMAKE_SOURCE_DIR}/wasm-utils) + +# set linker flags if EMSCRIPTEN +if(EMSCRIPTEN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=_main,_free,_malloc -s EXPORTED_RUNTIME_METHODS=FS,PROXYFS,ERRNO_CODES,allocateUTF8 -lproxyfs.js --js-library=${CMAKE_SOURCE_DIR}/../emlib/fsroot.js -lidbfs.js -flto -O3") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -O3") +endif() + +add_executable(wasm-transform ${WASM_TRANSFORM_SRC} ${WASM_UTILS_SRC} ${WASM_UTILS_HEADERS}) +add_executable(wasm-package ${WASM_PACKAGE_SRC} ${WASM_UTILS_SRC} ${WASM_UTILS_HEADERS}) \ No newline at end of file diff --git a/tooling/wasm-package/wasm-package.cpp b/tooling/wasm-package/wasm-package.cpp index d0509b89..112ced26 100755 --- a/tooling/wasm-package/wasm-package.cpp +++ b/tooling/wasm-package/wasm-package.cpp @@ -58,9 +58,13 @@ int main(int argc, const char *argv[]) { if (lstat(name, &status) == 0) { buffer.write(name); buffer.write(status.st_mode); +#if defined(__APPLE__) + buffer.write(status.st_atimespec.tv_sec); + buffer.write(status.st_mtimespec.tv_sec); +#else buffer.write(status.st_atim.tv_sec); buffer.write(status.st_mtim.tv_sec); - +#endif switch (status.st_mode & S_IFMT) { case S_IFREG: // normal file buffer.write(readFile(name));