diff options
| author | ruki <[email protected]> | 2025-11-24 15:53:42 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-24 15:53:42 +0800 |
| commit | 12877b5d101cfce9471b3d1286a26e7a8bf19c94 (patch) | |
| tree | da2063ad716a2a38bf68a3bb9658faa5dbd2264d | |
| parent | a89d5df3949aaa034c3ec98f900cac2eca5f24c3 (diff) | |
| parent | e57e495847d72e0997d86fe51f7ed8dd4366ab48 (diff) | |
Merge pull request #7055 from xmake-io/solaris
Add solaris platform
34 files changed, 513 insertions, 43 deletions
diff --git a/.github/workflows/solaris.yml b/.github/workflows/solaris.yml new file mode 100644 index 000000000..fa500ad89 --- /dev/null +++ b/.github/workflows/solaris.yml @@ -0,0 +1,37 @@ +name: Solaris + +on: + pull_request: + push: + release: + types: [published] + +jobs: + build: + + runs-on: ubuntu-latest + + concurrency: + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Solaris + cancel-in-progress: true + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Tests + uses: vmactions/solaris-vm@v1 + with: + usesh: true + prepare: | + pkgutil -y -i socat git gmake bash gcc4g++ || pkgutil -y -i socat git gmake bash gcc5g++ || pkg install -y developer/gcc || true + run: | + cd $GITHUB_WORKSPACE + bash ./configure + gmake -j4 + gmake install + export XMAKE_ROOT=y + xrepo --version + xmake l os.meminfo + xmake lua -v -D tests/run.lua + @@ -187,6 +187,7 @@ $ xmake f --menu * NetBSD (i386, x86_64) * OpenBSD (i386, x86_64) * DragonflyBSD (i386, x86_64) +* Solaris (i386, x86_64) * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) * iOS (armv7, armv7s, arm64, i386, x86_64) * WatchOS (armv7k, i386) diff --git a/README_zh.md b/README_zh.md index 4cd574c97..859caf791 100644 --- a/README_zh.md +++ b/README_zh.md @@ -248,6 +248,7 @@ $ xmake f --menu * NetBSD (i386, x86_64) * OpenBSD (i386, x86_64) * DragonflyBSD (i386, x86_64) +* Solaris (i386, x86_64) * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) * iOS (armv7, armv7s, arm64, i386, x86_64) * WatchOS (armv7k, i386) @@ -317,13 +317,31 @@ _os_iorunv() { } # find file in the given directory -# e.g. _os_find . xmake.sh +# e.g. _os_find . xmake.sh [depth] _os_find() { local dir="${1}" local name="${2}" local depth="${3}" if test_nz "${depth}"; then - _ret=$(find "${dir}" -maxdepth "${depth}" -mindepth "${depth}" -type f -name "${name}" | LC_ALL=C sort) + # Solaris doesn't support -maxdepth, use shell to filter depth + if is_host "solaris"; then + _ret="" + local file="" + for file in $(find "${dir}" -type f -name "${name}" | LC_ALL=C sort); do + local relpath="${file#${dir}/}" + local slash_count=$(echo "${relpath}" | tr -cd '/' | wc -c | tr -d ' ') + if test "${slash_count}" = "$((${depth} - 1))"; then + if test -z "${_ret}"; then + _ret="${file}" + else + _ret="${_ret} +${file}" + fi + fi + done + else + _ret=$(find "${dir}" -maxdepth "${depth}" -mindepth "${depth}" -type f -name "${name}" | LC_ALL=C sort) + fi else _ret=$(find "${dir}" -type f -name "${name}" | LC_ALL=C sort) fi @@ -2800,7 +2818,8 @@ _load_options_and_toolchains() { includes "${file}" else # include all xmake.sh files in next sub-directories - local files=`find ${xmake_sh_projectdir} -maxdepth 2 -mindepth 2 -name "xmake.sh"` + _os_find "${xmake_sh_projectdir}" "xmake.sh" "2" + local files="${_ret}" for file in ${files}; do includes "${file}" done diff --git a/core/src/tbox/inc/solaris/tbox.config.h b/core/src/tbox/inc/solaris/tbox.config.h new file mode 100644 index 000000000..4aa3c21df --- /dev/null +++ b/core/src/tbox/inc/solaris/tbox.config.h @@ -0,0 +1,240 @@ +#ifndef TB_CONFIG_H +#define TB_CONFIG_H + +// version +#define TB_CONFIG_VERSION "1.7.7" +#define TB_CONFIG_VERSION_MAJOR 1 +#define TB_CONFIG_VERSION_MINOR 7 +#define TB_CONFIG_VERSION_ALTER 7 +#define TB_CONFIG_VERSION_BUILD 20251123 + +// defines +#define TB_CONFIG_OS_SOLARIS 1 +#define _GNU_SOURCE 1 +#define _REENTRANT 1 +#define TB_CONFIG_SMALL 1 +/*#undef TB_CONFIG_MICRO_ENABLE*/ +/*#undef TB_CONFIG_TYPE_HAVE_WCHAR*/ +#define TB_CONFIG_TYPE_HAVE_FLOAT 1 +/*#undef TB_CONFIG_FORCE_UTF8*/ +/*#undef TB_CONFIG_API_HAVE_DEPRECATED*/ +/*#undef TB_CONFIG_EXCEPTION_ENABLE*/ + +// keywords +#define TB_CONFIG_KEYWORD_HAVE__thread 1 +#define TB_CONFIG_KEYWORD_HAVE_Thread_local 1 + +// features +#define TB_CONFIG_FEATURE_HAVE_ANONYMOUS_UNION 1 + +// modules +/* #undef TB_CONFIG_MODULE_HAVE_XML */ +/* #undef TB_CONFIG_MODULE_HAVE_ZIP */ +#define TB_CONFIG_MODULE_HAVE_HASH 1 +/* #undef TB_CONFIG_MODULE_HAVE_REGEX */ +/* #undef TB_CONFIG_MODULE_HAVE_OBJECT */ +#define TB_CONFIG_MODULE_HAVE_CHARSET 1 +/* #undef TB_CONFIG_MODULE_HAVE_DATABASE */ +/* #undef TB_CONFIG_MODULE_HAVE_COROUTINE */ + +// packages +/*#undef TB_CONFIG_PACKAGE_HAVE_ZLIB*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_MYSQL*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_SQLITE3*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_OPENSSL*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_POLARSSL*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_MBEDTLS*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_PCRE2*/ +/*#undef TB_CONFIG_PACKAGE_HAVE_PCRE*/ + +// libc functions +#define TB_CONFIG_LIBC_HAVE_MEMCPY 1 +#define TB_CONFIG_LIBC_HAVE_MEMSET 1 +#define TB_CONFIG_LIBC_HAVE_MEMMOVE 1 +#define TB_CONFIG_LIBC_HAVE_MEMCMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_MEMMEM*/ +#define TB_CONFIG_LIBC_HAVE_STRCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRNCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRNCPY 1 +/*#undef TB_CONFIG_LIBC_HAVE_STRLCPY*/ +#define TB_CONFIG_LIBC_HAVE_STRLEN 1 +/*#undef TB_CONFIG_LIBC_HAVE_STRNLEN*/ +#define TB_CONFIG_LIBC_HAVE_STRCHR 1 +#define TB_CONFIG_LIBC_HAVE_STRRCHR 1 +#define TB_CONFIG_LIBC_HAVE_STRSTR 1 +/*#undef TB_CONFIG_LIBC_HAVE_STRCASESTR*/ +#define TB_CONFIG_LIBC_HAVE_STRCMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_STRCASECMP*/ +#define TB_CONFIG_LIBC_HAVE_STRNCMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_STRNCASECMP*/ + +#define TB_CONFIG_LIBC_HAVE_WCSCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCPY 1 +/*#undef TB_CONFIG_LIBC_HAVE_WCSLCPY*/ +#define TB_CONFIG_LIBC_HAVE_WCSLEN 1 +/*#undef TB_CONFIG_LIBC_HAVE_WCSNLEN*/ +#define TB_CONFIG_LIBC_HAVE_WCSSTR 1 +/*#undef TB_CONFIG_LIBC_HAVE_WCSCASESTR*/ +#define TB_CONFIG_LIBC_HAVE_WCSCMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_WCSCASECMP*/ +#define TB_CONFIG_LIBC_HAVE_WCSNCMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_WCSNCASECMP*/ +#define TB_CONFIG_LIBC_HAVE_WCSTOMBS 1 +#define TB_CONFIG_LIBC_HAVE_MBSTOWCS 1 + +#define TB_CONFIG_LIBC_HAVE_GMTIME 1 +#define TB_CONFIG_LIBC_HAVE_MKTIME 1 +#define TB_CONFIG_LIBC_HAVE_LOCALTIME 1 +#define TB_CONFIG_LIBC_HAVE_GETTIMEOFDAY 1 +#define TB_CONFIG_LIBC_HAVE_SIGNAL 1 +#define TB_CONFIG_LIBC_HAVE_SETJMP 1 +/*#undef TB_CONFIG_LIBC_HAVE_SIGSETJMP*/ +/*#undef TB_CONFIG_LIBC_HAVE_KILL*/ +#define TB_CONFIG_LIBC_HAVE_BACKTRACE 1 +#define TB_CONFIG_LIBC_HAVE_SETLOCALE 1 +#define TB_CONFIG_LIBC_HAVE_FPUTC 1 +#define TB_CONFIG_LIBC_HAVE_FGETC 1 +#define TB_CONFIG_LIBC_HAVE_UNGETC 1 +#define TB_CONFIG_LIBC_HAVE_FPUTS 1 +#define TB_CONFIG_LIBC_HAVE_FGETS 1 +#define TB_CONFIG_LIBC_HAVE_FREAD 1 +#define TB_CONFIG_LIBC_HAVE_FWRITE 1 +/*#undef TB_CONFIG_LIBC_HAVE_SRANDOM*/ +/*#undef TB_CONFIG_LIBC_HAVE_RANDOM*/ + +// libm functions +/*#undef TB_CONFIG_LIBM_HAVE_SINCOS*/ +/*#undef TB_CONFIG_LIBM_HAVE_SINCOSF*/ +#define TB_CONFIG_LIBM_HAVE_LOG2 1 +#define TB_CONFIG_LIBM_HAVE_LOG2F 1 +#define TB_CONFIG_LIBM_HAVE_SQRT 1 +#define TB_CONFIG_LIBM_HAVE_SQRTF 1 +#define TB_CONFIG_LIBM_HAVE_ACOS 1 +#define TB_CONFIG_LIBM_HAVE_ACOSF 1 +#define TB_CONFIG_LIBM_HAVE_ASIN 1 +#define TB_CONFIG_LIBM_HAVE_ASINF 1 +#define TB_CONFIG_LIBM_HAVE_POW 1 +#define TB_CONFIG_LIBM_HAVE_POWF 1 +#define TB_CONFIG_LIBM_HAVE_FMOD 1 +#define TB_CONFIG_LIBM_HAVE_FMODF 1 +#define TB_CONFIG_LIBM_HAVE_TAN 1 +#define TB_CONFIG_LIBM_HAVE_TANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN 1 +#define TB_CONFIG_LIBM_HAVE_ATANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2F 1 +#define TB_CONFIG_LIBM_HAVE_COS 1 +#define TB_CONFIG_LIBM_HAVE_COSF 1 +#define TB_CONFIG_LIBM_HAVE_SIN 1 +#define TB_CONFIG_LIBM_HAVE_SINF 1 +#define TB_CONFIG_LIBM_HAVE_EXP 1 +#define TB_CONFIG_LIBM_HAVE_EXPF 1 + +// posix functions +#define TB_CONFIG_POSIX_HAVE_POLL 1 +#define TB_CONFIG_POSIX_HAVE_SELECT 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_MUTEX_INIT 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_SETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_GETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_DELETE 1 +/*#undef TB_CONFIG_POSIX_HAVE_PTHREAD_SETAFFINITY_NP*/ +#define TB_CONFIG_POSIX_HAVE_SOCKET 1 +#define TB_CONFIG_POSIX_HAVE_OPENDIR 1 +#define TB_CONFIG_POSIX_HAVE_DLOPEN 1 +#define TB_CONFIG_POSIX_HAVE_OPEN 1 +/*#undef TB_CONFIG_POSIX_HAVE_STAT64*/ +/*#undef TB_CONFIG_POSIX_HAVE_LSTAT64*/ +#define TB_CONFIG_POSIX_HAVE_GETHOSTNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETIFADDRS 1 +#define TB_CONFIG_POSIX_HAVE_SEM_INIT 1 +#define TB_CONFIG_POSIX_HAVE_GETPAGESIZE 1 +#define TB_CONFIG_POSIX_HAVE_SYSCONF 1 +#define TB_CONFIG_POSIX_HAVE_SCHED_YIELD 1 +/*#undef TB_CONFIG_POSIX_HAVE_SCHED_SETAFFINITY*/ +#define TB_CONFIG_POSIX_HAVE_REGCOMP 1 +#define TB_CONFIG_POSIX_HAVE_REGEXEC 1 +#define TB_CONFIG_POSIX_HAVE_READV 1 +#define TB_CONFIG_POSIX_HAVE_WRITEV 1 +#define TB_CONFIG_POSIX_HAVE_PREADV 1 +#define TB_CONFIG_POSIX_HAVE_PWRITEV 1 +/*#undef TB_CONFIG_POSIX_HAVE_PREAD64*/ +/*#undef TB_CONFIG_POSIX_HAVE_PWRITE64*/ +#define TB_CONFIG_POSIX_HAVE_FDATASYNC 1 +/*#undef TB_CONFIG_POSIX_HAVE_COPYFILE*/ +#define TB_CONFIG_POSIX_HAVE_SENDFILE 1 +/*#undef TB_CONFIG_POSIX_HAVE_EPOLL_CREATE*/ +/*#undef TB_CONFIG_POSIX_HAVE_EPOLL_WAIT*/ +#define TB_CONFIG_POSIX_HAVE_POSIX_SPAWNP 1 +/*#undef TB_CONFIG_POSIX_HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP*/ +#if (defined(__MACH__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 101400) +# undef TB_CONFIG_POSIX_HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP // only for macOS >=10.15 +#endif +#define TB_CONFIG_POSIX_HAVE_EXECVP 1 +#define TB_CONFIG_POSIX_HAVE_EXECVPE 1 +#define TB_CONFIG_POSIX_HAVE_FORK 1 +/*#undef TB_CONFIG_POSIX_HAVE_VFORK*/ +#define TB_CONFIG_POSIX_HAVE_WAITPID 1 +#define TB_CONFIG_POSIX_HAVE_GETDTABLESIZE 1 +#define TB_CONFIG_POSIX_HAVE_GETRLIMIT 1 +#define TB_CONFIG_POSIX_HAVE_GETADDRINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETNAMEINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYADDR 1 +#define TB_CONFIG_POSIX_HAVE_FCNTL 1 +#define TB_CONFIG_POSIX_HAVE_PIPE 1 +#define TB_CONFIG_POSIX_HAVE_PIPE2 1 +#define TB_CONFIG_POSIX_HAVE_MKFIFO 1 +#define TB_CONFIG_POSIX_HAVE_MMAP 1 +/*#undef TB_CONFIG_POSIX_HAVE_FUTIMENS*/ +/*#undef TB_CONFIG_POSIX_HAVE_UTIMENSAT*/ + +// windows functions +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_REL*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_NF*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_ACQ*/ +/*#undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_REL*/ + +// bsd functions +/*#undef TB_CONFIG_BSD_HAVE_FLOCK*/ + +// systemv functions +#define TB_CONFIG_SYSTEMV_HAVE_SEMGET 1 +#define TB_CONFIG_SYSTEMV_HAVE_SEMTIMEDOP 1 + +// linux functions +/*#undef TB_CONFIG_LINUX_HAVE_INOTIFY_INIT*/ +/*#undef TB_CONFIG_LINUX_HAVE_IFADDRS*/ + +// valgrind functions +/*#undef TB_CONFIG_VALGRIND_HAVE_VALGRIND_STACK_REGISTER*/ + +#endif diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject 486b29e0d2b587934dcbc897df850753765433b +Subproject 1d777aca24121df60d4219e08c0230e30fb0575 diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 6360bf978..d71c05c62 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -39,7 +39,7 @@ #include <mach-o/dyld.h> #include <signal.h> #elif defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) || defined(TB_CONFIG_OS_ANDROID) || \ - defined(TB_CONFIG_OS_HAIKU) + defined(TB_CONFIG_OS_HAIKU) || defined(TB_CONFIG_OS_SOLARIS) #include <unistd.h> #include <signal.h> #endif @@ -48,6 +48,10 @@ #include <sys/sysctl.h> #include <signal.h> #endif +#ifdef TB_CONFIG_OS_SOLARIS +#include <sys/types.h> +#include <signal.h> +#endif #ifdef TB_CONFIG_OS_HAIKU #include <image.h> #endif @@ -79,6 +83,8 @@ #else #define XM_PROC_SELF_FILE "/proc/curproc/file" #endif +#elif defined(TB_CONFIG_OS_SOLARIS) +#define XM_PROC_SELF_FILE "/proc/self/path/a.out" #endif // hook lua memory allocator @@ -1079,6 +1085,8 @@ static tb_void_t xm_engine_init_host(xm_engine_t *engine) { syshost = "linux"; #elif defined(TB_CONFIG_OS_BSD) syshost = "bsd"; +#elif defined(TB_CONFIG_OS_SOLARIS) + syshost = "solaris"; #elif defined(TB_CONFIG_OS_IOS) syshost = "ios"; #elif defined(TB_CONFIG_OS_ANDROID) diff --git a/core/src/xmake/os/getwinsize.c b/core/src/xmake/os/getwinsize.c index 6faef97d0..33f1396dc 100644 --- a/core/src/xmake/os/getwinsize.c +++ b/core/src/xmake/os/getwinsize.c @@ -55,6 +55,8 @@ tb_int_t xm_os_getwinsize(lua_State *lua) { w = (tb_int_t)csbi.dwSize.X; h = (tb_int_t)csbi.dwSize.Y; } +#elif defined(TB_CONFIG_OS_SOLARIS) + // Solaris doesn't support winsize/TIOCGWINSZ, use default values #else struct winsize size; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) { diff --git a/core/xmake.lua b/core/xmake.lua index 28ac10af4..24f5b9304 100644 --- a/core/xmake.lua +++ b/core/xmake.lua @@ -103,7 +103,7 @@ option("curses") end end) after_check(function (option) - if option:dep("cosmocc"):enabled() then + if option:dep("cosmocc"):enabled() or is_plat("solaris") then option:enable(false) end end) diff --git a/core/xmake.sh b/core/xmake.sh index 9b2dd509a..0660a2ccb 100755 --- a/core/xmake.sh +++ b/core/xmake.sh @@ -47,8 +47,11 @@ option_end option "curses" add_cfuncs "initscr" add_cincludes "curses.h" - add_defines "XM_CONFIG_API_HAVE_CURSES" before_check "option_find_curses" + add_defines "XM_CONFIG_API_HAVE_CURSES" + if is_host "solaris"; then + set_default "false" + fi option_end option_find_curses() { diff --git a/tests/actions/package/localpkg/test.lua b/tests/actions/package/localpkg/test.lua index a1f03b215..b3b3106ff 100644 --- a/tests/actions/package/localpkg/test.lua +++ b/tests/actions/package/localpkg/test.lua @@ -1,5 +1,5 @@ function main(t) - if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd") then + if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd", "solaris") then os.cd("libfoo") os.exec("xmake package -D -o ../bar/build") os.cd("../bar") diff --git a/tests/apis/namespace/package/test.lua b/tests/apis/namespace/package/test.lua index 38d054b75..7b7dabeff 100644 --- a/tests/apis/namespace/package/test.lua +++ b/tests/apis/namespace/package/test.lua @@ -1,5 +1,5 @@ function main() - if is_host("bsd") then + if is_host("bsd", "solaris") then return end os.exec("xmake -vD -y") diff --git a/tests/projects/c++/linkorders/test.lua b/tests/projects/c++/linkorders/test.lua index 704959e28..39898ef97 100644 --- a/tests/projects/c++/linkorders/test.lua +++ b/tests/projects/c++/linkorders/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end diff --git a/tests/projects/c++/snippet_runtimes/test.lua b/tests/projects/c++/snippet_runtimes/test.lua index 9f7e59b3b..e06f405f7 100644 --- a/tests/projects/c++/snippet_runtimes/test.lua +++ b/tests/projects/c++/snippet_runtimes/test.lua @@ -12,7 +12,7 @@ end function main(t) local clang = find_tool("clang") - if clang and not is_subhost("windows") and not is_subhost("bsd") then + if clang and not is_subhost("windows") and not is_subhost("bsd", "solaris") then os.exec("xmake f --toolchain=clang --runtimes=c++_shared --yes") _build() end diff --git a/tests/projects/c/library_with_cmakelists/test.lua b/tests/projects/c/library_with_cmakelists/test.lua index 3c28e0c3e..53b02d24c 100644 --- a/tests/projects/c/library_with_cmakelists/test.lua +++ b/tests/projects/c/library_with_cmakelists/test.lua @@ -2,7 +2,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end diff --git a/tests/projects/other/merge_archive/test.lua b/tests/projects/other/merge_archive/test.lua index b57362078..88594b1d5 100644 --- a/tests/projects/other/merge_archive/test.lua +++ b/tests/projects/other/merge_archive/test.lua @@ -1,3 +1,7 @@ function main(t) + -- Solaris ar does not support merging archives with duplicate object file names + if is_host("solaris") then + return + end t:build() end diff --git a/tests/projects/other/merge_archive2/test.lua b/tests/projects/other/merge_archive2/test.lua index b57362078..88594b1d5 100644 --- a/tests/projects/other/merge_archive2/test.lua +++ b/tests/projects/other/merge_archive2/test.lua @@ -1,3 +1,7 @@ function main(t) + -- Solaris ar does not support merging archives with duplicate object file names + if is_host("solaris") then + return + end t:build() end diff --git a/tests/projects/package/basic/test.lua b/tests/projects/package/basic/test.lua index 4964fecaa..65d2f2335 100644 --- a/tests/projects/package/basic/test.lua +++ b/tests/projects/package/basic/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end diff --git a/tests/projects/package/compatibility/deps_with_version/test.lua b/tests/projects/package/compatibility/deps_with_version/test.lua index a6690754b..b9f43bad5 100644 --- a/tests/projects/package/compatibility/deps_with_version/test.lua +++ b/tests/projects/package/compatibility/deps_with_version/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua index a6690754b..b9f43bad5 100644 --- a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua +++ b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/components/test.lua b/tests/projects/package/components/test.lua index a45153181..fdec596a7 100644 --- a/tests/projects/package/components/test.lua +++ b/tests/projects/package/components/test.lua @@ -1,5 +1,5 @@ function main(t) - if is_host("bsd") or is_subhost("msys") then + if is_host("bsd", "solaris") or is_subhost("msys") then return end diff --git a/tests/projects/package/depconfigs/test.lua b/tests/projects/package/depconfigs/test.lua index a6690754b..b9f43bad5 100644 --- a/tests/projects/package/depconfigs/test.lua +++ b/tests/projects/package/depconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/inherit_base/test.lua b/tests/projects/package/inherit_base/test.lua index a6690754b..b9f43bad5 100644 --- a/tests/projects/package/inherit_base/test.lua +++ b/tests/projects/package/inherit_base/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/multiconfig/test.lua b/tests/projects/package/multiconfig/test.lua index a6690754b..b9f43bad5 100644 --- a/tests/projects/package/multiconfig/test.lua +++ b/tests/projects/package/multiconfig/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/package_rule/test.lua b/tests/projects/package/package_rule/test.lua index 4964fecaa..65d2f2335 100644 --- a/tests/projects/package/package_rule/test.lua +++ b/tests/projects/package/package_rule/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end diff --git a/tests/projects/package/rootconfigs/test.lua b/tests/projects/package/rootconfigs/test.lua index 7d55eaf4e..d98f3385f 100644 --- a/tests/projects/package/rootconfigs/test.lua +++ b/tests/projects/package/rootconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/toolchain_muslcc/test.lua b/tests/projects/package/toolchain_muslcc/test.lua index 4964fecaa..65d2f2335 100644 --- a/tests/projects/package/toolchain_muslcc/test.lua +++ b/tests/projects/package/toolchain_muslcc/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd") then + if is_host("bsd", "solaris") then return end diff --git a/tests/projects/package/toolchain_muslcc/xmake.lua b/tests/projects/package/toolchain_muslcc/xmake.lua index 8fdd99b9f..6c5e8f8b3 100644 --- a/tests/projects/package/toolchain_muslcc/xmake.lua +++ b/tests/projects/package/toolchain_muslcc/xmake.lua @@ -25,7 +25,7 @@ toolchain_end() -- add library packages -- for testing zlib/xmake, libplist/autoconf, libogg/cmake add_requires("zlib", "libogg", {system = false}) -if is_host("macosx", "linux", "bsd") then +if is_host("macosx", "linux", "bsd", "solaris") then add_requires("libplist", {system = false}) end diff --git a/xmake/core/base/math.lua b/xmake/core/base/math.lua index 82dbdeb38..ce2e1c8b1 100644 --- a/xmake/core/base/math.lua +++ b/xmake/core/base/math.lua @@ -22,7 +22,7 @@ local math = math or {} -- init constants -math.nan = math.log(-1) +math.nan = 0/0 -- use 0/0 instead of math.log(-1) for better cross-platform compatibility (e.g., Solaris) math.e = math.exp(1) math.inf = 1/0 -- @see http://lua-users.org/wiki/InfAndNanComparisons diff --git a/xmake/core/base/serialize.lua b/xmake/core/base/serialize.lua index 274687f49..94d32ea95 100644 --- a/xmake/core/base/serialize.lua +++ b/xmake/core/base/serialize.lua @@ -256,6 +256,12 @@ function serialize._make(obj, opt) if math.isnan(obj) then -- fix nan for lua 5.3, -nan(ind) return "nan" end + local inf_val = math.isinf(obj) + if inf_val == 1 then -- fix huge for Solaris + return "inf" + elseif inf_val == -1 then -- fix -huge for Solaris + return "-inf" + end return serialize._makedefault(obj, opt) elseif type(obj) == "table" then return serialize._maketable(obj, opt) diff --git a/xmake/modules/utils/archive/merge_staticlib.lua b/xmake/modules/utils/archive/merge_staticlib.lua index 41f256740..f75aa64f6 100644 --- a/xmake/modules/utils/archive/merge_staticlib.lua +++ b/xmake/modules/utils/archive/merge_staticlib.lua @@ -22,31 +22,109 @@ import("core.base.option") import("private.tools.vstool") +-- merge *.a archive libraries using libtool +function _merge_for_ar_libtool(target, program, outputfile, libraryfiles, opt) + os.vrunv("libtool", table.join("-static", "-o", outputfile, libraryfiles)) +end + +-- merge *.a archive libraries using fallback method (extract and repack) +-- Used for platforms where ar does not support -M option (e.g., Solaris) +function _merge_for_ar_fallback(target, program, outputfile, libraryfiles, opt) + -- we need to handle duplicate object file names by adding prefixes + -- convert all library files to absolute paths before changing directory + local libraryfiles_abs = {} + for _, libraryfile in ipairs(libraryfiles) do + if os.isfile(libraryfile) then + table.insert(libraryfiles_abs, path.absolute(libraryfile)) + end + end + if #libraryfiles_abs == 0 then + return + end + local tmpdir = os.tmpfile() .. ".dir" + os.mkdir(tmpdir) + -- check for duplicate object file names and warn + for idx, libraryfile_abs in ipairs(libraryfiles_abs) do + local list = os.iorunv(program, {"-t", libraryfile_abs}, {curdir = tmpdir}) + if list then + local seen_files = {} + local duplicates = {} + for _, line in ipairs(list:split("\n")) do + line = line:trim() + if line:endswith(".o") then + if seen_files[line] then + if not duplicates[line] then + duplicates[line] = {} + end + table.insert(duplicates[line], libraryfile_abs) + else + seen_files[line] = true + end + end + end + if not table.empty(duplicates) then + local dup_names = table.keys(duplicates) + wprint("duplicate object file names found in %s: %s (some files may be lost during merge)", + path.filename(libraryfile_abs), table.concat(dup_names, ", ")) + end + end + end + -- extract and merge all archives + local objectfiles = {} + for idx, libraryfile_abs in ipairs(libraryfiles_abs) do + -- extract all files from this archive + os.vrunv(program, {"-x", libraryfile_abs}, {curdir = tmpdir}) + -- collect extracted object files (duplicate names will be overwritten) + for _, objfile in ipairs(os.files(path.join(tmpdir, "*.o"))) do + -- use relative path (filename only) since ar will run with curdir = tmpdir + table.insert(objectfiles, path.filename(objfile)) + end + end + -- create new archive with all object files + if #objectfiles > 0 then + os.mkdir(path.directory(outputfile)) + local outputfile_abs = path.absolute(outputfile) + -- remove output file if exists to avoid appending + os.tryrm(outputfile_abs) + -- create new archive with -c (create) and -r (replace/insert) + -- use relative paths for object files since curdir = tmpdir + os.vrunv(program, table.join("-cr", outputfile_abs, objectfiles), {curdir = tmpdir}) + end + os.rm(tmpdir) +end + +-- merge *.a archive libraries for GNU ar (using -M interactive mode) +function _merge_for_ar_gnu(target, program, outputfile, libraryfiles, opt) + -- we can't generate directly to outputfile, + -- because on windows/ndk, llvm-ar.exe may fail to write with no permission, even though it's a writable temp file. + -- + -- @see https://github.com/xmake-io/xmake/issues/1973 + local archivefile = target.autogenfile and target:autogenfile((hash.uuid(outputfile):gsub("%-", ""))) .. ".a" or (os.tmpfile() .. ".a") + os.mkdir(path.directory(archivefile)) + local tmpfile = os.tmpfile() + local mrifile = io.open(tmpfile, "w") + mrifile:print("create %s", archivefile) + for _, libraryfile in ipairs(libraryfiles) do + mrifile:print("addlib %s", libraryfile) + end + mrifile:print("save") + mrifile:print("end") + mrifile:close() + os.vrunv(program, {"-M"}, {stdin = tmpfile}) + os.cp(archivefile, outputfile) + os.rm(tmpfile) + os.rm(archivefile) +end + -- merge *.a archive libraries for ar function _merge_for_ar(target, program, outputfile, libraryfiles, opt) opt = opt or {} if target:is_plat("macosx", "iphoneos", "watchos", "appletvos") then - os.vrunv("libtool", table.join("-static", "-o", outputfile, libraryfiles)) + _merge_for_ar_libtool(target, program, outputfile, libraryfiles, opt) + elseif target:is_plat("solaris") then + _merge_for_ar_fallback(target, program, outputfile, libraryfiles, opt) else - -- we can't generate directly to outputfile, - -- because on windows/ndk, llvm-ar.exe may fail to write with no permission, even though it's a writable temp file. - -- - -- @see https://github.com/xmake-io/xmake/issues/1973 - local archivefile = target.autogenfile and target:autogenfile((hash.uuid(outputfile):gsub("%-", ""))) .. ".a" or (os.tmpfile() .. ".a") - os.mkdir(path.directory(archivefile)) - local tmpfile = os.tmpfile() - local mrifile = io.open(tmpfile, "w") - mrifile:print("create %s", archivefile) - for _, libraryfile in ipairs(libraryfiles) do - mrifile:print("addlib %s", libraryfile) - end - mrifile:print("save") - mrifile:print("end") - mrifile:close() - os.vrunv(program, {"-M"}, {stdin = tmpfile}) - os.cp(archivefile, outputfile) - os.rm(tmpfile) - os.rm(archivefile) + _merge_for_ar_gnu(target, program, outputfile, libraryfiles, opt) end end diff --git a/xmake/platforms/solaris/xmake.lua b/xmake/platforms/solaris/xmake.lua new file mode 100644 index 000000000..5abdde4fb --- /dev/null +++ b/xmake/platforms/solaris/xmake.lua @@ -0,0 +1,57 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @author ruki +-- @file xmake.lua +-- + +platform("solaris") + set_os("solaris") + set_hosts("solaris") + set_archs("i386", "x86_64") + + set_formats("static", "lib$(name).a") + set_formats("object", "$(name).o") + set_formats("shared", "lib$(name).so") + set_formats("symbol", "$(name).sym") + + set_installdir("/usr/local") + + set_toolchains("envs", "gcc", "clang", "yasm", "nasm", "fasm", "cuda", "go", "rust", "gfortran", "zig") + + set_menu { + config = + { + {category = "Cuda SDK Configuration" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {nil, "cuda_sdkver", "kv", "auto", "The Cuda SDK Version" } + , {category = "Qt SDK Configuration" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } + , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } + } + + , global = + { + {category = "Cuda SDK Configuration" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {category = "Qt SDK Configuration" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } + } + } + + diff --git a/xmake/rules/linker/version_scripts/xmake.lua b/xmake/rules/linker/version_scripts/xmake.lua index 3845274de..b163eaa04 100644 --- a/xmake/rules/linker/version_scripts/xmake.lua +++ b/xmake/rules/linker/version_scripts/xmake.lua @@ -39,6 +39,10 @@ rule("linker.version_scripts") if target:is_plat("macosx", "iphoneos", "watchos", "appletvos") then return end + -- @note Solaris linker does not support --version-script + if target:is_plat("solaris") then + return + end if target:has_tool("ld", "gcc", "gxx", "clang", "clangxx") or target:has_tool("sh", "gcc", "gxx", "clang", "clangxx") then target:add(target:is_shared() and "shflags" or "ldflags", "-Wl,--version-script=" .. scriptfile, {force = true}) diff --git a/xmake/rules/utils/symbols/export_list/xmake.lua b/xmake/rules/utils/symbols/export_list/xmake.lua index f156e22af..84878fe7b 100644 --- a/xmake/rules/utils/symbols/export_list/xmake.lua +++ b/xmake/rules/utils/symbols/export_list/xmake.lua @@ -66,6 +66,9 @@ rule("utils.symbols.export_list") exportkind = "apple" exportfile = path.join(target:autogendir(), "rules", "symbols", "export_list.exp") target:add("shflags", {"-L-exported_symbols_list", "-L" .. exportfile}, {force = true, expand = false}) + elseif target:is_plat("solaris") then + -- Solaris linker does not support --version-script + return else exportkind = "ver" exportfile = path.join(target:autogendir(), "rules", "symbols", "export_list.map") @@ -85,6 +88,9 @@ rule("utils.symbols.export_list") exportkind = "apple" exportfile = path.join(target:autogendir(), "rules", "symbols", "export_list.exp") target:add("shflags", {"-Wl,-exported_symbols_list", exportfile}, {force = true, expand = false}) + elseif target:is_plat("solaris") then + -- Solaris linker does not support --version-script + return elseif target:has_tool("ld", "gcc", "gxx", "clang", "clangxx") or target:has_tool("sh", "gcc", "gxx", "clang", "clangxx") then exportkind = "ver" |
