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

Refactor build scripts #962

Merged
merged 14 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Switch off architecture check for Windows
  • Loading branch information
VDovidaytis-HORIS committed Dec 8, 2023
commit 475ef573872e7617cddf382aaf33f0e06fc4e935
28 changes: 16 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ allprojects {
}
}

project.ext.currentOs = DefaultNativePlatform.getCurrentOperatingSystem()

// Read build settings from commandline parameters (for build_release.py script):
def readSettingsFromParameters() {
def settings = [
Expand All @@ -69,7 +71,9 @@ def readSettingsFromParameters() {
assert !settings.python.bin_path.isEmpty()
assert !settings.python.include_path.isEmpty()
}
settings.architecture = project.getProperty("architecture")
if (!project.currentOs.windows) {
settings.architecture = project.getProperty("architecture")
}

return settings
}
Expand All @@ -81,7 +85,9 @@ def readSettingsFromYaml() {
throw new GradleException("Couldn't read build_settings.yml")
}
def settings = new Yaml().load(build_settings_file.newInputStream())
assert settings.architecture != null
if (!project.currentOs.windows) {
assert settings.architecture != null // Skip architecture property for Windows systems.
}

if (settings.enable_python_package) {
assert settings.python.bin_path != null
Expand All @@ -98,8 +104,8 @@ if (project.hasProperty("build_release")) {
project.ext.buildSettings = readSettingsFromYaml() as LinkedHashMap
}

// Check architecture parameter, if python-package has been enabled:
if (project.buildSettings.enable_python_package) {
// Check architecture parameter, if python-package has been enabled (skipped for Windows):
if (project.buildSettings.enable_python_package && !project.currentOs.windows) {
def getArchOutput = new ByteArrayOutputStream()
exec {
commandLine "${project.buildSettings.python.bin_path}/python",
Expand All @@ -111,8 +117,8 @@ if (project.buildSettings.enable_python_package) {

if (currentPythonArch != project.buildSettings.architecture) {
throw new Exception("Project and Python architectures don't match!\n" +
"You have enabled python-package and your architecture from project settings\n" +
"doesn't match your Python architecture. Check these settings in your 'build_settings.yml' file.")
"You have enabled python-package and your architecture value from project settings doesn't match\n" +
"your Python architecture. Check these settings in your 'build_settings.yml' file.")
}
}

Expand Down Expand Up @@ -163,26 +169,24 @@ subprojects {
]) {
apply plugin: "org.jetbrains.kotlin.multiplatform"

def currentOs = DefaultNativePlatform.getCurrentOperatingSystem()

kotlin {
if (currentOs.macOsX & project.buildSettings.architecture == "x86_64") {
if (project.currentOs.macOsX & project.buildSettings.architecture == "x86_64") {
macosX64()
} else if (currentOs.macOsX & project.buildSettings.architecture == "arm64") {
} else if (project.currentOs.macOsX & project.buildSettings.architecture == "arm64") {
if (project.hasProperty("build_release")) {
macosX64()
macosArm64()
} else {
macosArm64()
}
} else if (currentOs.linux) {
} else if (project.currentOs.linux) {
if (project.hasProperty("build_release")) {
linuxX64()
linuxArm64()
} else if (project.buildSettings.architecture == "x86_64") {
linuxX64()
}
} else if (currentOs.windows) {
} else if (project.currentOs.windows) {
mingwX64()
} else {
throw new Exception("Unsupported platform! Check project settings.")
Expand Down
3 changes: 2 additions & 1 deletion build_settings.template.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
# Set project architecture. Available values: 'arm64', 'x86_64'"
# Set project architecture for Linux or Mac. Windows users can skip this parameter.
# Available values: 'arm64', 'x86_64'"
architecture: arm64

# enable tasks responsible for building and publishing of lets-plot python package
Expand Down