Skip to content

Commit

Permalink
1k: parse generater from cmake options
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Jun 14, 2024
1 parent 6cb7618 commit 8939723
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
63 changes: 36 additions & 27 deletions 1k/1kiss.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1662,33 +1662,6 @@ if (!$setupOnly) {

# determine generator, build_dir, inst_dir for non gradlew projects
if (!$is_gradlew) {
if (!$cmake_generator -and !$TARGET_OS.StartsWith('win')) {
$cmake_generator = $cmake_generators[$TARGET_OS]
if ($null -eq $cmake_generator) {
$cmake_generator = if (!$IsWin) { 'Unix Makefiles' } else { 'Ninja' }
}
}

if ($cmake_generator) {
$using_ninja = $cmake_generator.StartsWith('Ninja')

if (!$is_wasm) {
$CONFIG_ALL_OPTIONS += '-G', $cmake_generator
}

if ($cmake_generator -eq 'Unix Makefiles' -or $using_ninja) {
$CONFIG_ALL_OPTIONS += "-DCMAKE_BUILD_TYPE=$optimize_flag"
}

if ($using_ninja -and $Global:is_android) {
$CONFIG_ALL_OPTIONS += "-DCMAKE_MAKE_PROGRAM=$ninja_prog"
}

if ($cmake_generator -eq 'Xcode') {
setup_xcode
}
}

$INST_DIR = $null
$xopt_presets = 0
$xprefix_optname = '-DCMAKE_INSTALL_PREFIX='
Expand All @@ -1714,6 +1687,15 @@ if (!$setupOnly) {
}
++$xopt_presets
}
elseif ($opt.startsWith('-G')) {
if ($opt.Length -gt 2) {
$cmake_generator = $opt.Substring(2).Trim()
}
elseif (++$opti -lt $xopts.Count) {
$cmake_generator = $xopts[$opti]
}
++$xopt_presets
}
elseif ($opt.StartsWith($xprefix_optname)) {
++$xopt_presets
$INST_DIR = $opt.SubString($xprefix_optname.Length)
Expand All @@ -1723,6 +1705,33 @@ if (!$setupOnly) {
}
}

if (!$cmake_generator -and !$TARGET_OS.StartsWith('win')) {
$cmake_generator = $cmake_generators[$TARGET_OS]
if ($null -eq $cmake_generator) {
$cmake_generator = if (!$IsWin) { 'Unix Makefiles' } else { 'Ninja' }
}
}

if ($cmake_generator) {
$using_ninja = $cmake_generator.StartsWith('Ninja')

if (!$is_wasm) {
$CONFIG_ALL_OPTIONS += '-G', $cmake_generator
}

if ($cmake_generator -eq 'Unix Makefiles' -or $using_ninja) {
$CONFIG_ALL_OPTIONS += "-DCMAKE_BUILD_TYPE=$optimize_flag"
}

if ($using_ninja -and $Global:is_android) {
$CONFIG_ALL_OPTIONS += "-DCMAKE_MAKE_PROGRAM=$ninja_prog"
}

if ($cmake_generator -eq 'Xcode') {
setup_xcode
}
}

if (!$BUILD_DIR) {
$BUILD_DIR = resolve_out_dir 'build_'
}
Expand Down
8 changes: 7 additions & 1 deletion 1k/dm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ project(dm)
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)

message(STATUS "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_C_FLAGS=${CMAKE_C_FLAGS}")
message(STATUS "ANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}")
message(STATUS "CMAKE_SYSROOT=${CMAKE_SYSROOT}")

set(cross_flags "")
if(ANDROID)
message(STATUS "ANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
if(CMAKE_ANDROID_ARCH_ABI MATCHES "arm64-v8a")
set(cross_flags "-target aarch64-none-linux-android${ANDROID_NATIVE_API_LEVEL}")
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES "x86_64")
Expand All @@ -34,3 +38,5 @@ endif()
if(NOT ${CMAKE_C_COMPILER} MATCHES ".*cl\.exe" OR "${MSVC_VERSION}" GREATER_EQUAL 1928)
execute_process(COMMAND ${PWSH_PROG} "${CMAKE_CURRENT_SOURCE_DIR}/dm.ps1" "${CMAKE_C_COMPILER}" "${CMAKE_C_FLAGS} ${cross_flags}")
endif()

add_library(dm dm.c)
4 changes: 4 additions & 0 deletions 1k/dm/dm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
long double dm2x(long double v)
{
return v * 10.33;
}

0 comments on commit 8939723

Please sign in to comment.