-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
build-scriptConcerning build scriptConcerning build scriptenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Milestone
Description
The current native build system isn't incremental.
Here is a simple strategy to implement an incremental building system:
- Use this code first and compile each source C file into a static object file:
└──╼ $gcc -c test-source.c -o test-static-object.o- Each file in the unix system has a LDM (last-date-of-modification) including the source C files and the object code files.
- In the subsequent build, comparing these metadata (the last date of modification) of both the source code and the static object output will determine if the build will execute or not, here is a simple low-level similar approach:
#!/bin/bash
echo "Test ldm (Last Date of Modification) for incremental building units"
source="./source.c"
function getFormatedFileLdm() {
local target=$1
local format=$2
stat ${target} --format=${format}
local ldm=$?
return $ldm
}
function getFileLdm0() {
local target=$1
getFormatedFileLdm ${target} %Y
local ldm=$?
return $ldm
}
function saveFileLdm() {
local target="${1}-ldm.txt"
local ldm=$2
echo "${ldm}" > "${target}"
return $?
}
function loadFileLdm() {
local target="${1}-ldm.txt"
cat $target
return $?
}
function isModified() {
local ldm0=$1
local ldm1=$2
let elapsed_ldm=$ldm1-$ldm0
if (( $elapsed_ldm > 0 )); then
echo "Compiling now ...."
gcc $source --debug -o "${source}.o"
elif (( $elapsed_ldm == 0 )); then
echo "File not changed, leaving now ...."
else
echo "State undefined ...."
fi
}
# prepare LDMs (Last-Dates-Of-Modifications)
current_ldm=`getFileLdm0 $source`
last_ldm=`loadFileLdm $source`
# test if the file is modified
isModified $last_ldm $current_ldm
# update the file ldm with current new ldm
saveFileLdm $source $current_ldm- The compilation should end by a shared position-independent shared object file:
└──╼ $gcc -shared -fPIC test-static-object.o -o test-shared-object.soMetadata
Metadata
Assignees
Labels
build-scriptConcerning build scriptConcerning build scriptenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested