Windows installer working. Examples need help.

This commit is contained in:
Scott Duensing 2024-04-28 19:55:01 -05:00
parent 07d0b5b9f1
commit 0c83e2a535
6 changed files with 122 additions and 25 deletions

2
.gitignore vendored
View file

@ -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

80
build-distro.sh Executable file
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -26,6 +26,8 @@
#include <string.h>
#include <stdbool.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#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);

View file

@ -26,9 +26,16 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#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) {
}
}
}