-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for multiple astyle versions; add 3.4.7
- Loading branch information
Showing
21 changed files
with
205 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
tmp | ||
dist | ||
build | ||
*.egg-info | ||
__pycache__ | ||
.venv | ||
.idea | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Script to build WASM library for Astyle 3.1. | ||
|
||
Run: | ||
|
||
```bash | ||
./build.sh | ||
``` | ||
|
||
This should build the docker image with Emscripten SDK, download Astyle and build it with Emscripten. The resulting library will be copied to `astyle_py/lib/3.1/libastyle.wasm`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
if(NOT DEFINED ENV{EMSDK_PATH}) | ||
message(FATAL_ERROR "EMSDK_PATH environment variable not set") | ||
endif() | ||
|
||
if(NOT DEFINED ASTYLE_VER) | ||
message(FATAL_ERROR "ASTYLE_VER cache variable not set") | ||
endif() | ||
|
||
set(CMAKE_TOOLCHAIN_FILE $ENV{EMSDK_PATH}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake) | ||
|
||
set(BUILD_STATIC_LIBS 1 CACHE BOOL "Build static libraries") | ||
|
||
project(astyle-wasm) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
astyle | ||
GIT_REPOSITORY https://gitlab.com/saalen/astyle.git | ||
GIT_TAG ${ASTYLE_VER} | ||
) | ||
FetchContent_MakeAvailable(astyle) | ||
|
||
|
||
add_executable(astyle-wasm wrapper.c) | ||
target_link_libraries(astyle-wasm PRIVATE astyle) | ||
|
||
target_link_libraries(astyle-wasm PRIVATE "-s EXPORTED_FUNCTIONS=[\"_AStyleGetVersion\",\"_AStyleWrapper\",\"_malloc\",\"_free\",\"_AStyleErrorHandler\"]") | ||
target_link_libraries(astyle-wasm PRIVATE "-s STANDALONE_WASM=1") | ||
target_link_libraries(astyle-wasm PRIVATE "-s ERROR_ON_UNDEFINED_SYMBOLS=0") | ||
target_link_libraries(astyle-wasm PRIVATE "-s WARN_ON_UNDEFINED_SYMBOLS=1") | ||
target_link_libraries(astyle-wasm PRIVATE --no-entry) | ||
target_link_libraries(astyle-wasm PRIVATE -Wl,--import-undefined) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Build script for Astyle 3.3 and later. | ||
|
||
Run: | ||
|
||
``` | ||
./build.sh <version> | ||
``` | ||
|
||
where `<version>` is the version of Astyle you want to build. For example, `3.4.7`. | ||
|
||
The script will build a Docker image with Emscripten SDK, download the required version of Astyle and build it with Emscripten. Since Astyle >=3.3 has a CMake build system, everything is conveniently handled in CMakeLists.txt. | ||
|
||
The resulting library will be copied to `astyle_py/lib/<version>/libastyle.wasm`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# argument is the version number | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <astyle_version>" | ||
exit 1 | ||
fi | ||
|
||
ASTYLE_VERSION=$1 | ||
|
||
DOCKER_DIR=${PWD}/../docker | ||
docker build -t emsdk ${DOCKER_DIR} | ||
|
||
TMP_DIR=${PWD}/../tmp/${ASTYLE_VERSION} | ||
mkdir -p ${TMP_DIR} | ||
DST_DIR=${PWD}/../../astyle_py/lib/${ASTYLE_VERSION} | ||
mkdir -p ${DST_DIR} | ||
|
||
docker run --rm -v ${PWD}:/src -v ${TMP_DIR}:/build emsdk bash -c "cmake -S /src -B /build -DASTYLE_VER=${ASTYLE_VERSION} && cmake --build /build" | ||
cp ${TMP_DIR}/astyle-wasm.wasm ${DST_DIR}/libastyle.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdlib.h> | ||
void AStyleErrorHandler(int errorNumber, const char* errorMessage); | ||
char* AStyleMain(const char* pSourceIn, const char* pOptions, void (*fpError)(int, const char*), void* (*fpAlloc)(unsigned long)); | ||
|
||
char* AStyleWrapper(const char* pSourceIn, const char* pOptions) | ||
{ | ||
return AStyleMain(pSourceIn, pOptions, &AStyleErrorHandler, malloc); | ||
} |
Oops, something went wrong.