diff --git a/.gitignore b/.gitignore index 40e9886..eaf63e1 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ overlay overlayhelper f256lib.h /distro/llvm-mos +/distro/llvm-mos-f256.7z +/distro/llvm-mos-f256.tar.xz # These aren't for public use or aren't ready. build-foenix-ide.sh diff --git a/build-distro.sh b/build-distro.sh new file mode 100755 index 0000000..5d02395 --- /dev/null +++ b/build-distro.sh @@ -0,0 +1,80 @@ +#!/bin/bash -e + +# +# Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +ROOT=$(pwd) +INSTALL=${ROOT}/llvm-mos + + +function buildOverlayTool() { + local OS=$1 + local ARCH=$2 + local TARGET=$3 + + source <(${ROOT}/../toolchains/toolchains.sh use ${ARCH} ${OS}) + + pushd tools/shared + ${CC} -c util.c + popd + pushd tools/overlay + ${CC} overlay.c ../shared/util.o -o ${TARGET} -lm + popd +} + + +if [[ "${1,,}" == "all" ]]; then + ./build-llvm-mos.sh + ./update-defines.sh + ./build-merlin.sh +fi + +./build-f256lib.sh + +pushd distro + if [[ -d .builddir ]]; then + rm -rf .builddir + fi + mkdir -p .builddir + pushd .builddir + mkdir -p llvm-mos/mos-platform/f256 + mkdir -p llvm-mos/bin + + cp -Rf ${INSTALL}/mos-platform/f256/* llvm-mos/mos-platform/f256/. + cp -f ${INSTALL}/bin/mos-f256.cfg llvm-mos/bin/. + + cp -Rf ${ROOT}/tools . + cp -Rf ${ROOT}/examples . + cp -Rf ${ROOT}/f256lib . + cp -Rf ${ROOT}/include . + cp -f ${ROOT}/f256lib.h . + + buildOverlayTool linux x86_64 $(pwd)/overlay.linux + buildOverlayTool macos aarch64 $(pwd)/overlay.macos + buildOverlayTool windows x86_64 $(pwd)/overlay.windows + + tar cJf ../llvm-mos-f256.tar.xz . + 7z a ../llvm-mos-f256.7z . + + popd +popd diff --git a/build-llvm-mos.sh b/build-llvm-mos.sh index 9ac4808..d56a7f9 100755 --- a/build-llvm-mos.sh +++ b/build-llvm-mos.sh @@ -66,16 +66,5 @@ pushd llvm-mos-sdk-source -DCMAKE_INSTALL_PREFIX=${INSTALL} \ .. ninja install - - mkdir -p distro - pushd distro - mkdir -p llvm-mos/mos-platform/f256 - mkdir -p llvm-mos/bin - cp -Rf ${INSTALL}/mos-platform/f256/* llvm-mos/mos-platform/f256/. - cp -f ${INSTALL}/bin/mos-f256.cfg llvm-mos/bin/. - tar cJf llvm-mos-f256.tar.xz llvm-mos - 7z a llvm-mos-f256.7z llvm-mos - popd popd popd - diff --git a/distro/f256-install-windows.bat b/distro/f256-install-windows.bat index b9c079f..36908c5 100644 --- a/distro/f256-install-windows.bat +++ b/distro/f256-install-windows.bat @@ -57,7 +57,7 @@ if errorlevel 1 ( ) else ( curl.exe -L %REMOTE1% > %LOCAL1% curl.exe -L %REMOTE2% > %LOCAL2% - curl.exe -L %REMOTE2% > %LOCAL3% + curl.exe -L %REMOTE3% > %LOCAL3% ) %LOCAL3% /install /passive @@ -66,9 +66,9 @@ if exist "%ProgramFiles%\7-Zip\7z.exe" ( "%ProgramFiles%\7-Zip\7z.exe" x %LOCAL1% "%ProgramFiles%\7-Zip\7z.exe" x %LOCAL2% ) else ( - if exist "%ProgramFiles%\WinRAR\UnRAR.exe" ( - "%ProgramFiles%\WinRAR\UnRAR.exe" x %LOCAL1% - "%ProgramFiles%\WinRAR\UnRAR.exe" x %LOCAL2% + if exist "%ProgramFiles%\WinRAR\WinRAR.exe" ( + "%ProgramFiles%\WinRAR\WinRAR.exe" x %LOCAL1% + "%ProgramFiles%\WinRAR\WinRAR.exe" x %LOCAL2% ) else ( echo Unable to find 7-Zip or WinRAR. Exiting. del %LOCAL1% @@ -82,13 +82,26 @@ del %LOCAL1% del %LOCAL2% del %LOCAL3% -echo @"%%~dp0mos-clang++.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang++.bat -echo @"%%~dp0mos-clang-cpp.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang-cpp.bat -echo @"%%~dp0mos-clang.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang.bat +del overlay.linux +del overlay.macos +ren overlay.windows overlay.exe + +echo @"%%~dp0mos-clang++.exe" --config mos-f256.cfg %%* > llvm-mos\bin\mos-f256-clang++.bat +echo @"%%~dp0mos-clang-cpp.exe" --config mos-f256.cfg %%* > llvm-mos\bin\mos-f256-clang-cpp.bat +echo @"%%~dp0mos-clang.exe" --config mos-f256.cfg %%* > llvm-mos\bin\mos-f256-clang.bat + +call mos-f256-clang.bat --version > NUL 2> NUL +if %ERRORLEVEL% equ 0 goto dontaddpath +setx PATH "%PATH%;%~dp0llvm-mos\bin" +set PATH=%PATH%;%~dp0llvm-mos\bin +:dontaddpath echo. +echo ----------------------------------------------------------------------------- echo Installation complete! echo. -echo It is recommended that you add the following to your PATH: -echo %~dp0llvm-mos\bin +echo NOTE: The following has been added to your PATH: +echo %~dp0llvm-mos\bin +echo ----------------------------------------------------------------------------- echo. +pause diff --git a/tools/overlay/overlay.c b/tools/overlay/overlay.c index fbdecae..dc55563 100644 --- a/tools/overlay/overlay.c +++ b/tools/overlay/overlay.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "../shared/util.h" @@ -333,6 +335,7 @@ int main(int argc, char *argv[]) { int thisOffset; DIR *dir; struct dirent *dirent; + struct stat sb; /* * Command line: @@ -411,7 +414,12 @@ int main(int argc, char *argv[]) { } for (;;) { if ((dirent = readdir(dir)) == NULL) break; - if ((dirent->d_type == DT_LNK) || (dirent->d_type == DT_REG)) { + stat(dirent->d_name, &sb); +#ifdef _WIN32 + if (S_ISREG(sb.st_mode)) { +#else + if (S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) { +#endif // Is this a C file? if ((dirent->d_name[strlen(dirent->d_name) - 2] == '.') && (dirent->d_name[strlen(dirent->d_name) - 1] == 'c')) { cFile = utilCreateString("%s%s", sourceDir, dirent->d_name); diff --git a/tools/shared/util.c b/tools/shared/util.c index 6f6e815..c4b45f7 100644 --- a/tools/shared/util.c +++ b/tools/shared/util.c @@ -26,9 +26,16 @@ #include #include #include +#include #include "util.h" +#ifdef _WIN32 + #define ourMkDir(p,m) mkdir(p) +#else + #define ourMkDir mkdir +#endif + char *utilCreateString(char *format, ...) { va_list args; @@ -185,7 +192,7 @@ bool utilMkDirP(const char *dir, const mode_t mode) { *p = 0; if (stat(tmp, &sb) != 0) { // Does not exist - create it. - if (mkdir(tmp, mode) < 0) { + if (ourMkDir(tmp, mode) < 0) { return false; } } else { @@ -200,7 +207,7 @@ bool utilMkDirP(const char *dir, const mode_t mode) { // Check path if (stat(tmp, &sb) != 0) { // Does not exist - create it. - if (mkdir(tmp, mode) < 0) { + if (ourMkDir(tmp, mode) < 0) { return false; } } else { @@ -241,5 +248,3 @@ int utilStricmp(char *a, char *b) { } } } - -