Skip to content

Commit

Permalink
Improve build profiles (#2273)
Browse files Browse the repository at this point in the history
- Add 1k/build.profiles for android ndk, sdk tools, emsdk ...
- Android targetSdk and minSdk also control by 1k/build.profiles
- You can override some build profiles in .axproj file, i.e android ndk, android target_sdk and min_sdk and others
- support install ndk from ci.android.com
  • Loading branch information
halx99 authored Dec 13, 2024
1 parent 3d24cae commit 9036d58
Show file tree
Hide file tree
Showing 31 changed files with 681 additions and 358 deletions.
332 changes: 232 additions & 100 deletions 1k/1kiss.ps1

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions 1k/build.profiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# The cross platform build profiles, DO NOT MODIFY
# @hint means just for hint, not managed by axmol build system
#

# --- region platfom:common

# The axmol shader compiler, legacy name is 'glslcc' before axmol-2.3.0
axslcc=1.9.6+

# The cmake, @gradle @axmol-cmdline
# as latest as possible
cmake=3.30.0~3.31.2+

# The ninja
ninja=1.10.0~1.12.1+

# --- endregion

# --- region windows

# The nuget, since 5.6.0, requires .net 4.0
# DNT MODIFY
nuget=5.5.1.*

# The visual studio version, @axmol-cmdline @verify
vs=17.0+

# --- endregion

# region platform:android

# The microsoft openjdk, @axmol-cmdline
jdk=17.0.10~17.0.13+

# The android ndk version
# as stable as possible @setup.ps1 @gradle @axmol-cmdline
ndk=r23c

# The android target sdk version, @gradle
# as latest as possible
target_sdk=35

# The android min sdk version, @gradle
# as min as possible
min_sdk=17

# The gradle version, @setup.ps1
# as latest as possible
gradle=8.10

# The android gradle plugin, @setup.ps1
# as stable as possible, match with build-tools,android-studio
agp=8.6.0

# The android build-tools, @axmol-cmdline @gradle
# as stable as possible, match with agp,android-studio
build-tools=34.0.0

# The android-studio, @hint
# as latest as possible, but match with agp, build-tools
android-studio=2024.2.1+

# --- endregion

# --- region platform:wasm

emsdk=3.1.66~3.1.67

# --- endregion
23 changes: 23 additions & 0 deletions 1k/extensions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,26 @@ namespace System
$TrimLastMethod = [ExtensionMethods].GetMethod('TrimLast')
Update-TypeData -TypeName System.String -MemberName TrimLast -MemberType CodeMethod -Value $TrimLastMethod
}


function ConvertFrom-Props {
param(
[Parameter(Mandatory=$true)]
$InputObject
)

$props = @{}

foreach($_ in $InputObject) {
if ($_ -match "^#.*$") {
continue
}
if ($_ -match "^(.+?)\s*=\s*(.*)$") {
$key = $matches[1].Trim()
$value = $matches[2].Trim()
$props[$key] = $value
}
}

return $props
}
2 changes: 1 addition & 1 deletion 1k/fetch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function(_1kfetch_init)
find_program(PWSH_PROG NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
endif()

execute_process(COMMAND ${PWSH_PROG} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/resolv-uri.ps1
execute_process(COMMAND ${PWSH_PROG} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/resolv-url.ps1
-name "1kdist"
-manifest ${_1kfetch_manifest}
OUTPUT_VARIABLE _1kdist_url
Expand Down
33 changes: 23 additions & 10 deletions 1k/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@

# add or overwrite tool version like follow
if ($Global:is_axmol_app -or $Global:is_axmol_engine) {
$manifest['nuget'] = '5.5.1' # since 5.6.0, requires .net 4.0
$manifest['axslcc'] = '1.9.6+'
$manifest['cmake'] = '3.29.3~3.30.5+'
$manifest['emsdk'] = '3.1.66~3.1.67+'
$manifest['jdk'] = '17.0.10~17.0.12+'
$manifest['vs'] = '16.0+'
}
# load cross platform build.profiles
$build_profiles_file = Join-Path $PSScriptRoot 'build.profiles'
$build_profiles = ConvertFrom-Props (Get-Content $build_profiles_file)

$manifest['axslcc'] = $build_profiles['axslcc']
$manifest['nuget'] = $build_profiles['nuget']
$manifest['emsdk'] = $build_profiles['emsdk']
$manifest['jdk'] = $build_profiles['jdk']

$manifest['ninja'] = $build_profiles['ninja']

$manifest['ndk'] = $build_profiles['ndk']
$manifest['cmake'] = $build_profiles['cmake']

# android sdk tools
$android_sdk_tools['build-tools'] = '34.0.0' # match with AGP-8.2.1+, android studio 2023.1.1+
$android_sdk_tools['platforms'] = 'android-34'
$manifest['vs'] = $build_profiles['vs']

# android sdk tools
$android_sdk_tools['build-tools'] = $build_profiles['build-tools']
$android_sdk_tools['platforms'] = "android-$($build_profiles['target_sdk'])"

$Global:build_profiles = $build_profiles
} else {
$Global:build_profiles = @{}
}
17 changes: 0 additions & 17 deletions 1k/resolv-uri.ps1

This file was deleted.

61 changes: 61 additions & 0 deletions 1k/resolv-url.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# resolve artifact url
param(
[Alias('artifact')]
$name,
$manifest,
$target,
$build_id,
$branch,
$out_var
)

$artifact_url = $null

if ($manifest -eq 'gcloud') {
function Get-LatestGoodBuild {
param (
[string]$branch,
[string]$target
)

$apiURL = "https://androidbuildinternal.googleapis.com/android/internal/build/v3/builds?branches=$([uri]::EscapeDataString($branch))&buildAttemptStatus=complete&buildType=submitted&maxResults=1&successful=true&target=$([uri]::EscapeDataString($target))"
$body = Invoke-WebRequest -Uri $apiURL
$buildData = $body | ConvertFrom-Json
if ($buildData.builds.Count -eq 0) {
throw "No build ID is found"
}
return $buildData.builds[0].buildId
}

# Validate input parameters
$artifact = $name
if (-not $target) { throw "Missing target." }
if (-not $artifact) { throw "Missing artifact." }
if (-not $build_id -and -not $branch) { throw "Missing build_id or branch." }
if (-not $build_id -and $branch) {
$build_id = Get-LatestGoodBuild -branch $branch -target $target
}

$artifact_url = "https://androidbuildinternal.googleapis.com/android/internal/build/v3/builds/$([uri]::EscapeDataString($build_id))/$([uri]::EscapeDataString($target))/attempts/latest/artifacts/$([uri]::EscapeDataString($artifact))/url"
}
else {
if (Test-Path $manifest -PathType Leaf) {
$mirror = if (!(Test-Path (Join-Path $PSScriptRoot '.gitee') -PathType Leaf)) { 'github' } else { 'gitee' }

$manifest_map = ConvertFrom-Json (Get-Content $manifest -raw)
$ver = $manifest_map.versions.PSObject.Properties[$name].Value
$mirror_current = $manifest_map.mirrors.PSObject.Properties[$mirror].Value.PSObject.Properties
$url_base = "https://$($mirror_current['host'].Value)/"
$url_path = $mirror_current[$name].Value

$artifact_url = "$url_base$url_path#$ver"
}
}

if($artifact_url) {
if(!$out_var) {
Write-Host $artifact_url -NoNewline
} else {
Write-Information $artifact_url -InformationVariable $out_var
}
}
23 changes: 0 additions & 23 deletions 1k/setup-msvc.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ In order to see some of our community works, please check our Axmol Showcase: [M
## Reference links

- [1kiss](https://github.com/simdsoft/1kiss): A cross-platform one step build powershell script, with auto setup general dependent tools.
- [axmolengine/glslcc](https://github.com/axmolengine/glslcc): A fork of glslcc, for Axmol new shader workflow tool.
- [axslcc](https://github.com/axmolengine/axslcc): A fork of `glslcc`, for Axmol new shader workflow tool.
- [Official Cocos2d-x](https://github.com/cocos2d/cocos2d-x)

## Axmol Stats
Expand Down
Loading

0 comments on commit 9036d58

Please sign in to comment.