Skip to content

Commit 6bc8309

Browse files
authored
Fix missing etw dll in the final binary (#2534)
1 parent bb35191 commit 6bc8309

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

.github/workflows/reusable-assemble.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: gradle/gradle-build-action@v2
2828
with:
2929
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
30-
arguments: assemble -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
30+
arguments: assemble -Dai.etw.native.build=release -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
3131

3232
- name: Upload snapshot
3333
uses: actions/upload-artifact@v3

.pipelines/pipeline.user.windows.buddy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build:
99
- !!buildcommand
1010
name: 'Assemble'
1111
command: '.scripts/gradle.cmd'
12-
arguments: ':agent:agent:assemble --offline'
12+
arguments: ':agent:agent:assemble -Dai.etw.native.build=release --offline'
1313
artifacts:
1414
- to: 'Artifacts'
1515
include:

.pipelines/pipeline.user.windows.official.nonrelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ build:
1616
- !!buildcommand
1717
name: 'Assemble'
1818
command: '.scripts/gradle.cmd'
19-
arguments: ':agent:agent:assemble --offline'
19+
arguments: ':agent:agent:assemble -Dai.etw.native.build=release --offline'
2020
artifacts:
2121
- to: 'Artifacts'
2222
include:

.pipelines/pipeline.user.windows.official.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ build:
1616
- !!defaultcommand
1717
name: 'Assemble'
1818
command: '.scripts/gradle.cmd'
19-
arguments: 'publishToMavenLocal -DisRelease=true -Pai.etw.native.build=release --offline'
19+
arguments: 'publishToMavenLocal -DisRelease=true -Dai.etw.native.build=release --offline'
2020
- !!buildcommand
2121
name: 'Copy files from maven local repository'
2222
command: '.scripts/copy-from-maven-local.cmd'

etw/build.gradle

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ plugins {
44
id("base")
55
}
66

7-
clean {
8-
dependsOn(":etw:java:clean")
9-
def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS)
10-
if (buildNative) {
11-
dependsOn ":etw:native:clean"
12-
}
13-
}
14-
157
/**
168
* Configures the native build variant.
179
* Values: release|debug
1810
* Default: debug
1911
*/
2012
final def NATIVE_BUILD_VARIANT_PROPERTY = "ai.etw.native.build"
2113

14+
clean {
15+
dependsOn(":etw:java:clean")
16+
def buildNative = System.properties[NATIVE_BUILD_VARIANT_PROPERTY] != null && Os.isFamily(Os.FAMILY_WINDOWS)
17+
if (buildNative) {
18+
dependsOn ":etw:native:clean"
19+
}
20+
}
21+
2222
/**
2323
* Configures the verbosity of debug output.
2424
* This value is ignored if ai.etw.native.build=release
@@ -31,14 +31,13 @@ subprojects {
3131
ext["NATIVE_BUILD_VARIANT_PROPERTY"] = NATIVE_BUILD_VARIANT_PROPERTY
3232
ext["NATIVE_VERBOSE_OUTPUT_PROPERTY"] = NATIVE_VERBOSE_OUTPUT_PROPERTY
3333

34+
String buildNativeProperty = System.properties[NATIVE_BUILD_VARIANT_PROPERTY]
3435
// if prop does not exist, use isRelease value, otherwise override isRelease value.
35-
if (!project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY)) {
36-
if (System.getProperty(NATIVE_BUILD_VARIANT_PROPERTY) == null) {
37-
ext[NATIVE_BUILD_VARIANT_PROPERTY] = isRelease ? "release" : "debug"
38-
logger.info "setting ai.etw.native.build for ${project.name}: ${ext[NATIVE_BUILD_VARIANT_PROPERTY]}"
39-
} else {
40-
ext[NATIVE_BUILD_VARIANT_PROPERTY] = System.getProperty(NATIVE_BUILD_VARIANT_PROPERTY)
41-
}
36+
if (buildNativeProperty == null) {
37+
ext[NATIVE_BUILD_VARIANT_PROPERTY] = isRelease ? "release" : "debug"
38+
logger.info "setting ai.etw.native.build for ${project.name}: ${ext[NATIVE_BUILD_VARIANT_PROPERTY]}"
39+
} else {
40+
ext[NATIVE_BUILD_VARIANT_PROPERTY] = buildNativeProperty
4241
}
4342

4443
if (!project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY)) {
@@ -47,7 +46,7 @@ subprojects {
4746
}
4847
}
4948

50-
if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY)) {
49+
if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && buildNativeProperty != null) {
5150
// verbose=true is not allowed for release builds
5251
if ("true".equalsIgnoreCase(ext[NATIVE_VERBOSE_OUTPUT_PROPERTY]) && "release".equalsIgnoreCase(ext[NATIVE_BUILD_VARIANT_PROPERTY])) {
5352
logger.warn "$NATIVE_VERBOSE_OUTPUT_PROPERTY cannot be true when $NATIVE_BUILD_VARIANT_PROPERTY=relese."

etw/java/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ sourceSets {
2424

2525
archivesBaseName = "applicationinsights-java-etw-provider"
2626

27-
logger.info "project ${project.path} prop: ai.etw.native.build=${project.properties['ai.etw.native.build']}"
28-
29-
def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS)
27+
logger.info "project ${project.path} prop: ai.etw.native.build=${System.properties['ai.etw.native.build']}"
3028

29+
def buildNative = System.properties['ai.etw.native.build'] != null && Os.isFamily(Os.FAMILY_WINDOWS)
3130
dependencies {
3231
implementation("org.slf4j:slf4j-api")
3332

3433
if (buildNative) {
35-
jni32 project(path: ":etw:native", configuration: "${project.properties['ai.etw.native.build']}X86RuntimeElements")
36-
jni64 project(path: ":etw:native", configuration: "${project.properties['ai.etw.native.build']}X86-64RuntimeElements")
34+
jni32 project(path: ":etw:native", configuration: "${System.properties['ai.etw.native.build']}X86RuntimeElements")
35+
jni64 project(path: ":etw:native", configuration: "${System.properties['ai.etw.native.build']}X86-64RuntimeElements")
3736
} else {
3837
logger.info "Skipping build of :etw:native. EtwAppender/EtwProvider will not work because library is missing"
3938
}
@@ -58,7 +57,7 @@ if (hasProperty("ai.etw.native.generateHeaders")) {
5857

5958
if (buildNative) {
6059
tasks.register("processNativeResources", Copy) {
61-
def useReleaseBuild = project.getProperty("ai.etw.native.build").equalsIgnoreCase("release")
60+
def useReleaseBuild = System.properties["ai.etw.native.build"].equalsIgnoreCase("release")
6261
dependsOn project(":etw:native").tasks.named("assemble${useReleaseBuild ? 'Release' : 'Debug'}X86").get()
6362
dependsOn project(":etw:native").tasks.named("assemble${useReleaseBuild ? 'Release' : 'Debug'}X86-64").get()
6463

etw/native/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ library {
3838
}
3939

4040

41-
logger.info "$NATIVE_BUILD_VARIANT_PROPERTY = ${project.properties[NATIVE_BUILD_VARIANT_PROPERTY]}"
41+
logger.info "$NATIVE_BUILD_VARIANT_PROPERTY = ${System.properties[NATIVE_BUILD_VARIANT_PROPERTY]}"
4242
logger.info "$NATIVE_VERBOSE_OUTPUT_PROPERTY = ${project.properties[NATIVE_VERBOSE_OUTPUT_PROPERTY]}"
4343

4444
// NOTE: these options apply to Visual Studio Build Tools (cl.exe)
@@ -51,15 +51,17 @@ tasks.withType(CppCompile).configureEach {
5151
compilerArgs.add "/sdl"
5252
compilerArgs.add "/std:c++14"
5353

54-
if (project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY) && "release".equalsIgnoreCase(project.properties[NATIVE_BUILD_VARIANT_PROPERTY])) {
54+
String buildNative = System.properties[NATIVE_BUILD_VARIANT_PROPERTY]
55+
String outputNative = project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY)
56+
if (buildNative != null && "release".equalsIgnoreCase(buildNative)) {
5557
logger.info "Configuring ${it} for release build"
5658
macros.put("NDEBUG", null)
5759
compilerArgs.add "/O2" // optimize for speed
5860
compilerArgs.add "/MD" // multithreaded
5961
} else {
6062
logger.info "Configuring ${it} for debug build"
6163
compilerArgs.add "/MDd" // multithreaded, debug mode
62-
if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && "true".equalsIgnoreCase(project.properties[NATIVE_VERBOSE_OUTPUT_PROPERTY])) {
64+
if (outputNative != null && "true".equalsIgnoreCase(outputNative)) {
6365
logger.info "Verbose output enabled"
6466
macros.put("AIETW_VERBOSE", null)
6567
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ gradleEnterprise {
3434

3535
rootProject.name = 'applicationinsights-java'
3636

37-
def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS)
37+
def buildNative = System.properties["ai.etw.native.build"] != null && Os.isFamily(Os.FAMILY_WINDOWS)
3838
if (buildNative) {
3939
include ':etw:native'
4040
} else {

0 commit comments

Comments
 (0)