clang build scripts for concrete examples

main
Allen Webster 2024-04-24 06:01:18 -07:00
parent 40183c2eed
commit 4708b7697f
3 changed files with 59 additions and 3 deletions

27
linux_clang/build.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Path setup
cd ../linux_concrete
src=$PWD
cd ..
mkdir -p build
cd build
#### THE ARRANGEMENT OF THIS BUILD ####
# The "base layer" must be built and shared by all dynamic components.
# In this example the the base layer is linked via load-time linking with the other modules.
# The "plugin" is loaded at run-time.
# Build the base layer as a .so
clang -fvisibility=hidden -fPIC -shared $src/linux_base.c -o linux_base.so
# Build the executable; provide the base layer's load-time linking data via linux_base.so
clang -fvisibility=hidden $src/linux_main.c linux_base.so -o linux_main -Wl,-rpath,\$ORIGIN/
# Build the plugin as a .so; provide the base layer's load-time linking data via linux_base.so
clang -fvisibility=hidden -fPIC -shared $src/linux_plugin.c linux_base.so -o linux_plugin.so -Wl,-rpath,\$ORIGIN/

29
win32_clang/build.bat Normal file
View File

@ -0,0 +1,29 @@
@echo off
REM: Path setup
cd ..\win32_concrete
SET src=%cd%
cd ..
if not exist "build\" mkdir build
cd build
REM: ### THE ARRANGEMENT OF THIS BUILD ###
REM: The "base layer" must be built and shared by all dynamic components.
REM: In this example the the base layer is linked via load-time linking with the other modules.
REM: The "plugin" is loaded at run-time.
REM: Build the base layer as a .dll (also produces load-time linking data in win32_base.lib)
clang -shared %src%\win32_base.c -o win32_base.dll
REM: Build the executable; provide the base layer's load-time linking data via win32_base.lib
clang %src%\win32_main.c win32_base.lib -o win32_main.exe
REM: Build the plugin as a .dll; provide the base layer's load-time linking data via win32_base.lib
clang -shared %src%\win32_plugin.c win32_base.lib -o win32_plugin.dll

View File

@ -16,13 +16,13 @@ REM: The "plugin" is loaded at run-time.
REM: Build the base layer as a .dll (also produces load-time linking data in win32_base.lib)
cl /nologo /Zi /LD %src%\win32_base.c
cl /nologo /LD %src%\win32_base.c
REM: Build the executable; provide the base layer's load-time linking data via win32_base.lib
cl /nologo /Zi %src%\win32_main.c win32_base.lib
cl /nologo %src%\win32_main.c win32_base.lib
REM: Build the plugin as a .dll; provide the base layer's load-time linking data via win32_base.lib
cl /nologo /Zi /LD %src%\win32_plugin.c win32_base.lib
cl /nologo /LD %src%\win32_plugin.c win32_base.lib