Thread: build patch

build patch

From
Mike Beachy
Date:
While hacking about on the code, I've made another couple of tweaks to the
build files. They make it possible to use ant exclusively after running a
configure and a 'make build.properties'. The changes don't affect use of
make if you still want to use it.

Change summary:

To build.xml, I added a specification to retrieve properties from
build.properties, a new target called check_driver that makes sure
Driver.java gets regenerated if build.properties or Driver.java.in is newer
than it is, and a new 'clean_all' target that nukes the build.properties
file in addition to the things in the clean target.

To Makefile, I added a new target, build.properties, which creates a
file with the variables lifted from Makefile.global. I dropped the
command line definitions of these variables and made build.properties a
dependency of the targets that needed them.

Patch follows.

Mike

Index: build.xml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/build.xml,v
retrieving revision 1.30
diff -c -r1.30 build.xml
*** build.xml    2002/10/20 00:10:55    1.30
--- build.xml    2002/12/10 13:23:49
***************
*** 23,28 ****
--- 23,30 ----
    <property name="package" value="org/postgresql" />
    <property name="debug" value="on" />

+   <property file="build.properties"/>
+
    <!--
      This is a simpler method than utils.CheckVersion
      It defaults to jdbc1, but builds jdbc2 if the java.lang.Byte class is
***************
*** 115,126 ****
      </javac>
    </target>


    <!--
      This generates Driver.java from Driver.java.in
      It's required for importing the driver version properties
    -->
!   <target name="driver" depends="prepare,check_versions">
      <!-- determine the edition text -->
      <condition property="edition" value="JDBC1">
          <equals arg1="${jdbc1}" arg2="true"/>
--- 117,137 ----
      </javac>
    </target>

+   <target name="check_driver">
+     <uptodate targetfile="${package}/Driver.java" property="driver.uptodate">
+       <srcfiles dir=".">
+     <include name="${package}/Driver.java.in"/>
+     <include name="build.properties"/>
+       </srcfiles>
+     </uptodate>
+   </target>

    <!--
      This generates Driver.java from Driver.java.in
      It's required for importing the driver version properties
    -->
!   <target name="driver" depends="prepare,check_versions,check_driver"
!           unless="driver.uptodate">
      <!-- determine the edition text -->
      <condition property="edition" value="JDBC1">
          <equals arg1="${jdbc1}" arg2="true"/>
***************
*** 158,163 ****
--- 169,177 ----

       <fail unless="major" message="'major' undefined. Please follow the directions in README."/>
       <fail unless="minor" message="'minor' undefined. Please follow the directions in README."/>
+      <fail unless="fullversion" message="'fullversion' undefined. Please follow the directions in README."/>
+      <fail unless="def_pgport" message="'def_pgport' undefined. Please follow the directions in README."/>
+      <fail unless="enable_debug" message="'enable_debug' undefined. Please follow the directions in README."/>

      <!-- Put a check for the current version here -->

***************
*** 231,236 ****
--- 245,253 ----
      <delete quiet="true" file="${package}/Driver.java" />
    </target>

+   <target name="clean_all" depends="clean">
+     <delete quiet="true" file="build.properties" />
+   </target>


    <!-- This compiles and executes the JUnit tests -->
Index: Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/Makefile,v
retrieving revision 1.36
diff -c -r1.36 Makefile
*** Makefile    2002/10/20 02:55:50    1.36
--- Makefile    2002/12/10 13:23:49
***************
*** 15,32 ****
  majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/')
  minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/')

! properties := -Dmajor=$(majorversion) -Dminor=$(minorversion) \
!         -Dfullversion=$(VERSION) \
!         -Ddef_pgport=$(DEF_PGPORT) \
!         -Denable_debug=$(enable_debug)
!
! all:
!     $(ANT) -buildfile $(srcdir)/build.xml all \
!       $(properties)

! install: installdirs
      $(ANT) -buildfile $(srcdir)/build.xml install \
!       -Dinstall.directory=$(javadir) $(properties)

  installdirs:
      $(mkinstalldirs) $(javadir)
--- 15,34 ----
  majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/')
  minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/')

! build.properties: $(top_builddir)/src/Makefile.global
!     echo "# This file was created by 'make build.properties'." > build.properties
!     echo major=$(majorversion) >> build.properties
!     echo minor=$(minorversion) >> build.properties
!     echo fullversion=$(VERSION) >> build.properties
!     echo def_pgport=$(DEF_PGPORT) >> build.properties
!     echo enable_debug=$(enable_debug) >> build.properties

! all: build.properties
!     $(ANT) -buildfile $(srcdir)/build.xml all
!
! install: installdirs build.properties
      $(ANT) -buildfile $(srcdir)/build.xml install \
!       -Dinstall.directory=$(javadir)

  installdirs:
      $(mkinstalldirs) $(javadir)
***************
*** 36,42 ****
        -Dinstall.directory=$(javadir)

  clean distclean maintainer-clean:
!     $(ANT) -buildfile $(srcdir)/build.xml clean

! check: all
!     $(ANT) -buildfile $(srcdir)/build.xml test $(properties)
--- 38,44 ----
        -Dinstall.directory=$(javadir)

  clean distclean maintainer-clean:
!     $(ANT) -buildfile $(srcdir)/build.xml clean_all

! check: build.properties
!     $(ANT) -buildfile $(srcdir)/build.xml test

Re: build patch

From
Fernando Nasser
Date:
What about adding this new building info the the README file?

Regards,
Fernando

Mike Beachy wrote:
> While hacking about on the code, I've made another couple of tweaks to the
> build files. They make it possible to use ant exclusively after running a
> configure and a 'make build.properties'. The changes don't affect use of
> make if you still want to use it.
>
> Change summary:
>
> To build.xml, I added a specification to retrieve properties from
> build.properties, a new target called check_driver that makes sure
> Driver.java gets regenerated if build.properties or Driver.java.in is newer
> than it is, and a new 'clean_all' target that nukes the build.properties
> file in addition to the things in the clean target.
>
> To Makefile, I added a new target, build.properties, which creates a
> file with the variables lifted from Makefile.global. I dropped the
> command line definitions of these variables and made build.properties a
> dependency of the targets that needed them.
>
> Patch follows.
>
> Mike
>
> Index: build.xml
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/build.xml,v
> retrieving revision 1.30
> diff -c -r1.30 build.xml
> *** build.xml    2002/10/20 00:10:55    1.30
> --- build.xml    2002/12/10 13:23:49
> ***************
> *** 23,28 ****
> --- 23,30 ----
>     <property name="package" value="org/postgresql" />
>     <property name="debug" value="on" />
>
> +   <property file="build.properties"/>
> +
>     <!--
>       This is a simpler method than utils.CheckVersion
>       It defaults to jdbc1, but builds jdbc2 if the java.lang.Byte class is
> ***************
> *** 115,126 ****
>       </javac>
>     </target>
>
>
>     <!--
>       This generates Driver.java from Driver.java.in
>       It's required for importing the driver version properties
>     -->
> !   <target name="driver" depends="prepare,check_versions">
>       <!-- determine the edition text -->
>       <condition property="edition" value="JDBC1">
>           <equals arg1="${jdbc1}" arg2="true"/>
> --- 117,137 ----
>       </javac>
>     </target>
>
> +   <target name="check_driver">
> +     <uptodate targetfile="${package}/Driver.java" property="driver.uptodate">
> +       <srcfiles dir=".">
> +     <include name="${package}/Driver.java.in"/>
> +     <include name="build.properties"/>
> +       </srcfiles>
> +     </uptodate>
> +   </target>
>
>     <!--
>       This generates Driver.java from Driver.java.in
>       It's required for importing the driver version properties
>     -->
> !   <target name="driver" depends="prepare,check_versions,check_driver"
> !           unless="driver.uptodate">
>       <!-- determine the edition text -->
>       <condition property="edition" value="JDBC1">
>           <equals arg1="${jdbc1}" arg2="true"/>
> ***************
> *** 158,163 ****
> --- 169,177 ----
>
>        <fail unless="major" message="'major' undefined. Please follow the directions in README."/>
>        <fail unless="minor" message="'minor' undefined. Please follow the directions in README."/>
> +      <fail unless="fullversion" message="'fullversion' undefined. Please follow the directions in README."/>
> +      <fail unless="def_pgport" message="'def_pgport' undefined. Please follow the directions in README."/>
> +      <fail unless="enable_debug" message="'enable_debug' undefined. Please follow the directions in README."/>
>
>       <!-- Put a check for the current version here -->
>
> ***************
> *** 231,236 ****
> --- 245,253 ----
>       <delete quiet="true" file="${package}/Driver.java" />
>     </target>
>
> +   <target name="clean_all" depends="clean">
> +     <delete quiet="true" file="build.properties" />
> +   </target>
>
>
>     <!-- This compiles and executes the JUnit tests -->
> Index: Makefile
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/Makefile,v
> retrieving revision 1.36
> diff -c -r1.36 Makefile
> *** Makefile    2002/10/20 02:55:50    1.36
> --- Makefile    2002/12/10 13:23:49
> ***************
> *** 15,32 ****
>   majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/')
>   minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/')
>
> ! properties := -Dmajor=$(majorversion) -Dminor=$(minorversion) \
> !         -Dfullversion=$(VERSION) \
> !         -Ddef_pgport=$(DEF_PGPORT) \
> !         -Denable_debug=$(enable_debug)
> !
> ! all:
> !     $(ANT) -buildfile $(srcdir)/build.xml all \
> !       $(properties)
>
> ! install: installdirs
>       $(ANT) -buildfile $(srcdir)/build.xml install \
> !       -Dinstall.directory=$(javadir) $(properties)
>
>   installdirs:
>       $(mkinstalldirs) $(javadir)
> --- 15,34 ----
>   majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/')
>   minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/')
>
> ! build.properties: $(top_builddir)/src/Makefile.global
> !     echo "# This file was created by 'make build.properties'." > build.properties
> !     echo major=$(majorversion) >> build.properties
> !     echo minor=$(minorversion) >> build.properties
> !     echo fullversion=$(VERSION) >> build.properties
> !     echo def_pgport=$(DEF_PGPORT) >> build.properties
> !     echo enable_debug=$(enable_debug) >> build.properties
>
> ! all: build.properties
> !     $(ANT) -buildfile $(srcdir)/build.xml all
> !
> ! install: installdirs build.properties
>       $(ANT) -buildfile $(srcdir)/build.xml install \
> !       -Dinstall.directory=$(javadir)
>
>   installdirs:
>       $(mkinstalldirs) $(javadir)
> ***************
> *** 36,42 ****
>         -Dinstall.directory=$(javadir)
>
>   clean distclean maintainer-clean:
> !     $(ANT) -buildfile $(srcdir)/build.xml clean
>
> ! check: all
> !     $(ANT) -buildfile $(srcdir)/build.xml test $(properties)
> --- 38,44 ----
>         -Dinstall.directory=$(javadir)
>
>   clean distclean maintainer-clean:
> !     $(ANT) -buildfile $(srcdir)/build.xml clean_all
>
> ! check: build.properties
> !     $(ANT) -buildfile $(srcdir)/build.xml test
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


Re: build patch

From
Mike Beachy
Date:
On Tue, Dec 10, 2002 at 12:11:40PM -0500, Fernando Nasser wrote:
> What about adding this new building info the the README file?

Patch below. Feel free to suggest something else.

Index: README
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/README,v
retrieving revision 1.12
diff -c -r1.12 README
*** README    2002/10/20 00:10:55    1.12
--- README    2002/12/10 18:39:00
***************
*** 32,37 ****
--- 32,41 ----

  That jar file will contain the driver for _your_ version of the JDK.

+ If you would like to use ANT directly, first invoke 'make build.properties'
+ after running the configure script with the java option. This will create a
+ needed Java properties file from the configured information.
+
  REMEMBER: Once you have compiled the driver, it will work on ALL platforms
  that support that version of the API. You don't need to build it for each
  platform.

Re: build patch

From
Fernando Nasser
Date:
That is great.  Thanks.

Mike Beachy wrote:
> On Tue, Dec 10, 2002 at 12:11:40PM -0500, Fernando Nasser wrote:
>
>>What about adding this new building info the the README file?
>
>
> Patch below. Feel free to suggest something else.
>
> Index: README
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/README,v
> retrieving revision 1.12
> diff -c -r1.12 README
> *** README    2002/10/20 00:10:55    1.12
> --- README    2002/12/10 18:39:00
> ***************
> *** 32,37 ****
> --- 32,41 ----
>
>   That jar file will contain the driver for _your_ version of the JDK.
>
> + If you would like to use ANT directly, first invoke 'make build.properties'
> + after running the configure script with the java option. This will create a
> + needed Java properties file from the configured information.
> +
>   REMEMBER: Once you have compiled the driver, it will work on ALL platforms
>   that support that version of the API. You don't need to build it for each
>   platform.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


Re: build patch

From
Dave Cramer
Date:
All associated patch's applied

Thanks Mike!

On Tue, 2002-12-10 at 13:40, Mike Beachy wrote:
> On Tue, Dec 10, 2002 at 12:11:40PM -0500, Fernando Nasser wrote:
> > What about adding this new building info the the README file?
>
> Patch below. Feel free to suggest something else.
>
> Index: README
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/README,v
> retrieving revision 1.12
> diff -c -r1.12 README
> *** README    2002/10/20 00:10:55    1.12
> --- README    2002/12/10 18:39:00
> ***************
> *** 32,37 ****
> --- 32,41 ----
>
>   That jar file will contain the driver for _your_ version of the JDK.
>
> + If you would like to use ANT directly, first invoke 'make build.properties'
> + after running the configure script with the java option. This will create a
> + needed Java properties file from the configured information.
> +
>   REMEMBER: Once you have compiled the driver, it will work on ALL platforms
>   that support that version of the API. You don't need to build it for each
>   platform.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Dave Cramer <Dave@micro-automation.net>