Skip to content

Commit

Permalink
Merge pull request #37 from Bearsampp/newbuild
Browse files Browse the repository at this point in the history
build.xml improvement
  • Loading branch information
jwaisner authored Apr 22, 2024
2 parents b10cfcd + 909609d commit e3ac960
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
23 changes: 22 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="module-php" basedir=".">

<dirname property="project.basedir" file="${ant.file.module-php}"/>
<!-- Import sigcheck.xml -->
<import file="sigcheck.xml"/>

<!-- Define project properties -->
<property name="project.basedir" location="."/>
<property name="root.dir" location="${project.basedir}/.."/>
<property name="build.properties" value="${project.basedir}/build.properties"/>
<property file="${build.properties}"/>
Expand All @@ -16,16 +20,30 @@
<!-- Import build-bundle.xml -->
<import file="${dev.path}/build/build-bundle.xml"/>

<!-- Define directories -->
<property name="php-ext.path" location="${project.basedir}/ext"/>
<property name="pear-install.path" location="${project.basedir}/pear"/>
<property name="bundle.tmp.prep.path" location="${project.basedir}/tmp/prep"/>
<property name="build.tmp.path" location="${project.basedir}/tmp"/>

<!-- Define the executeSigcheck target -->
<target name="executeSigcheck">
<!-- Invoke the executeSigcheck target from sigcheck.xml -->
<ant antfile="sigcheck.xml" target="executeSigcheck"/>
</target>


<!-- Main target for release build -->
<target name="release.build">
<!-- Define the bundle folder -->
<basename property="bundle.folder" file="${bundle.path}"/>
<replaceproperty src="bundle.folder" dest="bundle.version" replace="${bundle.name}" with=""/>

<!-- Get the PHP module -->
<getmoduleuntouched name="${bundle.name}" version="${bundle.version}" propSrcDest="bundle.srcdest" propSrcFilename="bundle.srcfilename"/>
<assertfile file="${bundle.srcdest}/php.exe"/>

<!-- Prepare PHP -->
<property name="php.prep.path" location="${bundle.tmp.prep.path}/${bundle.name}${bundle.version}"/>
<delete dir="${php.prep.path}"/>
<mkdir dir="${php.prep.path}"/>
Expand Down Expand Up @@ -102,6 +120,9 @@
<condition property="phpext.dll" value="${phpext.dest}"><matches string="${phpext.dest}" pattern="\.dll$"/></condition>
<fail unless="phpext.dll" message="Main dll not found"/>

<!-- Call the Sigcheck routine -->
<antcall target="executeSigcheck"/>

<!-- Copy ext -->
<echo message="Copy @{phpext} ${phpext.version} extension..."/>
<copy file="${phpext.dll}" tofile="${php.prep.path}/ext/php_@{phpext}.dll" overwrite="true"/>
Expand Down
61 changes: 61 additions & 0 deletions sigcheck.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<project name = "Sigcheck" default = "executeSigcheck">

<!-- Define properties -->
<property name = "sigcheck" value = "sigcheck -q" />
<property name = "output.file" value = "sigcheck_output.txt" />

<!-- Define a property for the PHP extension DLL -->
<property name = "phpext.dll" value = "${phpext.dll}" />

<target name = "executeSigcheck">
<!-- Execute sigcheck and save the output to a file -->
<exec executable = "cmd" output = "${output.file}" failonerror = "false">
<arg value = "/c" />
<!-- Pass the value of ${phpext.dll} as an argument to sigcheck -->
<arg value = "${sigcheck}" />
<arg value = "${phpext.dll}" />
</exec>

<!-- Read the content of the output file and extract "MachineType" -->
<loadfile property = "arch" srcfile = "${output.file}">
<filterchain>
<linecontains>
<contains value = "MachineType:" />
</linecontains>
<tokenfilter>
<replaceregex pattern = "^.*MachineType:\s*(\S+).*$" replace = "\1" />
</tokenfilter>
</filterchain>
</loadfile>

<propertyregex property="filename" input="${phpext.dll}" regexp=".*/([^/]*)$" select="\1"/>

<!-- Echo the "MachineType" -->
<echo message = "MachineType: ${arch}" />
<echo message=".dll filename is: ${filename}"/>

<condition property = "property.matches.64">
<matches string = "${arch}" pattern = "64-bit" />
</condition>

<if>
<not>
<isset property = "property.matches.64" />
</not>
<then>
<echo message = "Your property does not match '64-bit'." />
<exec executable = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" failonerror = "true">
<arg value = "-NoLogo" />
<arg value = "-NoProfile" />
<arg value = "-Command" />
<arg value = "(New-Object -ComObject SAPI.SpVoice).Speak('OH NO!, the dll file ${filename}, is not built for x64, Halting build.')" />
</exec>
<fail message = " Architecture is not '64-bit'. Halting build." />
</then>
</if>

<!-- Delete sigchecks temp file -->
<delete file="sigcheck_output.txt"/>

</target>
</project>

0 comments on commit e3ac960

Please sign in to comment.