Skip to content

Commit

Permalink
🤺 Task v2 (sweetpad-dev#5)
Browse files Browse the repository at this point in the history
Add new task executor
  • Loading branch information
hyzyla authored Apr 6, 2024
1 parent 1c49237 commit 0397d82
Show file tree
Hide file tree
Showing 14 changed files with 684 additions and 186 deletions.
50 changes: 22 additions & 28 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": ["camelCase", "PascalCase"]
}
],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": [ "camelCase", "PascalCase" ]
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
}
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ dist
node_modules
.vscode-test/
*.vsix

# Temporary files for building setvbuf
.temp/
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,21 +298,36 @@
"type": "boolean",
"default": true,
"description": "Enable xcbeautify for build logs."
},
"sweetpad.system.taskExecutor": {
"type": "string",
"default": "v2",
"enum": [
"v1",
"v2"
],
"enumDescriptions": [
"Legacy executor, use this if you have issues with the new executor.",
"New executor, use this for better performance and better error handling."
],
"description": "Use version task executor for build tasks."
}
}
}
},
"scripts": {
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"vscode:prepublish": "npm run esbuild-base -- --minify",
"vscode:prepublish": "npm run compile-setvbuf && npm run esbuild-base -- --minify",
"build": "npm run esbuild-base -- --sourcemap",
"watch": "npm run esbuild-base -- --sourcemap --watch",
"test": "vscode-test",
"check": "eslint . --ext .ts && tsc --noEmit"
"check": "eslint . --ext .ts && tsc --noEmit",
"compile-setvbuf": "bash ./setvbuf/compile.sh"
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@types/node": "18.x",
"@types/shell-quote": "^1.7.5",
"@types/vscode": "^1.85.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
Expand All @@ -324,6 +339,7 @@
},
"dependencies": {
"execa": "npm:@esm2cjs/execa@^6.1.1-cjs.1",
"shell-quote": "^1.8.1",
"vscode-languageclient": "^9.0.1"
}
}
31 changes: 31 additions & 0 deletions setvbuf/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -Eeuo pipefail

# Path to your source file
SOURCE_FILE="setvbuf/setvbuf.c"

# Set locations
TEMP_DIR="./.temp"
OUT_DIR="./out"

# Ensure directories exist
mkdir -p $TEMP_DIR
mkdir -p $OUT_DIR

# Compile for arm64 architecture
clang -O2 -fpic -shared -arch arm64 -o $TEMP_DIR/setvbuf_arm64.so $SOURCE_FILE

# Compile for x86_64 architecture
clang -O2 -fpic -shared -arch x86_64 -o $TEMP_DIR/setvbuf_x86_64.so $SOURCE_FILE

# Create a Universal Binary from the architecture-specific files
lipo -create -output $OUT_DIR/setvbuf_universal.so $TEMP_DIR/setvbuf_arm64.so $TEMP_DIR/setvbuf_x86_64.so

# Optionally, remove the architecture-specific shared libraries if not needed
rm $TEMP_DIR/setvbuf_arm64.so $TEMP_DIR/setvbuf_x86_64.so

# Remove the temporary directory if not needed
rm -r $TEMP_DIR

echo "Universal binary created at out/setvbuf_universal.so"

13 changes: 13 additions & 0 deletions setvbuf/setvbuf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>

/**
* This program sets the buffering mode of stdout to line buffered.
*
* It's a hacky way to make sure that the output of the program is
* line buffered, even if the program is run in a non-interactive
* environment.
*/
void __attribute__((constructor)) initLibrary(void) {
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
}
Loading

0 comments on commit 0397d82

Please sign in to comment.