8000 Enforce strict mode by UrielCh · Pull Request #8 · aapoalas/libclang_deno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enforce strict mode #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b60ebed
fix ffi windows support
UrielCh Jan 30, 2023
0cbccbe
add windows test pipeline
UrielCh Jan 30, 2023
49509e6
add --allow-downgrade
UrielCh Jan 30, 2023
a6b2822
fix workflow name + add Ubuntu test
UrielCh Jan 30, 2023
0e49fc3
patch ubuntu test
UrielCh Jan 30, 2023
b9a5044
add macOS Test build
UrielCh Jan 30, 2023
621d05f
improve error handling
UrielCh Jan 30, 2023
43ee22b
add --allow-read
UrielCh Jan 30, 2023
bc7926e
patch test env
UrielCh Jan 30, 2023
d5c9692
fix Expressions syntax
UrielCh Jan 30, 2023
867c98f
hard code homebrew path
UrielCh Jan 30, 2023
b8a9f09
change LIBCLANG_PATH usAGE
UrielCh Jan 30, 2023
2901482
ADD MISSING }
UrielCh Jan 30, 2023
9dd8b32
add debug step
UrielCh Jan 30, 2023
2b669a1
patch macOS
UrielCh Jan 30, 2023
70b0b4a
more test
UrielCh Jan 30, 2023
8c93e19
add brew install
UrielCh Jan 30, 2023
e3b36bd
change lib to libclang.dylib
UrielCh Jan 30, 2023
53394d4
rempve allow-read
UrielCh Jan 30, 2023
8e47c74
improve testUbuntu
UrielCh Jan 30, 2023
d17c5d4
ubuntu patch
UrielCh Jan 30, 2023
31247c8
rollback ubuntu + update mac
UrielCh Jan 30, 2023
1b8fa27
2 patch in mac script
UrielCh Jan 30, 2023
228e983
add run test LIBCLANG_PATH pointing to directory
UrielCh Jan 30, 2023
e3db9e1
patch windows
UrielCh Jan 30, 2023
489aa3e
add second case in test windows
UrielCh Jan 30, 2023
b624cb6
fix ubuntu search
UrielCh Jan 30, 2023
b90325b
typo
UrielCh Jan 30, 2023
5ea35a5
Merge branch 'testing' of github.com:UrielCh/libclang_deno into testing
UrielCh Jan 30, 2023
a614b72
upper case constant
UrielCh Jan 30, 2023
5601c22
drop Set usage
UrielCh Jan 30, 2023
3e1d6b8
WINDOWS_SUBSET is now as const
UrielCh Jan 30, 2023
33b942b
add WindowsSubSet type
UrielCh Jan 30, 2023
24b5e81
change clang type
UrielCh Jan 30, 2023
a4173e3
reverst windows subset test
UrielCh Jan 30, 2023
2ff4103
deno fmt
UrielCh Jan 30, 2023
2b285d8
fix export
UrielCh Jan 30, 2023
54e7365
add test to avoid linter warnings
UrielCh Jan 30, 2023
f75b9ff
lint code
UrielCh Jan 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/testMacOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Testing LLVM on MacOS

on:
push:
branches: [ "testing", "main" ]
paths:
- ".github/workflows/testMacOS.yml"
- "build/**"
- "lib/**"
- "test/**"
pull_request:
branches: [ "testing", "main" ]
paths:
- ".github/workflows/testMacOS.yml"
- "build/**"
- "lib/**"
- "test/**"

jobs:
build:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: 1.30.0
- name: install llvm@14
run: brew install llvm@14
- name: debug path
run: brew --prefix llvm@14
- name: list lib
run: ls $(brew --prefix llvm@14)
- name: list lib/lib
run: ls $(brew --prefix llvm@14)/lib
- name: run test LIBCLANG_PATH pointing to file
run: |
export LIBCLANG_PATH="$(brew --prefix llvm@14)/lib/libclang.dylib"
deno task test
- name: run test LIBCLANG_PATH pointing to directory
run: |
export LIBCLANG_PATH="$(brew --prefix llvm@14)/lib/"
deno task test
44 changes: 44 additions & 0 deletions .github/workflows/testUbuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Testing LLVM on Ubuntu

on:
push:
branches: [ "testing", "main", "deno.json" ]
paths:
- ".github/workflows/testUbuntu.yml"
- "build/**"
- "lib/**"
- "test/**"
pull_request:
branches: [ "testing", "main", "deno.json" ]
paths:
- ".github/workflows/testUbuntu.yml"
- "build/**"
- "lib/**"
- "test/**"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: 1.30.0

- name: Uninstall old LLVM
run: |
sudo apt-get remove -y libclang*

- name: Install LLVM
run: |
sudo apt-get install -y libclang1-14

- name: run test LIBCLANG_PATH pointing to file
run: |
export LIBCLANG_PATH=/usr/lib/llvm-14/lib/libclang-14.so.1
deno task test

- name: run test LIBCLANG_PATH pointing to directory
run: |
export LIBCLANG_PATH=/usr/lib/llvm-14/lib/
deno task test
46 changes: 46 additions & 0 deletions .github/workflows/testWindows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Testing LLVM on windows

on:
push:
branches: [ "testing", "main" ]
paths:
- ".github/workflows/testWindows.yml"
- "build/**"
- "lib/**"
- "test/**"
pull_request:
branches: [ "testing", "main" ]
paths:
- ".github/workflows/testWindows.yml"
- "build/**"
- "lib/**"
- "test/**"

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: 1.30.0

- name: Install LLVM
run: |
choco install -y --allow-downgrade --version 14.0.6 llvm

# - name: add LLVM path to PATH environment variable
# uses: myci-actions/export-env-var-powershell@1
# with:
# name: PATH
# value: $env:PATH;$env:LIBCLANG_PATH

- name: run test LIBCLANG_PATH pointing to file
run: |
$Env:LIBCLANG_PATH="C:\Program Files\LLVM\bin\libclang.dll"
deno task test

- name: run test LIBCLANG_PATH pointing to directory
run: |
$Env:LIBCLANG_PATH="C:\Program Files\LLVM\bin\"
deno task test
17 changes: 15 additions & 2 deletions build/build_utils.ts
< FBA5 /tr>
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const toEnumType = (
) => {
const enumType = typeDeclaration.getEnumDeclarationIntegerType();
const values: EnumValue[] = [];
if (!enumType) throw Error('internal error "enumType" is null');
const isUnsignedInt = enumType.kind === CXTypeKind.CXType_Bool ||
enumType.kind === CXTypeKind.CXType_Char_U ||
enumType.kind === CXTypeKind.CXType_UChar ||
Expand Down Expand Up @@ -286,6 +287,7 @@ export const toAnyType = (
const typekind = type.kind;
if (typekind === CXTypeKind.CXType_Elaborated) {
const typeDeclaration = type.getTypeDeclaration();
if (!typeDeclaration) throw Error('internal error "typeDeclaration" is null');
if (typeDeclaration.kind === CXCursorKind.CXCursor_EnumDecl) {
const name = type.getSpelling().substring(5); // drop `enum ` prefix
if (typeMemory.has(name)) {
Expand All @@ -310,6 +312,7 @@ export const toAnyType = (
};
return voidType;
}
if (!structDeclaration) throw Error('internal error "structDeclaration" is null');
const structType: StructType = {
fields,
kind: "struct",
Expand All @@ -328,9 +331,11 @@ export const toAnyType = (
);
}
const fieldType = fieldCursor.getType();
if (!fieldType) throw Error('internal error "fieldType" is null');
if (fieldType.kind === CXTypeKind.CXType_ConstantArray) {
const length = fieldType.getArraySize();
const elementType = fieldType.getArrayElementType();
if (!elementType) throw Error('internal error "elementType" is null');
const baseName = fieldCursor.getDisplayName();
const baseOffset = fieldCursor.getOffsetOfField() / 8;
const elementSize = elementType.getSizeOf();
Expand Down Expand Up @@ -374,6 +379,9 @@ export const toAnyType = (
}
} else if (typekind === CXTypeKind.CXType_FunctionProto) {
const typeDeclaration = type.getTypeDeclaration();
if (!typeDeclaration) throw Error('internal error "typeDeclaration" is null');
const resultType = type.getResultType();
if (!resultType) throw Error('internal error "resultType" is null');
const result: FunctionType = {
comment: commentToJSDcoString(
typeDeclaration.getParsedComment(),
Expand All @@ -383,11 +391,12 @@ export const toAnyType = (
name: type.getSpelling(),
parameters: [],
reprName: `${type.getSpelling()}T`,
result: toAnyType(typeMemory, type.getResultType()),
result: toAnyType(typeMemory, resultType),
};
const length = type.getNumberOfArgumentTypes();
for (let i = 0; i < length; i++) {
const argument = type.getArgumentType(i);
if (!argument) throw Error('internal error "argument" is null');
result.parameters.push({
comment: null,
name: argument.getSpelling(),
Expand All @@ -397,6 +406,7 @@ export const toAnyType = (
return result;
} else if (typekind === CXTypeKind.CXType_Pointer) {
const pointee = type.getPointeeType();
if (!pointee) throw Error('internal error "pointee" is null')

if (
pointee.kind === CXTypeKind.CXType_Char_S
Expand All @@ -421,7 +431,7 @@ export const toAnyType = (
return cstringResult;
} else if (
pointee.kind === CXTypeKind.CXType_Pointer &&
pointee.getPointeeType().kind === CXTypeKind.CXType_Char_S
pointee.getPointeeType()!.kind === CXTypeKind.CXType_Char_S
) {
// `const char **` or `char **`
const cstringArrayResult: TypeReference = {
Expand Down Expand Up @@ -467,9 +477,11 @@ export const toAnyType = (
if (!typeMemory.has(name)) {
// Check for potentially needed system header definitions.
const typedecl = type.getTypeDeclaration();
if (!typedecl) throw Error('internal error "typedecl" is null')
const location = typedecl.getLocation();
if (location.isInSystemHeader()) {
const sourceType = typedecl.getTypedefDeclarationOfUnderlyingType();
if (!sourceType) throw Error('internal error "sourceType" is null')
const sourceAnyType = toAnyType(typeMemory, sourceType);
typeMemory.set(name, sourceAnyType);
}
Expand All @@ -486,6 +498,7 @@ export const toAnyType = (
return typeMemory.get(name)!;
}
const typeDeclaration = type.getTypeDeclaration();
if (!typeDeclaration) throw Error('internal error "typeDeclaration" is null');
const result = toEnumType(typeMemory, name, typeDeclaration);
typeMemory.set(name, result);
return result;
Expand Down
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"lock": true,
"tasks": {
"build": "deno run --unstable --allow-env=LIBCLANG_PATH --allow-run=deno --allow-ffi --allow-write=lib/include build/build.ts"
"build": "deno run --unstable --allow-env=LIBCLANG_PATH --allow-run=deno --allow-ffi --allow-write=lib/include build/build.ts",
"test": "deno test --unstable --allow-env=LIBCLANG_PATH --allow-run=deno --allow-ffi"
}
}
13 changes: 13 additions & 0 deletions deno.lock

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

Loading
0