Skip to content
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

usvm-python #169

Merged
merged 344 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
344 commits
Select commit Hold shift + click to select a range
767cb7f
fix on linux
Sep 13, 2023
1947679
tp_getattro
Sep 14, 2023
c43822d
slice fields
tochilinak Sep 14, 2023
e48c22c
list_subscript on slices
Sep 14, 2023
b86ffae
allowed path diversion in test for slices
tochilinak Sep 14, 2023
abf90b4
Fixed state termination
tochilinak Sep 19, 2023
bad2e36
Added depth limit in SymbolTypeTree
tochilinak Sep 19, 2023
c847217
fix in virtualPathSelector
tochilinak Sep 19, 2023
28e4ba9
Fix after rebase
tochilinak Sep 19, 2023
39f06c1
More tuple operations
Sep 19, 2023
469e95a
Fixes after rebase
tochilinak Sep 20, 2023
54fde05
Started working on floats
tochilinak Sep 20, 2023
82d4a18
Float operations
Sep 21, 2023
5a36f6b
Global clones; float to int
Sep 21, 2023
34b4958
Accurate float operations
tochilinak Sep 26, 2023
891563b
Fixed bug in ElementConstraints
tochilinak Sep 26, 2023
aba314d
Fixed issues with GlobalHeapRef
tochilinak Sep 27, 2023
4fd9295
small fix
Sep 27, 2023
433d262
New structure for global refs
tochilinak Sep 27, 2023
e89cdb2
Fix for linux
Sep 27, 2023
3e69e27
Added nb_true_div for ints
Sep 28, 2023
df751de
Fixed memory leak from PathTrieNode
tochilinak Sep 28, 2023
23d97d0
new params in VirtualPathSelector; soft constraints on floats
tochilinak Sep 28, 2023
8fd2015
modified state labels
tochilinak Oct 3, 2023
4f10aef
Fixes after rebase
tochilinak Oct 3, 2023
66a8395
Added unregistered virtual operations to statistics
tochilinak Oct 3, 2023
f842195
added list_pop
Oct 3, 2023
6950dd6
some new list methods
tochilinak Oct 3, 2023
f67aac4
Create structure.md
tochilinak Oct 4, 2023
a0f3c04
Started switching to annotation processing
tochilinak Oct 5, 2023
fef2049
Implemented CPythonFunctionProcessor
tochilinak Oct 5, 2023
44c2149
got rid of jsons in cpythonadapter
tochilinak Oct 10, 2023
1830d5f
added annotations for descriptors
tochilinak Oct 10, 2023
2b3b4e5
fixes for linux
Oct 10, 2023
2cc7c8c
Implemented SymbolicMethodProcessor
tochilinak Oct 11, 2023
f375e1f
Switched to new SymbolicMethods
Oct 11, 2023
3563956
Removed some redundant code
tochilinak Oct 11, 2023
7e4fd35
updated docs, gradle tasks, cpython patch
Oct 11, 2023
bcdc988
Update structure.md
tochilinak Oct 11, 2023
2f2429b
Update API.md
tochilinak Oct 11, 2023
3be6408
Update API.md
tochilinak Oct 11, 2023
fc74e7e
update of cpython (added docs)
Oct 11, 2023
98b2cdb
added list.extend method
tochilinak Oct 11, 2023
b77b9d4
implemented list.clear()
tochilinak Oct 11, 2023
0e000b6
New approximations
Oct 17, 2023
403b001
Fixed some bugs; some new tests
tochilinak Oct 18, 2023
a365109
Added list.reverse(); refactored some old approximations
tochilinak Oct 18, 2023
ec6e6db
Added usvm-python runner
Oct 31, 2023
b49c6ce
Fixes after rebase
Oct 31, 2023
17d2f39
Fixed some warnings
Oct 31, 2023
ffdedd8
work on usvm-python package
Oct 31, 2023
0882a9a
Fixes after rebase; work on gradle scripts
Oct 31, 2023
a39e780
fixes in configurations
Oct 31, 2023
0506779
Added environment to build task in actions
Oct 31, 2023
8df411a
Added permissions
Oct 31, 2023
d83f94e
Added MavenPublication
Oct 31, 2023
52e5cc4
Added debug runner
Nov 1, 2023
06c3642
Fixed blocking accept()
Nov 1, 2023
5daab16
Started working on fields
tochilinak Nov 2, 2023
d939644
Supported calls of python methods
Nov 2, 2023
ec23ad6
preparations for further objects support
tochilinak Nov 4, 2023
dda4ea1
Fixed some crashes
tochilinak Nov 5, 2023
45d4966
Fixed one crash
tochilinak Nov 7, 2023
557e858
Added venv; updated usvm-python-runner
Nov 7, 2023
bd0d873
Fix in getTypeFromTypeHint
tochilinak Nov 8, 2023
d7cb91f
Several fixes; core update
tochilinak Nov 9, 2023
51440f2
fixed compilation on linux
Nov 9, 2023
1092628
Fix in build script
Nov 9, 2023
9f9e01c
fix in usvm-python-runner
Nov 9, 2023
9298b39
supported constructor calls
Nov 9, 2023
e623bf9
Supported load of default parameters
Nov 9, 2023
ca71b05
some tests
tochilinak Nov 9, 2023
13f220c
Fix in standard tp_getattro/tp_setattro logic
Nov 9, 2023
e9ea83e
Added WrappedSetRegion
tochilinak Nov 14, 2023
adcc694
Added virtual tp_call
Nov 15, 2023
7626df9
Several fixes
tochilinak Nov 15, 2023
98445bc
Reduced waiting time in loop
tochilinak Nov 15, 2023
00738ff
Trying to catch segfault
tochilinak Nov 15, 2023
3eccce4
Started working on dicts
Nov 15, 2023
dcc2998
usvm-python-runner: wrapped interruped in while loop
tochilinak Nov 15, 2023
9a79472
small fix
tochilinak Nov 15, 2023
232c118
new attempt
tochilinak Nov 15, 2023
96b300a
fix
tochilinak Nov 15, 2023
5c605c7
preparations for dict
Nov 16, 2023
a401bfe
Added heuristic that adds default fields to an object
tochilinak Nov 16, 2023
cf9449c
Added filtration
tochilinak Nov 16, 2023
c1a82f5
Fixed segfault
tochilinak Nov 17, 2023
d2475f0
Supported propertied
Nov 17, 2023
2260caa
Fixes after rebase
Nov 17, 2023
391ec29
Added restriction for index type
Nov 17, 2023
7372ea9
Fixed silly bug
tochilinak Nov 17, 2023
1a0061c
Added approximation for contains_op
Nov 21, 2023
1aa79a9
Changed processing of UnregisteredVirtualOperation
tochilinak Nov 21, 2023
d255b6a
Added nb_positive and nb_negative
Nov 21, 2023
f59d675
Started implementing dicts
tochilinak Nov 22, 2023
2946a94
Further work on dicts: int keys
Nov 22, 2023
2b0711d
Added some samples
tochilinak Nov 23, 2023
519ef4f
Added dict_set_item
tochilinak Nov 23, 2023
96831c3
fixed create_dict_const_key
Nov 23, 2023
f9fb2c9
Fixed one case of underapproximation
tochilinak Nov 23, 2023
54a97b2
Fixed a case of path diversion
tochilinak Nov 24, 2023
68bc86b
More work on underapproximations
tochilinak Nov 24, 2023
ca5e0e0
Fixed message in DebugRunner
tochilinak Nov 27, 2023
877010d
Fixed parsing of venv info
tochilinak Nov 27, 2023
3759d0d
Removed warning about loggin
tochilinak Nov 27, 2023
3637a2a
Changed logic of standard tp_getattro
tochilinak Nov 28, 2023
b8167e5
Added support for generators
tochilinak Nov 28, 2023
0253a78
Working on sending inputs from new states
tochilinak Nov 28, 2023
daf9e37
Added substitution of virtual objects to None
Nov 28, 2023
aafef78
onNewState for initial state
Nov 28, 2023
1c083b6
Fixed dict type conversion
tochilinak Nov 28, 2023
02bd5f5
Added dict.isEmpty and dict contains_op
tochilinak Nov 29, 2023
694be0c
Added approximation scheme for constructors; started working on sets
Nov 30, 2023
2cc1914
Changed logic of virtual objects as keys in dicts
tochilinak Nov 30, 2023
4b1f02e
Further work on sets
tochilinak Nov 30, 2023
e4c990d
Fixed segfault with PyTuple_Pack
tochilinak Dec 1, 2023
57f4e2c
One more check
tochilinak Dec 1, 2023
e640c8d
set.add; fork on dict_iter; fixed constructor call
tochilinak Dec 5, 2023
3001c9b
Fixed compilation error on linux
Dec 5, 2023
a4eca7c
Supported enumerate
Dec 5, 2023
d4b80da
Added repetition check in NewStateObserverForRunner
tochilinak Dec 5, 2023
ad3d417
Added several approximations
tochilinak Dec 6, 2023
ad6dc88
Supported build_set
Dec 6, 2023
d3eed1a
Added str_eq and str_neq
Dec 7, 2023
4ded8b7
Some tests
Dec 7, 2023
dda0d14
Fixes after rebase
tochilinak Dec 12, 2023
bc161e4
Structure refactoring
tochilinak Dec 13, 2023
ee60196
Refactoring: removed ConverterToPythonObject + started changing API f…
tochilinak Dec 20, 2023
a1e535e
Finished working on new saving interface
Dec 21, 2023
e64a64f
Small fixes in python_approximations
tochilinak Dec 21, 2023
9539278
Added constraints from native calls
tochilinak Dec 26, 2023
b45dbfa
Refactored PyVirtualPathSelector
tochilinak Jan 24, 2024
02b76f3
Added default value for arrays
tochilinak Jan 25, 2024
8e4c2f2
Moved makeTypeRating function
tochilinak Jan 25, 2024
5a46fc8
Added innerType
tochilinak Jan 29, 2024
b410195
Added BaselineWeightedByNumberOfVirtual path selector
tochilinak Jan 30, 2024
5dbf1f4
Fixed visitor for recursive objects
tochilinak Jan 30, 2024
ec1816e
Made Python modules optional
tochilinak Jan 31, 2024
4ccb598
Update README.md
tochilinak Jan 31, 2024
12fa32b
Added PyPathSelectorType.DelayedForkByInstructionDfs
tochilinak Feb 7, 2024
08adde1
Fix in BaselineStrategy
tochilinak Feb 7, 2024
67df9ec
small fix
tochilinak Feb 7, 2024
1e7f380
Added TypeRatingByNumberOfHints
tochilinak Feb 7, 2024
a2f9c73
Changed ResultReceiver in runner
tochilinak Feb 12, 2024
4137f3c
Removed commented out code
tochilinak Feb 19, 2024
c45ce93
small fix in model visitor
tochilinak Feb 19, 2024
11b791b
Changed usvm-python module logic
tochilinak Feb 20, 2024
3bb9317
Work on test task dependencies
tochilinak Feb 20, 2024
3a2abf0
More work on dependencies
tochilinak Feb 20, 2024
982c1ab
Fix in ArrayCastExample + experiment with CI
tochilinak Feb 20, 2024
858ccb7
Added optional dependencies installation + fix in usvm-jvm test
tochilinak Feb 20, 2024
e8403fc
Added apt update
tochilinak Feb 20, 2024
2e7a2f0
Removed some optional packages
tochilinak Feb 20, 2024
531bd82
next attempt
tochilinak Feb 20, 2024
62606c7
more work on dependencies
tochilinak Feb 20, 2024
d6a02d6
updated readme
tochilinak Feb 20, 2024
9741f3f
fix after rebase
tochilinak Feb 22, 2024
6edc110
Added RandomizedPriorityActionStrategy
tochilinak Feb 22, 2024
c14ce3a
Fixed python soft constraints
tochilinak Feb 22, 2024
076949e
Added DelayedForkByInstructionWeightedRandomTree
tochilinak Feb 26, 2024
f16350f
Fixed exception catching
tochilinak Feb 26, 2024
f85bc78
Updated usvm-python/buildDistWithoutPip.sh
tochilinak Feb 29, 2024
8fa7e8f
Added pathSelector parameter to usvm-python-runner
tochilinak Feb 29, 2024
d295904
Fixed module dependency
tochilinak Feb 29, 2024
cc2aa89
Added publication of usvm-python-commons
tochilinak Feb 29, 2024
ce620e8
Fixed publish task
tochilinak Feb 29, 2024
2265ecc
Added WeightedByNumberOfVirtualPathSelector; changed baseline probabi…
tochilinak Mar 1, 2024
02e1748
Changed parameter in WeightedByNumberOfVirtualPathSelector
tochilinak Mar 1, 2024
b8c3278
Fixed WeightedByNumberOfVirtualPathSelector
tochilinak Mar 3, 2024
03611ad
Added path selectors weighted by number of instructions
tochilinak Mar 3, 2024
2ea0fd7
Added parameter proportionalToSelectorSize in WeightedPyPathSelector
tochilinak Mar 4, 2024
0fd00a5
Added PyMockTypeStream
tochilinak Mar 4, 2024
b1ffaa2
Fixed compilation error
tochilinak Mar 4, 2024
3aa1b95
Fixed usage of RandomTreePathSelector
tochilinak Mar 11, 2024
41214ca
fix: auto-formatting
sergeypospelov Mar 14, 2024
3e7dd17
fix: try to fix gradle error
sergeypospelov Mar 14, 2024
d0c294f
added new path selector type
tochilinak May 23, 2024
e6da76e
fmt
tochilinak May 23, 2024
0dde6d2
Formatting
tochilinak May 28, 2024
12d6a1c
More formatting
tochilinak May 29, 2024
6b8a84d
exclude rule with false-positive
tochilinak May 29, 2024
d4811a5
Started refactoring build scripts
tochilinak May 30, 2024
da7ac72
Fixed property access
tochilinak May 30, 2024
e58dbeb
fixed typo
tochilinak May 30, 2024
07b1a05
More refactoring
tochilinak May 30, 2024
f7d7dae
Increased Gradle max JVM heap size
tochilinak May 30, 2024
6f3d7a4
more build refactoring
tochilinak May 30, 2024
41ce2d8
Started refactoring manualTest
tochilinak May 30, 2024
6de9daf
Update README.md
tochilinak May 30, 2024
36686cf
More refactoring
tochilinak May 31, 2024
93e7aa6
More refactoring
tochilinak May 31, 2024
2544ada
refactoring + enhancement of SymbolTypeTree
tochilinak May 31, 2024
590d095
More formatting
tochilinak Jun 4, 2024
a6e3567
fmt
tochilinak Jun 7, 2024
4c658ce
reverted some changes in usvm-core
tochilinak Jun 7, 2024
d7b00ea
PyPathConstraints
tochilinak Jun 7, 2024
68e4ebc
fix: MacOS build support
sergeypospelov Jun 7, 2024
78bf09f
revert USoftConstraintsProvider
tochilinak Jun 7, 2024
3944e3e
fix: remove property
sergeypospelov Jun 7, 2024
f77330d
LocalProgramProvider
tochilinak Jun 7, 2024
531b839
Finished refactoring manualTestKt
tochilinak Jun 7, 2024
e80ad25
fmt
tochilinak Jun 7, 2024
a77ea5a
changed println to logger in tests
tochilinak Jun 7, 2024
86e7ce2
more formatting
tochilinak Jun 7, 2024
a3f63a8
fmt
tochilinak Jun 7, 2024
331453b
fmt
tochilinak Jun 7, 2024
fc1b414
fmt
tochilinak Jun 7, 2024
7b6542e
fmt
tochilinak Jun 7, 2024
b24d5c0
chore: flaky test disabled
sergeypospelov Jun 7, 2024
27da4f5
Refactored exception structure
tochilinak Jun 10, 2024
41f16f2
Removed handlerPOWLong
tochilinak Jun 10, 2024
6813c65
refactoring in usvm-python-annotations
tochilinak Jun 10, 2024
e7a013a
removed nbBoolKt
tochilinak Jun 10, 2024
89c055a
Update usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/…
tochilinak Jul 1, 2024
84dcaa6
Added description for Gradle modules
tochilinak Jul 2, 2024
256c4f5
Fixed unused import
tochilinak Jul 2, 2024
22149b1
Fixed api in ManualTest
tochilinak Jul 5, 2024
6b152b9
Update usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/…
tochilinak Jul 5, 2024
29f8e84
refactored jni header generation + pr fixes
tochilinak Jul 5, 2024
129c22b
Update usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/…
tochilinak Jul 5, 2024
f345355
CE fix
tochilinak Jul 5, 2024
80d8f5f
Converted several classes from Java to Kotlin
tochilinak Jul 5, 2024
0e8b82b
removed some redundant code
tochilinak Jul 5, 2024
cad71c5
Update usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/…
tochilinak Jul 5, 2024
5b332d2
Update usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/…
tochilinak Jul 5, 2024
0f280f4
detekt fixes
tochilinak Jul 5, 2024
a8b33c6
pr fixes
tochilinak Jul 5, 2024
d182bd9
several renamings
tochilinak Jul 5, 2024
feb249b
fixes in usvm-python-runner
tochilinak Jul 8, 2024
395fe56
Docs for withTracing
tochilinak Jul 8, 2024
cdf64f5
spacing in PyMachine
tochilinak Jul 8, 2024
ee0b0b0
detekt fix
tochilinak Jul 9, 2024
085a611
Simplified PyState
tochilinak Jul 9, 2024
2925e85
several simple fixes
tochilinak Jul 9, 2024
aa47aab
more simple pr fixes
tochilinak Jul 9, 2024
f301d01
description for handlerIsinstanceKt + minor
tochilinak Jul 9, 2024
cb76ed3
fix
tochilinak Jul 9, 2024
7abd3c2
more simple pr fixes
tochilinak Jul 9, 2024
675d594
pr fixes
tochilinak Jul 9, 2024
e67a238
trickier pr fixes
tochilinak Jul 9, 2024
c9b3b69
detekt fixes
tochilinak Jul 9, 2024
96d1d7e
Separate action for python package
tochilinak Jul 11, 2024
dcb5203
removed duplicated lines
tochilinak Jul 11, 2024
7f9da19
removed redundant step
tochilinak Jul 11, 2024
a2fc4a0
pr comments
tochilinak Jul 12, 2024
ba507b1
detekt fix
tochilinak Jul 12, 2024
ca5075d
Updated Python link in README
tochilinak Jul 12, 2024
a98cda2
switch from self-hosted to ubuntu-20.04 runners
bissquit Jul 13, 2024
e94a5b5
lead pipeline to common look
bissquit Jul 13, 2024
78dc83f
switch another pipelines to github hosted runners
bissquit Jul 13, 2024
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
43 changes: 16 additions & 27 deletions .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
# This is a basic workflow to help you get started with Actions

name: Build and Run Tests [gradle]

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
strategy:
matrix:
# java: [ '11', '17' ]
java: [ '11' ]

runs-on: [self-hosted, usvm]

# Steps represent a sequence of tasks that will be executed as part of the job
runs-on: ubuntu-20.04
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "true"

# Runs a single command using the runners shell
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand All @@ -41,22 +29,23 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Runs a set of commands using the runners shell
- name: Build and run tests
run: ./gradlew build --no-daemon
- name: Install CPython optional dependencies
run: |
sudo apt-get update
sudo apt-get install -yq\
libssl-dev \
libffi-dev

# - name: Upload usvm test reports
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: usvm-tests-report-linux
# path: ./**/build/reports/tests/test/
- name: Build and run tests
run: |
./gradlew build --no-daemon -PcpythonActivated=true

- name: Run Detekt
run: ./gradlew detektMain detektTest --no-daemon
run: |
./gradlew detektMain detektTest --no-daemon

- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: build/reports/detekt/detekt.sarif
sarif_file: build/reports/detekt/detekt.sarif
4 changes: 1 addition & 3 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ on:

jobs:
build:

runs-on: [self-hosted, usvm]
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/python-runner-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Package `usvm-python-runner`

on:
workflow_dispatch:
inputs:
version:
description: Release version
type: string
required: true

jobs:
build:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish usvm-python-runner to GitHub Packages
uses: gradle/gradle-build-action@v2
with:
arguments: :usvm-python:usvm-python-runner:publishAllPublicationsToGitHubPackagesRepository :usvm-python:usvm-python-common:publishAllPublicationsToGitHubPackagesRepository -Pversion=${{ inputs.version }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ buildSrc/.gradle

# Ignore Idea directory
.idea

# Ignore vim cache
*.swp

# Ignore Python execution cache
__pycache__/
run_python_with_gdb.sh
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "usvm-python/cpythonadapter/cpython"]
path = usvm-python/cpythonadapter/cpython
url = https://github.com/tochilinak/cpython.git
branch = wrapper-v2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ With USVM, you can achieve completely automated
* [unit test cases generation](#usvm-for-unit-test-generation),
* [targeted fuzzing and more symbolic execution based solutions](#using-usvm-to-confirm-sarif-reports).

Right now, we have ready-to-be-used implementation for [Java](https://github.com/UnitTestBot/usvm/tree/main/usvm-jvm) and experimental implementation for [Python](https://github.com/UnitTestBot/usvm/tree/tochilinak/python/usvm-python).
Right now, we have ready-to-be-used implementation for [Java](https://github.com/UnitTestBot/usvm/tree/main/usvm-jvm) and experimental implementation for [Python](https://github.com/UnitTestBot/usvm/tree/main/usvm-python).

# Taint analysis with USVM

Expand Down
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ plugins {

val kotlinVersion = "1.9.20"
val detektVersion = "1.23.5"
val gjavahVersion = "0.3.1"

repositories {
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
}


dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion")
implementation("org.glavo:gjavah:$gjavahVersion")
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ object Versions {
const val ini4j = "0.5.4"

const val sarif4k = "0.5.0"

const val pythonTypesAPIHash = "139b81d"
const val utbotMypyRunner = "0.2.17"
}
35 changes: 35 additions & 0 deletions buildSrc/src/main/kotlin/usvmpython/Names.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package usvmpython

/** Module names */
const val USVM_PYTHON_MODULE = "usvm-python"
const val CPYTHON_ADAPTER_MODULE = "usvm-python:cpythonadapter"
const val USVM_PYTHON_ANNOTATIONS_MODULE = "usvm-python:usvm-python-annotations"
const val USVM_PYTHON_MAIN_MODULE = "usvm-python:usvm-python-main"
const val USVM_PYTHON_RUNNER_MODULE = "usvm-python:usvm-python-runner"
const val USVM_PYTHON_COMMONS_MODULE = "usvm-python:usvm-python-commons"

/** Task group names */
const val CPYTHON_GROUP_NAME = "cpython"
const val SAMPLE_GROUP_NAME = "samples"
const val MANUAL_RUN_GROUP_NAME = "run"

/** Task names */
const val CPYTHON_BUILD_DEBUG_CONFIGURATION = "CPythonBuildConfigurationDebug"
const val CPYTHON_BUILD_DEBUG = "CPythonBuildDebug"
const val INSTALL_MYPY_RUNNER_TASK = "installUtbotMypyRunner"
const val BUILD_SAMPLES_TASK = "buildSamples"
const val MANUAL_TEST_FOR_RUNNER = "manualTestOfRunner"
const val MANUAL_TEST_DEBUG_TASK = "manualTestDebug"
const val MANUAL_TEST_DEBUG_NO_LOGS_TASK = "manualTestDebugNoLogs"

/** Property names */
const val PROPERTY_FOR_CPYTHON_ACTIVATION = "cpythonActivated"
const val PROPERTY_FOR_CPYTHON_SSL_PATH = "cpython.ssl.path"

/** Entry points */
const val BUILD_SAMPLES_ENTRY_POINT = "org.usvm.runner.BuildSamplesKt"
const val MANUAL_TEST_FOR_RUNNER_ENTRY = "org.usvm.runner.ManualTestKt"
const val RUNNER_ENTRY_POINT = "org.usvm.runner.UtBotPythonRunnerEntryPointKt"
const val MANUAL_TEST_ENTRY = "org.usvm.runner.manual.ManualTestKt"

const val CPYTHON_ADAPTER_CLASS = "org.usvm.interpreter.CPythonAdapter"
75 changes: 75 additions & 0 deletions buildSrc/src/main/kotlin/usvmpython/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package usvmpython

import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.Project
import java.io.File

fun Project.cpythonIsActivated(): Boolean {
if (!project.hasProperty(PROPERTY_FOR_CPYTHON_ACTIVATION))
return false
val prop = project.property(PROPERTY_FOR_CPYTHON_ACTIVATION) as? String
return prop?.lowercase() == "true"
}

fun Project.getCPythonModule() =
rootProject.findProject(CPYTHON_ADAPTER_MODULE)!!

fun Project.getUsvmPythonModule() =
rootProject.findProject(USVM_PYTHON_MODULE)!!

fun Project.getCPythonBuildPath(): File {
val cpythonModule = getCPythonModule()
return cpythonModule.layout.buildDirectory.file("cpython_build").get().asFile
}

fun Project.getCPythonSourcePath(): File {
val cpythonModule = getCPythonModule()
return File(cpythonModule.layout.projectDirectory.asFile, "cpython")
}

fun Project.getCPythonAdapterBuildPath(): File {
val cpythonModule = getCPythonModule()
return cpythonModule.layout.buildDirectory.file("lib/main/debug").get().asFile
}

val isWindows = Os.isFamily(Os.FAMILY_WINDOWS)
val isMacos = Os.isFamily(Os.FAMILY_MAC)

fun Project.getWidowsBuildScriptPath(): File =
File(getCPythonSourcePath(), "PCBuild/build.bat")

fun Project.getIncludePipFile(): File {
val cpythonModule = getCPythonModule()
return File(cpythonModule.projectDir, "include_pip_in_build")
}

fun Project.includePipInBuildLine(): String {
val includePipFile = getIncludePipFile()
val includePip = includePipFile.readText().trim() != "false"
return if (includePip) {
"--with-ensurepip=yes"
} else {
"--with-ensurepip=no"
}
}

fun Project.getGeneratedHeadersPath(): File =
getCPythonModule().layout.buildDirectory.file("adapter_include").get().asFile

fun Project.getSamplesSourceDir(): File =
File(getUsvmPythonModule().projectDir, "src/test/resources/samples")

fun Project.getSamplesBuildDir(): File =
getUsvmPythonModule().layout.buildDirectory.file("samples_build").get().asFile

fun Project.getApproximationsDir(): File =
File(getUsvmPythonModule().projectDir, "python_approximations")

fun Project.getPythonBinaryPath(): File {
val cpythonBuildPath = getCPythonBuildPath()
return if (isWindows) {
File(cpythonBuildPath, "python_d.exe")
} else {
File(cpythonBuildPath, "bin/python3")
}
}
Loading
Loading